ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/brains/Thermo.cpp
(Generate patch)

Comparing trunk/src/brains/Thermo.cpp (file contents):
Revision 1638 by chuckv, Fri Sep 23 20:52:24 2011 UTC vs.
Revision 1792 by gezelter, Fri Aug 31 17:29:35 2012 UTC

# Line 36 | Line 36
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38   * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 < * [4]  Vardeman & Gezelter, in progress (2009).                        
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   #include <math.h>
# Line 50 | Line 51
51   #include "primitives/Molecule.hpp"
52   #include "utils/simError.h"
53   #include "utils/PhysicalConstants.hpp"
54 + #include "types/FixedChargeAdapter.hpp"
55 + #include "types/FluctuatingChargeAdapter.hpp"
56 + #include "types/MultipoleAdapter.hpp"
57 + #ifdef HAVE_QHULL
58 + #include "math/ConvexHull.hpp"
59 + #include "math/AlphaHull.hpp"
60 + #endif
61  
62 + using namespace std;
63   namespace OpenMD {
64  
65 <  RealType Thermo::getKinetic() {
66 <    SimInfo::MoleculeIterator miter;
67 <    std::vector<StuntDouble*>::iterator iiter;
68 <    Molecule* mol;
69 <    StuntDouble* integrableObject;    
70 <    Vector3d vel;
71 <    Vector3d angMom;
72 <    Mat3x3d I;
73 <    int i;
74 <    int j;
75 <    int k;
76 <    RealType mass;
77 <    RealType kinetic = 0.0;
78 <    RealType kinetic_global = 0.0;
70 <    
71 <    for (mol = info_->beginMolecule(miter); mol != NULL; mol = info_->nextMolecule(miter)) {
72 <      for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
73 <           integrableObject = mol->nextIntegrableObject(iiter)) {
65 >  RealType Thermo::getTranslationalKinetic() {
66 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
67 >
68 >    if (!snap->hasTranslationalKineticEnergy) {
69 >      SimInfo::MoleculeIterator miter;
70 >      vector<StuntDouble*>::iterator iiter;
71 >      Molecule* mol;
72 >      StuntDouble* sd;    
73 >      Vector3d vel;
74 >      RealType mass;
75 >      RealType kinetic(0.0);
76 >      
77 >      for (mol = info_->beginMolecule(miter); mol != NULL;
78 >           mol = info_->nextMolecule(miter)) {
79          
80 <        mass = integrableObject->getMass();
81 <        vel = integrableObject->getVel();
82 <        
83 <        kinetic += mass * (vel[0]*vel[0] + vel[1]*vel[1] + vel[2]*vel[2]);
84 <        
85 <        if (integrableObject->isDirectional()) {
86 <          angMom = integrableObject->getJ();
87 <          I = integrableObject->getI();
80 >        for (sd = mol->beginIntegrableObject(iiter); sd != NULL;
81 >             sd = mol->nextIntegrableObject(iiter)) {
82 >          
83 >          mass = sd->getMass();
84 >          vel = sd->getVel();
85 >          
86 >          kinetic += mass * (vel[0]*vel[0] + vel[1]*vel[1] + vel[2]*vel[2]);
87 >          
88 >        }
89 >      }
90 >      
91 > #ifdef IS_MPI
92 >      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &kinetic, 1, MPI::REALTYPE,
93 >                                MPI::SUM);
94 > #endif
95 >      
96 >      kinetic = kinetic * 0.5 / PhysicalConstants::energyConvert;
97 >      
98 >      
99 >      snap->setTranslationalKineticEnergy(kinetic);
100 >    }
101 >    return snap->getTranslationalKineticEnergy();
102 >  }
103  
104 <          if (integrableObject->isLinear()) {
105 <            i = integrableObject->linearAxis();
106 <            j = (i + 1) % 3;
107 <            k = (i + 2) % 3;
108 <            kinetic += angMom[j] * angMom[j] / I(j, j) + angMom[k] * angMom[k] / I(k, k);
109 <          } else {                        
110 <            kinetic += angMom[0]*angMom[0]/I(0, 0) + angMom[1]*angMom[1]/I(1, 1)
111 <              + angMom[2]*angMom[2]/I(2, 2);
112 <          }
113 <        }
104 >  RealType Thermo::getRotationalKinetic() {
105 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
106 >
107 >    if (!snap->hasRotationalKineticEnergy) {
108 >      SimInfo::MoleculeIterator miter;
109 >      vector<StuntDouble*>::iterator iiter;
110 >      Molecule* mol;
111 >      StuntDouble* sd;    
112 >      Vector3d angMom;
113 >      Mat3x3d I;
114 >      int i, j, k;
115 >      RealType kinetic(0.0);
116 >      
117 >      for (mol = info_->beginMolecule(miter); mol != NULL;
118 >           mol = info_->nextMolecule(miter)) {
119 >        
120 >        for (sd = mol->beginIntegrableObject(iiter); sd != NULL;
121 >             sd = mol->nextIntegrableObject(iiter)) {
122 >          
123 >          if (sd->isDirectional()) {
124 >            angMom = sd->getJ();
125 >            I = sd->getI();
126              
127 +            if (sd->isLinear()) {
128 +              i = sd->linearAxis();
129 +              j = (i + 1) % 3;
130 +              k = (i + 2) % 3;
131 +              kinetic += angMom[j] * angMom[j] / I(j, j)
132 +                + angMom[k] * angMom[k] / I(k, k);
133 +            } else {                        
134 +              kinetic += angMom[0]*angMom[0]/I(0, 0)
135 +                + angMom[1]*angMom[1]/I(1, 1)
136 +                + angMom[2]*angMom[2]/I(2, 2);
137 +            }
138 +          }          
139 +        }
140        }
141 <    }
97 <    
141 >      
142   #ifdef IS_MPI
143 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &kinetic, 1, MPI::REALTYPE,
144 +                                MPI::SUM);
145 + #endif
146 +      
147 +      kinetic = kinetic * 0.5 / PhysicalConstants::energyConvert;
148 +          
149 +      snap->setRotationalKineticEnergy(kinetic);
150 +    }
151 +    return snap->getRotationalKineticEnergy();
152 +  }
153  
154 <    MPI_Allreduce(&kinetic, &kinetic_global, 1, MPI_REALTYPE, MPI_SUM,
101 <                  MPI_COMM_WORLD);
102 <    kinetic = kinetic_global;
154 >      
155  
156 < #endif //is_mpi
156 >  RealType Thermo::getKinetic() {
157 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
158  
159 <    kinetic = kinetic * 0.5 / PhysicalConstants::energyConvert;
160 <
161 <    return kinetic;
159 >    if (!snap->hasKineticEnergy) {
160 >      RealType ke = getTranslationalKinetic() + getRotationalKinetic();
161 >      snap->setKineticEnergy(ke);
162 >    }
163 >    return snap->getKineticEnergy();
164    }
165  
166    RealType Thermo::getPotential() {
112    RealType potential = 0.0;
113    Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
114    RealType shortRangePot_local =  curSnapshot->statData[Stats::SHORT_RANGE_POTENTIAL] ;
167  
168 <    // Get total potential for entire system from MPI.
168 >    // ForceManager computes the potential and stores it in the
169 >    // Snapshot.  All we have to do is report it.
170  
171 < #ifdef IS_MPI
171 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
172 >    return snap->getPotentialEnergy();
173 >  }
174  
175 <    MPI_Allreduce(&shortRangePot_local, &potential, 1, MPI_REALTYPE, MPI_SUM,
121 <                  MPI_COMM_WORLD);
122 <    potential += curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL];
175 >  RealType Thermo::getTotalEnergy() {
176  
177 < #else
177 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
178  
179 <    potential = shortRangePot_local + curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL];
179 >    if (!snap->hasTotalEnergy) {
180 >      snap->setTotalEnergy(this->getKinetic() + this->getPotential());
181 >    }
182  
183 < #endif // is_mpi
129 <
130 <    return potential;
183 >    return snap->getTotalEnergy();
184    }
185  
133  RealType Thermo::getTotalE() {
134    RealType total;
135
136    total = this->getKinetic() + this->getPotential();
137    return total;
138  }
139
186    RealType Thermo::getTemperature() {
141    
142    RealType temperature = ( 2.0 * this->getKinetic() ) / (info_->getNdf()* PhysicalConstants::kb );
143    return temperature;
144  }
187  
188 <  RealType Thermo::getVolume() {
147 <    Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
148 <    return curSnapshot->getVolume();
149 <  }
188 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
189  
190 <  RealType Thermo::getPressure() {
190 >    if (!snap->hasTemperature) {
191  
192 <    // Relies on the calculation of the full molecular pressure tensor
192 >      RealType temperature = ( 2.0 * this->getKinetic() )
193 >        / (info_->getNdf()* PhysicalConstants::kb );
194  
195 +      snap->setTemperature(temperature);
196 +    }
197 +    
198 +    return snap->getTemperature();
199 +  }
200  
201 <    Mat3x3d tensor;
202 <    RealType pressure;
201 >  RealType Thermo::getElectronicTemperature() {
202 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
203  
204 <    tensor = getPressureTensor();
204 >    if (!snap->hasElectronicTemperature) {
205 >      
206 >      SimInfo::MoleculeIterator miter;
207 >      vector<Atom*>::iterator iiter;
208 >      Molecule* mol;
209 >      Atom* atom;    
210 >      RealType cvel;
211 >      RealType cmass;
212 >      RealType kinetic(0.0);
213 >      RealType eTemp;
214 >      
215 >      for (mol = info_->beginMolecule(miter); mol != NULL;
216 >           mol = info_->nextMolecule(miter)) {
217 >        
218 >        for (atom = mol->beginFluctuatingCharge(iiter); atom != NULL;
219 >             atom = mol->nextFluctuatingCharge(iiter)) {
220 >          
221 >          cmass = atom->getChargeMass();
222 >          cvel = atom->getFlucQVel();
223 >          
224 >          kinetic += cmass * cvel * cvel;
225 >          
226 >        }
227 >      }
228 >    
229 > #ifdef IS_MPI
230 >      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &kinetic, 1, MPI::REALTYPE,
231 >                                MPI::SUM);
232 > #endif
233  
234 <    pressure = PhysicalConstants::pressureConvert * (tensor(0, 0) + tensor(1, 1) + tensor(2, 2)) / 3.0;
234 >      kinetic *= 0.5;
235 >      eTemp =  (2.0 * kinetic) /
236 >        (info_->getNFluctuatingCharges() * PhysicalConstants::kb );
237 >    
238 >      snap->setElectronicTemperature(eTemp);
239 >    }
240  
241 <    return pressure;
241 >    return snap->getElectronicTemperature();
242    }
243  
166  RealType Thermo::getPressure(int direction) {
244  
245 <    // Relies on the calculation of the full molecular pressure tensor
245 >  RealType Thermo::getVolume() {
246 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
247 >    return snap->getVolume();
248 >  }
249  
250 <          
251 <    Mat3x3d tensor;
172 <    RealType pressure;
250 >  RealType Thermo::getPressure() {
251 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
252  
253 <    tensor = getPressureTensor();
254 <
255 <    pressure = PhysicalConstants::pressureConvert * tensor(direction, direction);
256 <
257 <    return pressure;
253 >    if (!snap->hasPressure) {
254 >      // Relies on the calculation of the full molecular pressure tensor
255 >      
256 >      Mat3x3d tensor;
257 >      RealType pressure;
258 >      
259 >      tensor = getPressureTensor();
260 >      
261 >      pressure = PhysicalConstants::pressureConvert *
262 >        (tensor(0, 0) + tensor(1, 1) + tensor(2, 2)) / 3.0;
263 >      
264 >      snap->setPressure(pressure);
265 >    }
266 >    
267 >    return snap->getPressure();    
268    }
269  
270    Mat3x3d Thermo::getPressureTensor() {
271      // returns pressure tensor in units amu*fs^-2*Ang^-1
272      // routine derived via viral theorem description in:
273      // Paci, E. and Marchi, M. J.Phys.Chem. 1996, 100, 4314-4322
274 <    Mat3x3d pressureTensor;
186 <    Mat3x3d p_local(0.0);
187 <    Mat3x3d p_global(0.0);
188 <
189 <    SimInfo::MoleculeIterator i;
190 <    std::vector<StuntDouble*>::iterator j;
191 <    Molecule* mol;
192 <    StuntDouble* integrableObject;    
193 <    for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {
194 <      for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL;
195 <           integrableObject = mol->nextIntegrableObject(j)) {
274 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
275  
276 <        RealType mass = integrableObject->getMass();
277 <        Vector3d vcom = integrableObject->getVel();
278 <        p_local += mass * outProduct(vcom, vcom);        
276 >    if (!snap->hasPressureTensor) {
277 >
278 >      Mat3x3d pressureTensor;
279 >      Mat3x3d p_tens(0.0);
280 >      RealType mass;
281 >      Vector3d vcom;
282 >      
283 >      SimInfo::MoleculeIterator i;
284 >      vector<StuntDouble*>::iterator j;
285 >      Molecule* mol;
286 >      StuntDouble* sd;    
287 >      for (mol = info_->beginMolecule(i); mol != NULL;
288 >           mol = info_->nextMolecule(i)) {
289 >        
290 >        for (sd = mol->beginIntegrableObject(j); sd != NULL;
291 >             sd = mol->nextIntegrableObject(j)) {
292 >          
293 >          mass = sd->getMass();
294 >          vcom = sd->getVel();
295 >          p_tens += mass * outProduct(vcom, vcom);        
296 >        }
297        }
298 +      
299 + #ifdef IS_MPI
300 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, p_tens.getArrayPointer(), 9,
301 +                                MPI::REALTYPE, MPI::SUM);
302 + #endif
303 +      
304 +      RealType volume = this->getVolume();
305 +      Mat3x3d stressTensor = snap->getStressTensor();
306 +      
307 +      pressureTensor =  (p_tens +
308 +                         PhysicalConstants::energyConvert * stressTensor)/volume;
309 +      
310 +      snap->setPressureTensor(pressureTensor);
311      }
312 <    
312 >    return snap->getPressureTensor();
313 >  }
314 >
315 >
316 >
317 >
318 >  Vector3d Thermo::getSystemDipole() {
319 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
320 >
321 >    if (!snap->hasSystemDipole) {
322 >      SimInfo::MoleculeIterator miter;
323 >      vector<Atom*>::iterator aiter;
324 >      Molecule* mol;
325 >      Atom* atom;
326 >      RealType charge;
327 >      RealType moment(0.0);
328 >      Vector3d ri(0.0);
329 >      Vector3d dipoleVector(0.0);
330 >      Vector3d nPos(0.0);
331 >      Vector3d pPos(0.0);
332 >      RealType nChg(0.0);
333 >      RealType pChg(0.0);
334 >      int nCount = 0;
335 >      int pCount = 0;
336 >      
337 >      RealType chargeToC = 1.60217733e-19;
338 >      RealType angstromToM = 1.0e-10;
339 >      RealType debyeToCm = 3.33564095198e-30;
340 >      
341 >      for (mol = info_->beginMolecule(miter); mol != NULL;
342 >           mol = info_->nextMolecule(miter)) {
343 >        
344 >        for (atom = mol->beginAtom(aiter); atom != NULL;
345 >             atom = mol->nextAtom(aiter)) {
346 >          
347 >          charge = 0.0;
348 >          
349 >          FixedChargeAdapter fca = FixedChargeAdapter(atom->getAtomType());
350 >          if ( fca.isFixedCharge() ) {
351 >            charge = fca.getCharge();
352 >          }
353 >          
354 >          FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atom->getAtomType());
355 >          if ( fqa.isFluctuatingCharge() ) {
356 >            charge += atom->getFlucQPos();
357 >          }
358 >          
359 >          charge *= chargeToC;
360 >          
361 >          ri = atom->getPos();
362 >          snap->wrapVector(ri);
363 >          ri *= angstromToM;
364 >          
365 >          if (charge < 0.0) {
366 >            nPos += ri;
367 >            nChg -= charge;
368 >            nCount++;
369 >          } else if (charge > 0.0) {
370 >            pPos += ri;
371 >            pChg += charge;
372 >            pCount++;
373 >          }
374 >          
375 >          MultipoleAdapter ma = MultipoleAdapter(atom->getAtomType());
376 >          if (ma.isDipole() ) {
377 >            Vector3d u_i = atom->getElectroFrame().getColumn(2);
378 >            moment = ma.getDipoleMoment();
379 >            moment *= debyeToCm;
380 >            dipoleVector += u_i * moment;
381 >          }
382 >        }
383 >      }
384 >      
385 >      
386   #ifdef IS_MPI
387 <    MPI_Allreduce(p_local.getArrayPointer(), p_global.getArrayPointer(), 9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
388 < #else
389 <    p_global = p_local;
390 < #endif // is_mpi
387 >      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &pChg, 1, MPI::REALTYPE,
388 >                                MPI::SUM);
389 >      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &nChg, 1, MPI::REALTYPE,
390 >                                MPI::SUM);
391  
392 <    RealType volume = this->getVolume();
393 <    Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
394 <    Mat3x3d tau = curSnapshot->statData.getTau();
392 >      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &pCount, 1, MPI::INTEGER,
393 >                                MPI::SUM);
394 >      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &nCount, 1, MPI::INTEGER,
395 >                                MPI::SUM);
396  
397 <    pressureTensor =  (p_global + PhysicalConstants::energyConvert* tau)/volume;
398 <    
399 <    return pressureTensor;
400 <  }
397 >      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, pPos.getArrayPointer(), 3,
398 >                                MPI::REALTYPE, MPI::SUM);
399 >      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, nPos.getArrayPointer(), 3,
400 >                                MPI::REALTYPE, MPI::SUM);
401  
402 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, dipoleVector.getArrayPointer(),
403 +                                3, MPI::REALTYPE, MPI::SUM);
404 + #endif
405 +      
406 +      // first load the accumulated dipole moment (if dipoles were present)
407 +      Vector3d boxDipole = dipoleVector;
408 +      // now include the dipole moment due to charges
409 +      // use the lesser of the positive and negative charge totals
410 +      RealType chg_value = nChg <= pChg ? nChg : pChg;
411 +      
412 +      // find the average positions
413 +      if (pCount > 0 && nCount > 0 ) {
414 +        pPos /= pCount;
415 +        nPos /= nCount;
416 +      }
417 +      
418 +      // dipole is from the negative to the positive (physics notation)
419 +      boxDipole += (pPos - nPos) * chg_value;
420 +      snap->setSystemDipole(boxDipole);
421 +    }
422  
423 <  void Thermo::saveStat(){
423 >    return snap->getSystemDipole();
424 >  }
425 >
426 >  // Returns the Heat Flux Vector for the system
427 >  Vector3d Thermo::getHeatFlux(){
428      Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
429 <    Stats& stat = currSnapshot->statData;
429 >    SimInfo::MoleculeIterator miter;
430 >    vector<StuntDouble*>::iterator iiter;
431 >    Molecule* mol;
432 >    StuntDouble* sd;    
433 >    RigidBody::AtomIterator ai;
434 >    Atom* atom;      
435 >    Vector3d vel;
436 >    Vector3d angMom;
437 >    Mat3x3d I;
438 >    int i;
439 >    int j;
440 >    int k;
441 >    RealType mass;
442 >
443 >    Vector3d x_a;
444 >    RealType kinetic;
445 >    RealType potential;
446 >    RealType eatom;
447 >    // Convective portion of the heat flux
448 >    Vector3d heatFluxJc = V3Zero;
449 >
450 >    /* Calculate convective portion of the heat flux */
451 >    for (mol = info_->beginMolecule(miter); mol != NULL;
452 >         mol = info_->nextMolecule(miter)) {
453 >      
454 >      for (sd = mol->beginIntegrableObject(iiter);
455 >           sd != NULL;
456 >           sd = mol->nextIntegrableObject(iiter)) {
457 >        
458 >        mass = sd->getMass();
459 >        vel = sd->getVel();
460 >
461 >        kinetic = mass * (vel[0]*vel[0] + vel[1]*vel[1] + vel[2]*vel[2]);
462 >        
463 >        if (sd->isDirectional()) {
464 >          angMom = sd->getJ();
465 >          I = sd->getI();
466 >
467 >          if (sd->isLinear()) {
468 >            i = sd->linearAxis();
469 >            j = (i + 1) % 3;
470 >            k = (i + 2) % 3;
471 >            kinetic += angMom[j] * angMom[j] / I(j, j)
472 >              + angMom[k] * angMom[k] / I(k, k);
473 >          } else {                        
474 >            kinetic += angMom[0]*angMom[0]/I(0, 0)
475 >              + angMom[1]*angMom[1]/I(1, 1)
476 >              + angMom[2]*angMom[2]/I(2, 2);
477 >          }
478 >        }
479 >
480 >        potential = 0.0;
481 >
482 >        if (sd->isRigidBody()) {
483 >          RigidBody* rb = dynamic_cast<RigidBody*>(sd);
484 >          for (atom = rb->beginAtom(ai); atom != NULL;
485 >               atom = rb->nextAtom(ai)) {
486 >            potential +=  atom->getParticlePot();
487 >          }          
488 >        } else {
489 >          potential = sd->getParticlePot();
490 >        }
491 >
492 >        potential *= PhysicalConstants::energyConvert; // amu A^2/fs^2
493 >        // The potential may not be a 1/2 factor
494 >        eatom = (kinetic + potential)/2.0;  // amu A^2/fs^2
495 >        heatFluxJc[0] += eatom*vel[0]; // amu A^3/fs^3
496 >        heatFluxJc[1] += eatom*vel[1]; // amu A^3/fs^3
497 >        heatFluxJc[2] += eatom*vel[2]; // amu A^3/fs^3
498 >      }
499 >    }
500 >
501 >    /* The J_v vector is reduced in the forceManager so everyone has
502 >     *  the global Jv. Jc is computed over the local atoms and must be
503 >     *  reduced among all processors.
504 >     */
505 > #ifdef IS_MPI
506 >    MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &heatFluxJc[0], 3, MPI::REALTYPE,
507 >                              MPI::SUM);
508 > #endif
509      
510 <    stat[Stats::KINETIC_ENERGY] = getKinetic();
224 <    stat[Stats::POTENTIAL_ENERGY] = getPotential();
225 <    stat[Stats::TOTAL_ENERGY] = stat[Stats::KINETIC_ENERGY]  + stat[Stats::POTENTIAL_ENERGY] ;
226 <    stat[Stats::TEMPERATURE] = getTemperature();
227 <    stat[Stats::PRESSURE] = getPressure();
228 <    stat[Stats::VOLUME] = getVolume();      
510 >    // (kcal/mol * A/fs) * conversion => (amu A^3)/fs^3
511  
512 <    Mat3x3d tensor =getPressureTensor();
513 <    stat[Stats::PRESSURE_TENSOR_XX] = tensor(0, 0);      
514 <    stat[Stats::PRESSURE_TENSOR_XY] = tensor(0, 1);      
515 <    stat[Stats::PRESSURE_TENSOR_XZ] = tensor(0, 2);      
516 <    stat[Stats::PRESSURE_TENSOR_YX] = tensor(1, 0);      
517 <    stat[Stats::PRESSURE_TENSOR_YY] = tensor(1, 1);      
518 <    stat[Stats::PRESSURE_TENSOR_YZ] = tensor(1, 2);      
519 <    stat[Stats::PRESSURE_TENSOR_ZX] = tensor(2, 0);      
520 <    stat[Stats::PRESSURE_TENSOR_ZY] = tensor(2, 1);      
521 <    stat[Stats::PRESSURE_TENSOR_ZZ] = tensor(2, 2);      
522 <    Vector3d GKappa_t = getThermalHelfand();
523 <    stat[Stats::THERMAL_HELFANDMOMENT_X] = GKappa_t.x();
242 <    stat[Stats::THERMAL_HELFANDMOMENT_Y] = GKappa_t.y();
243 <    stat[Stats::THERMAL_HELFANDMOMENT_Z] = GKappa_t.z();
512 >    Vector3d heatFluxJv = currSnapshot->getConductiveHeatFlux() *
513 >      PhysicalConstants::energyConvert;
514 >        
515 >    // Correct for the fact the flux is 1/V (Jc + Jv)
516 >    return (heatFluxJv + heatFluxJc) / this->getVolume(); // amu / fs^3
517 >  }
518 >
519 >
520 >  Vector3d Thermo::getComVel(){
521 >    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
522 >
523 >    if (!snap->hasCOMvel) {
524  
525 <    Globals* simParams = info_->getSimParams();
525 >      SimInfo::MoleculeIterator i;
526 >      Molecule* mol;
527 >      
528 >      Vector3d comVel(0.0);
529 >      RealType totalMass(0.0);
530 >      
531 >      for (mol = info_->beginMolecule(i); mol != NULL;
532 >           mol = info_->nextMolecule(i)) {
533 >        RealType mass = mol->getMass();
534 >        totalMass += mass;
535 >        comVel += mass * mol->getComVel();
536 >      }  
537 >      
538 > #ifdef IS_MPI
539 >      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &totalMass, 1, MPI::REALTYPE,
540 >                                MPI::SUM);
541 >      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, comVel.getArrayPointer(), 3,
542 >                                MPI::REALTYPE, MPI::SUM);
543 > #endif
544 >      
545 >      comVel /= totalMass;
546 >      snap->setCOMvel(comVel);
547 >    }
548 >    return snap->getCOMvel();
549 >  }
550  
551 +  Vector3d Thermo::getCom(){
552 +    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
553 +
554 +    if (!snap->hasCOM) {
555 +      
556 +      SimInfo::MoleculeIterator i;
557 +      Molecule* mol;
558 +      
559 +      Vector3d com(0.0);
560 +      RealType totalMass(0.0);
561 +      
562 +      for (mol = info_->beginMolecule(i); mol != NULL;
563 +           mol = info_->nextMolecule(i)) {
564 +        RealType mass = mol->getMass();
565 +        totalMass += mass;
566 +        com += mass * mol->getCom();
567 +      }  
568 +      
569 + #ifdef IS_MPI
570 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &totalMass, 1, MPI::REALTYPE,
571 +                                MPI::SUM);
572 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, com.getArrayPointer(), 3,
573 +                                MPI::REALTYPE, MPI::SUM);
574 + #endif
575 +      
576 +      com /= totalMass;
577 +      snap->setCOM(com);
578 +    }
579 +    return snap->getCOM();
580 +  }        
581 +
582 +  /**
583 +   * Returns center of mass and center of mass velocity in one
584 +   * function call.
585 +   */  
586 +  void Thermo::getComAll(Vector3d &com, Vector3d &comVel){
587 +    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
588 +
589 +    if (!(snap->hasCOM && snap->hasCOMvel)) {
590 +
591 +      SimInfo::MoleculeIterator i;
592 +      Molecule* mol;
593 +      
594 +      RealType totalMass(0.0);
595 +      
596 +      com = 0.0;
597 +      comVel = 0.0;
598 +      
599 +      for (mol = info_->beginMolecule(i); mol != NULL;
600 +           mol = info_->nextMolecule(i)) {
601 +        RealType mass = mol->getMass();
602 +        totalMass += mass;
603 +        com += mass * mol->getCom();
604 +        comVel += mass * mol->getComVel();          
605 +      }  
606 +      
607 + #ifdef IS_MPI
608 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &totalMass, 1, MPI::REALTYPE,
609 +                                MPI::SUM);
610 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, com.getArrayPointer(), 3,
611 +                                MPI::REALTYPE, MPI::SUM);
612 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, comVel.getArrayPointer(), 3,
613 +                                MPI::REALTYPE, MPI::SUM);
614 + #endif
615 +      
616 +      com /= totalMass;
617 +      comVel /= totalMass;
618 +      snap->setCOM(com);
619 +      snap->setCOMvel(comVel);
620 +    }    
621 +    com = snap->getCOM();
622 +    comVel = snap->getCOMvel();
623 +    return;
624 +  }        
625 +  
626 +  /**
627 +   * Return intertia tensor for entire system and angular momentum
628 +   * Vector.
629 +   *
630 +   *
631 +   *
632 +   *    [  Ixx -Ixy  -Ixz ]
633 +   * I =| -Iyx  Iyy  -Iyz |
634 +   *    [ -Izx -Iyz   Izz ]
635 +   */
636 +  void Thermo::getInertiaTensor(Mat3x3d &inertiaTensor,
637 +                                Vector3d &angularMomentum){
638 +
639 +    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
640 +    
641 +    if (!(snap->hasInertiaTensor && snap->hasCOMw)) {
642 +      
643 +      RealType xx = 0.0;
644 +      RealType yy = 0.0;
645 +      RealType zz = 0.0;
646 +      RealType xy = 0.0;
647 +      RealType xz = 0.0;
648 +      RealType yz = 0.0;
649 +      Vector3d com(0.0);
650 +      Vector3d comVel(0.0);
651 +      
652 +      getComAll(com, comVel);
653 +      
654 +      SimInfo::MoleculeIterator i;
655 +      Molecule* mol;
656 +      
657 +      Vector3d thisq(0.0);
658 +      Vector3d thisv(0.0);
659 +      
660 +      RealType thisMass = 0.0;
661 +      
662 +      for (mol = info_->beginMolecule(i); mol != NULL;
663 +           mol = info_->nextMolecule(i)) {
664 +        
665 +        thisq = mol->getCom()-com;
666 +        thisv = mol->getComVel()-comVel;
667 +        thisMass = mol->getMass();
668 +        // Compute moment of intertia coefficients.
669 +        xx += thisq[0]*thisq[0]*thisMass;
670 +        yy += thisq[1]*thisq[1]*thisMass;
671 +        zz += thisq[2]*thisq[2]*thisMass;
672 +        
673 +        // compute products of intertia
674 +        xy += thisq[0]*thisq[1]*thisMass;
675 +        xz += thisq[0]*thisq[2]*thisMass;
676 +        yz += thisq[1]*thisq[2]*thisMass;
677 +        
678 +        angularMomentum += cross( thisq, thisv ) * thisMass;            
679 +      }
680 +      
681 +      inertiaTensor(0,0) = yy + zz;
682 +      inertiaTensor(0,1) = -xy;
683 +      inertiaTensor(0,2) = -xz;
684 +      inertiaTensor(1,0) = -xy;
685 +      inertiaTensor(1,1) = xx + zz;
686 +      inertiaTensor(1,2) = -yz;
687 +      inertiaTensor(2,0) = -xz;
688 +      inertiaTensor(2,1) = -yz;
689 +      inertiaTensor(2,2) = xx + yy;
690 +      
691 + #ifdef IS_MPI
692 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, inertiaTensor.getArrayPointer(),
693 +                                9, MPI::REALTYPE, MPI::SUM);
694 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE,
695 +                                angularMomentum.getArrayPointer(), 3,
696 +                                MPI::REALTYPE, MPI::SUM);
697 + #endif
698 +      
699 +      snap->setCOMw(angularMomentum);
700 +      snap->setInertiaTensor(inertiaTensor);
701 +    }
702 +    
703 +    angularMomentum = snap->getCOMw();
704 +    inertiaTensor = snap->getInertiaTensor();
705 +    
706 +    return;
707 +  }
708 +
709 +  // Returns the angular momentum of the system
710 +  Vector3d Thermo::getAngularMomentum(){
711 +    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
712 +    
713 +    if (!snap->hasCOMw) {
714 +      
715 +      Vector3d com(0.0);
716 +      Vector3d comVel(0.0);
717 +      Vector3d angularMomentum(0.0);
718 +      
719 +      getComAll(com, comVel);
720 +      
721 +      SimInfo::MoleculeIterator i;
722 +      Molecule* mol;
723 +      
724 +      Vector3d thisr(0.0);
725 +      Vector3d thisp(0.0);
726 +      
727 +      RealType thisMass;
728 +      
729 +      for (mol = info_->beginMolecule(i); mol != NULL;
730 +           mol = info_->nextMolecule(i)) {
731 +        thisMass = mol->getMass();
732 +        thisr = mol->getCom() - com;
733 +        thisp = (mol->getComVel() - comVel) * thisMass;
734 +        
735 +        angularMomentum += cross( thisr, thisp );      
736 +      }  
737 +      
738 + #ifdef IS_MPI
739 +      MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE,
740 +                                angularMomentum.getArrayPointer(), 3,
741 +                                MPI::REALTYPE, MPI::SUM);
742 + #endif
743 +      
744 +      snap->setCOMw(angularMomentum);
745 +    }
746 +    
747 +    return snap->getCOMw();
748 +  }
749 +  
750 +  
751 +  /**
752 +   * Returns the Volume of the system based on a ellipsoid with
753 +   * semi-axes based on the radius of gyration V=4/3*Pi*R_1*R_2*R_3
754 +   * where R_i are related to the principle inertia moments
755 +   *  R_i = sqrt(C*I_i/N), this reduces to
756 +   *  V = 4/3*Pi*(C/N)^3/2*sqrt(det(I)).
757 +   * See S.E. Baltazar et. al. Comp. Mat. Sci. 37 (2006) 526-536.
758 +   */
759 +  RealType Thermo::getGyrationalVolume(){
760 +    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
761 +    
762 +    if (!snap->hasGyrationalVolume) {
763 +      
764 +      Mat3x3d intTensor;
765 +      RealType det;
766 +      Vector3d dummyAngMom;
767 +      RealType sysconstants;
768 +      RealType geomCnst;
769 +      RealType volume;
770 +      
771 +      geomCnst = 3.0/2.0;
772 +      /* Get the inertial tensor and angular momentum for free*/
773 +      getInertiaTensor(intTensor, dummyAngMom);
774 +      
775 +      det = intTensor.determinant();
776 +      sysconstants = geomCnst / (RealType)(info_->getNGlobalIntegrableObjects());
777 +      volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,geomCnst)*sqrt(det);
778 +
779 +      snap->setGyrationalVolume(volume);
780 +    }
781 +    return snap->getGyrationalVolume();
782 +  }
783 +  
784 +  void Thermo::getGyrationalVolume(RealType &volume, RealType &detI){
785 +    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
786 +
787 +    if (!(snap->hasInertiaTensor && snap->hasGyrationalVolume)) {
788 +    
789 +      Mat3x3d intTensor;
790 +      Vector3d dummyAngMom;
791 +      RealType sysconstants;
792 +      RealType geomCnst;
793 +      
794 +      geomCnst = 3.0/2.0;
795 +      /* Get the inertia tensor and angular momentum for free*/
796 +      this->getInertiaTensor(intTensor, dummyAngMom);
797 +      
798 +      detI = intTensor.determinant();
799 +      sysconstants = geomCnst/(RealType)(info_->getNGlobalIntegrableObjects());
800 +      volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,geomCnst)*sqrt(detI);
801 +      snap->setGyrationalVolume(volume);
802 +    } else {
803 +      volume = snap->getGyrationalVolume();
804 +      detI = snap->getInertiaTensor().determinant();
805 +    }
806 +    return;
807 +  }
808 +  
809 +  RealType Thermo::getTaggedAtomPairDistance(){
810 +    Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
811 +    Globals* simParams = info_->getSimParams();
812 +    
813      if (simParams->haveTaggedAtomPair() &&
814          simParams->havePrintTaggedPairDistance()) {
815        if ( simParams->getPrintTaggedPairDistance()) {
816          
817 <        std::pair<int, int> tap = simParams->getTaggedAtomPair();
817 >        pair<int, int> tap = simParams->getTaggedAtomPair();
818          Vector3d pos1, pos2, rab;
819 <
819 >        
820   #ifdef IS_MPI        
255        std::cerr << "tap = " << tap.first << "  " << tap.second << std::endl;
256
821          int mol1 = info_->getGlobalMolMembership(tap.first);
822          int mol2 = info_->getGlobalMolMembership(tap.second);
259        std::cerr << "mols = " << mol1 << " " << mol2 << std::endl;
823  
824          int proc1 = info_->getMolToProc(mol1);
825          int proc2 = info_->getMolToProc(mol2);
826  
264        std::cerr << " procs = " << proc1 << " " <<proc2 <<std::endl;
265
827          RealType data[3];
828          if (proc1 == worldRank) {
829            StuntDouble* sd1 = info_->getIOIndexToIntegrableObject(tap.first);
269          std::cerr << " on proc " << proc1 << ", sd1 has global index= " << sd1->getGlobalIndex() << std::endl;
830            pos1 = sd1->getPos();
831            data[0] = pos1.x();
832            data[1] = pos1.y();
# Line 277 | Line 837 | namespace OpenMD {
837            pos1 = Vector3d(data);
838          }
839  
280
840          if (proc2 == worldRank) {
841            StuntDouble* sd2 = info_->getIOIndexToIntegrableObject(tap.second);
283          std::cerr << " on proc " << proc2 << ", sd2 has global index= " << sd2->getGlobalIndex() << std::endl;
842            pos2 = sd2->getPos();
843            data[0] = pos2.x();
844            data[1] = pos2.y();
# Line 298 | Line 856 | namespace OpenMD {
856   #endif        
857          rab = pos2 - pos1;
858          currSnapshot->wrapVector(rab);
859 <        stat[Stats::TAGGED_PAIR_DISTANCE] =  rab.length();
859 >        return rab.length();
860        }
861 +      return 0.0;    
862      }
863 <      
305 <    /**@todo need refactorying*/
306 <    //Conserved Quantity is set by integrator and time is set by setTime
307 <    
863 >    return 0.0;
864    }
865  
866 +  RealType Thermo::getHullVolume(){
867 +    Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
868  
869 + #ifdef HAVE_QHULL    
870 +    if (!snap->hasHullVolume) {
871 +      Hull* surfaceMesh_;
872  
873 < Vector3d Thermo::getBoxDipole() {
874 <    Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
875 <    SimInfo::MoleculeIterator miter;
876 <    std::vector<Atom*>::iterator aiter;
877 <    Molecule* mol;
878 <    Atom* atom;
879 <    RealType charge;
880 <    RealType moment(0.0);
881 <    Vector3d ri(0.0);
321 <    Vector3d dipoleVector(0.0);
322 <    Vector3d nPos(0.0);
323 <    Vector3d pPos(0.0);
324 <    RealType nChg(0.0);
325 <    RealType pChg(0.0);
326 <    int nCount = 0;
327 <    int pCount = 0;
328 <
329 <    RealType chargeToC = 1.60217733e-19;
330 <    RealType angstromToM = 1.0e-10;    RealType debyeToCm = 3.33564095198e-30;
331 <
332 <    for (mol = info_->beginMolecule(miter); mol != NULL;
333 <         mol = info_->nextMolecule(miter)) {
334 <
335 <      for (atom = mol->beginAtom(aiter); atom != NULL;
336 <           atom = mol->nextAtom(aiter)) {
337 <
338 <        if (atom->isCharge() ) {
339 <          charge = 0.0;
340 <          GenericData* data = atom->getAtomType()->getPropertyByName("Charge");
341 <          if (data != NULL) {
342 <
343 <            charge = (dynamic_cast<DoubleGenericData*>(data))->getData();
344 <            charge *= chargeToC;
345 <
346 <            ri = atom->getPos();
347 <            currSnapshot->wrapVector(ri);
348 <            ri *= angstromToM;
349 <
350 <            if (charge < 0.0) {
351 <              nPos += ri;
352 <              nChg -= charge;
353 <              nCount++;
354 <            } else if (charge > 0.0) {
355 <              pPos += ri;
356 <              pChg += charge;
357 <              pCount++;
358 <            }
359 <          }
360 <        }
361 <
362 <        if (atom->isDipole() ) {
363 <          Vector3d u_i = atom->getElectroFrame().getColumn(2);
364 <          GenericData* data = dynamic_cast<DirectionalAtomType*>(atom->getAtomType())->getPropertyByName("Dipole");
365 <          if (data != NULL) {
366 <            moment = (dynamic_cast<DoubleGenericData*>(data))->getData();
367 <
368 <            moment *= debyeToCm;
369 <            dipoleVector += u_i * moment;
370 <          }
371 <        }
873 >      Globals* simParams = info_->getSimParams();
874 >      const std::string ht = simParams->getHULL_Method();
875 >      
876 >      if (ht == "Convex") {
877 >        surfaceMesh_ = new ConvexHull();
878 >      } else if (ht == "AlphaShape") {
879 >        surfaceMesh_ = new AlphaHull(simParams->getAlpha());
880 >      } else {
881 >        return 0.0;
882        }
373    }
374
375
376 #ifdef IS_MPI
377    RealType pChg_global, nChg_global;
378    int pCount_global, nCount_global;
379    Vector3d pPos_global, nPos_global, dipVec_global;
380
381    MPI_Allreduce(&pChg, &pChg_global, 1, MPI_REALTYPE, MPI_SUM,
382                  MPI_COMM_WORLD);
383    pChg = pChg_global;
384    MPI_Allreduce(&nChg, &nChg_global, 1, MPI_REALTYPE, MPI_SUM,
385                  MPI_COMM_WORLD);
386    nChg = nChg_global;
387    MPI_Allreduce(&pCount, &pCount_global, 1, MPI_INTEGER, MPI_SUM,
388                  MPI_COMM_WORLD);
389    pCount = pCount_global;
390    MPI_Allreduce(&nCount, &nCount_global, 1, MPI_INTEGER, MPI_SUM,
391                  MPI_COMM_WORLD);
392    nCount = nCount_global;
393    MPI_Allreduce(pPos.getArrayPointer(), pPos_global.getArrayPointer(), 3,
394                  MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
395    pPos = pPos_global;
396    MPI_Allreduce(nPos.getArrayPointer(), nPos_global.getArrayPointer(), 3,
397                  MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
398    nPos = nPos_global;
399    MPI_Allreduce(dipoleVector.getArrayPointer(),
400                  dipVec_global.getArrayPointer(), 3,
401                  MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
402    dipoleVector = dipVec_global;
403 #endif //is_mpi
404
405    // first load the accumulated dipole moment (if dipoles were present)
406    Vector3d boxDipole = dipoleVector;
407    // now include the dipole moment due to charges
408    // use the lesser of the positive and negative charge totals
409    RealType chg_value = nChg <= pChg ? nChg : pChg;
410
411    // find the average positions
412    if (pCount > 0 && nCount > 0 ) {
413      pPos /= pCount;
414      nPos /= nCount;
415    }
416
417    // dipole is from the negative to the positive (physics notation)
418    boxDipole += (pPos - nPos) * chg_value;
419
420    return boxDipole;
421  }
422
423 Vector3d Thermo::getThermalHelfand() {
424    Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
425    SimInfo::MoleculeIterator miter;
426    std::vector<Atom*>::iterator aiter;
427    Molecule* mol;
428    Atom* atom;
429    RealType mass;
430    Vector3d velocity;
431    Vector3d x_a;
432    RealType kinetic;
433    RealType potential;
434    RealType eatom;
435    RealType AvgE_a_ = 0;
436    Vector3d GKappa_t = V3Zero;
437    Vector3d ThermalHelfandMoment;
438    
439    for (mol = info_->beginMolecule(miter); mol != NULL;
440         mol = info_->nextMolecule(miter)) {
441
442      for (atom = mol->beginAtom(aiter); atom != NULL;
443           atom = mol->nextAtom(aiter)) {
444
445        mass = atom->getMass();
446        velocity = atom->getVel();
447        kinetic = mass * (velocity[0]*velocity[0] + velocity[1]*velocity[1] +
448                                   velocity[2]*velocity[2]) / PhysicalConstants::energyConvert;
449        potential =  atom->getParticlePot();
450        eatom += (kinetic + potential)/2.0;
451      }
452    }
453
454   int natoms = info_->getNGlobalAtoms();
455 #ifdef IS_MPI
456    
457    MPI_Allreduce(&eatom, &AvgE_a_, 1, MPI_REALTYPE, MPI_SUM,
458                  MPI_COMM_WORLD);
459 #else    
460    AvgE_a_ = eatom;
461 #endif
462    AvgE_a_ = AvgE_a_/RealType(natoms);
463    
464    for (mol = info_->beginMolecule(miter); mol != NULL;
465         mol = info_->nextMolecule(miter)) {
883        
884 <      for (atom = mol->beginAtom(aiter); atom != NULL;
885 <           atom = mol->nextAtom(aiter)) {
886 <        
887 <        /* We think that x_a is relative to the total box and should be a wrapped coordinate */
888 <        x_a = atom->getPos();
889 <        currSnapshot->wrapVector(x_a);
890 <        potential =  atom->getParticlePot();
891 <
892 <        GKappa_t += x_a*(potential-AvgE_a_);
884 >      // Build a vector of stunt doubles to determine if they are
885 >      // surface atoms
886 >      std::vector<StuntDouble*> localSites_;
887 >      Molecule* mol;
888 >      StuntDouble* sd;
889 >      SimInfo::MoleculeIterator i;
890 >      Molecule::IntegrableObjectIterator  j;
891 >      
892 >      for (mol = info_->beginMolecule(i); mol != NULL;
893 >           mol = info_->nextMolecule(i)) {          
894 >        for (sd = mol->beginIntegrableObject(j);
895 >             sd != NULL;
896 >             sd = mol->nextIntegrableObject(j)) {  
897 >          localSites_.push_back(sd);
898          }
899 <      }
900 < #ifdef IS_MPI
901 <     MPI_Allreduce(GKappa_t.getArrayPointer(), ThermalHelfandMoment.getArrayPointer(), 3,
902 <                  MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
903 < #else    
904 <     ThermalHelfandMoment = GKappa_t;
905 < #endif  
906 <     return ThermalHelfandMoment;
907 <    
908 < }
909 <
910 <
489 <
490 < } //end namespace OpenMD
899 >      }  
900 >      
901 >      // Compute surface Mesh
902 >      surfaceMesh_->computeHull(localSites_);
903 >      snap->setHullVolume(surfaceMesh_->getVolume());
904 >    }
905 >    return snap->getHullVolume();
906 > #else
907 >    return 0.0;
908 > #endif
909 >  }
910 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines