--- trunk/OOPSE/libmdtools/Molecule.cpp 2003/04/03 21:12:51 450 +++ trunk/OOPSE/libmdtools/Molecule.cpp 2003/07/15 14:28:54 607 @@ -165,3 +165,36 @@ void Molecule::getCOM( double COM[3] ) { COM[2] /= 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; + +}