/* one particle - quantum lattice gas model 1D */ /* coded by Ikeuchi Mitsuru */ /* ver 0.0.1 2004.12.18 */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class quantumLatticeGas1D extends Applet implements ActionListener, AdjustmentListener, Runnable { /* -------------------------------------- set global ------ */ Button bt_reset, bt_start, bt_stop; Scrollbar sc_ww, sc_wh, spx; Thread th = null; Dimension dim; Image imgOff; Graphics gOff; int sleepTime = 30; int started = 1; double px0 = 1.0; double t = 0.0; double dx = 16.0/256.0; double dt = 1.0; int now = 0; int NNx = 256; double psi[][][][] = new double[2][2][NNx][2]; double phRe[] = new double[NNx]; double phIm[] = new double[NNx]; double vv[] = new double[NNx]; int NN = NNx+1; double aaRe[] = new double[NN]; double aaIm[] = new double[NN]; double bbRe[] = new double[NN]; double bbIm[] = new double[NN]; double bRe[] = new double[NN]; double bIm[] = new double[NN]; double uRe[] = new double[NN]; double uIm[] = new double[NN]; int xpts[] = new int[NN]; int ypts[] = new int[NN]; /* ----------------------------- applet control ------ */ public void init() { resize(630,300); setBackground(Color.white); dim = getSize(); imgOff = createImage(dim.width,dim.height); gOff = imgOff.getGraphics(); bt_reset= new Button("reset"); bt_reset.addActionListener(this); bt_start= new Button("start"); bt_start.addActionListener(this); bt_stop = new Button("stop"); bt_stop.addActionListener(this); sc_ww= new Scrollbar(Scrollbar.HORIZONTAL,30,10,0,110); sc_ww.addAdjustmentListener(this); sc_wh= new Scrollbar(Scrollbar.HORIZONTAL,85,10,0,160); sc_wh.addAdjustmentListener(this); spx= new Scrollbar(Scrollbar.HORIZONTAL,60,10,0,110); spx.addAdjustmentListener(this); setLayout(new BorderLayout()); Panel pnl = new Panel(); pnl.setLayout(new GridLayout(1,6,5,0)); pnl.add(bt_reset); pnl.add(bt_start); pnl.add(bt_stop); pnl.add(new Label(" ")); pnl.add(new Label(" ")); pnl.add(spx); add(pnl,"North"); setInitialCondition(); } public void start() { if (th == null) { th = new Thread(this); th.start(); } } public void stop() { if (th != null) { th.stop(); th = null; } } public void actionPerformed(ActionEvent ev){ if(ev.getSource() == bt_reset){ t = 0.0; setInitialCondition(); started = 0; } else if(ev.getSource() == bt_start){ started = 1; } else if(ev.getSource() == bt_stop){ started = 0; } } public void adjustmentValueChanged(AdjustmentEvent ev){ if (ev.getSource() == spx) { px0 = 0.1*(double)(spx.getValue())-5.0; setInitialCondition(); } } public void run() { while (th != null) { try { timeEvolution(); offPaint(); repaint(); Thread.sleep(sleepTime); } catch (InterruptedException e) { } } } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { g.drawImage(imgOff,0,0,this); } /* ----------------------------- offPaint -------------------- */ void offPaint() { int i,gbx,gby; double v1,v2,ph2,y,z; double p0,p1,nrm; gOff.setColor(Color.white); gOff.fillRect(0,0,dim.width,dim.height); gbx = 30; gby = 220; /* gOff.setColor(Color.cyan); for (i=1; i=0.5) { gOff.drawLine(gbx+i,gby-(int)(ph2+0.5), gbx+i, gby); } } */ gOff.setColor(Color.cyan); nrm = norm(); for (i=1; i=0.5) { gOff.drawLine(gbx+i,gby-(int)(ph2+0.5), gbx+i, gby); } } /* for (i=0; i