ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/staticProps/RNEMDStats.cpp
(Generate patch)

Comparing trunk/src/applications/staticProps/RNEMDStats.cpp (file contents):
Revision 1881 by gezelter, Tue Jun 18 16:07:27 2013 UTC vs.
Revision 1883 by gezelter, Tue Jun 18 16:16:40 2013 UTC

# Line 96 | Line 96 | namespace OpenMD {
96      vector<RealType> binMass(nBins_, 0.0);
97      vector<Vector3d> binVel(nBins_, V3Zero);
98      vector<RealType> binKE(nBins_, 0.0);
99 <    vector<int> binDof(nBins_, 0);
100 <    vector<int> binCount(nBins_, 0);
99 >    vector<unsigned int> binDof(nBins_, 0);
100 >    vector<unsigned int> binCount(nBins_, 0);
101      
102      
103      for (mol = info_->beginMolecule(mi); mol != NULL;
# Line 122 | Line 122 | namespace OpenMD {
122        
123        // figure out where that object is:
124        Vector3d pos = sd->getPos();
125 <      currentSnapshot_->wrapVector(pos);
125 >      Vector3d vel = sd->getVel();
126 >      RealType m = sd->getMass();
127  
128 +      currentSnapshot_->wrapVector(pos);
129        int bin = getBin(pos);
130 <      binCount[bin]++;
130 >      binCount[bin] += 1;
131  
130      RealType m = sd->getMass();
132        binMass[bin] += m;
132      Vector3d vel = sd->getVel();
133        binVel[bin] += vel;
134        binKE[bin] += 0.5 * (m * vel.lengthSquare());
135        binDof[bin] += 3;
# Line 153 | Line 153 | namespace OpenMD {
153        }
154      }
155      
156 <    for (int i = 0; i < nBins_; i++) {
157 <      RealType temp = 2.0 * binKE[i] / (binDof[i] * PhysicalConstants::kb *
158 <                                        PhysicalConstants::energyConvert);
159 <      RealType den = binMass[i] * nBins_ * PhysicalConstants::densityConvert
160 <        / volume_;
161 <      Vector3d vel = binVel[i] / RealType(binCount[i]);
162 <      dynamic_cast<Accumulator *>(temperature->accumulator[i])->add(temp);
163 <      dynamic_cast<VectorAccumulator *>(velocity->accumulator[i])->add(vel);
164 <      dynamic_cast<Accumulator *>(density->accumulator[i])->add(den);
165 <      dynamic_cast<Accumulator *>(counts_->accumulator[i])->add(1);
156 >    for (unsigned int i = 0; i < nBins_; i++) {
157 >      if (binDof[i] > 0) {
158 >        RealType temp = 2.0 * binKE[i] / (binDof[i] * PhysicalConstants::kb *
159 >                                          PhysicalConstants::energyConvert);
160 >        RealType den = binMass[i] * nBins_ * PhysicalConstants::densityConvert
161 >          / volume_;
162 >        Vector3d vel = binVel[i] / RealType(binCount[i]);
163 >        dynamic_cast<Accumulator *>(temperature->accumulator[i])->add(temp);
164 >        dynamic_cast<VectorAccumulator *>(velocity->accumulator[i])->add(vel);
165 >        dynamic_cast<Accumulator *>(density->accumulator[i])->add(den);
166 >        dynamic_cast<Accumulator *>(counts_->accumulator[i])->add(1);
167 >      }
168      }
169    }
170    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines