In the right-hand side of equation (9.56) on page 341, the term "u(x + Delta x, t)" appears twice. One of these should be replaced with "u(x - Delta x, t)".
This is not actually an "error", as I initially thought that it was. Currently the variables systemEnergyAccumulator and demonEnergyAccumulator are being updated every time that a change is proposed, rather than being updated once per MCS. Unless the number of MCS is large, these two methods of averaging will yield different results. The code below shows the changes that will result in data only being accumulated once per MCS.
Alternate method for IdealDemon.java:
public void doOneMCStep() { for(int j = 0;j LESSTHAN N;++j) { int particleIndex = (int) (Math.random()*N); // choose particle at random double dv = (2.0*Math.random()-1.0)*delta; // random change in velocity double trialVelocity = v[particleIndex]+dv; double dE = 0.5*(trialVelocity*trialVelocity-v[particleIndex]*v[particleIndex]); if(dE LESSTHANOREQUALTO demonEnergy) { v[particleIndex] = trialVelocity; acceptedMoves++; systemEnergy += dE; demonEnergy -= dE; } } systemEnergyAccumulator += systemEnergy; demonEnergyAccumulator += demonEnergy; mcs++; }
Alternate code for IdealDemonApp.java:
control.println("Mean Ed = "+idealGas.demonEnergyAccumulator/idealGas.mcs); control.println("Mean E = "+idealGas.systemEnergyAccumulator/idealGas.mcs);
PBCs in setRandomPositions()
- Jan 17, 2009 at 12:21PM
Larry Engelhardt
15 Posts
In the setRandomPositions() method in the file LJParticles.java, the periodic boundary conditions are not taken into account when determining whether or not two molecules are overlapping, often causing the simulation to get stuck when using these initial conditions. Listing 8.4 in the CSM texbook correctly incorporates the PBCs in the lines:
double dx = pbcSeparation(state[4*i]-state[4*j], Lx); double dy = pbcSeparation(state[4*i+2]-state[4*j+2], Ly);
BifurcateApp.java plotting too few data points
- Nov 19, 2008 at 3:36PM
Larry Engelhardt
15 Posts
The file BifurcateApp.java (from Ch. 6 of CSM) shows the bifurcation that occurs for the logistic map as a function of the parameter r. The application receives the number of data points to be plotted (per r value) as input (from the user) through the control window, which is written into the variable "nplot". However, the application only plots 0.75*nplot data points, because the command i++ appears twice in the loop for dataset 1. It appears both as the iterator for the for loop,
for(int i = nplot/2+1; i lessthan nplot; i++)
and it appears as the last statement within the body of the for loop,
The file Lorenz.java is meant to simulate the model represented by Eqs. 6.33 (a)-(c) on page 167 of CSM. However, there is an error in the getRate method.
Axis labels in GraphicalSolutionApp.java in Ch. 6
- Nov 12, 2008 at 10:06AM
Larry Engelhardt
15 Posts
The file GraphicalSolutionApp.java (listing 6.3 in the CSM textbook) is used to graphically show how the logistic map is iterated. The quantity on the horizontal axis should be "x" (the current value of x_n), and the quantity on the vertical axis should be "f(x)" (the next value of x_n). These axis are mislabeled as "iterations" for the horizontal-axis label and "x" for the vertical-axis label.
which is equivalent to the second equation above. In other words, E(r,t) can be simplified slightly in HuygensApp.java by writing it without minus signs as: