Class TimeDepSchrodinger

java.lang.Object
  |
  +--TimeDepSchrodinger
Direct Known Subclasses:
HaynesShockley

class TimeDepSchrodinger
extends java.lang.Object
implements Solvable, TimeDependent

Performs numerical integration of the time-dependend Schrodinger equation.


Field Summary
protected  double dt
           
protected  double energy
           
protected  double h
           
protected  double[] pot
          A cache of the values of the potential function
protected  Function potFn
          The potential function
protected  Complex[] psi
          The function data
protected  double t
           
protected  double width
           
protected  double x0
           
 
Constructor Summary
TimeDepSchrodinger()
          Creates a new instance, using a single square well for the potential function.
TimeDepSchrodinger(Function fn)
           
 
Method Summary
 void advanceOnce()
          Performs one step of the Runge-Kutta method, using the member variable dt to determine the size of the step in the time direction.
protected  void advanceOnce(double dt)
          Performs one step of the Runge-Kutta method.
 double getEnergy()
          Returns the value of the energy parameter
 double getT()
          Returns the simulation time
 double getWidth()
          Returns the width of the initial gaussian
 double getX0()
          Returns the position of the initial gaussian
 void initFunction(double x, double h, int steps)
          Resets the model, replacing the function data with a new gaussian.
 double integralCheck()
          Approximates the integral of the function, by summing the (modulus squared of the) function data and dividing by h.
 void setEnergy(double d)
          Sets the value of the energy parameter
 void setT(double t)
          Sets the simulation time.
 void setWidth(double d)
          Sets the width of the initial gaussian
 void setX0(double d)
          Sets the position of the initial gaussian
 void solve(double x, double h, double[] vals)
          Since all the work is done in advanceOnce(), this method need only return the (modulus squared of the) function data.
protected  Complex xderiv(Complex[] c, int i)
          Measures the second derivative with respect to x using a finite difference method.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

psi

protected Complex[] psi
The function data

energy

protected double energy

x0

protected double x0

width

protected double width

t

protected double t

dt

protected double dt

h

protected double h

potFn

protected Function potFn
The potential function

pot

protected double[] pot
A cache of the values of the potential function
Constructor Detail

TimeDepSchrodinger

public TimeDepSchrodinger(Function fn)
Parameters:
fn - The potential function to use

TimeDepSchrodinger

public TimeDepSchrodinger()
Creates a new instance, using a single square well for the potential function.
Method Detail

initFunction

public void initFunction(double x,
                         double h,
                         int steps)
Resets the model, replacing the function data with a new gaussian.
Parameters:
x - The smallest x-value to consider
h - The gap between x-values
steps - The number of x-values to consider

advanceOnce

protected void advanceOnce(double dt)
Performs one step of the Runge-Kutta method.
Parameters:
dt - The size of the advancement in time

xderiv

protected Complex xderiv(Complex[] c,
                         int i)
Measures the second derivative with respect to x using a finite difference method. If the region considered touches the edge of the function data (so i <= 1 or i >= c.length-2, zero will be returned.
Parameters:
c - The function data on which to operate
i - The index at which the derivative is required
Returns:
(c[i+1]+c[i-1]-2c[i])/(h*h)

advanceOnce

public void advanceOnce()
Performs one step of the Runge-Kutta method, using the member variable dt to determine the size of the step in the time direction.
Specified by:
advanceOnce in interface TimeDependent

solve

public void solve(double x,
                  double h,
                  double[] vals)
Since all the work is done in advanceOnce(), this method need only return the (modulus squared of the) function data. Since it is not practical to adjust the size or x-spacing of the data in the array while the simulation is running, the x and h parameters are ignored.
Specified by:
solve in interface Solvable
Throws:
java.lang.RuntimeException - if vals is not the same size as the array of function data

integralCheck

public double integralCheck()
Approximates the integral of the function, by summing the (modulus squared of the) function data and dividing by h.

getT

public double getT()
Returns the simulation time
Specified by:
getT in interface TimeDependent

setT

public void setT(double t)
Sets the simulation time. This will not affect the simulation data in any way, just as setting your watch to midnight won't make it dark outside.

getEnergy

public double getEnergy()
Returns the value of the energy parameter

setEnergy

public void setEnergy(double d)
Sets the value of the energy parameter

getX0

public double getX0()
Returns the position of the initial gaussian

setX0

public void setX0(double d)
Sets the position of the initial gaussian

getWidth

public double getWidth()
Returns the width of the initial gaussian

setWidth

public void setWidth(double d)
Sets the width of the initial gaussian