/*
Hybrid Path Integral Monte Carlo
m = mass
eta = damping
beta = inverse temperature
jmax = number of tau-slices = 64
Upper panel: phi(tau) vs tau (0
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
//import java.text.NumberFormat;
public class HPIMC extends JApplet
implements Runnable, ActionListener, ComponentListener {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Variable declarations
final double pi=Math.PI,twopi=2*pi;
Thread thread1 = null;
boolean running = true;
JPanel jPanel0,jPanelL,jPanelR,jPanel1,jPanel2;
JLabel[] jLabelArray;
JTextField[] jTextFieldArray;
MyPicture myPicture1,myPicture2;
final int iparams=20;
int Xmin,Xmax,Ymin,Ymax;
double xmin,xmax,ymin,ymax;
int jmax = 64;
int cfgs;
double tt[],uu[],vv[],ff[],cc[],ss[],CC[],CCsum[],CCmean[],aa[];
double dd1[];
double m,kappa,eta,beta,eps,ds;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Mathematical functions
public double linmap
(double x, double x1, double x2, double y1, double y2) {
return y1 + (y2-y1)/(x2-x1)*(x-x1);
}
public double randomGaussian () {
double x,y,u,t,xx,yy;
do {
x = Math.random()*2-1;
y = Math.random()*2-1;
u = x*x + y*y;
} while (u>1);
t = Math.sqrt(-2*Math.log(u)/u);
xx = t*x;
yy = t*y;
return xx;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Given displacements uu, compute forces ff
// f[j] = m/eps*..
void computeForce() {
int i,j,k;
double dum1,dum2;
for (j=0; j tm) {
tm += 500; // no effect?!
for (j=0; j0)
if (Math.abs(Y2-Y1)*2 < (Ymin-Ymax))
g.drawLine (X1, Y1, X2, Y2);
X1 = X2;
Y1 = Y2;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The MyPicture class contains an image. It is like a label.
public class MyPicture extends JComponent {
Image image1;
protected void paintComponent(Graphics g) {
g.drawImage (image1, 0, 0, null);
}
}
}