ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Thermo.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/Thermo.cpp (file contents):
Revision 1127 by tim, Tue Apr 20 16:56:40 2004 UTC vs.
Revision 1133 by gezelter, Mon Apr 26 14:29:18 2004 UTC

# Line 10 | Line 10 | using namespace std;
10   #include "SRI.hpp"
11   #include "Integrator.hpp"
12   #include "simError.h"
13 + #include "MatVec3.h"
14  
15   #ifdef IS_MPI
16   #define __C
17   #include "mpiSimulation.hpp"
18   #endif // is_mpi
19  
20 + inline double roundMe( double x ){
21 +          return ( x >= 0 ) ? floor( x + 0.5 ) : ceil( x - 0.5 );
22 + }
23 +
24   Thermo::Thermo( SimInfo* the_info ) {
25    info = the_info;
26    int baseSeed = the_info->getSeed();
# Line 195 | Line 200 | void Thermo::getPressureTensor(double press[3][3]){
200    const double e_convert = 4.184e-4;
201  
202    double molmass, volume;
203 <  double vcom[3];
203 >  double vcom[3], pcom[3], fcom[3], scaled[3];
204    double p_local[9], p_global[9];
205    int i, j, k, nMols;
206    Molecule* molecules;
# Line 210 | Line 215 | void Thermo::getPressureTensor(double press[3][3]){
215      p_global[i] = 0.0;
216    }
217  
218 <  for (i=0; i < nMols; i++) {
214 <    molmass = molecules[i].getCOMvel(vcom);
218 >  for (i=0; i < info->integrableObjects.size(); i++) {
219  
220 <    p_local[0] += molmass * (vcom[0] * vcom[0]);
221 <    p_local[1] += molmass * (vcom[0] * vcom[1]);
222 <    p_local[2] += molmass * (vcom[0] * vcom[2]);
223 <    p_local[3] += molmass * (vcom[1] * vcom[0]);
224 <    p_local[4] += molmass * (vcom[1] * vcom[1]);
225 <    p_local[5] += molmass * (vcom[1] * vcom[2]);
226 <    p_local[6] += molmass * (vcom[2] * vcom[0]);
227 <    p_local[7] += molmass * (vcom[2] * vcom[1]);
228 <    p_local[8] += molmass * (vcom[2] * vcom[2]);
220 >    molmass = info->integrableObjects[i]->getMass();
221 >    
222 >    info->integrableObjects[i]->getVel(vcom);
223 >    info->integrableObjects[i]->getPos(pcom);
224 >    info->integrableObjects[i]->getFrc(fcom);
225 >
226 >    matVecMul3(info->HmatInv, pcom, scaled);
227 >  
228 >    for(j=0; j<3; j++)
229 >      scaled[j] -= roundMe(scaled[j]);
230 >
231 >    // calc the wrapped real coordinates from the wrapped scaled coordinates
232 >  
233 >    matVecMul3(info->Hmat, scaled, pcom);
234 >    
235 >    p_local[0] += molmass * (vcom[0] * vcom[0]) + fcom[0]*pcom[0]*eConvert;
236 >    p_local[1] += molmass * (vcom[0] * vcom[1]) + fcom[0]*pcom[1]*eConvert;
237 >    p_local[2] += molmass * (vcom[0] * vcom[2]) + fcom[0]*pcom[2]*eConvert;
238 >    p_local[3] += molmass * (vcom[1] * vcom[0]) + fcom[1]*pcom[0]*eConvert;
239 >    p_local[4] += molmass * (vcom[1] * vcom[1]) + fcom[1]*pcom[1]*eConvert;
240 >    p_local[5] += molmass * (vcom[1] * vcom[2]) + fcom[1]*pcom[2]*eConvert;
241 >    p_local[6] += molmass * (vcom[2] * vcom[0]) + fcom[2]*pcom[0]*eConvert;
242 >    p_local[7] += molmass * (vcom[2] * vcom[1]) + fcom[2]*pcom[1]*eConvert;
243 >    p_local[8] += molmass * (vcom[2] * vcom[2]) + fcom[2]*pcom[2]*eConvert;
244 >    
245    }
246  
247    // Get total for entire system from MPI.
# Line 239 | Line 259 | void Thermo::getPressureTensor(double press[3][3]){
259    for(i = 0; i < 3; i++) {
260      for (j = 0; j < 3; j++) {
261        k = 3*i + j;
262 <      press[i][j] = (p_global[k] + info->tau[k]*e_convert) / volume;
262 >      press[i][j] = p_global[k] /  volume;
263  
264      }
265    }
# Line 431 | Line 451 | void Thermo::removeCOMdrift() {
451          
452      info->integrableObjects[vd]->setVel( aVel );
453    }
454 < }
454 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines