Home
|
Course Outline
|
Lectures
|
Homework
|
Files
The potential V(x) is plotted in green, the real and imaginary parts of the initially Gaussian wave packet are plotted in red and blue respectively, and the probability distribution is shaded in yellow.
Here is the code which generates this applet:
// TDSE.java
// Chapter 18: The Time-Dependent Schroedinger Equation
import comphys.*;
import comphys.graphics.*;
public class TDSE extends Animation {
// system and spatial grid
double xmax = 20;
double xmin = -xmax;
double dx = 0.4;
// arrays to hold wavefunction
int n;
double[] Re;
double[] Im;
double[] Imold;
void allocateArrays () {
n = (int) ( (xmax - xmin) / dx );
if (Re == null || Re.length != n + 2) {
Re = new double[n + 2];
Im = new double[n + 2];
Imold = new double [n + 2];
}
}
// step potential
double V0 = 2;
double a = 0;
double V (double x) {
if (x > a)
return V0;
else return 0;
}
double probability () {
double Psum = 0;
for (int i = 1; i <= n; i++)
Psum += Re[i] * Re[i] + Im[i] * Imold[i];
return Psum * dx;
}
// Visscher et al., algorithm for time evolution
double t = 0;
double dt = 0.1;
void evolve () {
double dx2 = dx * dx;
for (int i = 1; i <= n; i++) {
double x = xmin + (i - 1) * dx;
double HIm = V(x) * Im[i] -
0.5 * (Im[i + 1] - 2 * Im[i] + Im[i - 1]) / dx2;
Re[i] += HIm * dt;
}
for (int i = 1; i <= n; i++) {
double x = xmin + (i - 1) * dx;
Imold[i] = Im[i];
double HRe = V(x) * Re[i] -
0.5 * (Re[i + 1] - 2 * Re[i] + Re[i - 1]) / dx2;
Im[i] -= HRe * dt;
}
t += dt;
}
// initial Gaussian wave packet
double x0 = -15;
double k0 = 2;
double width = 1;
void initial () {
allocateArrays();
double delta2 = width * width;
double A = 2 * Math.PI * delta2;
A = Math.pow(A, -0.25);
double b = 0.5 * k0 * dt;
Re[0] = Im[0] = Imold[0] = 0;
for (int i = 1; i <= n; i++) {
double x = xmin + (i - 1) * dx;
double arg = 0.25 * (x - x0) * (x - x0) / delta2;
double e = Math.exp(-arg);
Re[i] = A * Math.cos(k0 * (x - x0)) * e;
Im[i] = A * Math.sin(k0 * (x - x0 - 0.5 * b)) * e;
Imold[i] = Im[i];
}
Re[n + 1] = Im[n + 1] = Imold[n + 1] = 0;
}
class Movie extends Plot {
Movie () {
setSize(400, 400);
setBackground("white");
}
public void paint () {
clear();
setColor("gray");
double ymax = 0.5;
double ymin = -ymax;
drawAxes(xmin, xmax, ymin, ymax);
double x = xmin;
double xOld = x;
double yOld = 0;
x = xOld = xmin;
yOld = 2 * (Re[0] * Re[0] + Im[0] * Im[0]);
for (int i = 1; i <= n; i++) {
x = xmin + i * dx;
double y = 2 * (Re[i] * Re[i] + Im[i] * Im[i]);
double y1 = (yOld + y) / 2;
setColor("yellow");
boxArea(xOld, x, 0, y1);
setColor("black");
plotLine(xOld, y1, x, y1);
xOld = x;
yOld = y;
}
setColor("red");
x = xOld = xmin;
yOld = Re[0];
for (int i = 1; i <= n; i++) {
x = xmin + i * dx;
double y = Re[i];
plotLine(xOld, yOld, x, y);
xOld = x;
yOld = y;
}
setColor("blue");
x = xOld = xmin;
yOld = Im[0];
for (int i = 1; i <= n; i++) {
x = xmin + i * dx;
double y = Im[i];
plotLine(xOld, yOld, x, y);
xOld = x;
yOld = y;
}
setColor("green");
x = xOld = xmin;
yOld = V(x) / V0 * ymax;
for (int i = 0; i < n; i++) {
x = xmin + i * dx;
double y = V(x) / V0 * ymax;
plotLine(xOld, yOld, x, y);
xOld = x;
yOld = y;
}
setColor("black");
plotString("t = " + Easy.format(t, 5), xmin, 1.1 * ymin);
plotStringLeft("Probability = " + Easy.format(probability(), 6),
xmax, 1.1 * ymin);
}
}
Movie movie;
Reader widthReader, k0Reader, dxReader, dtReader, skipReader;
int skip = 0;
public void init () {
initial();
add(movie = new Movie());
add(widthReader = new Reader("Packet Width", width, 4));
add(k0Reader = new Reader("Group Velocity", k0, 4));
add(dxReader = new Reader("Lattice dx", dx, 4));
add(dtReader = new Reader("Time step dt", dt, 4));
add(skipReader = new Reader("skip steps", skip));
addControlPanel();
}
public void step () {
for (int s = 0; s <= skip; s++)
evolve();
movie.repaint();
}
public void reset () {
width = widthReader.readDouble();
k0 = k0Reader.readDouble();
dx = dxReader.readDouble();
dt = dtReader.readDouble();
skip = skipReader.readInt();
initial();
movie.repaint();
}
public static void main (String[] args) {
TDSE tdse = new TDSE();
tdse.frame("Time-Dependent Schroedinger Equation", 430, 600);
}
}