ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new-templateless/OOPSE/libmdtools/NPTi.cpp
(Generate patch)

Comparing:
trunk/OOPSE/libmdtools/NPTi.cpp (file contents), Revision 763 by tim, Mon Sep 15 16:52:02 2003 UTC vs.
branches/new-templateless/OOPSE/libmdtools/NPTi.cpp (file contents), Revision 851 by mmeineke, Wed Nov 5 19:18:17 2003 UTC

# Line 1 | Line 1
1 < #include <cmath>
1 > #include <iostream>
2 > #include <math.h>
3 >
4 >
5   #include "Atom.hpp"
6   #include "SRI.hpp"
7   #include "AbstractClasses.hpp"
# Line 7 | Line 10
10   #include "Thermo.hpp"
11   #include "ReadWrite.hpp"
12   #include "Integrator.hpp"
13 < #include "simError.h"
13 > #include "simError.h"
14  
15   #ifdef IS_MPI
16   #include "mpiSimulation.hpp"
17   #endif
18  
16
19   // Basic isotropic thermostating and barostating via the Melchionna
20   // modification of the Hoover algorithm:
21   //
22   //    Melchionna, S., Ciccotti, G., and Holian, B. L., 1993,
23 < //       Molec. Phys., 78, 533.
23 > //       Molec. Phys., 78, 533.
24   //
25   //           and
26 < //
26 > //
27   //    Hoover, W. G., 1986, Phys. Rev. A, 34, 2499.
28  
29 < template<typename T> NPTi<T>::NPTi ( SimInfo *theInfo, ForceFields* the_ff):
30 <  T( theInfo, the_ff )
29 > NPTi::NPTi ( SimInfo *theInfo, ForceFields* the_ff):
30 >  NPT( theInfo, the_ff )
31   {
32 <  chi = 0.0;
32 >  GenericData* data;
33 >  double *etaArray;
34 >  int test;
35 >
36    eta = 0.0;
37 <  integralOfChidt = 0.0;
33 <  have_tau_thermostat = 0;
34 <  have_tau_barostat = 0;
35 <  have_target_temp = 0;
36 <  have_target_pressure = 0;
37 <  have_chi_tolerance = 0;
38 <  have_eta_tolerance = 0;
39 <  have_pos_iter_tolerance = 0;
37 >  oldEta = 0.0;
38  
39 <  oldPos = new double[3*nAtoms];
40 <  oldVel = new double[3*nAtoms];
41 <  oldJi = new double[3*nAtoms];
44 < #ifdef IS_MPI
45 <  Nparticles = mpiSim->getTotAtoms();
46 < #else
47 <  Nparticles = theInfo->n_atoms;
48 < #endif
49 <
50 < }
51 <
52 < template<typename T> NPTi<T>::~NPTi() {
53 <  delete[] oldPos;
54 <  delete[] oldVel;
55 <  delete[] oldJi;
56 < }
57 <
58 < template<typename T> void NPTi<T>::moveA() {
59 <
60 <
61 < //   int i, j;
62 < //   DirectionalAtom* dAtom;
63 < //   double Tb[3], ji[3];
64 < //   double A[3][3], I[3][3];
65 < //   double angle, mass;
66 < //   double vel[3], pos[3], frc[3];
67 <
68 < //   double rj[3];
69 < //   double instaTemp, instaPress, instaVol;
70 < //   double tt2, tb2, scaleFactor;
71 <
72 < //   tt2 = tauThermostat * tauThermostat;
73 < //   tb2 = tauBarostat * tauBarostat;
74 <
75 < //   instaTemp = tStats->getTemperature();
76 < //   instaPress = tStats->getPressure();
77 < //   instaVol = tStats->getVolume();
78 <  
79 < //    // first evolve chi a half step
80 <  
81 < //   chi += dt2 * ( instaTemp / targetTemp - 1.0) / tt2;
82 < //   eta += dt2 * ( instaVol * (instaPress - targetPressure) /
83 < //               (p_convert*NkBT*tb2));
84 <
85 < //   integralOfChidt += dt2* chi;
86 <
87 < //   for( i=0; i<nAtoms; i++ ){
88 < //     atoms[i]->getVel( vel );
89 < //     atoms[i]->getPos( pos );
90 < //     atoms[i]->getFrc( frc );
91 <
92 < //     mass = atoms[i]->getMass();
93 <
94 < //     for (j=0; j < 3; j++) {
95 < //       vel[j] += dt2 * ((frc[j] / mass ) * eConvert - vel[j]*(chi+eta));
96 < //       rj[j] = pos[j];
97 < //     }
98 <
99 < //     atoms[i]->setVel( vel );
100 <
101 < //     info->wrapVector(rj);
102 <
103 < //     for (j = 0; j < 3; j++)
104 < //       pos[j] += dt * (vel[j] + eta*rj[j]);
105 <
106 < //     atoms[i]->setPos( pos );
107 <
108 < //     if( atoms[i]->isDirectional() ){
109 <
110 < //       dAtom = (DirectionalAtom *)atoms[i];
111 <          
112 < //       // get and convert the torque to body frame
113 <      
114 < //       dAtom->getTrq( Tb );
115 < //       dAtom->lab2Body( Tb );
116 <      
117 < //       // get the angular momentum, and propagate a half step
118 <
119 < //       dAtom->getJ( ji );
120 <
121 < //       for (j=0; j < 3; j++)
122 < //         ji[j] += dt2 * (Tb[j] * eConvert - ji[j]*chi);
123 <      
124 < //       // use the angular velocities to propagate the rotation matrix a
125 < //       // full time step
126 <
127 < //       dAtom->getA(A);
128 < //       dAtom->getI(I);
39 >  // retrieve eta array from simInfo if it exists
40 >  data = info->getProperty(ETAVALUE_ID);
41 >  if(data != NULL){
42      
43 < //       // rotate about the x-axis      
44 < //       angle = dt2 * ji[0] / I[0][0];
45 < //       this->rotate( 1, 2, angle, ji, A );
133 <
134 < //       // rotate about the y-axis
135 < //       angle = dt2 * ji[1] / I[1][1];
136 < //       this->rotate( 2, 0, angle, ji, A );
43 >    test = data->getDarray(etaArray);
44 >    
45 >    if( test == 9 ){
46        
47 < //       // rotate about the z-axis
48 < //       angle = dt * ji[2] / I[2][2];
140 < //       this->rotate( 0, 1, angle, ji, A);
141 <      
142 < //       // rotate about the y-axis
143 < //       angle = dt2 * ji[1] / I[1][1];
144 < //       this->rotate( 2, 0, angle, ji, A );
145 <      
146 < //        // rotate about the x-axis
147 < //       angle = dt2 * ji[0] / I[0][0];
148 < //       this->rotate( 1, 2, angle, ji, A );
149 <      
150 < //       dAtom->setJ( ji );
151 < //       dAtom->setA( A  );    
152 < //     }                
153 <
154 < //   }
155 <
156 < //   // Scale the box after all the positions have been moved:
157 <  
158 < //   scaleFactor = exp(dt*eta);
159 <
160 < //   if ((scaleFactor > 1.1) || (scaleFactor < 0.9)) {
161 < //     sprintf( painCave.errMsg,
162 < //              "NPTi error: Attempting a Box scaling of more than 10 percent"
163 < //              " check your tauBarostat, as it is probably too small!\n"
164 < //              " eta = %lf, scaleFactor = %lf\n", eta, scaleFactor
165 < //              );
166 < //     painCave.isFatal = 1;
167 < //     simError();
168 < //   } else {        
169 < //     info->scaleBox(exp(dt*eta));      
170 < //   }
171 <  
172 <
173 <  //new version of NPTi
174 <  int i, j, k;
175 <  DirectionalAtom* dAtom;
176 <  double Tb[3], ji[3];
177 <  double A[3][3], I[3][3];
178 <  double angle, mass;
179 <  double vel[3], pos[3], frc[3];
180 <
181 <  double rj[3];
182 <  double instaTemp, instaPress, instaVol;
183 <  double tt2, tb2, scaleFactor;
184 <  double COM[3];
185 <
186 <  tt2 = tauThermostat * tauThermostat;
187 <  tb2 = tauBarostat * tauBarostat;
188 <
189 <  instaTemp = tStats->getTemperature();
190 <  instaPress = tStats->getPressure();
191 <  instaVol = tStats->getVolume();
192 <  
193 <  tStats->getCOM(COM);
194 <  
195 <  //evolve velocity half step
196 <  for( i=0; i<nAtoms; i++ ){
197 <
198 <    atoms[i]->getVel( vel );
199 <    atoms[i]->getFrc( frc );
200 <
201 <    mass = atoms[i]->getMass();
202 <
203 <    for (j=0; j < 3; j++) {
204 <      // velocity half step  (use chi from previous step here):
205 <      vel[j] += dt2 * ((frc[j] / mass ) * eConvert - vel[j]*(chi + eta));
206 <  
47 >      eta = etaArray[0];
48 >      delete[] etaArray;
49      }
50 +    else
51 +      std::cerr << "NPTi error: etaArray is not length 9 (actual = " << test
52 +                << ").\n"
53 +                << "            Simulation wil proceed with eta = 0;\n";
54 +  }
55 + }
56  
57 <    atoms[i]->setVel( vel );
58 <  
59 <    if( atoms[i]->isDirectional() ){
57 > NPTi::~NPTi() {
58 >  //nothing for now
59 > }
60  
61 <      dAtom = (DirectionalAtom *)atoms[i];
61 > void NPTi::resetIntegrator() {
62 >  eta = 0.0;
63 >  NPT::resetIntegrator();
64 > }
65  
66 <      // get and convert the torque to body frame
67 <      
68 <      dAtom->getTrq( Tb );
69 <      dAtom->lab2Body( Tb );
70 <      
220 <      // get the angular momentum, and propagate a half step
66 > void NPTi::evolveEtaA() {
67 >  eta += dt2 * ( instaVol * (instaPress - targetPressure) /
68 >                 (p_convert*NkBT*tb2));
69 >  oldEta = eta;
70 > }
71  
72 <      dAtom->getJ( ji );
72 > void NPTi::evolveEtaB() {
73  
74 <      for (j=0; j < 3; j++)
75 <        ji[j] += dt2 * (Tb[j] * eConvert - ji[j]*chi);
76 <      
77 <      // use the angular velocities to propagate the rotation matrix a
228 <      // full time step
74 >  prevEta = eta;
75 >  eta = oldEta + dt2 * ( instaVol * (instaPress - targetPressure) /
76 >                 (p_convert*NkBT*tb2));
77 > }
78  
79 <      dAtom->getA(A);
80 <      dAtom->getI(I);
232 <    
233 <      // rotate about the x-axis      
234 <      angle = dt2 * ji[0] / I[0][0];
235 <      this->rotate( 1, 2, angle, ji, A );
79 > void NPTi::getVelScaleA(double sc[3], double vel[3]) {
80 >  int i;
81  
82 <      // rotate about the y-axis
83 <      angle = dt2 * ji[1] / I[1][1];
239 <      this->rotate( 2, 0, angle, ji, A );
240 <      
241 <      // rotate about the z-axis
242 <      angle = dt * ji[2] / I[2][2];
243 <      this->rotate( 0, 1, angle, ji, A);
244 <      
245 <      // rotate about the y-axis
246 <      angle = dt2 * ji[1] / I[1][1];
247 <      this->rotate( 2, 0, angle, ji, A );
248 <      
249 <       // rotate about the x-axis
250 <      angle = dt2 * ji[0] / I[0][0];
251 <      this->rotate( 1, 2, angle, ji, A );
252 <      
253 <      dAtom->setJ( ji );
254 <      dAtom->setA( A  );    
255 <    }    
256 <  }
82 >  for(i=0; i<3; i++) sc[i] = vel[i] * ( chi + eta );
83 > }
84  
85 <  // evolve chi and eta  half step
86 <  
260 <  chi += dt2 * ( instaTemp / targetTemp - 1.0) / tt2;
261 <  eta += dt2 * ( instaVol * (instaPress - targetPressure) / (p_convert*NkBT*tb2));
85 > void NPTi::getVelScaleB(double sc[3], int index ){
86 >  int i;
87  
88 <  //calculate the integral of chidt
89 <  integralOfChidt += dt2*chi;
88 >  for(i=0; i<3; i++) sc[i] = oldVel[index*3 + i] * ( chi + eta );
89 > }
90  
266  //save the old positions
267  for(i = 0; i < nAtoms; i++){
268    atoms[i]->getPos(pos);
269    for(j = 0; j < 3; j++)
270      oldPos[i*3 + j] = pos[j];
271  }
272  
273  //the first estimation of r(t+dt) is equal to  r(t)
274    
275  for(k = 0; k < 4; k ++){
91  
92 <    for(i =0 ; i < nAtoms; i++){
92 > void NPTi::getPosScale(double pos[3], double COM[3],
93 >                                               int index, double sc[3]){
94 >  int j;
95  
96 <      atoms[i]->getVel(vel);
97 <      atoms[i]->getPos(pos);
96 >  for(j=0; j<3; j++)
97 >    sc[j] = ( oldPos[index*3+j] + pos[j]) / 2.0 - COM[j];
98  
99 <      for(j = 0; j < 3; j++)
100 <        rj[j] = (oldPos[i*3 + j] + pos[j])/2 - COM[j];
99 >  for(j=0; j<3; j++)
100 >    sc[j] *= eta;
101 > }
102  
103 <      
286 <      //wrapVector(r(t)) = r(t)-R0
287 <      //info->wrapVector(rj);
288 <      
289 <      for(j = 0; j < 3; j++)
290 <        pos[j] = oldPos[i*3 + j] + dt*(vel[j] + eta*rj[j]);
103 > void NPTi::scaleSimBox( void ){
104  
105 <      atoms[i]->setPos( pos );
105 >  double scaleFactor;
106  
294    }
295
296  }
297    
298
299  // Scale the box after all the positions have been moved:
300  
107    scaleFactor = exp(dt*eta);
108  
109    if ((scaleFactor > 1.1) || (scaleFactor < 0.9)) {
# Line 308 | Line 114 | template<typename T> void NPTi<T>::moveA() {
114               );
115      painCave.isFatal = 1;
116      simError();
117 <  } else {        
118 <    info->scaleBox(scaleFactor);      
119 <  }  
117 >  } else {
118 >    info->scaleBox(scaleFactor);
119 >  }
120  
315  //advance volume;
316  volume = volume * exp(dt*eta);
121   }
122  
123 < template<typename T> void NPTi<T>::moveB( void ){
123 > bool NPTi::etaConverged() {
124  
125 < /*
126 <  int i, j;
323 <  DirectionalAtom* dAtom;
324 <  double Tb[3], ji[3];
325 <  double vel[3], frc[3];
326 <  double mass;
125 >  return ( fabs(prevEta - eta) <= etaTolerance );
126 > }
127  
128 <  double instaTemp, instaPress, instaVol;
329 <  double tt2, tb2;
330 <  
331 <  tt2 = tauThermostat * tauThermostat;
332 <  tb2 = tauBarostat * tauBarostat;
128 > double NPTi::getConservedQuantity(void){
129  
130 <  instaTemp = tStats->getTemperature();
131 <  instaPress = tStats->getPressure();
132 <  instaVol = tStats->getVolume();
130 >  double conservedQuantity;
131 >  double Energy;
132 >  double thermostat_kinetic;
133 >  double thermostat_potential;
134 >  double barostat_kinetic;
135 >  double barostat_potential;
136  
137 <  chi += dt2 * ( instaTemp / targetTemp - 1.0) / tt2;
339 <  eta += dt2 * ( instaVol * (instaPress - targetPressure) /
340 <                 (p_convert*NkBT*tb2));
341 <  integralOfChidt += dt2*chi;
342 <  
343 <  for( i=0; i<nAtoms; i++ ){
137 >  Energy = tStats->getTotalE();
138  
139 <    atoms[i]->getVel( vel );
140 <    atoms[i]->getFrc( frc );
139 >  thermostat_kinetic = fkBT* tt2 * chi * chi /
140 >    (2.0 * eConvert);
141  
142 <    mass = atoms[i]->getMass();
142 >  thermostat_potential = fkBT* integralOfChidt / eConvert;
143  
350    // velocity half step
351    for (j=0; j < 3; j++)
352      vel[j] += dt2 * ((frc[j] / mass ) * eConvert - vel[j]*(chi+eta));
353    
354    atoms[i]->setVel( vel );
144  
145 <    if( atoms[i]->isDirectional() ){
145 >  barostat_kinetic = 3.0 * NkBT * tb2 * eta * eta /
146 >    (2.0 * eConvert);
147  
148 <      dAtom = (DirectionalAtom *)atoms[i];
148 >  barostat_potential = (targetPressure * tStats->getVolume() / p_convert) /
149 >    eConvert;
150  
151 <      // get and convert the torque to body frame      
151 >  conservedQuantity = Energy + thermostat_kinetic + thermostat_potential +
152 >    barostat_kinetic + barostat_potential;
153  
154 <      dAtom->getTrq( Tb );
155 <      dAtom->lab2Body( Tb );
154 > //   cout.width(8);
155 > //   cout.precision(8);
156  
157 <      // get the angular momentum, and propagate a half step
158 <
159 <      dAtom->getJ( ji );
160 <
369 <      for (j=0; j < 3; j++)
370 <        ji[j] += dt2 * (Tb[j] * eConvert - ji[j]*chi);    
371 <
372 <      dAtom->setJ( ji );
373 <    }
374 <  }
375 <
376 < */
377 <  
378 <  //new version of NPTi
379 <  int i, j, k;
380 <  DirectionalAtom* dAtom;
381 <  double Tb[3], ji[3];
382 <  double vel[3], frc[3];
383 <  double mass;
384 <
385 <  double instTemp, instPress, instVol;
386 <  double tt2, tb2;
387 <  double oldChi, prevChi;
388 <  double oldEta, preEta;
389 <  
390 <  tt2 = tauThermostat * tauThermostat;
391 <  tb2 = tauBarostat * tauBarostat;
392 <
393 <
394 <  // Set things up for the iteration:
395 <
396 <  oldChi = chi;
397 <  oldEta = eta;
398 <
399 <  for( i=0; i<nAtoms; i++ ){
400 <
401 <    atoms[i]->getVel( vel );
402 <
403 <    for (j=0; j < 3; j++)
404 <      oldVel[3*i + j]  = vel[j];
405 <
406 <    if( atoms[i]->isDirectional() ){
407 <
408 <      dAtom = (DirectionalAtom *)atoms[i];
409 <
410 <      dAtom->getJ( ji );
411 <
412 <      for (j=0; j < 3; j++)
413 <        oldJi[3*i + j] = ji[j];
414 <
415 <    }
416 <  }
417 <
418 <  // do the iteration:
419 <
420 <  instVol = tStats->getVolume();
421 <  
422 <  for (k=0; k < 4; k++) {
423 <    
424 <    instTemp = tStats->getTemperature();
425 <    instPress = tStats->getPressure();
426 <
427 <    // evolve chi another half step using the temperature at t + dt/2
428 <
429 <    prevChi = chi;
430 <    chi = oldChi + dt2 * ( instTemp / targetTemp - 1.0) /
431 <      (tauThermostat*tauThermostat);
432 <
433 <    preEta = eta;
434 <    eta = oldEta + dt2 * ( instVol * (instPress - targetPressure) /
435 <       (p_convert*NkBT*tb2));
436 <
437 <  
438 <    for( i=0; i<nAtoms; i++ ){
439 <
440 <      atoms[i]->getFrc( frc );
441 <      atoms[i]->getVel(vel);
442 <      
443 <      mass = atoms[i]->getMass();
444 <      
445 <      // velocity half step
446 <      for (j=0; j < 3; j++)
447 <        vel[j] = oldVel[3*i+j] + dt2 * ((frc[j] / mass ) * eConvert - oldVel[3*i + j]*(chi + eta));
448 <      
449 <      atoms[i]->setVel( vel );
450 <      
451 <      if( atoms[i]->isDirectional() ){
452 <
453 <        dAtom = (DirectionalAtom *)atoms[i];
454 <  
455 <        // get and convert the torque to body frame      
456 <  
457 <        dAtom->getTrq( Tb );
458 <        dAtom->lab2Body( Tb );      
459 <            
460 <        for (j=0; j < 3; j++)
461 <          ji[j] = oldJi[3*i + j] + dt2 * (Tb[j] * eConvert - oldJi[3*i+j]*chi);
462 <      
463 <          dAtom->setJ( ji );
464 <      }
465 <    }
466 <
467 <    if (fabs(prevChi - chi) <= chiTolerance && fabs(preEta -eta) <= etaTolerance)
468 <      break;
469 <  }
470 <
471 <  //calculate integral of chida
472 <  integralOfChidt += dt2*chi;
473 <
474 <
157 > //   cerr << info->getTime() << "\t" << Energy << "\t" << thermostat_kinetic <<
158 > //       "\t" << thermostat_potential << "\t" << barostat_kinetic <<
159 > //       "\t" << barostat_potential << "\t" << conservedQuantity << endl;
160 >  return conservedQuantity;
161   }
162  
163 < template<typename T> void NPTi<T>::resetIntegrator() {
478 <  chi = 0.0;
479 <  eta = 0.0;
480 < }
163 > char* NPTi::getAdditionalParameters(void){
164  
165 < template<typename T> int NPTi<T>::readyCheck() {
165 >  sprintf(addParamBuffer,
166 >          "\t%G\t%G;"
167 >          "\t%G\t%0.0\t%0.0;"
168 >          "\t%0.0\t%G\t%0.0;"
169 >          "\t%0.0\t%0.0\t%G;",
170 >          chi, integralOfChidt,
171 >          eta, eta, eta
172 >          );
173  
174 <  //check parent's readyCheck() first
485 <  if (T::readyCheck() == -1)
486 <    return -1;
487 <
488 <  // First check to see if we have a target temperature.
489 <  // Not having one is fatal.
490 <  
491 <  if (!have_target_temp) {
492 <    sprintf( painCave.errMsg,
493 <             "NPTi error: You can't use the NPTi integrator\n"
494 <             "   without a targetTemp!\n"
495 <             );
496 <    painCave.isFatal = 1;
497 <    simError();
498 <    return -1;
499 <  }
500 <
501 <  if (!have_target_pressure) {
502 <    sprintf( painCave.errMsg,
503 <             "NPTi error: You can't use the NPTi integrator\n"
504 <             "   without a targetPressure!\n"
505 <             );
506 <    painCave.isFatal = 1;
507 <    simError();
508 <    return -1;
509 <  }
510 <  
511 <  // We must set tauThermostat.
512 <  
513 <  if (!have_tau_thermostat) {
514 <    sprintf( painCave.errMsg,
515 <             "NPTi error: If you use the NPTi\n"
516 <             "   integrator, you must set tauThermostat.\n");
517 <    painCave.isFatal = 1;
518 <    simError();
519 <    return -1;
520 <  }    
521 <
522 <  // We must set tauBarostat.
523 <  
524 <  if (!have_tau_barostat) {
525 <    sprintf( painCave.errMsg,
526 <             "NPTi error: If you use the NPTi\n"
527 <             "   integrator, you must set tauBarostat.\n");
528 <    painCave.isFatal = 1;
529 <    simError();
530 <    return -1;
531 <  }    
532 <
533 <  if (!have_chi_tolerance) {
534 <    sprintf( painCave.errMsg,
535 <             "NPTi warning: setting chi tolerance to 1e-6\n");
536 <    chiTolerance = 1e-6;
537 <    have_chi_tolerance = 1;
538 <    painCave.isFatal = 0;
539 <    simError();
540 <  }
541 <
542 <    if (!have_eta_tolerance) {
543 <    sprintf( painCave.errMsg,
544 <             "NPTi warning: setting eta tolerance to 1e-6\n");
545 <    etaTolerance = 1e-6;
546 <    have_eta_tolerance = 1;
547 <    painCave.isFatal = 0;
548 <    simError();
549 <  }
550 <  // We need NkBT a lot, so just set it here:
551 <
552 <  NkBT = (double)Nparticles * kB * targetTemp;
553 <  fkBT = (double)info->ndf * kB * targetTemp;
554 <
555 <  return 1;
174 >  return addParamBuffer;
175   }
557
558 template<typename T> double NPTi<T>::getConservedQuantity(void){
559
560  double conservedQuantity;
561  double tb2;
562  double eta2;  
563  double E_NPT;
564  double U;
565  double TS;
566  double PV;
567  double extra;
568
569  static double pre_U;
570  static double pre_TS;
571  static double pre_PV;
572  static double pre_extra;
573  static int hackCount = 0;
574
575  double delta_U;
576  double delta_TS;
577  double delta_PV;
578  double delta_extra;
579
580  U = tStats->getTotalE();
581
582  TS = fkBT *
583    (integralOfChidt + tauThermostat * tauThermostat * chi * chi / 2.0) / eConvert;
584
585  PV = (targetPressure * tStats->getVolume() / p_convert) / eConvert;
586
587  tb2 = tauBarostat * tauBarostat;
588  eta2 = eta * eta;
589
590  extra = (fkBT * tb2 * eta2 / 2.0 ) / eConvert;
591  /*
592  if(hackCount == 0){
593    pre_U = U;
594    pre_TS =TS;
595    pre_PV = PV;
596    pre_extra =extra;
597    hackCount ++;
598  }
599
600  delta_U = U - pre_U;
601  delta_TS = TS - pre_TS;
602  delta_PV = PV - pre_PV;
603  delta_extra = extra - pre_extra;
604 */
605  cout.width(8);
606  cout.precision(8);
607
608  
609  cout << info->getTime() << "\t"
610       << chi << "\t"
611       << eta << "\t"
612       << U << "\t"
613       << TS << "\t"
614       << PV << "\t"
615       << extra << "\t"
616       << U+TS+PV+extra << endl;
617
618 /*
619    pre_U = U;
620    pre_TS =TS;
621    pre_PV = PV;
622    pre_extra =extra;
623
624
625  cout << info->getTime() << "\t"
626       << U << "\t"
627       << U+TS << "\t"
628       << U+TS+PV << "\t"
629       << U+TS+PV+extra << endl;
630 */
631  conservedQuantity = U+TS+PV+extra;
632  return conservedQuantity;
633 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines