--- trunk/OOPSE/libmdtools/Molecule.cpp 2004/04/15 16:18:26 1113 +++ trunk/OOPSE/libmdtools/Molecule.cpp 2004/04/28 22:34:02 1140 @@ -12,7 +12,7 @@ Molecule::Molecule( void ){ myBonds = NULL; myBends = NULL; myTorsions = NULL; - + hasMassRatio = false; } Molecule::~Molecule( void ){ @@ -61,17 +61,33 @@ void Molecule::initialize( molInit &theInit ){ for (int i = 0; i < myRigidBodies.size(); i++) myRigidBodies[i]->calcRefCoords(); - + } void Molecule::calcForces( void ){ int i; + double com[3]; for(i=0; iupdateAtoms(); } + //the mass ratio will never change during the simulation. Thus, we could + //just calculate it at the begining of the simulation + if (!hasMassRatio){ + double totMass = getTotalMass(); + for(int i = 0; i < nAtoms; i ++) + myAtoms[i]->setMassRatio(myAtoms[i]->getMass()/totMass); + hasMassRatio = true; + } + + //calculate the center of mass of the molecule + getCOM(com); + for(int i = 0; i < nAtoms; i ++) + myAtoms[i]->setRc(com); + + for(i=0; icalc_forces(); }