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 618 by mmeineke, Tue Jul 15 21:34:56 2003 UTC vs.
Revision 626 by mmeineke, Wed Jul 16 21:30:56 2003 UTC

# Line 35 | Line 35 | SimInfo::SimInfo(){
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 74 | 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    
81  //  cerr
82  // << "setting Hmat ->\n"
83  // << "[ " << Hmat[0][0] << ", " << Hmat[0][1] << ", " << Hmat[0][2] << " ]\n"
84  // << "[ " << Hmat[1][0] << ", " << Hmat[1][1] << ", " << Hmat[1][2] << " ]\n"
85  // << "[ " << Hmat[2][0] << ", " << Hmat[2][1] << ", " << Hmat[2][2] << " ]\n";
86
92    calcBoxL();
93    calcHmatInv();
94  
# Line 96 | Line 101 | void SimInfo::setBoxM( double theBox[3][3] ){
101  
102    setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic);
103  
99  smallestBoxL = boxLx;
100  if (boxLy < smallestBoxL) smallestBoxL = boxLy;
101  if (boxLz < smallestBoxL) smallestBoxL = boxLz;
102
103  maxCutoff = smallestBoxL / 2.0;
104
105  if (rList > maxCutoff) {
106    sprintf( painCave.errMsg,
107             "New Box size is forcing neighborlist radius down to %lf\n",
108             maxCutoff );
109    painCave.isFatal = 0;
110    simError();
111
112    rList = maxCutoff;
113
114    sprintf( painCave.errMsg,
115             "New Box size is forcing cutoff radius down to %lf\n",
116             maxCutoff - 1.0 );
117    painCave.isFatal = 0;
118    simError();
119
120    rCut = rList - 1.0;
121
122    // list radius changed so we have to refresh the simulation structure.
123    refreshSim();
124  }
125
126  if( ecr > maxCutoff ){
127
128    sprintf( painCave.errMsg,
129             "New Box size is forcing electrostatic cutoff radius "
130             "down to %lf\n",
131             maxCutoff );
132    painCave.isFatal = 0;
133    simError();
134
135    ecr = maxCutoff;
136    est = 0.05 * ecr;
137
138    refreshSim();
139  }
140    
104   }
105  
106  
# Line 312 | 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 405 | Line 371 | void SimInfo::refreshSim(){
371    int isError;
372    int n_global;
373    int* excl;
374 <  
409 <  fInfo.rrf = 0.0;
410 <  fInfo.rt = 0.0;
374 >
375    fInfo.dielect = 0.0;
376  
413  fInfo.rlist = rList;
414  fInfo.rcut = rCut;
415
377    if( useDipole ){
417    fInfo.rrf = ecr;
418    fInfo.rt = ecr - est;
378      if( useReactionField )fInfo.dielect = dielectric;
379    }
380  
# Line 461 | Line 420 | void SimInfo::refreshSim(){
420  
421    this->ndf = this->getNDF();
422    this->ndfRaw = this->getNDFraw();
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