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 1884 by gezelter, Tue Jun 18 17:08:40 2013 UTC

# Line 86 | Line 86 | namespace OpenMD {
86    }
87  
88    void RNEMDZ::processFrame(int istep) {
89 +    RealType z;
90 +
91 +    hmat_ = currentSnapshot_->getHmat();
92 +    for (int i = 0; i < nBins_; i++) {
93 +      z = (((RealType)i + 0.5) / (RealType)nBins_) * hmat_(2,2);
94 +      dynamic_cast<Accumulator*>(z_->accumulator[i])->add(z);
95 +    }
96 +    volume_ = currentSnapshot_->getVolume();
97 +
98 +
99      Molecule* mol;
100      RigidBody* rb;
101      StuntDouble* sd;
# Line 96 | Line 106 | namespace OpenMD {
106      vector<RealType> binMass(nBins_, 0.0);
107      vector<Vector3d> binVel(nBins_, V3Zero);
108      vector<RealType> binKE(nBins_, 0.0);
109 <    vector<int> binDof(nBins_, 0);
110 <    vector<int> binCount(nBins_, 0);
109 >    vector<unsigned int> binDof(nBins_, 0);
110 >    vector<unsigned int> binCount(nBins_, 0);
111      
112      
113      for (mol = info_->beginMolecule(mi); mol != NULL;
# Line 110 | Line 120 | namespace OpenMD {
120          rb->updateAtoms();
121        }
122      }
123 <    
123 >  
124      if (evaluator_.isDynamic()) {
125        seleMan_.setSelectionSet(evaluator_.evaluate());
126      }
# Line 122 | Line 132 | namespace OpenMD {
132        
133        // figure out where that object is:
134        Vector3d pos = sd->getPos();
135 <      currentSnapshot_->wrapVector(pos);
135 >      Vector3d vel = sd->getVel();
136 >      RealType m = sd->getMass();
137  
138        int bin = getBin(pos);
128      binCount[bin]++;
139  
140 <      RealType m = sd->getMass();
140 >      binCount[bin] += 1;
141 >
142        binMass[bin] += m;
132      Vector3d vel = sd->getVel();
143        binVel[bin] += vel;
144        binKE[bin] += 0.5 * (m * vel.lengthSquare());
145        binDof[bin] += 3;
# Line 153 | Line 163 | namespace OpenMD {
163        }
164      }
165      
166 <    for (int i = 0; i < nBins_; i++) {
167 <      RealType temp = 2.0 * binKE[i] / (binDof[i] * PhysicalConstants::kb *
168 <                                        PhysicalConstants::energyConvert);
169 <      RealType den = binMass[i] * nBins_ * PhysicalConstants::densityConvert
170 <        / volume_;
171 <      Vector3d vel = binVel[i] / RealType(binCount[i]);
172 <      dynamic_cast<Accumulator *>(temperature->accumulator[i])->add(temp);
173 <      dynamic_cast<VectorAccumulator *>(velocity->accumulator[i])->add(vel);
174 <      dynamic_cast<Accumulator *>(density->accumulator[i])->add(den);
175 <      dynamic_cast<Accumulator *>(counts_->accumulator[i])->add(1);
166 >    for (unsigned int i = 0; i < nBins_; i++) {
167 >      if (binDof[i] > 0) {
168 >        RealType temp = 2.0 * binKE[i] / (binDof[i] * PhysicalConstants::kb *
169 >                                          PhysicalConstants::energyConvert);
170 >        RealType den = binMass[i] * nBins_ * PhysicalConstants::densityConvert
171 >          / volume_;
172 >        Vector3d vel = binVel[i] / RealType(binCount[i]);
173 >        dynamic_cast<Accumulator *>(temperature->accumulator[i])->add(temp);
174 >        dynamic_cast<VectorAccumulator *>(velocity->accumulator[i])->add(vel);
175 >        dynamic_cast<Accumulator *>(density->accumulator[i])->add(den);
176 >        dynamic_cast<Accumulator *>(counts_->accumulator[i])->add(1);
177 >      }
178      }
179    }
180    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines