Volume-change Trial Move5. Examination of Java Code
public void thisTrial(Phase phase) {
double hOld, hNew, vOld, vNew;
hOld = phase.potentialEnergy.currentValue() //current value of the enthalpy
+ pressure*vOld*Constants.PV2T; //PV2T is a conversion factor
double vScale = (2.*rand.nextDouble()-1.)*stepSize; //choose step size
vNew = vOld * Math.exp(vScale); //Step in ln(V)
double rScale = Math.exp(vScale/(double)Simulation.D); //evaluate linear scaling
phase.inflate(rScale); //scale all center-of-mass coordinates
hNew = phase.potentialEnergy.currentValue() //new value of the enthalpy
+ pressure*vNew*Constants.PV2T;
if(hNew >= Double.MAX_VALUE || //decide acceptance
Math.exp(-(hNew-hOld)/parentIntegrator.temperature+(phase.moleculeCount+1)*vScale)
{ //reject; put coordinates back to original positions
phase.inflate(1.0/rScale);