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

Comparing trunk/OOPSE/libmdtools/NPTf.cpp (file contents):
Revision 600 by gezelter, Mon Jul 14 22:38:13 2003 UTC vs.
Revision 617 by gezelter, Tue Jul 15 19:56:08 2003 UTC

# Line 1 | Line 1
1 + #include <cmath>
2   #include "Atom.hpp"
3   #include "SRI.hpp"
4   #include "AbstractClasses.hpp"
# Line 50 | Line 51 | void NPTf::moveA() {
51    double sc[3];
52    double eta2ij;
53    double press[3][3], vScale[3][3], hm[3][3], hmnew[3][3], scaleMat[3][3];
54 +  double bigScale, smallScale, offDiagMax;
55  
56    tt2 = tauThermostat * tauThermostat;
57    tb2 = tauBarostat * tauBarostat;
# Line 108 | Line 110 | void NPTf::moveA() {
110  
111      for (j = 0; j < 3; j++ )
112        pos[j] += dt * (vel[j] + sc[j]);
113 +
114 +    atoms[i]->setPos( pos );
115    
116      if( atoms[i]->isDirectional() ){
117  
# Line 161 | Line 165 | void NPTf::moveA() {
165    // Use a taylor expansion for eta products:  Hmat = Hmat . exp(dt * etaMat)
166    //  Hmat = Hmat . ( Ident + dt * etaMat  + dt^2 * etaMat*etaMat / 2)
167    
168 +  bigScale = 1.0;
169 +  smallScale = 1.0;
170 +  offDiagMax = 0.0;
171    
172    for(i=0; i<3; i++){
173      for(j=0; j<3; j++){
# Line 178 | Line 185 | void NPTf::moveA() {
185        if (i == j) scaleMat[i][j] = 1.0;
186        // Taylor expansion for the exponential truncated at second order:
187        scaleMat[i][j] += dt*eta[i][j]  + 0.5*dt*dt*eta2ij;
188 +
189 +      if (i != j)
190 +        if (fabs(scaleMat[i][j]) > offDiagMax)
191 +          offDiagMax = fabs(scaleMat[i][j]);
192        
193      }
194 +
195 +    if (scaleMat[i][i] > bigScale) bigScale = scaleMat[i][i];
196 +    if (scaleMat[i][i] < smallScale) smallScale = scaleMat[i][i];
197    }
198    
199 <  info->getBoxM(hm);
200 <  info->matMul3(hm, scaleMat, hmnew);
201 <  info->setBoxM(hmnew);
199 >  if ((bigScale > 1.1) || (smallScale < 0.9)) {
200 >    sprintf( painCave.errMsg,
201 >             "NPTf error: Attempting a Box scaling of more than 10 percent.\n"
202 >             " Check your tauBarostat, as it is probably too small!\n\n"
203 >             " scaleMat = [%lf\t%lf\t%lf]\n"
204 >             "            [%lf\t%lf\t%lf]\n"
205 >             "            [%lf\t%lf\t%lf]\n",
206 >             scaleMat[0][0],scaleMat[0][1],scaleMat[0][2],
207 >             scaleMat[1][0],scaleMat[1][1],scaleMat[1][2],
208 >             scaleMat[2][0],scaleMat[2][1],scaleMat[2][2]);
209 >    painCave.isFatal = 1;
210 >    simError();
211 >  } else if (offDiagMax > 0.1) {
212 >    sprintf( painCave.errMsg,
213 >             "NPTf error: Attempting an off-diagonal Box scaling of more than 10 percent.\n"
214 >             " Check your tauBarostat, as it is probably too small!\n\n"
215 >             " scaleMat = [%lf\t%lf\t%lf]\n"
216 >             "            [%lf\t%lf\t%lf]\n"
217 >             "            [%lf\t%lf\t%lf]\n",
218 >             scaleMat[0][0],scaleMat[0][1],scaleMat[0][2],
219 >             scaleMat[1][0],scaleMat[1][1],scaleMat[1][2],
220 >             scaleMat[2][0],scaleMat[2][1],scaleMat[2][2]);
221 >    painCave.isFatal = 1;
222 >    simError();
223 >  } else {
224 >    info->getBoxM(hm);
225 >    info->matMul3(hm, scaleMat, hmnew);
226 >    info->setBoxM(hmnew);
227 >  }
228    
229   }
230  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines