| 42 |
|
|
| 43 |
|
|
| 44 |
|
void Molecule::initialize( molInit &theInit ){ |
| 45 |
< |
|
| 45 |
> |
double totMass; |
| 46 |
> |
|
| 47 |
|
nAtoms = theInit.nAtoms; |
| 48 |
|
nMembers = nAtoms; |
| 49 |
|
nBonds = theInit.nBonds; |
| 62 |
|
|
| 63 |
|
for (int i = 0; i < myRigidBodies.size(); i++) |
| 64 |
|
myRigidBodies[i]->calcRefCoords(); |
| 65 |
< |
|
| 65 |
> |
|
| 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); |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
void Molecule::calcForces( void ){ |
| 75 |
|
|
| 76 |
|
int i; |
| 77 |
+ |
double com[3]; |
| 78 |
|
|
| 79 |
|
for(i=0; i<myRigidBodies.size(); i++) { |
| 80 |
|
myRigidBodies[i]->updateAtoms(); |
| 81 |
|
} |
| 82 |
|
|
| 83 |
+ |
//calculate the center of mass of the molecule |
| 84 |
+ |
getCOM(com); |
| 85 |
+ |
for(int i = 0; i < nAtoms; i ++) |
| 86 |
+ |
myAtoms[i]->setRc(com); |
| 87 |
+ |
|
| 88 |
+ |
|
| 89 |
|
for(i=0; i<nBonds; i++){ |
| 90 |
|
myBonds[i]->calc_forces(); |
| 91 |
|
} |