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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines