--- trunk/OOPSE/libmdtools/Molecule.cpp 2003/10/28 16:03:37 829 +++ trunk/OOPSE/libmdtools/Molecule.cpp 2004/04/15 16:18:26 1113 @@ -15,8 +15,6 @@ Molecule::Molecule( void ){ } - - Molecule::~Molecule( void ){ int i; @@ -40,10 +38,6 @@ Molecule::~Molecule( void ){ delete[] myTorsions; } - if( myExcludes != NULL ){ - for(i=0; icalcRefCoords(); } @@ -69,6 +68,10 @@ void Molecule::calcForces( void ){ int i; + for(i=0; iupdateAtoms(); + } + for(i=0; icalc_forces(); } @@ -80,6 +83,9 @@ void Molecule::calcForces( void ){ for(i=0; icalc_forces(); } + + // Rigid Body forces and torques are done after the fortran force loop + } @@ -87,6 +93,10 @@ double Molecule::getPotential( void ){ int i; double myPot = 0.0; + + for(i=0; iupdateAtoms(); + } for(i=0; iget_potential(); @@ -118,25 +128,43 @@ void Molecule::printMe( void ){ for(i=0; iprintMe(); } + } void Molecule::moveCOM(double delta[3]){ double aPos[3]; int i, j; - for(i=0; igetPos( aPos ); + myIntegrableObjects[i]->getPos( aPos ); for (j=0; j< 3; j++) aPos[j] += delta[j]; - myAtoms[i]->setPos( aPos ); + myIntegrableObjects[i]->setPos( aPos ); } } + + for(i=0; igetPos( aPos ); + + for (j=0; j< 3; j++) + aPos[j] += delta[j]; + + myRigidBodies[i]->setPos( aPos ); + } } +void Molecule::atoms2rigidBodies( void ) { + int i; + for (i = 0; i < myRigidBodies.size(); i++) { + myRigidBodies[i]->calcForcesAndTorques(); + } +} + void Molecule::getCOM( double COM[3] ) { double mass, mtot; @@ -148,13 +176,13 @@ void Molecule::getCOM( double COM[3] ) { mtot = 0.0; - for (i=0; i < nAtoms; i++) { - if (myAtoms[i] != NULL) { + for (i=0; i < myIntegrableObjects.size(); i++) { + if (myIntegrableObjects[i] != NULL) { - mass = myAtoms[i]->getMass(); + mass = myIntegrableObjects[i]->getMass(); mtot += mass; - myAtoms[i]->getPos( aPos ); + myIntegrableObjects[i]->getPos( aPos ); for( j = 0; j < 3; j++) COM[j] += aPos[j] * mass; @@ -178,13 +206,13 @@ double Molecule::getCOMvel( double COMvel[3] ) { mtot = 0.0; - for (i=0; i < nAtoms; i++) { - if (myAtoms[i] != NULL) { + for (i=0; i < myIntegrableObjects.size(); i++) { + if (myIntegrableObjects[i] != NULL) { - mass = myAtoms[i]->getMass(); + mass = myIntegrableObjects[i]->getMass(); mtot += mass; - myAtoms[i]->getVel(aVel); + myIntegrableObjects[i]->getVel(aVel); for (j=0; j<3; j++) COMvel[j] += aVel[j]*mass; @@ -201,15 +229,12 @@ double Molecule::getTotalMass() double Molecule::getTotalMass() { - int natoms; - Atom** atoms; + double totalMass; - natoms = getNAtoms(); - atoms = getMyAtoms(); totalMass = 0; - for(int i =0; i < natoms; i++){ - totalMass += atoms[i]->getMass(); + for(int i =0; i < myIntegrableObjects.size(); i++){ + totalMass += myIntegrableObjects[i]->getMass(); } return totalMass;