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 621 by gezelter, Wed Jul 16 02:11:02 2003 UTC vs.
Revision 642 by mmeineke, Mon Jul 21 16:23:57 2003 UTC

# Line 33 | Line 33 | SimInfo::SimInfo(){
33    the_integrator = NULL;
34    setTemp = 0;
35    thermalTime = 0.0;
36 +  currentTime = 0.0;
37    rCut = 0.0;
38    ecr = 0.0;
39    est = 0.0;
40 +  oldEcr = 0.0;
41 +  oldRcut = 0.0;
42  
43 +  haveOrigRcut = 0;
44 +  haveOrigEcr = 0;
45 +  boxIsInit = 0;
46 +  
47 +  
48 +
49    usePBC = 0;
50    useLJ = 0;
51    useSticky = 0;
# Line 75 | Line 84 | void SimInfo::setBoxM( double theBox[3][3] ){
84                           // [ 2 5 8 ]
85    double FortranHmatInv[9]; // the inverted Hmat (for Fortran);
86  
87 +  
88 +  if( !boxIsInit ) boxIsInit = 1;
89  
90    for(i=0; i < 3; i++)
91      for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j];
92    
82  //  cerr
83  // << "setting Hmat ->\n"
84  // << "[ " << Hmat[0][0] << ", " << Hmat[0][1] << ", " << Hmat[0][2] << " ]\n"
85  // << "[ " << Hmat[1][0] << ", " << Hmat[1][1] << ", " << Hmat[1][2] << " ]\n"
86  // << "[ " << Hmat[2][0] << ", " << Hmat[2][1] << ", " << Hmat[2][2] << " ]\n";
87
93    calcBoxL();
94    calcHmatInv();
95  
# Line 97 | Line 102 | void SimInfo::setBoxM( double theBox[3][3] ){
102  
103    setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic);
104  
100  smallestBoxL = boxL[0];
101  if (boxL[1] < smallestBoxL) smallestBoxL = boxL[1];
102  if (boxL[2] > smallestBoxL) smallestBoxL = boxL[2];
103
104  maxCutoff = smallestBoxL / 2.0;
105
106  if (rList > maxCutoff) {
107    sprintf( painCave.errMsg,
108             "New Box size is forcing neighborlist radius down to %lf\n",
109             maxCutoff );
110    painCave.isFatal = 0;
111    simError();
112    rList = maxCutoff;
113
114    if (rCut > (rList - 1.0)) {
115      sprintf( painCave.errMsg,
116               "New Box size is forcing LJ cutoff radius down to %lf\n",
117               rList - 1.0 );
118      painCave.isFatal = 0;
119      simError();
120      rCut = rList - 1.0;
121    }
122
123    if( ecr > (rList - 1.0) ){
124      sprintf( painCave.errMsg,
125               "New Box size is forcing electrostaticCutoffRadius "
126               "down to %lf\n"
127               "electrostaticSkinThickness is now %lf\n",
128               rList - 1.0, 0.05*(rList-1.0) );
129      painCave.isFatal = 0;
130      simError();      
131      ecr = maxCutoff;
132      est = 0.05 * ecr;
133    }
134
135    // At least one of the radii changed, so we need a refresh:
136    refreshSim();
137  }    
105   }
106  
107  
# Line 310 | Line 277 | void SimInfo::calcBoxL( void ){
277    dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0];
278    dsq = dx*dx + dy*dy + dz*dz;
279    boxL[0] = sqrt( dsq );
280 +  maxCutoff = 0.5 * boxL[0];
281  
282    // boxLy
283    
284    dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1];
285    dsq = dx*dx + dy*dy + dz*dz;
286    boxL[1] = sqrt( dsq );
287 +  if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1];
288  
289    // boxLz
290    
291    dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2];
292    dsq = dx*dx + dy*dy + dz*dz;
293    boxL[2] = sqrt( dsq );
294 <  
294 >  if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2];
295 >
296   }
297  
298  
# Line 402 | Line 372 | void SimInfo::refreshSim(){
372    int isError;
373    int n_global;
374    int* excl;
405  
406  fInfo.rrf = 0.0;
407  fInfo.rt = 0.0;
408  fInfo.dielect = 0.0;
375  
376 <  fInfo.rlist = rList;
411 <  fInfo.rcut = rCut;
376 >  fInfo.dielect = 0.0;
377  
378    if( useDipole ){
414    fInfo.rrf = ecr;
415    fInfo.rt = ecr - est;
379      if( useReactionField )fInfo.dielect = dielectric;
380    }
381  
# Line 458 | Line 421 | void SimInfo::refreshSim(){
421  
422    this->ndf = this->getNDF();
423    this->ndfRaw = this->getNDFraw();
424 +
425 + }
426 +
427 +
428 + void SimInfo::setRcut( double theRcut ){
429 +
430 +  if( !haveOrigRcut ){
431 +    haveOrigRcut = 1;
432 +    origRcut = theRcut;
433 +  }
434 +
435 +  rCut = theRcut;
436 +  checkCutOffs();
437 + }
438 +
439 + void SimInfo::setEcr( double theEcr ){
440 +
441 +  if( !haveOrigEcr ){
442 +    haveOrigEcr = 1;
443 +    origEcr = theEcr;
444 +  }
445  
446 +  ecr = theEcr;
447 +  checkCutOffs();
448   }
449  
450 + void SimInfo::setEcr( double theEcr, double theEst ){
451 +
452 +  est = theEst;
453 +  setEcr( theEcr );
454 + }
455 +
456 +
457 + void SimInfo::checkCutOffs( void ){
458 +
459 +  int cutChanged = 0;
460 +
461 +  if( boxIsInit ){
462 +    
463 +    //we need to check cutOffs against the box
464 +    
465 +    if( maxCutoff > rCut ){
466 +      if( rCut < origRcut ){
467 +        rCut = origRcut;
468 +        if (rCut > maxCutoff) rCut = maxCutoff;
469 +        
470 +        sprintf( painCave.errMsg,
471 +                 "New Box size is setting the long range cutoff radius "
472 +                 "to %lf\n",
473 +                 rCut );
474 +        painCave.isFatal = 0;
475 +        simError();
476 +      }
477 +    }
478 +
479 +    if( maxCutoff > ecr ){
480 +      if( ecr < origEcr ){
481 +        rCut = origEcr;
482 +        if (ecr > maxCutoff) ecr = maxCutoff;
483 +        
484 +        sprintf( painCave.errMsg,
485 +                 "New Box size is setting the electrostaticCutoffRadius "
486 +                 "to %lf\n",
487 +                 ecr );
488 +        painCave.isFatal = 0;
489 +        simError();
490 +      }
491 +    }
492 +
493 +
494 +    if (rCut > maxCutoff) {
495 +      sprintf( painCave.errMsg,
496 +               "New Box size is setting the long range cutoff radius "
497 +               "to %lf\n",
498 +               maxCutoff );
499 +      painCave.isFatal = 0;
500 +      simError();
501 +      rCut = maxCutoff;
502 +    }
503 +
504 +    if( ecr > maxCutoff){
505 +      sprintf( painCave.errMsg,
506 +               "New Box size is setting the electrostaticCutoffRadius "
507 +               "to %lf\n",
508 +               maxCutoff  );
509 +      painCave.isFatal = 0;
510 +      simError();      
511 +      ecr = maxCutoff;
512 +    }
513 +
514 +    
515 +  }
516 +  
517 +
518 +  if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1;
519 +
520 +  // rlist is the 1.0 plus max( rcut, ecr )
521 +  
522 +  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
523 +
524 +  if( cutChanged ){
525 +    
526 +    notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
527 +  }
528 +
529 +  oldEcr = ecr;
530 +  oldRcut = rCut;
531 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines