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

Comparing trunk/OOPSE/libmdtools/SimInfo.cpp (file contents):
Revision 588 by gezelter, Thu Jul 10 17:10:56 2003 UTC vs.
Revision 626 by mmeineke, Wed Jul 16 21:30:56 2003 UTC

# Line 34 | Line 34 | SimInfo::SimInfo(){
34    setTemp = 0;
35    thermalTime = 0.0;
36    rCut = 0.0;
37 +  ecr = 0.0;
38 +  est = 0.0;
39 +  oldEcr = 0.0;
40 +  oldRcut = 0.0;
41  
42 +  haveOrigRcut = 0;
43 +  haveOrigEcr = 0;
44 +  boxIsInit = 0;
45 +  
46 +  
47 +
48    usePBC = 0;
49    useLJ = 0;
50    useSticky = 0;
# Line 73 | Line 83 | void SimInfo::setBoxM( double theBox[3][3] ){
83                           // [ 2 5 8 ]
84    double FortranHmatInv[9]; // the inverted Hmat (for Fortran);
85  
86 +  
87 +  if( !boxIsInit ) boxIsInit = 1;
88  
89    for(i=0; i < 3; i++)
90      for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j];
91    
80  cerr
81    << "setting Hmat ->\n"
82    << "[ " << Hmat[0][0] << ", " << Hmat[0][1] << ", " << Hmat[0][2] << " ]\n"
83    << "[ " << Hmat[1][0] << ", " << Hmat[1][1] << ", " << Hmat[1][2] << " ]\n"
84    << "[ " << Hmat[2][0] << ", " << Hmat[2][1] << ", " << Hmat[2][2] << " ]\n";
85
92    calcBoxL();
93    calcHmatInv();
94  
# Line 93 | Line 99 | void SimInfo::setBoxM( double theBox[3][3] ){
99      }
100    }
101  
102 <  setFortranBoxSize(FortranHmat, FortranHmatI, &orthoRhombic);
102 >  setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic);
103  
98  smallestBoxL = boxLx;
99  if (boxLy < smallestBoxL) smallestBoxL = boxLy;
100  if (boxLz < smallestBoxL) smallestBoxL = boxLz;
101
102  maxCutoff = smallestBoxL / 2.0;
103
104  if (rList > maxCutoff) {
105    sprintf( painCave.errMsg,
106             "New Box size is forcing neighborlist radius down to %lf\n",
107             maxCutoff );
108    painCave.isFatal = 0;
109    simError();
110
111    rList = maxCutoff;
112
113    sprintf( painCave.errMsg,
114             "New Box size is forcing cutoff radius down to %lf\n",
115             maxCutoff - 1.0 );
116    painCave.isFatal = 0;
117    simError();
118
119    rCut = rList - 1.0;
120
121    // list radius changed so we have to refresh the simulation structure.
122    refreshSim();
123  }
124
125  if (rCut > maxCutoff) {
126    sprintf( painCave.errMsg,
127             "New Box size is forcing cutoff radius down to %lf\n",
128             maxCutoff );
129    painCave.isFatal = 0;
130    simError();
131
132    status = 0;
133    LJ_new_rcut(&rCut, &status);
134    if (status != 0) {
135      sprintf( painCave.errMsg,
136               "Error in recomputing LJ shifts based on new rcut\n");
137      painCave.isFatal = 1;
138      simError();
139    }
140  }
104   }
105  
106  
# Line 153 | Line 116 | void SimInfo::scaleBox(double scale) {
116    double theBox[3][3];
117    int i, j;
118  
119 <  cerr << "Scaling box by " << scale << "\n";
119 >  // cerr << "Scaling box by " << scale << "\n";
120  
121    for(i=0; i<3; i++)
122      for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale;
# Line 163 | Line 126 | void SimInfo::calcHmatInv( void ) {
126   }
127  
128   void SimInfo::calcHmatInv( void ) {
129 <
129 >  
130 >  int i,j;
131    double smallDiag;
132    double tol;
133    double sanity[3][3];
# Line 173 | Line 137 | void SimInfo::calcHmatInv( void ) {
137    // Check the inverse to make sure it is sane:
138  
139    matMul3( Hmat, HmatInv, sanity );
176
177  cerr << "sanity => \n"
178       << sanity[0][0] << "\t" << sanity[0][1] << "\t" << sanity [0][2] << "\n"
179       << sanity[1][0] << "\t" << sanity[1][1] << "\t" << sanity [1][2] << "\n"
180       << sanity[2][0] << "\t" << sanity[2][1] << "\t" << sanity [2][2]
181       << "\n";
140      
141    // check to see if Hmat is orthorhombic
142    
# Line 271 | Line 229 | void SimInfo::matVecMul3(double m[3][3], double inVec[
229    outVec[1] = m[1][0]*a0 + m[1][1]*a1 + m[1][2]*a2;
230    outVec[2] = m[2][0]*a0 + m[2][1]*a1 + m[2][2]*a2;
231   }
232 +
233 + void SimInfo::transposeMat3(double in[3][3], double out[3][3]) {
234 +  double temp[3][3];
235 +  int i, j;
236 +
237 +  for (i = 0; i < 3; i++) {
238 +    for (j = 0; j < 3; j++) {
239 +      temp[j][i] = in[i][j];
240 +    }
241 +  }
242 +  for (i = 0; i < 3; i++) {
243 +    for (j = 0; j < 3; j++) {
244 +      out[i][j] = temp[i][j];
245 +    }
246 +  }
247 + }
248    
249 + void SimInfo::printMat3(double A[3][3] ){
250 +
251 +  std::cerr
252 +            << "[ " << A[0][0] << ", " << A[0][1] << ", " << A[0][2] << " ]\n"
253 +            << "[ " << A[1][0] << ", " << A[1][1] << ", " << A[1][2] << " ]\n"
254 +            << "[ " << A[2][0] << ", " << A[2][1] << ", " << A[2][2] << " ]\n";
255 + }
256 +
257 + void SimInfo::printMat9(double A[9] ){
258 +
259 +  std::cerr
260 +            << "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n"
261 +            << "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n"
262 +            << "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n";
263 + }
264 +
265   void SimInfo::calcBoxL( void ){
266  
267    double dx, dy, dz, dsq;
# Line 285 | Line 275 | void SimInfo::calcBoxL( void ){
275    
276    dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0];
277    dsq = dx*dx + dy*dy + dz*dz;
278 <  boxLx = sqrt( dsq );
278 >  boxL[0] = sqrt( dsq );
279 >  maxCutoff = 0.5 * boxL[0];
280  
281    // boxLy
282    
283    dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1];
284    dsq = dx*dx + dy*dy + dz*dz;
285 <  boxLy = sqrt( dsq );
285 >  boxL[1] = sqrt( dsq );
286 >  if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1];
287  
288    // boxLz
289    
290    dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2];
291    dsq = dx*dx + dy*dy + dz*dz;
292 <  boxLz = sqrt( dsq );
293 <  
292 >  boxL[2] = sqrt( dsq );
293 >  if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2];
294 >
295   }
296  
297  
# Line 378 | Line 371 | void SimInfo::refreshSim(){
371    int isError;
372    int n_global;
373    int* excl;
374 <  
382 <  fInfo.rrf = 0.0;
383 <  fInfo.rt = 0.0;
374 >
375    fInfo.dielect = 0.0;
376  
386  fInfo.rlist = rList;
387  fInfo.rcut = rCut;
388
377    if( useDipole ){
390    fInfo.rrf = ecr;
391    fInfo.rt = ecr - est;
378      if( useReactionField )fInfo.dielect = dielectric;
379    }
380  
# Line 437 | Line 423 | void SimInfo::refreshSim(){
423  
424   }
425  
426 +
427 + void SimInfo::setRcut( double theRcut ){
428 +
429 +  if( !haveOrigRcut ){
430 +    haveOrigRcut = 1;
431 +    origRcut = theRcut;
432 +  }
433 +
434 +  rCut = theRcut;
435 +  checkCutOffs();
436 + }
437 +
438 + void SimInfo::setEcr( double theEcr ){
439 +
440 +  if( !haveOrigEcr ){
441 +    haveOrigEcr = 1;
442 +    origEcr = theEcr;
443 +  }
444 +
445 +  ecr = theEcr;
446 +  checkCutOffs();
447 + }
448 +
449 + void SimInfo::setEcr( double theEcr, double theEst ){
450 +
451 +  est = theEst;
452 +  setEcr( theEcr );
453 + }
454 +
455 +
456 + void SimInfo::checkCutOffs( void ){
457 +
458 +  int cutChanged = 0;
459 +
460 +  if( boxIsInit ){
461 +    
462 +    //we need to check cutOffs against the box
463 +    
464 +    if( maxCutoff > rCut ){
465 +      if( rCut < origRcut ){
466 +        rCut = origRcut;
467 +        if (rCut > maxCutoff) rCut = maxCutoff;
468 +        
469 +        sprintf( painCave.errMsg,
470 +                 "New Box size is setting the long range cutoff radius "
471 +                 "to %lf\n",
472 +                 rCut );
473 +        painCave.isFatal = 0;
474 +        simError();
475 +      }
476 +    }
477 +
478 +    if( maxCutoff > ecr ){
479 +      if( ecr < origEcr ){
480 +        rCut = origEcr;
481 +        if (ecr > maxCutoff) ecr = maxCutoff;
482 +        
483 +        sprintf( painCave.errMsg,
484 +                 "New Box size is setting the electrostaticCutoffRadius "
485 +                 "to %lf\n",
486 +                 ecr );
487 +        painCave.isFatal = 0;
488 +        simError();
489 +      }
490 +    }
491 +
492 +
493 +    if (rCut > maxCutoff) {
494 +      sprintf( painCave.errMsg,
495 +               "New Box size is setting the long range cutoff radius "
496 +               "to %lf\n",
497 +               maxCutoff );
498 +      painCave.isFatal = 0;
499 +      simError();
500 +      rCut = maxCutoff;
501 +    }
502 +
503 +    if( ecr > maxCutoff){
504 +      sprintf( painCave.errMsg,
505 +               "New Box size is setting the electrostaticCutoffRadius "
506 +               "to %lf\n",
507 +               maxCutoff  );
508 +      painCave.isFatal = 0;
509 +      simError();      
510 +      ecr = maxCutoff;
511 +    }
512 +
513 +    
514 +  }
515 +  
516 +
517 +  if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1;
518 +
519 +  // rlist is the 1.0 plus max( rcut, ecr )
520 +  
521 +  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
522 +
523 +  if( cutChanged ){
524 +    
525 +    notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
526 +  }
527 +
528 +  oldEcr = ecr;
529 +  oldRcut = rCut;
530 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines