OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
BAOAB.cpp
1/*
2 * Copyright (c) 2019 The University of Notre Dame. All Rights Reserved.
3 *
4 * The University of Notre Dame grants you ("Licensee") a
5 * non-exclusive, royalty free, license to use, modify and
6 * redistribute this software in source and binary code form, provided
7 * that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * This software is provided "AS IS," without a warranty of any
18 * kind. All express or implied conditions, representations and
19 * warranties, including any implied warranty of merchantability,
20 * fitness for a particular purpose or non-infringement, are hereby
21 * excluded. The University of Notre Dame and its licensors shall not
22 * be liable for any damages suffered by licensee as a result of
23 * using, modifying or distributing the software or its
24 * derivatives. In no event will the University of Notre Dame or its
25 * licensors be liable for any lost revenue, profit or data, or for
26 * direct, indirect, special, consequential, incidental or punitive
27 * damages, however caused and regardless of the theory of liability,
28 * arising out of the use of or inability to use software, even if the
29 * University of Notre Dame has been advised of the possibility of
30 * such damages.
31 *
32 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
33 * research, please cite the appropriate papers when you publish your
34 * work. Good starting points are:
35 *
36 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
37 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
38 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
39 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
40 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
41 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
42 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
43 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
44 */
45
46#include <fstream>
47#include <iostream>
48#include "integrators/BAOAB.hpp"
50#include "utils/Constants.hpp"
52#include "math/CholeskyDecomposition.hpp"
53#include "utils/Constants.hpp"
54#include "hydrodynamics/Sphere.hpp"
55#include "hydrodynamics/Ellipsoid.hpp"
57#include "types/LennardJonesAdapter.hpp"
58#include "types/GayBerneAdapter.hpp"
59
60namespace OpenMD {
61
62 BAOAB::BAOAB(SimInfo* info) : Integrator(info){
63 simParams = info->getSimParams();
64 veloMunge = new Velocitizer(info);
65
66 sphericalBoundaryConditions_ = false;
67 if (simParams->getUseSphericalBoundaryConditions()) {
68 sphericalBoundaryConditions_ = true;
69 if (simParams->haveLangevinBufferRadius()) {
70 langevinBufferRadius_ = simParams->getLangevinBufferRadius();
71 } else {
72 sprintf( painCave.errMsg,
73 "langevinBufferRadius must be specified "
74 "when useSphericalBoundaryConditions is turned on.\n");
75 painCave.severity = OPENMD_ERROR;
76 painCave.isFatal = 1;
77 simError();
78 }
79
80 if (simParams->haveFrozenBufferRadius()) {
81 frozenBufferRadius_ = simParams->getFrozenBufferRadius();
82 } else {
83 sprintf( painCave.errMsg,
84 "frozenBufferRadius must be specified "
85 "when useSphericalBoundaryConditions is turned on.\n");
86 painCave.severity = OPENMD_ERROR;
87 painCave.isFatal = 1;
88 simError();
89 }
90
91 if (frozenBufferRadius_ < langevinBufferRadius_) {
92 sprintf( painCave.errMsg,
93 "frozenBufferRadius has been set smaller than the "
94 "langevinBufferRadius. This is probably an error.\n");
95 painCave.severity = OPENMD_WARNING;
96 painCave.isFatal = 0;
97 simError();
98 }
99 }
100
101 // Build the hydroProp_ map:
102
103 Molecule* mol;
104 StuntDouble* sd;
105 SimInfo::MoleculeIterator i;
106 Molecule::IntegrableObjectIterator j;
107 bool needHydroPropFile = false;
108
109 for (mol = info->beginMolecule(i); mol != NULL;
110 mol = info->nextMolecule(i)) {
111
112 for (sd = mol->beginIntegrableObject(j); sd != NULL;
113 sd = mol->nextIntegrableObject(j)) {
114
115 if (sd->isRigidBody()) {
116 RigidBody* rb = static_cast<RigidBody*>(sd);
117 if (rb->getNumAtoms() > 1) needHydroPropFile = true;
118 }
119
120 }
121 }
122
123 if (needHydroPropFile) {
124 if (simParams->haveHydroPropFile()) {
125 hydroPropMap_ = parseFrictionFile(simParams->getHydroPropFile());
126 } else {
127 sprintf( painCave.errMsg,
128 "HydroPropFile must be set to a file name if Langevin Dynamics\n"
129 "\tis specified for rigidBodies which contain more than one atom\n"
130 "\tTo create a HydroPropFile, run the \"Hydro\" program.\n");
131 painCave.severity = OPENMD_ERROR;
132 painCave.isFatal = 1;
133 simError();
134 }
135
136 for (mol = info->beginMolecule(i); mol != NULL;
137 mol = info->nextMolecule(i)) {
138
139 for (sd = mol->beginIntegrableObject(j); sd != NULL;
140 sd = mol->nextIntegrableObject(j)) {
141
142 map<string, HydroProp*>::iterator iter = hydroPropMap_.find(sd->getType());
143 if (iter != hydroPropMap_.end()) {
144
145 hydroProps_.push_back(iter->second);
146 moments_.push_back(getMomentData(sd));
147
148 } else {
149 sprintf( painCave.errMsg,
150 "Can not find resistance tensor for atom [%s]\n",
151 sd->getType().c_str());
152 painCave.severity = OPENMD_ERROR;
153 painCave.isFatal = 1;
154 simError();
155 }
156 }
157 }
158
159 } else {
160
161 for (mol = info->beginMolecule(i); mol != NULL;
162 mol = info->nextMolecule(i)) {
163
164 for (sd = mol->beginIntegrableObject(j); sd != NULL;
165 sd = mol->nextIntegrableObject(j)) {
166
167 Shape* currShape = NULL;
168
169 if (sd->isAtom()){
170 Atom* atom = static_cast<Atom*>(sd);
171 AtomType* atomType = atom->getAtomType();
172 GayBerneAdapter gba = GayBerneAdapter(atomType);
173 if (gba.isGayBerne()) {
174 currShape = new Ellipsoid(V3Zero, gba.getL() / 2.0,
175 gba.getD() / 2.0,
177 } else {
179 if (lja.isLennardJones()){
180 currShape = new Sphere(atom->getPos(), lja.getSigma()/2.0);
181 } else {
182
183 int aNum(0);
184 vector<AtomType*> atChain = atomType->allYourBase();
185 vector<AtomType*>::iterator i;
186 for (i = atChain.begin(); i != atChain.end(); ++i) {
187 aNum = etab.GetAtomicNum((*i)->getName().c_str());
188 if (aNum != 0) {
189 currShape = new Sphere(atom->getPos(),
190 etab.GetVdwRad(aNum));
191 break;
192 }
193 }
194 if (aNum == 0) {
195 sprintf( painCave.errMsg,
196 "Could not find atom type in default element.txt\n");
197 painCave.severity = OPENMD_ERROR;
198 painCave.isFatal = 1;
199 simError();
200 }
201 }
202 }
203 }
204
205 if (!simParams->haveTargetTemp()) {
206 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
207 "You can't use BAOAB without a targetTemp!\n");
208 painCave.isFatal = 1;
209 painCave.severity = OPENMD_ERROR;
210 simError();
211 }
212
213 if (!simParams->haveViscosity()) {
214 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
215 "You can't use BAOAB without a viscosity!\n");
216 painCave.isFatal = 1;
217 painCave.severity = OPENMD_ERROR;
218 simError();
219 }
220
221
222 HydroProp* currHydroProp = currShape->getHydroProp(simParams->getViscosity(),simParams->getTargetTemp());
223 map<string, HydroProp*>::iterator iter = hydroPropMap_.find(sd->getType());
224 if (iter != hydroPropMap_.end()) {
225
226 hydroProps_.push_back(iter->second);
227 moments_.push_back(getMomentData(sd));
228
229 } else {
230 currHydroProp->complete();
231 hydroPropMap_.insert(map<string, HydroProp*>::value_type(sd->getType(), currHydroProp));
232 hydroProps_.push_back(currHydroProp);
233 moments_.push_back(getMomentData(sd));
234 }
235 delete currShape;
236 }
237 }
238 }
239 variance_ = 2.0 * Constants::kb*simParams->getTargetTemp()/simParams->getDt();
240 }
241
242 void BAOAB::step() {
243 if (method == LANGEVIN_METHOD_BAOAB) {
244 // Velocity half-step (B)
245 VelocityStep(0.5 * dt);
246 ResolveVelocityConstraints(0.5 * dt);
247
248 // Position half step (A)
249 PositionStep(0.5 * dt);
250 ResolvePositionConstraints(0.5 * dt);
251 ResolveVelocityConstraints(0.5 * dt);
252
253 // Velocity update (O)
254 OStep(dt);
255 ResolveVelocityConstraints(dt);
256
257 // Position half step (A)
258 PositionStep(0.5 * dt);
259 ResolvePositionConstraints(0.5 * dt);
260 ResolveVelocityConstraints(0.5 * dt);
261
262 calcForce();
263
264 // Velocity half-step (B)
265 VelocityStep(0.5 * dt);
266 ResolveVelocityConstraints(0.5 * dt);
267
268 } else if (method == LANGEVIN_METHOD_ABOBA) {
269 // Position half step (A)
270 PositionStep(0.5 * dt);
271 ResolvePositionConstraints(0.5 * dt);
272 ResolveVelocityConstraints(0.5 * dt);
273
274 calcForce();
275
276 // Velocity half-step (B)
277 VelocityStep(0.5 * dt);
278 ResolveVelocityConstraints(0.5 * dt);
279
280 // Velocity update (O)
281 OStep(dt);
282 ResolveVelocityConstraints(dt);
283
284 // Velocity half-step (B)
285 VelocityStep(0.5 * dt);
286 ResolveVelocityConstraints(0.5 * dt);
287
288 // Position half step (A)
289 PositionStep(0.5 * dt);
290 ResolvePositionConstraints(0.5 * dt);
291 ResolveVelocityConstraints(0.5 * dt);
292 }
293
294 }
295
296 void BAOAB::PositionStep(RealType dt) {
297 SimInfo::MoleculeIterator i;
298 Molecule::IntegrableObjectIterator j;
299 Molecule* mol;
300 StuntDouble* sd;
301 Vector3d vel;
302 Vector3d pos;
303 Vector3d ji;
304
305 for (mol = info_->beginMolecule(i); mol != NULL;
306 mol = info_->nextMolecule(i)) {
307
308 for (sd = mol->beginIntegrableObject(j); sd != NULL;
309 sd = mol->nextIntegrableObject(j)) {
310
311 vel = sd->getVel();
312 pos = sd->getPos();
313
314 // position whole step
315 pos += dt * vel;
316
317 sd->setPos(pos);
318
319 if (sd->isDirectional()){
320
321 ji = sd->getJ();
322
323 rotAlgo_->rotate(sd, ji, dt);
324
325 sd->setJ(ji);
326 }
327 }
328 }
329 }
330
331 void BAOAB::Ostep(){
332 SimInfo::MoleculeIterator i;
333 Molecule::IntegrableObjectIterator j;
334 Molecule* mol;
335 StuntDouble* sd;
336 RealType mass;
337 Vector3d pos;
338 Vector3d frc;
339 Mat3x3d A;
340 Mat3x3d Atrans;
341 Vector3d Tb;
342 Vector3d ji;
343 unsigned int index = 0;
344 bool doLangevinForces;
345 bool freezeMolecule;
346 int fdf;
347
348 fdf = 0;
349
350 for (mol = info_->beginMolecule(i); mol != NULL;
351 mol = info_->nextMolecule(i)) {
352
353 doLangevinForces = true;
354 freezeMolecule = false;
355
356 if (sphericalBoundaryConditions_) {
357
358 Vector3d molPos = mol->getCom();
359 RealType molRad = molPos.length();
360
361 doLangevinForces = false;
362
363 if (molRad > langevinBufferRadius_) {
364 doLangevinForces = true;
365 freezeMolecule = false;
366 }
367 if (molRad > frozenBufferRadius_) {
368 doLangevinForces = false;
369 freezeMolecule = true;
370 }
371 }
372
373 for (sd = mol->beginIntegrableObject(j); sd != NULL;
374 sd = mol->nextIntegrableObject(j)) {
375
376 if (freezeMolecule)
377 fdf += sd->freeze();
378
379 if (doLangevinForces) {
380 mass = sd->getMass();
381
382 if (sd->isDirectional()){
383
384 // preliminaries for directional objects:
385
386 A = sd->getA();
387 Atrans = A.transpose();
388
389 Vector3d rcrLab = Atrans * moments_[index]->rcr;
390
391 //apply random force and torque at center of resistance
392
393 Vector3d randomForceBody;
394 Vector3d randomTorqueBody;
395 genRandomForceAndTorque(randomForceBody, randomTorqueBody,
396 index, variance_);
397 Vector3d randomForceLab = Atrans * randomForceBody;
398 Vector3d randomTorqueLab = Atrans * randomTorqueBody;
399 sd->addFrc(randomForceLab);
400 sd->addTrq(randomTorqueLab + cross(rcrLab, randomForceLab ));
401
402 Vector3d omegaBody;
403
404 // What remains contains velocity explicitly, but the
405 // velocity required is at the full step: v(t + h), while
406 // we have initially the velocity at the half step: v(t + h/2).
407 // We need to iterate to converge the friction
408 // force and friction torque vectors.
409
410 // this is the velocity at the half-step:
411
412 Vector3d vel =sd->getVel();
413 Vector3d angMom = sd->getJ();
414
415 // estimate velocity at full-step using everything but
416 // friction forces:
417
418 frc = sd->getFrc();
419 Vector3d velStep = vel + (dt2_ /mass * Constants::energyConvert) * frc;
420
421 Tb = sd->lab2Body(sd->getTrq());
422 Vector3d angMomStep = angMom + (dt2_ * Constants::energyConvert) * Tb;
423
424 Vector3d omegaLab;
425 Vector3d vcdLab;
426 Vector3d vcdBody;
427 Vector3d frictionForceBody;
428 Vector3d frictionForceLab(0.0);
429 Vector3d oldFFL; // used to test for convergence
430 Vector3d frictionTorqueBody(0.0);
431 Vector3d oldFTB; // used to test for convergence
432 Vector3d frictionTorqueLab;
433 RealType fdot;
434 RealType tdot;
435
436 //iteration starts here:
437
438 for (int k = 0; k < maxIterNum_; k++) {
439
440 if (sd->isLinear()) {
441 int linearAxis = sd->linearAxis();
442 int l = (linearAxis +1 )%3;
443 int m = (linearAxis +2 )%3;
444 omegaBody[l] = angMomStep[l] /moments_[index]->Icr(l, l);
445 omegaBody[m] = angMomStep[m] /moments_[index]->Icr(m, m);
446
447 } else {
448 omegaBody = moments_[index]->IcrInv * angMomStep;
449 //omegaBody[0] = angMomStep[0] /I(0, 0);
450 //omegaBody[1] = angMomStep[1] /I(1, 1);
451 //omegaBody[2] = angMomStep[2] /I(2, 2);
452 }
453
454 omegaLab = Atrans * omegaBody;
455
456 // apply friction force and torque at center of resistance
457
458 vcdLab = velStep + cross(omegaLab, rcrLab);
459 vcdBody = A * vcdLab;
460 frictionForceBody = -(hydroProps_[index]->getXitt() * vcdBody +
461 hydroProps_[index]->getXirt() * omegaBody);
462 oldFFL = frictionForceLab;
463 frictionForceLab = Atrans * frictionForceBody;
464 oldFTB = frictionTorqueBody;
465 frictionTorqueBody = -(hydroProps_[index]->getXitr() * vcdBody +
466 hydroProps_[index]->getXirr() * omegaBody);
467 frictionTorqueLab = Atrans * frictionTorqueBody;
468
469 // re-estimate velocities at full-step using friction forces:
470
471 velStep = vel + (dt2_ / mass * Constants::energyConvert) * (frc + frictionForceLab);
472 angMomStep = angMom + (dt2_ * Constants::energyConvert) * (Tb + frictionTorqueBody);
473
474 // check for convergence (if the vectors have converged, fdot and tdot will both be 1.0):
475
476 fdot = dot(frictionForceLab, oldFFL) / frictionForceLab.lengthSquare();
477 tdot = dot(frictionTorqueBody, oldFTB) / frictionTorqueBody.lengthSquare();
478
479 if (fabs(1.0 - fdot) <= forceTolerance_ &&
480 fabs(1.0 - tdot) <= forceTolerance_)
481 break; // iteration ends here
482 }
483
484 sd->addFrc(frictionForceLab);
485 sd->addTrq(frictionTorqueLab + cross(rcrLab, frictionForceLab));
486
487
488 } else {
489 //spherical atom
490
491 Vector3d randomForce;
492 Vector3d randomTorque;
493 genRandomForceAndTorque(randomForce, randomTorque,
494 index, variance_);
495 sd->addFrc(randomForce);
496
497 // What remains contains velocity explicitly, but the
498 // velocity required is at the full step: v(t + h), while
499 // we have initially the velocity at the half step: v(t + h/2).
500 // We need to iterate to converge the friction
501 // force vector.
502
503 // this is the velocity at the half-step:
504
505 Vector3d vel =sd->getVel();
506
507 // estimate velocity at full-step using everything but
508 // friction forces:
509
510 frc = sd->getFrc();
511 Vector3d velStep = vel + (dt2_ / mass * Constants::energyConvert) * frc;
512
513 Vector3d frictionForce(0.0);
514 Vector3d oldFF; // used to test for convergence
515 RealType fdot;
516
517 //iteration starts here:
518
519 for (int k = 0; k < maxIterNum_; k++) {
520
521 oldFF = frictionForce;
522 frictionForce = -hydroProps_[index]->getXitt() * velStep;
523
524 // re-estimate velocities at full-step using friction forces:
525
526 velStep = vel + (dt2_ / mass * Constants::energyConvert) * (frc + frictionForce);
527
528 // check for convergence (if the vector has converged,
529 // fdot will be 1.0):
530
531 fdot = dot(frictionForce, oldFF) / frictionForce.lengthSquare();
532
533 if (fabs(1.0 - fdot) <= forceTolerance_)
534 break; // iteration ends here
535 }
536
537 sd->addFrc(frictionForce);
538
539 }
540 }
541
542 ++index;
543
544 }
545 }
546
547 info_->setFdf(fdf);
548 veloMunge->removeComDrift();
549 // Remove angular drift if we are not using periodic boundary conditions.
550 if(!simParams->getUsePeriodicBoundaryConditions())
551 veloMunge->removeAngularDrift();
552
553 ForceManager::postCalculation();
554 }
555
556
557 void BAOAB::VelocityStep(RealType dt) {
558 SimInfo::MoleculeIterator i;
559 Molecule::IntegrableObjectIterator j;
560 Molecule* mol;
561 StuntDouble* sd;
562 Vector3d vel;
563 Vector3d frc;
564 Vector3d Tb;
565 Vector3d ji;
566 RealType mass;
567
568 for (mol = info_->beginMolecule(i); mol != NULL;
569 mol = info_->nextMolecule(i)) {
570
571 for (sd = mol->beginIntegrableObject(j); sd != NULL;
572 sd = mol->nextIntegrableObject(j)) {
573
574 vel = sd->getVel();
575 frc = sd->getFrc();
576 mass = sd->getMass();
577
578 vel += (dt * Constants::energyConvert / mass) * frc;
579
580 sd->setVel(vel);
581
582 if (sd->isDirectional()){
583
584 // get and convert the torque to body frame
585
586 Tb = sd->lab2Body(sd->getTrq());
587
588 // propagate the angular momentum
589
590 ji = sd->getJ();
591
592 ji += (dt * Constants::energyConvert) * Tb;
593
594 sd->setJ(ji);
595 }
596 }
597 }
598 }
599
600 map<string, HydroProp*> BAOAB::parseFrictionFile(const string& filename) {
601 map<string, HydroProp*> props;
602 ifstream ifs(filename.c_str());
603 if (ifs.is_open()) {
604
605 }
606
607 const unsigned int BufferSize = 65535;
608 char buffer[BufferSize];
609 while (ifs.getline(buffer, BufferSize)) {
610 HydroProp* currProp = new HydroProp(buffer);
611 props.insert(map<string, HydroProp*>::value_type(currProp->getName(),
612 currProp));
613 }
614
615 return props;
616 }
617
618 MomentData* BAOAB::getMomentData(StuntDouble* sd) {
619
620 map<string, MomentData*>::iterator j = momentsMap_.find(sd->getType());
621 if (j != momentsMap_.end()) {
622 return j->second;
623 } else {
624
625 MomentData* moment = new MomentData;
626 map<string, HydroProp*>::iterator i = hydroPropMap_.find(sd->getType());
627
628 if (i != hydroPropMap_.end()) {
629 // Center of Resistance:
630 moment->rcr = i->second->getCOR();
631 } else {
632 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
633 "LDForceManager createMomentData: Couldn't find HydroProp for\n"
634 "object type %s!\n", sd->getType().c_str());
635 painCave.isFatal = 1;
636 painCave.severity = OPENMD_ERROR;
637 simError();
638 }
639
640 if (sd->isRigidBody())
641 moment->rcr -= dynamic_cast<RigidBody*>(sd)->getRefCOM();
642
643 // Parallel axis formula to get the moment of inertia around
644 // the center of resistance:
645 RealType mass = sd->getMass();
646 moment->Ir = sd->getI();
647 moment->Ir += mass*(dot(moment->rcr, moment->rcr) * Mat3x3d::identity() +
648 outProduct(moment->rcr, moment->rcr));
649
650 // Mr is a 6x6 mass matrix (no longer diagonal at center of resistance):
651 Mat6x6d Mr(0.0);
652 Mr(0,0) = mass;
653 Mr(1,1) = mass;
654 Mr(2,2) = mass;
655 Mr.setSubMatrix(3,3, moment->Ir);
656 Mat6x6d MrInv = Mr.inverse();
657
658 // little-mr is a square root (approximately) of the Mr matrix:
659 Mat6x6d mr(0.0);
660 CholeskyDecomposition(Mr, mr);
661
662 Mat6x6d GammaR = -(i->second->getXi() * MrInv);
663 Mat6x6d S = i->second->getS();
664
665 Mat6x6d sigma = sqrt(2.0*Constants::kb*simParams->getTargetTemp()) * S*mr;
666
667 DynamicRectMatrix<RealType> mat(6,6) = GammaR;
668
669 JAMA::Eigenvalue<RealType> eigensystem(mat);
670
671 DynamicRectMatrix<RealType> evects(6,6);
673
674 eigensystem.getRealEigenvalues(evals);
675 eigensystem.getV(evects);
676
677
678
679
680 momentsMap_.insert(map<string, MomentData*>::value_type(sd->getType(),
681 moment));
682 return moment;
683 }
684 }
685
686
687 void BAOAB::genRandomForceAndTorque(Vector3d& force,
688 Vector3d& torque,
689 unsigned int index,
690 RealType variance) {
692 Vector<RealType, 6> generalForce;
693
694 Z[0] = randNumGen_.randNorm(0, variance);
695 Z[1] = randNumGen_.randNorm(0, variance);
696 Z[2] = randNumGen_.randNorm(0, variance);
697 Z[3] = randNumGen_.randNorm(0, variance);
698 Z[4] = randNumGen_.randNorm(0, variance);
699 Z[5] = randNumGen_.randNorm(0, variance);
700
701 generalForce = hydroProps_[index]->getS()*Z;
702
703 force[0] = generalForce[0];
704 force[1] = generalForce[1];
705 force[2] = generalForce[2];
706 torque[0] = generalForce[3];
707 torque[1] = generalForce[4];
708 torque[2] = generalForce[5];
709 }
710}
This basic Periodic Table class was originally taken from the data.h file in OpenBabel.
Computes eigenvalues and eigenvectors of a real (non-complex) matrix.
AtomType * getAtomType()
Returns the AtomType of this Atom.
Definition A.hpp:93
AtomType is what OpenMD looks to for unchanging data about an atom.
Definition AtomType.hpp:66
virtual void step()
Computes an integration step from t to t+dt.
Definition BAOAB.cpp:242
rectangular matrix class
Dynamically-sized vector class.
RealType GetVdwRad(int atomicnum)
int GetAtomicNum(const char *str)
An ellipsoid in OpenMD is restricted to having two equal equatorial semi-axes.
Definition Ellipsoid.hpp:68
Container for information about the hydrodynamic behavior of objects interacting with surroundings.
Definition HydroProp.hpp:74
Declaration of the Integrator base class, which all other integrators inherit from.
Vector3d getCom()
Returns the current center of mass position of this molecule.
Definition Molecule.cpp:298
size_t getNumAtoms()
Returns the number of atoms in this rigid body.
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Definition SimInfo.hpp:93
Molecule * beginMolecule(MoleculeIterator &i)
Returns the first molecule in this SimInfo and intialize the iterator.
Definition SimInfo.cpp:240
Molecule * nextMolecule(MoleculeIterator &i)
Returns the next avaliable Molecule based on the iterator.
Definition SimInfo.cpp:245
void setFdf(int fdf)
sets the current number of frozen degrees of freedom
Definition SimInfo.hpp:232
static SquareMatrix< RealType, Dim > identity()
SquareMatrix< Real, Dim > inverse()
Returns the inverse of this matrix.
"Don't move, or you're dead! Stand up! Captain, we've got them!"
Vector3d getTrq()
Returns the current torque of this stuntDouble.
Vector3d lab2Body(const Vector3d &v)
Converts a lab fixed vector to a body fixed vector.
RotMat3x3d getA()
Returns the current rotation matrix of this stuntDouble.
Vector3d getVel()
Returns the current velocity of this stuntDouble.
int linearAxis()
Returns the linear axis of the rigidbody, atom and directional atom will always return -1.
RealType getMass()
Returns the mass of this stuntDouble.
virtual Mat3x3d getI()=0
Returns the inertia tensor of this stuntDouble.
virtual std::string getType()=0
Returns the name of this stuntDouble.
bool isLinear()
Tests the if this stuntDouble is a linear rigidbody.
Vector3d getPos()
Returns the current position of this stuntDouble.
void setPos(const Vector3d &pos)
Sets the current position of this stuntDouble.
void setVel(const Vector3d &vel)
Sets the current velocity of this stuntDouble.
void addTrq(const Vector3d &trq)
Adds torque into the current torque of this stuntDouble.
bool isRigidBody()
Tests if this stuntDouble is a rigid body.
Vector3d getJ()
Returns the current angular momentum of this stuntDouble (body -fixed).
bool isAtom()
Tests if this stuntDouble is an atom.
bool isDirectional()
Tests if this stuntDouble is a directional one.
int freeze()
Freezes out all velocity, angular velocity, forces and torques on this StuntDouble.
Vector3d getFrc()
Returns the current force of this stuntDouble.
void setJ(const Vector3d &angMom)
Sets the current angular momentum of this stuntDouble (body-fixed).
void addFrc(const Vector3d &frc)
Adds force into the current force of this stuntDouble.
Fix length vector class.
Definition Vector.hpp:78
Real length()
Returns the length of this vector.
Definition Vector.hpp:393
Velocity-modifying routines.
void removeComDrift()
Removes Center of Mass Drift Velocity Removes the center of mass drift velocity (required for accurat...
void removeAngularDrift()
Removes Center of Mass Angular momentum Removes the center of mass angular momentum (particularly use...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Vector3< Real > cross(const Vector3< Real > &v1, const Vector3< Real > &v2)
Returns the cross product of two Vectors.
Definition Vector3.hpp:136
Real dot(const DynamicVector< Real > &v1, const DynamicVector< Real > &v2)
Returns the dot product of two DynamicVectors.
Vector3d rcr
Distance between CoM and Center of Resistance.
Definition BAOAB.hpp:64