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 674 by mmeineke, Mon Aug 11 18:29:46 2003 UTC

# Line 30 | Line 30 | SimInfo::SimInfo(){
30    n_dipoles = 0;
31    ndf = 0;
32    ndfRaw = 0;
33 +  nZconstraints = 0;
34    the_integrator = NULL;
35    setTemp = 0;
36    thermalTime = 0.0;
37 +  currentTime = 0.0;
38    rCut = 0.0;
39    ecr = 0.0;
40    est = 0.0;
41 +  oldEcr = 0.0;
42 +  oldRcut = 0.0;
43  
44 +  haveOrigRcut = 0;
45 +  haveOrigEcr = 0;
46 +  boxIsInit = 0;
47 +  
48 +  
49 +
50    usePBC = 0;
51    useLJ = 0;
52    useSticky = 0;
# Line 45 | Line 55 | SimInfo::SimInfo(){
55    useGB = 0;
56    useEAM = 0;
57  
58 +  myConfiguration = new SimState();
59 +
60    wrapMeSimInfo( this );
61   }
62  
63 +
64 + SimInfo::~SimInfo(){
65 +
66 +  delete myConfiguration;
67 +
68 +  map<string, GenericData*>::iterator i;
69 +  
70 +  for(i = properties.begin(); i != properties.end(); i++)
71 +    delete (*i).second;
72 +    
73 + }
74 +
75   void SimInfo::setBox(double newBox[3]) {
76    
77    int i, j;
# Line 75 | Line 99 | void SimInfo::setBoxM( double theBox[3][3] ){
99                           // [ 2 5 8 ]
100    double FortranHmatInv[9]; // the inverted Hmat (for Fortran);
101  
102 +  
103 +  if( !boxIsInit ) boxIsInit = 1;
104  
105    for(i=0; i < 3; i++)
106      for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j];
107    
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
108    calcBoxL();
109    calcHmatInv();
110  
# Line 97 | Line 117 | void SimInfo::setBoxM( double theBox[3][3] ){
117  
118    setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic);
119  
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  }    
120   }
121  
122  
# Line 310 | Line 292 | void SimInfo::calcBoxL( void ){
292    dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0];
293    dsq = dx*dx + dy*dy + dz*dz;
294    boxL[0] = sqrt( dsq );
295 +  maxCutoff = 0.5 * boxL[0];
296  
297    // boxLy
298    
299    dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1];
300    dsq = dx*dx + dy*dy + dz*dz;
301    boxL[1] = sqrt( dsq );
302 +  if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1];
303  
304    // boxLz
305    
306    dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2];
307    dsq = dx*dx + dy*dy + dz*dz;
308    boxL[2] = sqrt( dsq );
309 +  if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2];
310    
311 +  checkCutOffs();
312 +
313   }
314  
315  
# Line 376 | Line 363 | int SimInfo::getNDF(){
363    ndf = ndf_local;
364   #endif
365  
366 <  ndf = ndf - 3;
366 >  ndf = ndf - 3 - nZconstraints;
367  
368    return ndf;
369   }
# Line 402 | Line 389 | void SimInfo::refreshSim(){
389    int isError;
390    int n_global;
391    int* excl;
392 <  
406 <  fInfo.rrf = 0.0;
407 <  fInfo.rt = 0.0;
392 >
393    fInfo.dielect = 0.0;
394  
410  fInfo.rlist = rList;
411  fInfo.rcut = rCut;
412
395    if( useDipole ){
414    fInfo.rrf = ecr;
415    fInfo.rt = ecr - est;
396      if( useReactionField )fInfo.dielect = dielectric;
397    }
398  
# Line 458 | Line 438 | void SimInfo::refreshSim(){
438  
439    this->ndf = this->getNDF();
440    this->ndfRaw = this->getNDFraw();
441 +
442 + }
443 +
444 +
445 + void SimInfo::setRcut( double theRcut ){
446 +
447 +  if( !haveOrigRcut ){
448 +    haveOrigRcut = 1;
449 +    origRcut = theRcut;
450 +  }
451 +
452 +  rCut = theRcut;
453 +  checkCutOffs();
454 + }
455 +
456 + void SimInfo::setEcr( double theEcr ){
457 +
458 +  if( !haveOrigEcr ){
459 +    haveOrigEcr = 1;
460 +    origEcr = theEcr;
461 +  }
462 +
463 +  ecr = theEcr;
464 +  checkCutOffs();
465 + }
466 +
467 + void SimInfo::setEcr( double theEcr, double theEst ){
468 +
469 +  est = theEst;
470 +  setEcr( theEcr );
471 + }
472 +
473 +
474 + void SimInfo::checkCutOffs( void ){
475 +
476 +  int cutChanged = 0;
477  
478 +
479 +
480 +  if( boxIsInit ){
481 +    
482 +    //we need to check cutOffs against the box
483 +  
484 +    if(( maxCutoff > rCut )&&(usePBC)){
485 +      if( rCut < origRcut ){
486 +        rCut = origRcut;
487 +        if (rCut > maxCutoff) rCut = maxCutoff;
488 +        
489 +        sprintf( painCave.errMsg,
490 +                 "New Box size is setting the long range cutoff radius "
491 +                 "to %lf\n",
492 +                 rCut );
493 +        painCave.isFatal = 0;
494 +        simError();
495 +      }
496 +    }
497 +
498 +    if( maxCutoff > ecr ){
499 +      if( ecr < origEcr ){
500 +        rCut = origEcr;
501 +        if (ecr > maxCutoff) ecr = maxCutoff;
502 +        
503 +        sprintf( painCave.errMsg,
504 +                 "New Box size is setting the electrostaticCutoffRadius "
505 +                 "to %lf\n",
506 +                 ecr );
507 +        painCave.isFatal = 0;
508 +        simError();
509 +      }
510 +    }
511 +
512 +
513 +    if ((rCut > maxCutoff)&&(usePBC)) {
514 +      sprintf( painCave.errMsg,
515 +               "New Box size is setting the long range cutoff radius "
516 +               "to %lf\n",
517 +               maxCutoff );
518 +      painCave.isFatal = 0;
519 +      simError();
520 +      rCut = maxCutoff;
521 +    }
522 +
523 +    if( ecr > maxCutoff){
524 +      sprintf( painCave.errMsg,
525 +               "New Box size is setting the electrostaticCutoffRadius "
526 +               "to %lf\n",
527 +               maxCutoff  );
528 +      painCave.isFatal = 0;
529 +      simError();      
530 +      ecr = maxCutoff;
531 +    }
532 +
533 +    
534 +  }
535 +  
536 +
537 +  if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1;
538 +
539 +  // rlist is the 1.0 plus max( rcut, ecr )
540 +  
541 +  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
542 +
543 +  if( cutChanged ){
544 +    
545 +    notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
546 +  }
547 +
548 +  oldEcr = ecr;
549 +  oldRcut = rCut;
550   }
551  
552 + void SimInfo::addProperty(GenericData* prop){
553 +
554 +  map<string, GenericData*>::iterator result;
555 +  result = properties.find(prop->getID());
556 +  
557 +  //we can't simply use  properties[prop->getID()] = prop,
558 +  //it will cause memory leak if we already contain a propery which has the same name of prop
559 +  
560 +  if(result != properties.end()){
561 +    
562 +    delete (*result).second;
563 +    (*result).second = prop;
564 +      
565 +  }
566 +  else{
567 +
568 +    properties[prop->getID()] = prop;
569 +
570 +  }
571 +    
572 + }
573 +
574 + GenericData* SimInfo::getProperty(const string& propName){
575 +
576 +  map<string, GenericData*>::iterator result;
577 +  
578 +  //string lowerCaseName = ();
579 +  
580 +  result = properties.find(propName);
581 +  
582 +  if(result != properties.end())
583 +    return (*result).second;  
584 +  else  
585 +    return NULL;  
586 + }
587 +
588 + vector<GenericData*> SimInfo::getProperties(){
589 +
590 +  vector<GenericData*> result;
591 +  map<string, GenericData*>::iterator i;
592 +  
593 +  for(i = properties.begin(); i != properties.end(); i++)
594 +    result.push_back((*i).second);
595 +    
596 +  return result;
597 + }
598 +
599 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines