| 12 |
|
myBonds = NULL; |
| 13 |
|
myBends = NULL; |
| 14 |
|
myTorsions = NULL; |
| 15 |
< |
|
| 15 |
> |
hasMassRatio = false; |
| 16 |
|
} |
| 17 |
|
|
| 18 |
|
Molecule::~Molecule( void ){ |
| 61 |
|
|
| 62 |
|
for (int i = 0; i < myRigidBodies.size(); i++) |
| 63 |
|
myRigidBodies[i]->calcRefCoords(); |
| 64 |
< |
|
| 64 |
> |
|
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
void Molecule::calcForces( void ){ |
| 68 |
|
|
| 69 |
|
int i; |
| 70 |
+ |
double com[3]; |
| 71 |
|
|
| 72 |
|
for(i=0; i<myRigidBodies.size(); i++) { |
| 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 ++) |
| 88 |
+ |
myAtoms[i]->setRc(com); |
| 89 |
+ |
|
| 90 |
+ |
|
| 91 |
|
for(i=0; i<nBonds; i++){ |
| 92 |
|
myBonds[i]->calc_forces(); |
| 93 |
|
} |