Unverified Commit ebde66b4 authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Fixed bug in computing pressure (#4980)

parent 643473ce
...@@ -79,7 +79,7 @@ KERNEL void computeMolecularKineticEnergy(int numMolecules, GLOBAL mixed4* RESTR ...@@ -79,7 +79,7 @@ KERNEL void computeMolecularKineticEnergy(int numMolecules, GLOBAL mixed4* RESTR
molVel += mass*trimTo3(v); molVel += mass*trimTo3(v);
molMass += mass; molMass += mass;
} }
molVel *= RECIP((mixed) numAtoms); molVel *= RECIP((mixed) molMass);
#if COMPONENTS == 1 #if COMPONENTS == 1
ke[0] += 0.5f*molMass*dot(molVel, molVel); ke[0] += 0.5f*molMass*dot(molVel, molVel);
#else #else
......
...@@ -133,7 +133,7 @@ void ReferenceMonteCarloBarostat::computeMolecularKineticEnergy(const vector<Vec ...@@ -133,7 +133,7 @@ void ReferenceMonteCarloBarostat::computeMolecularKineticEnergy(const vector<Vec
molVel += masses[atom]*velocities[atom]; molVel += masses[atom]*velocities[atom];
molMass += masses[atom]; molMass += masses[atom];
} }
molVel /= molecule.size(); molVel /= molMass;
if (components == 1) if (components == 1)
ke[0] += 0.5*molMass*molVel.dot(molVel); ke[0] += 0.5*molMass*molVel.dot(molVel);
else { else {
......
...@@ -167,8 +167,8 @@ void testMolecularGas() { ...@@ -167,8 +167,8 @@ void testMolecularGas() {
init_gen_rand(0, sfmt); init_gen_rand(0, sfmt);
for (int i = 0; i < numMolecules; ++i) { for (int i = 0; i < numMolecules; ++i) {
system.addParticle(1.0); system.addParticle(1.0);
system.addParticle(1.0); system.addParticle(2.0);
system.addParticle(1.0); system.addParticle(3.0);
Vec3 pos(initialLength*genrand_real2(sfmt), 0.5*initialLength*genrand_real2(sfmt), 2*initialLength*genrand_real2(sfmt)); Vec3 pos(initialLength*genrand_real2(sfmt), 0.5*initialLength*genrand_real2(sfmt), 2*initialLength*genrand_real2(sfmt));
bonds->addBond(positions.size(), positions.size()+1, 0.1, 10.0); bonds->addBond(positions.size(), positions.size()+1, 0.1, 10.0);
system.addConstraint(positions.size(), positions.size()+2, 0.1); system.addConstraint(positions.size(), positions.size()+2, 0.1);
......
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