--- trunk/OOPSE/libmdtools/Molecule.cpp 2003/03/27 20:48:37 427 +++ trunk/OOPSE/libmdtools/Molecule.cpp 2003/07/15 15:50:55 610 @@ -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::calcForces( void ){ } -void Molecule::getPotential( void ){ +double Molecule::getPotential( void ){ int i; double myPot = 0.0; @@ -101,3 +102,99 @@ 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 aPos[3]; + int i, j; + + for(i=0; igetPos( aPos ); + + for (j=0; j< 3; j++) + aPos[j] += delta[j]; + + myAtoms[i]->setPos( aPos ); + } + } +} + +void Molecule::getCOM( double COM[3] ) { + + double mass, mtot; + double aPos[3]; + int i, j; + + for (j=0; j<3; j++) + COM[j] = 0.0; + + mtot = 0.0; + + for (i=0; i < nAtoms; i++) { + if (myAtoms[i] != NULL) { + + mass = myAtoms[i]->getMass(); + mtot += mass; + + myAtoms[i]->getPos( aPos ); + + for( j = 0; j < 3; j++) + COM[j] += aPos[j] * mass; + + } + } + + for (j = 0; j < 3; j++) + COM[j] /= mtot; +} + +double Molecule::getCOMvel( double COMvel[3] ) { + + double mass, mtot; + double aVel[3]; + int i, j; + + + for (j=0; j<3; j++) + COMvel[j] = 0.0; + + mtot = 0.0; + + for (i=0; i < nAtoms; i++) { + if (myAtoms[i] != NULL) { + + mass = myAtoms[i]->getMass(); + mtot += mass; + + myAtoms[i]->getVel(aVel); + + for (j=0; j<3; j++) + COMvel[j] += aVel[j]*mass; + + } + } + + for (j=0; j<3; j++) + COMvel[j] /= mtot; + + return mtot; + +}