org.opensourcephysics.sip.ch08.md
Class LJParticles

java.lang.Object
  extended by org.opensourcephysics.sip.ch08.md.LJParticles
All Implemented Interfaces:
Drawable, ODE

public class LJParticles
extends java.lang.Object
implements Drawable, ODE

LJParticlesApp evolves a two-dimensional system of interacting particles via the Lennard-Jones potential using a Verlet ODESolver. getHeatCapacity method corrected based on bug report by Mike Cooke.


Field Summary
 double[] ax
           
 double[] ay
           
 double dt
           
 java.lang.String initialConfiguration
           
 double initialKineticEnergy
           
 double Lx
           
 double Ly
           
 int N
           
 int nx
           
 int ny
           
 double radius
           
 double rho
           
 double[] state
           
 int steps
           
 double t
           
 double totalKineticEnergyAccumulator
           
 double totalKineticEnergySquaredAccumulator
           
 double totalPotentialEnergyAccumulator
           
 double virialAccumulator
           
 
Constructor Summary
LJParticles()
           
 
Method Summary
 void computeAcceleration()
           
 void draw(DrawingPanel panel, java.awt.Graphics g)
          Draws a representation of an object in a drawing panel.
 double getHeatCapacity()
          Gets the heat capacity.
 double getMeanEnergy()
           
 double getMeanPressure()
           
 double getMeanTemperature()
           
 void getRate(double[] state, double[] rate)
          Gets the rate of change using the argument's state variables.
 double[] getState()
          Gets the state variables.
 void initialize()
           
 void resetAverages()
           
 void setRandomPositions()
           
 void setRectangularLattice()
           
 void setTriangularLattice()
           
 void setVelocities()
           
 void step(HistogramFrame xVelocityHistogram)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

state

public double[] state

ax

public double[] ax

ay

public double[] ay

N

public int N

nx

public int nx

ny

public int ny

Lx

public double Lx

Ly

public double Ly

rho

public double rho

initialKineticEnergy

public double initialKineticEnergy

steps

public int steps

dt

public double dt

t

public double t

totalPotentialEnergyAccumulator

public double totalPotentialEnergyAccumulator

totalKineticEnergyAccumulator

public double totalKineticEnergyAccumulator

totalKineticEnergySquaredAccumulator

public double totalKineticEnergySquaredAccumulator

virialAccumulator

public double virialAccumulator

initialConfiguration

public java.lang.String initialConfiguration

radius

public double radius
Constructor Detail

LJParticles

public LJParticles()
Method Detail

initialize

public void initialize()

setRandomPositions

public void setRandomPositions()

setRectangularLattice

public void setRectangularLattice()

setTriangularLattice

public void setTriangularLattice()

setVelocities

public void setVelocities()

getMeanTemperature

public double getMeanTemperature()

getMeanEnergy

public double getMeanEnergy()

getMeanPressure

public double getMeanPressure()

getHeatCapacity

public double getHeatCapacity()
Gets the heat capacity. Errata: On page 276 in Eq. 8.11, after the equal sign, the first appearance of N should be 1/N and in Eq. 8.12 after the minus sign 1/N should be N. We thank Mike Cooke for pointing out this error.

Returns:
double

resetAverages

public void resetAverages()

computeAcceleration

public void computeAcceleration()

getRate

public void getRate(double[] state,
                    double[] rate)
Description copied from interface: ODE
Gets the rate of change using the argument's state variables. This method may be invoked many times with different intermediate states as an ODESolver is carrying out the solution.

Specified by:
getRate in interface ODE
Parameters:
state - the state array
rate - the rate array

getState

public double[] getState()
Description copied from interface: ODE
Gets the state variables. The getState method is invoked by an ODESolver to obtain the initial state of the system. The ODE solver advances the solution and then copies new values into the state array at the end of the solution step.

Specified by:
getState in interface ODE
Returns:
state the state

step

public void step(HistogramFrame xVelocityHistogram)

draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics g)
Description copied from interface: Drawable
Draws a representation of an object in a drawing panel.

Specified by:
draw in interface Drawable