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; |
120 |
|
rb->updateAtoms(); |
121 |
|
} |
122 |
|
} |
123 |
< |
|
123 |
> |
|
124 |
|
if (evaluator_.isDynamic()) { |
125 |
|
seleMan_.setSelectionSet(evaluator_.evaluate()); |
126 |
|
} |
135 |
|
Vector3d vel = sd->getVel(); |
136 |
|
RealType m = sd->getMass(); |
137 |
|
|
128 |
– |
currentSnapshot_->wrapVector(pos); |
138 |
|
int bin = getBin(pos); |
139 |
+ |
|
140 |
|
binCount[bin] += 1; |
141 |
|
|
142 |
|
binMass[bin] += m; |
164 |
|
} |
165 |
|
|
166 |
|
for (unsigned int i = 0; i < nBins_; i++) { |
167 |
+ |
|
168 |
|
if (binDof[i] > 0) { |
169 |
|
RealType temp = 2.0 * binKE[i] / (binDof[i] * PhysicalConstants::kb * |
170 |
|
PhysicalConstants::energyConvert); |
220 |
|
data_.push_back(density); |
221 |
|
} |
222 |
|
|
212 |
– |
void RNEMDR::processStuntDouble(StuntDouble* sd, int bin) { |
213 |
– |
RealType mass = sd->getMass(); |
214 |
– |
Vector3d vel = sd->getVel(); |
215 |
– |
Vector3d rPos = sd->getPos() - coordinateOrigin_; |
216 |
– |
Vector3d aVel = cross(rPos, vel); |
223 |
|
|
224 |
< |
RealType KE = 0.5 * (mass * vel.lengthSquare()); |
219 |
< |
int dof = 3; |
224 |
> |
void RNEMDR::processFrame(int istep) { |
225 |
|
|
226 |
< |
if (sd->isDirectional()) { |
227 |
< |
Vector3d angMom = sd->getJ(); |
228 |
< |
Mat3x3d I = sd->getI(); |
229 |
< |
if (sd->isLinear()) { |
230 |
< |
int i = sd->linearAxis(); |
231 |
< |
int j = (i + 1) % 3; |
232 |
< |
int k = (i + 2) % 3; |
233 |
< |
KE += 0.5 * (angMom[j] * angMom[j] / I(j, j) + |
234 |
< |
angMom[k] * angMom[k] / I(k, k)); |
235 |
< |
dof += 2; |
236 |
< |
} else { |
237 |
< |
KE += 0.5 * (angMom[0] * angMom[0] / I(0, 0) + |
238 |
< |
angMom[1] * angMom[1] / I(1, 1) + |
239 |
< |
angMom[2] * angMom[2] / I(2, 2)); |
240 |
< |
dof += 3; |
226 |
> |
Molecule* mol; |
227 |
> |
RigidBody* rb; |
228 |
> |
StuntDouble* sd; |
229 |
> |
SimInfo::MoleculeIterator mi; |
230 |
> |
Molecule::RigidBodyIterator rbIter; |
231 |
> |
int i; |
232 |
> |
|
233 |
> |
vector<RealType> binMass(nBins_, 0.0); |
234 |
> |
vector<Vector3d> binaVel(nBins_, V3Zero); |
235 |
> |
vector<RealType> binKE(nBins_, 0.0); |
236 |
> |
vector<unsigned int> binDof(nBins_, 0); |
237 |
> |
vector<unsigned int> binCount(nBins_, 0); |
238 |
> |
|
239 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
240 |
> |
mol = info_->nextMolecule(mi)) { |
241 |
> |
|
242 |
> |
// change the positions of atoms which belong to the rigidbodies |
243 |
> |
|
244 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
245 |
> |
rb = mol->nextRigidBody(rbIter)) { |
246 |
> |
rb->updateAtoms(); |
247 |
|
} |
248 |
|
} |
249 |
+ |
|
250 |
+ |
if (evaluator_.isDynamic()) { |
251 |
+ |
seleMan_.setSelectionSet(evaluator_.evaluate()); |
252 |
+ |
} |
253 |
|
|
254 |
< |
RealType temp = 2.0 * KE / (dof * PhysicalConstants::kb * |
255 |
< |
PhysicalConstants::energyConvert); |
254 |
> |
// loop over the selected atoms: |
255 |
> |
|
256 |
> |
for (sd = seleMan_.beginSelected(i); sd != NULL; |
257 |
> |
sd = seleMan_.nextSelected(i)) { |
258 |
> |
|
259 |
> |
// figure out where that object is: |
260 |
|
|
261 |
< |
RealType rinner = (RealType)bin * binWidth_; |
262 |
< |
RealType router = (RealType)(bin+1) * binWidth_; |
263 |
< |
RealType den = mass * 3.0 * PhysicalConstants::densityConvert |
264 |
< |
/ (4.0 * M_PI * (pow(router,3) - pow(rinner,3))); |
261 |
> |
Vector3d rPos = sd->getPos() - coordinateOrigin_; |
262 |
> |
Vector3d vel = sd->getVel(); |
263 |
> |
Vector3d aVel = cross(rPos, vel); |
264 |
> |
RealType m = sd->getMass(); |
265 |
> |
|
266 |
> |
int bin = getBin(pos); |
267 |
> |
|
268 |
> |
binCount[bin] += 1; |
269 |
> |
|
270 |
> |
binMass[bin] += m; |
271 |
> |
binaVel[bin] += aVel; |
272 |
> |
binKE[bin] += 0.5 * (m * vel.lengthSquare()); |
273 |
> |
binDof[bin] += 3; |
274 |
> |
|
275 |
> |
if (sd->isDirectional()) { |
276 |
> |
Vector3d angMom = sd->getJ(); |
277 |
> |
Mat3x3d I = sd->getI(); |
278 |
> |
if (sd->isLinear()) { |
279 |
> |
int i = sd->linearAxis(); |
280 |
> |
int j = (i + 1) % 3; |
281 |
> |
int k = (i + 2) % 3; |
282 |
> |
binKE[bin] += 0.5 * (angMom[j] * angMom[j] / I(j, j) + |
283 |
> |
angMom[k] * angMom[k] / I(k, k)); |
284 |
> |
binDof[bin] += 2; |
285 |
> |
} else { |
286 |
> |
binKE[bin] += 0.5 * (angMom[0] * angMom[0] / I(0, 0) + |
287 |
> |
angMom[1] * angMom[1] / I(1, 1) + |
288 |
> |
angMom[2] * angMom[2] / I(2, 2)); |
289 |
> |
binDof[bin] += 3; |
290 |
> |
} |
291 |
> |
} |
292 |
> |
} |
293 |
|
|
294 |
< |
dynamic_cast<Accumulator *>(temperature->accumulator[bin])->add(temp); |
295 |
< |
dynamic_cast<VectorAccumulator *>(angularVelocity->accumulator[bin])->add(aVel); |
296 |
< |
dynamic_cast<Accumulator *>(density->accumulator[bin])->add(den); |
294 |
> |
for (unsigned int i = 0; i < nBins_; i++) { |
295 |
> |
RealType rinner = (RealType)i * binWidth_; |
296 |
> |
RealType router = (RealType)(i+1) * binWidth_; |
297 |
> |
if (binDof[i] > 0) { |
298 |
> |
RealType temp = 2.0 * binKE[i] / (binDof[i] * PhysicalConstants::kb * |
299 |
> |
PhysicalConstants::energyConvert); |
300 |
> |
RealType den = binMass[i] * 3.0 * PhysicalConstants::densityConvert |
301 |
> |
/ (4.0 * M_PI * (pow(router,3) - pow(rinner,3))); |
302 |
> |
Vector3d aVel = binaVel[i] / RealType(binCount[i]); |
303 |
> |
dynamic_cast<Accumulator *>(temperature->accumulator[i])->add(temp); |
304 |
> |
dynamic_cast<VectorAccumulator *>(angularVelocity->accumulator[i])->add(aVel); |
305 |
> |
dynamic_cast<Accumulator *>(density->accumulator[i])->add(den); |
306 |
> |
dynamic_cast<Accumulator *>(counts_->accumulator[i])->add(1); |
307 |
> |
} |
308 |
> |
} |
309 |
> |
} |
310 |
|
|
311 |
+ |
|
312 |
+ |
void RNEMDR::processStuntDouble(StuntDouble* sd, int bin) { |
313 |
|
} |
314 |
|
} |
315 |
|
|