Commit 35c7dcfe authored by John Chodera's avatar John Chodera
Browse files

Fixed unit conversion bug in Monte Carlo barostat where pV work was being...

Fixed unit conversion bug in Monte Carlo barostat where pV work was being divided by a factor of AVOGADRO*1e-25 (kJ/mol)/(bar nm^3), rather than multiplied by it.
Checking this bug in since Peter Eastman is on vacation; he should double-check the fix upon return.
parent 98c30a3f
...@@ -81,7 +81,7 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context) { ...@@ -81,7 +81,7 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context) {
// Compute the energy of the modified system. // Compute the energy of the modified system.
double finalEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); double finalEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy();
double pressure = context.getParameter(MonteCarloBarostat::Pressure())/(AVOGADRO*1e-25); double pressure = context.getParameter(MonteCarloBarostat::Pressure())*(AVOGADRO*1e-25);
double kT = BOLTZ*owner.getTemperature(); double kT = BOLTZ*owner.getTemperature();
double w = finalEnergy-initialEnergy + pressure*deltaVolume - context.getMolecules().size()*kT*std::log(newVolume/volume); double w = finalEnergy-initialEnergy + pressure*deltaVolume - context.getMolecules().size()*kT*std::log(newVolume/volume);
if (w > 0 && genrand_real2(random) > std::exp(-w/kT)) { if (w > 0 && genrand_real2(random) > std::exp(-w/kT)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment