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

Comparing trunk/OOPSE/libmdtools/NPTim.cpp (file contents):
Revision 605 by gezelter, Tue Jul 15 03:27:24 2003 UTC vs.
Revision 763 by tim, Mon Sep 15 16:52:02 2003 UTC

# Line 24 | Line 24
24   //  The NPTim variant scales the molecular center-of-mass coordinates
25   //  instead of the atomic coordinates
26  
27 < NPTim::NPTim ( SimInfo *theInfo, ForceFields* the_ff):
28 <  Integrator( theInfo, the_ff )
27 > template<typename T> NPTim<T>::NPTim ( SimInfo *theInfo, ForceFields* the_ff):
28 >  T( theInfo, the_ff )
29   {
30    chi = 0.0;
31    eta = 0.0;
32 +  integralOfChidt = 0.0;
33    have_tau_thermostat = 0;
34    have_tau_barostat = 0;
35    have_target_temp = 0;
36    have_target_pressure = 0;
37   }
38  
39 < void NPTim::moveA() {
39 > template<typename T> void NPTim<T>::moveA() {
40    
41    int i, j, k;
42    DirectionalAtom* dAtom;
# Line 46 | Line 47 | void NPTim::moveA() {
47  
48    double rj[3];
49    double instaTemp, instaPress, instaVol;
50 <  double tt2, tb2;
50 >  double tt2, tb2, scaleFactor;
51  
52    int nInMol;
53    double rc[3];
# Line 146 | Line 147 | void NPTim::moveA() {
147        }
148      }
149    }
150 +
151    // Scale the box after all the positions have been moved:
152    
153 <  cerr << "eta = " << eta
154 <       << "; exp(dt*eta) = " << exp(eta*dt) << "\n";
155 <  
156 <  info->scaleBox(exp(dt*eta));
153 >  scaleFactor = exp(dt*eta);
154 >
155 >  if (scaleFactor > 1.1 || scaleFactor < 0.9) {
156 >    sprintf( painCave.errMsg,
157 >             "NPTi error: Attempting a Box scaling of more than 10 percent"
158 >             " check your tauBarostat, as it is probably too small!\n"
159 >             " eta = %lf, scaleFactor = %lf\n", eta, scaleFactor
160 >             );
161 >    painCave.isFatal = 1;
162 >    simError();
163 >  } else {        
164 >    info->scaleBox(exp(dt*eta));      
165 >  }
166   }
167  
168 < void NPTim::moveB( void ){
168 > template<typename T> void NPTim<T>::moveB( void ){
169    int i, j;
170    DirectionalAtom* dAtom;
171    double Tb[3], ji[3];
# Line 209 | Line 220 | void NPTim::moveB( void ){
220    }
221   }
222  
223 < int NPTim::readyCheck() {
223 > template<typename T> void NPTim<T>::resetIntegrator() {
224 >  chi = 0.0;
225 >  eta = 0.0;
226 > }
227 >
228 > template<typename T> int NPTim<T>::readyCheck() {
229 >
230 >  //check parent's readyCheck() first
231 >  if (T::readyCheck() == -1)
232 >    return -1;
233  
234    // First check to see if we have a target temperature.
235    // Not having one is fatal.
# Line 262 | Line 282 | int NPTim::readyCheck() {
282  
283    return 1;
284   }
285 +
286 + template<typename T> double NPTim<T>::getConservedQuantity(void){
287 +
288 +  double conservedQuantity;
289 +  double tb2;
290 +  double eta2;  
291 +
292 +
293 +  //HNVE
294 +  conservedQuantity = tStats->getTotalE();
295 +
296 +  //HNVT
297 +  conservedQuantity += (info->getNDF() * kB * targetTemp *
298 +                        (integralOfChidt + tauThermostat * tauThermostat * chi * chi /2))/ eConvert ;
299 +
300 +  //HNPT
301 +  tb2 = tauBarostat *tauBarostat;
302 +  eta2 = eta * eta;
303 +  
304 +  conservedQuantity += (targetPressure * tStats->getVolume() / p_convert +
305 +                        3*NkBT/2 * tb2 * eta2) / eConvert;
306 +  
307 +  return conservedQuantity;
308 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines