--- trunk/src/applications/staticProps/RNEMDStats.cpp 2013/06/18 16:07:27 1881 +++ trunk/src/applications/staticProps/RNEMDStats.cpp 2013/06/18 17:16:15 1885 @@ -86,6 +86,16 @@ namespace OpenMD { } void RNEMDZ::processFrame(int istep) { + RealType z; + + hmat_ = currentSnapshot_->getHmat(); + for (int i = 0; i < nBins_; i++) { + z = (((RealType)i + 0.5) / (RealType)nBins_) * hmat_(2,2); + dynamic_cast(z_->accumulator[i])->add(z); + } + volume_ = currentSnapshot_->getVolume(); + + Molecule* mol; RigidBody* rb; StuntDouble* sd; @@ -96,8 +106,8 @@ namespace OpenMD { vector binMass(nBins_, 0.0); vector binVel(nBins_, V3Zero); vector binKE(nBins_, 0.0); - vector binDof(nBins_, 0); - vector binCount(nBins_, 0); + vector binDof(nBins_, 0); + vector binCount(nBins_, 0); for (mol = info_->beginMolecule(mi); mol != NULL; @@ -110,7 +120,7 @@ namespace OpenMD { rb->updateAtoms(); } } - + if (evaluator_.isDynamic()) { seleMan_.setSelectionSet(evaluator_.evaluate()); } @@ -122,14 +132,14 @@ namespace OpenMD { // figure out where that object is: Vector3d pos = sd->getPos(); - currentSnapshot_->wrapVector(pos); + Vector3d vel = sd->getVel(); + RealType m = sd->getMass(); int bin = getBin(pos); - binCount[bin]++; - RealType m = sd->getMass(); + binCount[bin] += 1; + binMass[bin] += m; - Vector3d vel = sd->getVel(); binVel[bin] += vel; binKE[bin] += 0.5 * (m * vel.lengthSquare()); binDof[bin] += 3; @@ -153,16 +163,19 @@ namespace OpenMD { } } - for (int i = 0; i < nBins_; i++) { - RealType temp = 2.0 * binKE[i] / (binDof[i] * PhysicalConstants::kb * - PhysicalConstants::energyConvert); - RealType den = binMass[i] * nBins_ * PhysicalConstants::densityConvert - / volume_; - Vector3d vel = binVel[i] / RealType(binCount[i]); - dynamic_cast(temperature->accumulator[i])->add(temp); - dynamic_cast(velocity->accumulator[i])->add(vel); - dynamic_cast(density->accumulator[i])->add(den); - dynamic_cast(counts_->accumulator[i])->add(1); + for (unsigned int i = 0; i < nBins_; i++) { + + if (binDof[i] > 0) { + RealType temp = 2.0 * binKE[i] / (binDof[i] * PhysicalConstants::kb * + PhysicalConstants::energyConvert); + RealType den = binMass[i] * nBins_ * PhysicalConstants::densityConvert + / volume_; + Vector3d vel = binVel[i] / RealType(binCount[i]); + dynamic_cast(temperature->accumulator[i])->add(temp); + dynamic_cast(velocity->accumulator[i])->add(vel); + dynamic_cast(density->accumulator[i])->add(den); + dynamic_cast(counts_->accumulator[i])->add(1); + } } }