--- trunk/OOPSE/libmdtools/Molecule.cpp 2003/04/03 20:19:50 446 +++ trunk/OOPSE/libmdtools/Molecule.cpp 2003/07/15 14:28:54 607 @@ -120,7 +120,7 @@ void Molecule::printMe( void ){ } } -void Molecule::moveCOM(double* delta){ +void Molecule::moveCOM(double delta[3]){ double x, y, z; int i; @@ -138,7 +138,7 @@ void Molecule::moveCOM(double* delta){ } } -double* Molecule::getCOM() { +void Molecule::getCOM( double COM[3] ) { double mass, mtot; int i; @@ -164,5 +164,37 @@ double* Molecule::getCOM() { COM[1] /= mtot; COM[2] /= mtot; - return COM; } + +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; + +}