--- trunk/OOPSE/libmdtools/Thermo.cpp 2003/10/28 16:03:37 829 +++ trunk/OOPSE/libmdtools/Thermo.cpp 2004/04/19 22:13:01 1125 @@ -33,46 +33,43 @@ double Thermo::getKinetic(){ double kinetic; double amass; double aVel[3], aJ[3], I[3][3]; - int j, kl; + int i, j, k, kl; - DirectionalAtom *dAtom; - - int n_atoms; double kinetic_global; - Atom** atoms; - + vector integrableObjects = info->integrableObjects; - n_atoms = info->n_atoms; - atoms = info->atoms; - kinetic = 0.0; kinetic_global = 0.0; - for( kl=0; kl < n_atoms; kl++ ){ - - atoms[kl]->getVel(aVel); - amass = atoms[kl]->getMass(); - - for (j=0; j < 3; j++) - kinetic += amass * aVel[j] * aVel[j]; - if( atoms[kl]->isDirectional() ){ - - dAtom = (DirectionalAtom *)atoms[kl]; + for (kl=0; klgetVel(aVel); + amass = integrableObjects[kl]->getMass(); - dAtom->getJ( aJ ); - dAtom->getI( I ); - - for (j=0; j<3; j++) - kinetic += aJ[j]*aJ[j] / I[j][j]; - - } + for(j=0; j<3; j++) + kinetic += amass*aVel[j]*aVel[j]; + + if (integrableObjects[kl]->isDirectional()){ + + integrableObjects[kl]->getJ( aJ ); + integrableObjects[kl]->getI( I ); + + if (integrableObjects[kl]->isLinear()) { + i = integrableObjects[kl]->linearAxis(); + j = (i+1)%3; + k = (i+2)%3; + kinetic += aJ[j]*aJ[j]/I[j][j] + aJ[k]*aJ[k]/I[k][k]; + } else { + for (j=0; j<3; j++) + kinetic += aJ[j]*aJ[j] / I[j][j]; + } + } } #ifdef IS_MPI MPI_Allreduce(&kinetic,&kinetic_global,1,MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); kinetic = kinetic_global; #endif //is_mpi - + kinetic = kinetic * 0.5 / e_convert; return kinetic; @@ -104,12 +101,6 @@ double Thermo::getPotential(){ potential = potential_local; #endif // is_mpi -#ifdef IS_MPI - /* - std::cerr << "node " << worldRank << ": after pot = " << potential << "\n"; - */ -#endif - return potential; } @@ -125,7 +116,7 @@ double Thermo::getTemperature(){ const double kb = 1.9872156E-3; // boltzman's constant in kcal/(mol K) double temperature; - + temperature = ( 2.0 * this->getKinetic() ) / ((double)info->ndf * kb ); return temperature; } @@ -285,9 +276,7 @@ void Thermo::velocitize() { av2 = 2.0 * kebar / atoms[vr]->getMass(); vbar = sqrt( av2 ); - -// vbar = sqrt( 8.31451e-7 * temperature / atoms[vr]->getMass() ); - + // picks random velocities from a gaussian distribution // centered on vbar