--- trunk/OOPSE/libmdtools/Molecule.cpp 2003/03/27 20:48:37 427 +++ trunk/OOPSE/libmdtools/Molecule.cpp 2003/04/09 04:06:43 483 @@ -2,6 +2,7 @@ #include "Molecule.hpp" +#include "simError.h" @@ -60,7 +61,7 @@ void Molecule::initialize( molInit &theInit ){ myBonds = theInit.myBonds; myBends = theInit.myBends; myTorsions = theInit.myTorsions; - myExcludes = theInit.myExcludses; + myExcludes = theInit.myExcludes; } @@ -82,7 +83,7 @@ void Molecule::getPotential( void ){ } -void Molecule::getPotential( void ){ +double Molecule::getPotential( void ){ int i; double myPot = 0.0; @@ -101,3 +102,107 @@ void Molecule::getPotential( void ){ return myPot; } + +void Molecule::printMe( void ){ + + int i; + + for(i=0; iprintMe(); + } + + for(i=0; iprintMe(); + } + + for(i=0; iprintMe(); + } +} + +void Molecule::moveCOM(double delta[3]){ + double x, y, z; + int i; + + for(i=0; igetX() + delta[0]; + y = myAtoms[i]->getY() + delta[1]; + z = myAtoms[i]->getZ() + delta[2]; + + myAtoms[i]->setX(x); + myAtoms[i]->setY(y); + myAtoms[i]->setZ(z); + } + } +} + +void Molecule::getCOM( double COM[3] ) { + + double mass, mtot; + int i; + + COM[0] = 0.0; + COM[1] = 0.0; + COM[2] = 0.0; + mtot = 0.0; + + for (i=0; i < nAtoms; i++) { + if (myAtoms[i] != NULL) { + + mass = myAtoms[i]->getMass(); + mtot += mass; + COM[0] += myAtoms[i]->getX() * mass; + COM[1] += myAtoms[i]->getY() * mass; + COM[2] += myAtoms[i]->getZ() * mass; + + } + } + + COM[0] /= mtot; + COM[1] /= mtot; + COM[2] /= mtot; + +} + +double Molecule::getCOMvel( double COMvel[3] ) { + + double mass, mtot; + int i; + + COMvel[0] = 0.0; + COMvel[1] = 0.0; + COMvel[2] = 0.0; + mtot = 0.0; + + for (i=0; i < nAtoms; i++) { + if (myAtoms[i] != NULL) { + + mass = myAtoms[i]->getMass(); + mtot += mass; + COMvel[0] += myAtoms[i]->get_vx() * mass; + COMvel[1] += myAtoms[i]->get_vy() * mass; + COMvel[2] += myAtoms[i]->get_vz() * mass; + + } + } + + COMvel[0] /= mtot; + COMvel[1] /= mtot; + COMvel[2] /= mtot; + + return mtot; + +} + +void Molecule::atomicRollCall(int* molMembership) { + int i, which; + + for (i=0; i < nAtoms; i++) { + if (myAtoms[i] != NULL) { + which = myAtoms[i]->getIndex(); + molMembership[which] = myIndex; + } + } +}