220 |
|
data_.push_back(density); |
221 |
|
} |
222 |
|
|
223 |
– |
void RNEMDR::processStuntDouble(StuntDouble* sd, int bin) { |
224 |
– |
RealType mass = sd->getMass(); |
225 |
– |
Vector3d vel = sd->getVel(); |
226 |
– |
Vector3d rPos = sd->getPos() - coordinateOrigin_; |
227 |
– |
Vector3d aVel = cross(rPos, vel); |
223 |
|
|
224 |
< |
RealType KE = 0.5 * (mass * vel.lengthSquare()); |
230 |
< |
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); |
256 |
< |
|
257 |
< |
RealType rinner = (RealType)bin * binWidth_; |
258 |
< |
RealType router = (RealType)(bin+1) * binWidth_; |
259 |
< |
RealType den = mass * 3.0 * PhysicalConstants::densityConvert |
256 |
< |
/ (4.0 * M_PI * (pow(router,3) - pow(rinner,3))); |
257 |
< |
|
258 |
< |
dynamic_cast<Accumulator *>(temperature->accumulator[bin])->add(temp); |
259 |
< |
dynamic_cast<VectorAccumulator *>(angularVelocity->accumulator[bin])->add(aVel); |
260 |
< |
dynamic_cast<Accumulator *>(density->accumulator[bin])->add(den); |
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 |
+ |
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(rPos); |
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 |
+ |
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 |
|
|