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

Comparing trunk/OOPSE/libmdtools/NPTfm.cpp (file contents):
Revision 606 by gezelter, Tue Jul 15 03:28:05 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 "Molecule.hpp"
4   #include "SRI.hpp"
# Line 51 | Line 52 | void NPTfm::moveA() {
52    double instaTemp, instaPress, instaVol;
53    double tt2, tb2;
54    double sc[3];
55 <  double eta2ij;
55 >  double eta2ij, smallScale, bigScale, offDiagMax;
56    double press[3][3], vScale[3][3], hm[3][3], hmnew[3][3], scaleMat[3][3];
57  
58    int nInMol;
# Line 127 | Line 128 | void NPTfm::moveA() {
128  
129          for (k = 0; k < 3; k++ )
130            pos[k] += dt * (vel[k] + sc[k]);
131 +
132 +        myAtoms[j]->setPos( pos );
133    
134          if( myAtoms[j]->isDirectional() ){
135  
# Line 183 | Line 186 | void NPTfm::moveA() {
186    //  Hmat = Hmat . ( Ident + dt * etaMat  + dt^2 * etaMat*etaMat / 2)
187    
188    
189 +  bigScale = 1.0;
190 +  smallScale = 1.0;
191 +  offDiagMax = 0.0;
192 +
193    for(i=0; i<3; i++){
194      for(j=0; j<3; j++){
195        
# Line 199 | Line 206 | void NPTfm::moveA() {
206        if (i == j) scaleMat[i][j] = 1.0;
207        // Taylor expansion for the exponential truncated at second order:
208        scaleMat[i][j] += dt*eta[i][j]  + 0.5*dt*dt*eta2ij;
209 <      
209 >
210 >      if (i != j)
211 >        if (fabs(scaleMat[i][j]) > offDiagMax)
212 >          offDiagMax = fabs(scaleMat[i][j]);      
213      }
214 +    if (scaleMat[i][i] > bigScale) bigScale = scaleMat[i][i];
215 +    if (scaleMat[i][i] < smallScale) smallScale = scaleMat[i][i];
216    }
217    
218 <  info->getBoxM(hm);
219 <  info->matMul3(hm, scaleMat, hmnew);
220 <  info->setBoxM(hmnew);
221 <  
218 >  if ((bigScale > 1.1) || (smallScale < 0.9)) {
219 >    sprintf( painCave.errMsg,
220 >             "NPTf error: Attempting a Box scaling of more than 10 percent.\n"
221 >             " Check your tauBarostat, as it is probably too small!\n\n"
222 >             " scaleMat = [%lf\t%lf\t%lf]\n"
223 >             "            [%lf\t%lf\t%lf]\n"
224 >             "            [%lf\t%lf\t%lf]\n",
225 >             scaleMat[0][0],scaleMat[0][1],scaleMat[0][2],
226 >             scaleMat[1][0],scaleMat[1][1],scaleMat[1][2],
227 >             scaleMat[2][0],scaleMat[2][1],scaleMat[2][2]);
228 >    painCave.isFatal = 1;
229 >    simError();
230 >  } else if (offDiagMax > 0.1) {
231 >    sprintf( painCave.errMsg,
232 >             "NPTf error: Attempting an off-diagonal Box scaling of more than 10 percent.\n"
233 >             " Check your tauBarostat, as it is probably too small!\n\n"
234 >             " scaleMat = [%lf\t%lf\t%lf]\n"
235 >             "            [%lf\t%lf\t%lf]\n"
236 >             "            [%lf\t%lf\t%lf]\n",
237 >             scaleMat[0][0],scaleMat[0][1],scaleMat[0][2],
238 >             scaleMat[1][0],scaleMat[1][1],scaleMat[1][2],
239 >             scaleMat[2][0],scaleMat[2][1],scaleMat[2][2]);
240 >    painCave.isFatal = 1;
241 >    simError();
242 >  } else {
243 >    info->getBoxM(hm);
244 >    info->matMul3(hm, scaleMat, hmnew);
245 >    info->setBoxM(hmnew);
246 >  }  
247   }
248  
249   void NPTfm::moveB( void ){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines