--- trunk/OOPSE/libmdtools/Thermo.cpp 2004/04/20 16:56:40 1127 +++ trunk/OOPSE/libmdtools/Thermo.cpp 2004/06/07 14:09:02 1251 @@ -10,12 +10,17 @@ using namespace std; #include "SRI.hpp" #include "Integrator.hpp" #include "simError.h" +#include "MatVec3.h" #ifdef IS_MPI #define __C #include "mpiSimulation.hpp" #endif // is_mpi +inline double roundMe( double x ){ + return ( x >= 0 ) ? floor( x + 0.5 ) : ceil( x - 0.5 ); +} + Thermo::Thermo( SimInfo* the_info ) { info = the_info; int baseSeed = the_info->getSeed(); @@ -197,22 +202,23 @@ void Thermo::getPressureTensor(double press[3][3]){ double molmass, volume; double vcom[3]; double p_local[9], p_global[9]; - int i, j, k, nMols; - Molecule* molecules; + int i, j, k; - nMols = info->n_mol; - molecules = info->molecules; - //tau = info->tau; - // use velocities of molecular centers of mass and molecular masses: + for (i=0; i < 9; i++) { p_local[i] = 0.0; p_global[i] = 0.0; } - for (i=0; i < nMols; i++) { - molmass = molecules[i].getCOMvel(vcom); + // use velocities of integrableObjects and their masses: + for (i=0; i < info->integrableObjects.size(); i++) { + + molmass = info->integrableObjects[i]->getMass(); + + info->integrableObjects[i]->getVel(vcom); + p_local[0] += molmass * (vcom[0] * vcom[0]); p_local[1] += molmass * (vcom[0] * vcom[1]); p_local[2] += molmass * (vcom[0] * vcom[2]); @@ -222,10 +228,11 @@ void Thermo::getPressureTensor(double press[3][3]){ p_local[6] += molmass * (vcom[2] * vcom[0]); p_local[7] += molmass * (vcom[2] * vcom[1]); p_local[8] += molmass * (vcom[2] * vcom[2]); + } // Get total for entire system from MPI. - + #ifdef IS_MPI MPI_Allreduce(p_local,p_global,9,MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); #else @@ -240,7 +247,6 @@ void Thermo::getPressureTensor(double press[3][3]){ for (j = 0; j < 3; j++) { k = 3*i + j; press[i][j] = (p_global[k] + info->tau[k]*e_convert) / volume; - } } } @@ -431,4 +437,4 @@ void Thermo::removeCOMdrift() { info->integrableObjects[vd]->setVel( aVel ); } -} \ No newline at end of file +}