/* * Integrating the Schrodinger Wave Equation * John L. Richardson * jlr@sgi.com * December 1995 */ import java.awt.*; public class WaveMap extends java.applet.Applet implements Runnable { int wx,wy,yoff,xpts[],ypts[],nx; double x0,xmin,xmax,dx,ymin,ymax,dy,xscale,yscale,tmin,t,dt; double hbar,mass,epsilon,width,vx,vwidth,energy,energyScale; complex Psi[],EtoV[],alpha,beta; Thread kicker = null; Button Restart = new Button("Restart"); Button Pause = new Button("Pause"); Button Stop = new Button("Stop"); Choice C = new Choice(); public void init() { wx = size().width; wy = size().height; resize(wx,wy); setBackground(Color.white); nx = wx / 2; yoff = 50; wy -= yoff; xpts = new int[nx]; ypts = new int[nx]; Psi = new complex[nx]; EtoV = new complex[nx]; energyScale = 1; initPhysics(); Panel p = new Panel(); p.setLayout(new FlowLayout()); p.add(Pause); p.add(Restart); p.add(Stop); C.addItem("Barrier V = 2*E"); C.addItem("Barrier V = E"); C.addItem("Barrier V = E/2"); C.addItem("No Barrier"); C.addItem("Well V = -E/2"); C.addItem("Well V = -E"); C.addItem("Well V = -2*E"); C.select("Barrier V = E"); p.add(C); add("North",p); Restart.disable(); C.disable(); } public void initPhysics() { x0 = -2; xmin = -3; xmax = 3; dx = (xmax-xmin)/(nx-1); xscale = (wx-0.5)/(xmax-xmin); ymin = -1.5; ymax = 1.5; dy = (ymax-ymin)/(wy-1); yscale = (wy-0.5)/(ymax-ymin); tmin = 0; t = tmin; hbar = 1; mass = 100; width = 0.50; vwidth = 0.25; vx = 0.25; dt = 0.8 * mass * dx * dx / hbar; epsilon = hbar * dt /( mass * dx * dx ); alpha = new complex(0.5 * (1.0+Math.cos(epsilon/2)) , -0.5 * Math.sin(epsilon/2)); beta = new complex((Math.sin(epsilon/4))*Math.sin(epsilon/4) , 0.5 * Math.sin(epsilon/2)); energy = 0.5 * mass * vx * vx ; for(int x=0;x