Exemplo n.º 1
0
 /** One Monte Carlo step */
 public void doStep() {
   qmwalk.doMCS();
   phiFrame.clearData();
   phiFrame.append(0, qmwalk.xv, qmwalk.phi0);
   phiFrame.setMessage(
       "E = " + decimalFormat.format(qmwalk.eAccum / qmwalk.mcs) + " N = " + qmwalk.N);
 }
 /**
  * Computes and plots correlation functions
  *
  * @param tauMax is the maximum time for correlation functions
  */
 public void computeCorrelation(int tauMax) {
   plotFrame.clearData();
   double energyAccumulator = 0, magnetizationAccumulator = 0;
   double energySquaredAccumulator = 0, magnetizationSquaredAccumulator = 0;
   for (int t = 0; t < numberOfPoints; t++) {
     energyAccumulator += energy[t];
     magnetizationAccumulator += magnetization[t];
     energySquaredAccumulator += energy[t] * energy[t];
     magnetizationSquaredAccumulator += magnetization[t] * magnetization[t];
   }
   double averageEnergySquared = Math.pow(energyAccumulator / numberOfPoints, 2);
   double averageMagnetizationSquared = Math.pow(magnetizationAccumulator / numberOfPoints, 2);
   // compute normalization factors
   double normE = (energySquaredAccumulator / numberOfPoints) - averageEnergySquared;
   double normM = (magnetizationSquaredAccumulator / numberOfPoints) - averageMagnetizationSquared;
   for (int tau = 1; tau <= tauMax; tau++) {
     double c_MAccumulator = 0;
     double c_EAccumulator = 0;
     int counter = 0;
     for (int t = 0; t < numberOfPoints - tau; t++) {
       c_MAccumulator += magnetization[t] * magnetization[t + tau];
       c_EAccumulator += energy[t] * energy[t + tau];
       counter++;
     }
     // correlation function defined so that c(0) = 1 and c(infinity) -> 0
     plotFrame.append(0, tau, ((c_MAccumulator / counter) - averageMagnetizationSquared) / normM);
     plotFrame.append(1, tau, ((c_EAccumulator / counter) - averageEnergySquared) / normE);
   }
   plotFrame.setVisible(true);
 }
Exemplo n.º 3
0
 MeanFieldApp() {
   root = new double[3];
   plotFrame.setConnected(true);
   plotFrame.setMarkerColor(1, Color.RED);
   plotFrame.setMarkerColor(0, Color.BLUE);
   energyFrame.setMarkerColor(0, Color.BLUE);
   energyFrame.setConnected(true);
   numberFormat.setMinimumFractionDigits(3);
 }
Exemplo n.º 4
0
 public void plot() {
   double x = mxlimit;
   while (x < pxlimit) {
     plotFrame.append(0, x, mftanh(x));
     plotFrame.append(1, x, x);
     energyFrame.append(0, x, freeenergy(x));
     x += 0.02;
   }
   plotFrame.render();
 }
Exemplo n.º 5
0
 public static void main(String[] args) {
   PlotFrame frame =
       new PlotFrame(
           "$\\theta$", "$\\Psi$_{$\\theta$}", "Special Characters: $\\alpha$ to $\\Omega$");
   String inputStr = "Wave function $\\Psi$_{$\\theta$}";
   DrawableTextLine textLine = new DrawableTextLine(inputStr, -8, 0);
   frame.addDrawable(textLine);
   textLine.setFontSize(22);
   textLine.setFontStyle(java.awt.Font.BOLD);
   frame.setVisible(true);
   frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
 }
Exemplo n.º 6
0
 /**
  * Calculates the trajectory of a falling particle and plots the position as a function of time.
  */
 public void calculate() {
   plotFrame.setAutoclear(false); // data not cleared at beginning of each calculation
   // gets initial conditions
   double y0 = control.getDouble("Initial y");
   double v0 = control.getDouble("Initial v");
   // sets initial conditions
   Particle ball = new FallingParticle(y0, v0);
   // gets parameters
   ball.dt = control.getDouble("dt");
   while (ball.y > 0) {
     ball.step();
     plotFrame.append(0, ball.t, ball.y);
     plotFrame.append(1, ball.t, ball.analyticPosition());
   }
 }
 public void readXMLData() {
   energy = new double[0];
   magnetization = new double[0];
   numberOfPoints = 0;
   String filename = "ising_data.xml";
   JFileChooser chooser = OSPFrame.getChooser();
   int result = chooser.showOpenDialog(null);
   if (result == JFileChooser.APPROVE_OPTION) {
     filename = chooser.getSelectedFile().getAbsolutePath();
   } else {
     return;
   }
   XMLControlElement xmlControl = new XMLControlElement(filename);
   if (xmlControl.failedToRead()) {
     control.println("failed to read: " + filename);
   } else {
     // gets the datasets in the xml file
     Iterator it = xmlControl.getObjects(Dataset.class, false).iterator();
     while (it.hasNext()) {
       Dataset dataset = (Dataset) it.next();
       if (dataset.getName().equals("magnetization")) {
         magnetization = dataset.getYPoints();
       }
       if (dataset.getName().equals("energy")) {
         energy = dataset.getYPoints();
       }
     }
     numberOfPoints = magnetization.length;
     control.println("Reading: " + filename);
     control.println("Number of points = " + numberOfPoints);
   }
   calculate();
   plotFrame.repaint();
 }
Exemplo n.º 8
0
 /** Calculates the wave function. */
 public void calculate() {
   schroedinger.xmin = control.getDouble("xmin");
   schroedinger.xmax = control.getDouble("xmax");
   schroedinger.stepHeight = control.getDouble("step height at x = 0");
   schroedinger.numberOfPoints = control.getInt("number of points");
   schroedinger.energy = control.getDouble("energy");
   schroedinger.initialize();
   schroedinger.solve();
   frame.append(0, schroedinger.x, schroedinger.phi);
 }
Exemplo n.º 9
0
 public void computeDistribution(PlotFrame data) {
   int numberOfBins = 20;
   int numberOccupied = 0;
   double occupied[] = new double[numberOfBins];
   double number[] = new double[numberOfBins];
   double binSize = 1.0 / numberOfBins;
   int minX = Lx / 3;
   int maxX = 2 * minX;
   for (int x = minX; x <= maxX; x++) {
     for (int y = 0; y < Ly; y++) {
       int bin = (int) (numberOfBins * (site[x][y] % 1));
       number[bin]++;
       if ((site[x][y] > 1) && (site[x][y] < 2)) {
         numberOccupied++;
         occupied[bin]++;
       }
     }
   }
   data.setMessage("Number occupied = " + numberOccupied);
   for (int bin = 0; bin < numberOfBins; bin++) {
     data.append(0, (bin + 0.5) * binSize, occupied[bin] / number[bin]);
   }
 }
Exemplo n.º 10
0
 /** Resets the accumulated data. */
 public void resetData() {
   qmwalk.resetData();
   phiFrame.clearData();
   phiFrame.repaint();
 }
Exemplo n.º 11
0
 /** Constructs SchroedingerApp and sets plotting frame parameters. */
 public SchroedingerApp() {
   frame.setConnected(0, true);
   frame.setMarkerShape(0, Dataset.NO_MARKER);
 }