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 1131 by tim, Thu Apr 22 21:33:55 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
# Line 195 | Line 196 | void Thermo::getPressureTensor(double press[3][3]){
196    const double e_convert = 4.184e-4;
197  
198    double molmass, volume;
199 <  double vcom[3];
199 >  double vcom[3], pcom[3], fcom[3], scaled[3];
200    double p_local[9], p_global[9];
201    int i, j, k, nMols;
202    Molecule* molecules;
# Line 210 | Line 211 | void Thermo::getPressureTensor(double press[3][3]){
211      p_global[i] = 0.0;
212    }
213  
214 <  for (i=0; i < nMols; i++) {
214 <    molmass = molecules[i].getCOMvel(vcom);
214 >  for (i=0; i < info->integrableObjects.size(); i++) {
215  
216 <    p_local[0] += molmass * (vcom[0] * vcom[0]);
217 <    p_local[1] += molmass * (vcom[0] * vcom[1]);
218 <    p_local[2] += molmass * (vcom[0] * vcom[2]);
219 <    p_local[3] += molmass * (vcom[1] * vcom[0]);
220 <    p_local[4] += molmass * (vcom[1] * vcom[1]);
221 <    p_local[5] += molmass * (vcom[1] * vcom[2]);
222 <    p_local[6] += molmass * (vcom[2] * vcom[0]);
223 <    p_local[7] += molmass * (vcom[2] * vcom[1]);
224 <    p_local[8] += molmass * (vcom[2] * vcom[2]);
216 >    molmass = info->integrableObjects[i]->getMass();
217 >    
218 >    info->integrableObjects[i]->getVel(vcom);
219 >    info->integrableObjects[i]->getPos(pcom);
220 >    info->integrableObjects[i]->getFrc(fcom);
221 >
222 >    matVecMul3(info->HmatInv, pcom, scaled);
223 >  
224 >    for(j=0; j<3; j++)
225 >      scaled[j] -= roundMe(scaled[j]);
226 >
227 >    // calc the wrapped real coordinates from the wrapped scaled coordinates
228 >  
229 >    matVecMul3(info->Hmat, scaled, pcom);
230 >    
231 >    p_local[0] += molmass * (vcom[0] * vcom[0]) + fcom[0]*pcom[0]*eConvert;
232 >    p_local[1] += molmass * (vcom[0] * vcom[1]) + fcom[0]*pcom[1]*eConvert;
233 >    p_local[2] += molmass * (vcom[0] * vcom[2]) + fcom[0]*pcom[2]*eConvert;
234 >    p_local[3] += molmass * (vcom[1] * vcom[0]) + fcom[1]*pcom[0]*eConvert;
235 >    p_local[4] += molmass * (vcom[1] * vcom[1]) + fcom[1]*pcom[1]*eConvert;
236 >    p_local[5] += molmass * (vcom[1] * vcom[2]) + fcom[1]*pcom[2]*eConvert;
237 >    p_local[6] += molmass * (vcom[2] * vcom[0]) + fcom[2]*pcom[0]*eConvert;
238 >    p_local[7] += molmass * (vcom[2] * vcom[1]) + fcom[2]*pcom[1]*eConvert;
239 >    p_local[8] += molmass * (vcom[2] * vcom[2]) + fcom[2]*pcom[2]*eConvert;
240 >    
241    }
242  
243    // Get total for entire system from MPI.
# Line 239 | Line 255 | void Thermo::getPressureTensor(double press[3][3]){
255    for(i = 0; i < 3; i++) {
256      for (j = 0; j < 3; j++) {
257        k = 3*i + j;
258 <      press[i][j] = (p_global[k] + info->tau[k]*e_convert) / volume;
258 >      press[i][j] = p_global[k] /  volume;
259  
260      }
261    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines