12 |
|
myBonds = NULL; |
13 |
|
myBends = NULL; |
14 |
|
myTorsions = NULL; |
15 |
< |
|
15 |
> |
hasMassRatio = false; |
16 |
|
} |
17 |
|
|
18 |
|
Molecule::~Molecule( void ){ |
42 |
|
|
43 |
|
|
44 |
|
void Molecule::initialize( molInit &theInit ){ |
45 |
< |
double totMass; |
46 |
< |
|
45 |
> |
|
46 |
|
nAtoms = theInit.nAtoms; |
47 |
|
nMembers = nAtoms; |
48 |
|
nBonds = theInit.nBonds; |
62 |
|
for (int i = 0; i < myRigidBodies.size(); i++) |
63 |
|
myRigidBodies[i]->calcRefCoords(); |
64 |
|
|
66 |
– |
|
67 |
– |
//the mass ratio will never change during the simulation. Thus, we could |
68 |
– |
//just calculate it at the begining of the simulation |
69 |
– |
totMass = getTotalMass(); |
70 |
– |
for(int i = 0; i < nAtoms; i ++) |
71 |
– |
myAtoms[i]->setMassRatio(myAtoms[i]->getMass()/totMass); |
65 |
|
} |
66 |
|
|
67 |
|
void Molecule::calcForces( void ){ |
73 |
|
myRigidBodies[i]->updateAtoms(); |
74 |
|
} |
75 |
|
|
76 |
+ |
//the mass ratio will never change during the simulation. Thus, we could |
77 |
+ |
//just calculate it at the begining of the simulation |
78 |
+ |
if (!hasMassRatio){ |
79 |
+ |
double totMass = getTotalMass(); |
80 |
+ |
for(int i = 0; i < nAtoms; i ++) |
81 |
+ |
myAtoms[i]->setMassRatio(myAtoms[i]->getMass()/totMass); |
82 |
+ |
hasMassRatio = true; |
83 |
+ |
} |
84 |
+ |
|
85 |
|
//calculate the center of mass of the molecule |
86 |
|
getCOM(com); |
87 |
|
for(int i = 0; i < nAtoms; i ++) |