--- trunk/OOPSE/libmdtools/Molecule.cpp 2004/04/15 16:18:26 1113 +++ trunk/OOPSE/libmdtools/Molecule.cpp 2004/04/27 16:26:44 1136 @@ -42,7 +42,8 @@ void Molecule::initialize( molInit &theInit ){ void Molecule::initialize( molInit &theInit ){ - + double totMass; + nAtoms = theInit.nAtoms; nMembers = nAtoms; nBonds = theInit.nBonds; @@ -61,17 +62,30 @@ void Molecule::initialize( molInit &theInit ){ for (int i = 0; i < myRigidBodies.size(); i++) myRigidBodies[i]->calcRefCoords(); - + + + //the mass ratio will never change during the simulation. Thus, we could + //just calculate it at the begining of the simulation + totMass = getTotalMass(); + for(int i = 0; i < nAtoms; i ++) + myAtoms[i]->setMassRatio(myAtoms[i]->getMass()/totMass); } void Molecule::calcForces( void ){ int i; + double com[3]; for(i=0; iupdateAtoms(); } + //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(); }