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 1097 by gezelter, Mon Apr 12 20:32:20 2004 UTC vs.
Revision 1218 by gezelter, Wed Jun 2 14:21:54 2004 UTC

# Line 42 | Line 42 | SimInfo::SimInfo(){
42    thermalTime = 0.0;
43    currentTime = 0.0;
44    rCut = 0.0;
45 <  ecr = 0.0;
46 <  est = 0.0;
45 >  rSw = 0.0;
46  
47    haveRcut = 0;
48 <  haveEcr = 0;
48 >  haveRsw = 0;
49    boxIsInit = 0;
50    
51    resetTime = 1e99;
# Line 63 | Line 62 | SimInfo::SimInfo(){
62    useReactionField = 0;
63    useGB = 0;
64    useEAM = 0;
65 +  useSolidThermInt = 0;
66 +  useLiquidThermInt = 0;
67  
68 +  haveCutoffGroups = false;
69 +
70    excludes = Exclude::Instance();
71  
72    myConfiguration = new SimState();
# Line 71 | Line 74 | SimInfo::SimInfo(){
74    has_minimizer = false;
75    the_minimizer =NULL;
76  
77 +  ngroup = 0;
78 +
79    wrapMeSimInfo( this );
80   }
81  
# Line 83 | Line 88 | SimInfo::~SimInfo(){
88    
89    for(i = properties.begin(); i != properties.end(); i++)
90      delete (*i).second;
91 <    
91 >  
92   }
93  
94   void SimInfo::setBox(double newBox[3]) {
# Line 186 | Line 191 | void SimInfo::calcHmatInv( void ) {
191  
192    if( oldOrtho != orthoRhombic ){
193      
194 <    if( orthoRhombic ){
194 >    if( orthoRhombic ) {
195        sprintf( painCave.errMsg,
196 <               "OOPSE is switching from the default Non-Orthorhombic\n"
196 >               "\n\tOOPSE is switching from the default Non-Orthorhombic\n"
197                 "\tto the faster Orthorhombic periodic boundary computations.\n"
198                 "\tThis is usually a good thing, but if you wan't the\n"
199                 "\tNon-Orthorhombic computations, make the orthoBoxTolerance\n"
200                 "\tvariable ( currently set to %G ) smaller.\n",
201                 orthoTolerance);
202 +      painCave.severity = OOPSE_INFO;
203        simError();
204      }
205      else {
206        sprintf( painCave.errMsg,
207 <               "OOPSE is switching from the faster Orthorhombic to the more\n"
207 >               "\n\tOOPSE is switching from the faster Orthorhombic to the more\n"
208                 "\tflexible Non-Orthorhombic periodic boundary computations.\n"
209                 "\tThis is usually because the box has deformed under\n"
210                 "\tNPTf integration. If you wan't to live on the edge with\n"
211                 "\tthe Orthorhombic computations, make the orthoBoxTolerance\n"
212                 "\tvariable ( currently set to %G ) larger.\n",
213                 orthoTolerance);
214 +      painCave.severity = OOPSE_WARNING;
215        simError();
216      }
217    }
# Line 322 | Line 329 | int SimInfo::getNDF(){
329   int SimInfo::getNDF(){
330    int ndf_local;
331  
332 +  ndf_local = 0;
333 +  
334    for(int i = 0; i < integrableObjects.size(); i++){
335      ndf_local += 3;
336 <    if (integrableObjects[i]->isDirectional())
337 <      ndf_local += 3;
336 >    if (integrableObjects[i]->isDirectional()) {
337 >      if (integrableObjects[i]->isLinear())
338 >        ndf_local += 2;
339 >      else
340 >        ndf_local += 3;
341 >    }
342    }
343  
344    // n_constraints is local, so subtract them on each processor:
# Line 350 | Line 363 | int SimInfo::getNDFraw() {
363    int ndfRaw_local;
364  
365    // Raw degrees of freedom that we have to set
366 +  ndfRaw_local = 0;
367  
368    for(int i = 0; i < integrableObjects.size(); i++){
369      ndfRaw_local += 3;
370 <    if (integrableObjects[i]->isDirectional())
371 <      ndfRaw_local += 3;
370 >    if (integrableObjects[i]->isDirectional()) {
371 >       if (integrableObjects[i]->isLinear())
372 >        ndfRaw_local += 2;
373 >      else
374 >        ndfRaw_local += 3;
375 >    }
376    }
377      
378   #ifdef IS_MPI
# Line 383 | Line 401 | int SimInfo::getNDFtranslational() {
401    return ndfTrans;
402   }
403  
404 + int SimInfo::getTotIntegrableObjects() {
405 +  int nObjs_local;
406 +  int nObjs;
407 +
408 +  nObjs_local =  integrableObjects.size();
409 +
410 +
411 + #ifdef IS_MPI
412 +  MPI_Allreduce(&nObjs_local,&nObjs,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
413 + #else
414 +  nObjs = nObjs_local;
415 + #endif
416 +
417 +
418 +  return nObjs;
419 + }
420 +
421   void SimInfo::refreshSim(){
422  
423    simtype fInfo;
# Line 411 | Line 446 | void SimInfo::refreshSim(){
446  
447    n_exclude = excludes->getSize();
448    excl = excludes->getFortranArray();
449 <
449 >  
450   #ifdef IS_MPI
451 <  n_global = mpiSim->getTotAtoms();
451 >  n_global = mpiSim->getNAtomsGlobal();
452   #else
453    n_global = n_atoms;
454   #endif
455 <
455 >  
456    isError = 0;
457 <
457 >  
458 >  getFortranGroupArrays(this, FglobalGroupMembership, mfact);
459 >  //it may not be a good idea to pass the address of first element in vector
460 >  //since c++ standard does not require vector to be stored continuously in meomory
461 >  //Most of the compilers will organize the memory of vector continuously
462    setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl,
463 <                  &nGlobalExcludes, globalExcludes, molMembershipArray,
464 <                  &isError );
463 >                  &nGlobalExcludes, globalExcludes, molMembershipArray,
464 >                  &mfact[0], &ngroup, &FglobalGroupMembership[0], &isError);
465  
466    if( isError ){
467 <
467 >    
468      sprintf( painCave.errMsg,
469 <             "There was an error setting the simulation information in fortran.\n" );
469 >             "There was an error setting the simulation information in fortran.\n" );
470      painCave.isFatal = 1;
471      simError();
472    }
473 <
473 >  
474   #ifdef IS_MPI
475    sprintf( checkPointMsg,
476             "succesfully sent the simulation information to fortran.\n");
477    MPIcheckPoint();
478   #endif // is_mpi
479 <
479 >  
480    this->ndf = this->getNDF();
481    this->ndfRaw = this->getNDFraw();
482    this->ndfTrans = this->getNDFtranslational();
483   }
484  
485   void SimInfo::setDefaultRcut( double theRcut ){
486 <
486 >  
487    haveRcut = 1;
488    rCut = theRcut;
489 <
451 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
452 <
453 <  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
454 < }
455 <
456 < void SimInfo::setDefaultEcr( double theEcr ){
457 <
458 <  haveEcr = 1;
459 <  ecr = theEcr;
489 >  rList = rCut + 1.0;
490    
491 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
462 <
463 <  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
491 >  notifyFortranCutOffs( &rCut, &rSw, &rList );
492   }
493  
494 < void SimInfo::setDefaultEcr( double theEcr, double theEst ){
494 > void SimInfo::setDefaultRcut( double theRcut, double theRsw ){
495  
496 <  est = theEst;
497 <  setDefaultEcr( theEcr );
496 >  rSw = theRsw;
497 >  setDefaultRcut( theRcut );
498   }
499  
500  
# Line 478 | Line 506 | void SimInfo::checkCutOffs( void ){
506      
507      if( rCut > maxCutoff ){
508        sprintf( painCave.errMsg,
509 <               "LJrcut is too large for the current periodic box.\n"
510 <               "\tCurrent Value of LJrcut = %G at time %G\n "
509 >               "\n\tcutoffRadius is too large for the current periodic box.\n"
510 >               "\tCurrent Value of cutoffRadius = %G at time %G\n "
511                 "\tThis is larger than half of at least one of the\n"
512                 "\tperiodic box vectors.  Right now, the Box matrix is:\n"
513 <               "\n, %G"
513 >               "\n"
514                 "\t[ %G %G %G ]\n"
515                 "\t[ %G %G %G ]\n"
516                 "\t[ %G %G %G ]\n",
517 <               rCut, currentTime, maxCutoff,
517 >               rCut, currentTime,
518                 Hmat[0][0], Hmat[0][1], Hmat[0][2],
519                 Hmat[1][0], Hmat[1][1], Hmat[1][2],
520                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
521 +      painCave.severity = OOPSE_ERROR;
522        painCave.isFatal = 1;
523        simError();
524 <    }
496 <    
497 <    if( haveEcr ){
498 <      if( ecr > maxCutoff ){
499 <        sprintf( painCave.errMsg,
500 <                 "electrostaticCutoffRadius is too large for the current\n"
501 <                 "\tperiodic box.\n\n"
502 <                 "\tCurrent Value of ECR = %G at time %G\n "
503 <                 "\tThis is larger than half of at least one of the\n"
504 <                 "\tperiodic box vectors.  Right now, the Box matrix is:\n"
505 <                 "\n"
506 <                 "\t[ %G %G %G ]\n"
507 <                 "\t[ %G %G %G ]\n"
508 <                 "\t[ %G %G %G ]\n",
509 <                 ecr, currentTime,
510 <                 Hmat[0][0], Hmat[0][1], Hmat[0][2],
511 <                 Hmat[1][0], Hmat[1][1], Hmat[1][2],
512 <                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
513 <        painCave.isFatal = 1;
514 <        simError();
515 <      }
516 <    }
524 >    }    
525    } else {
526      // initialize this stuff before using it, OK?
527      sprintf( painCave.errMsg,
528 <             "Trying to check cutoffs without a box.\n"
528 >             "\n\tTrying to check cutoffs without a box.\n"
529               "\tOOPSE should have better programmers than that.\n" );
530 +    painCave.severity = OOPSE_ERROR;
531      painCave.isFatal = 1;
532      simError();      
533    }
# Line 561 | Line 570 | GenericData* SimInfo::getProperty(const string& propNa
570      return NULL;  
571   }
572  
564 vector<GenericData*> SimInfo::getProperties(){
573  
574 <  vector<GenericData*> result;
575 <  map<string, GenericData*>::iterator i;
574 > void SimInfo::getFortranGroupArrays(SimInfo* info,
575 >                                    vector<int>& FglobalGroupMembership,
576 >                                    vector<double>& mfact){
577    
578 <  for(i = properties.begin(); i != properties.end(); i++)
579 <    result.push_back((*i).second);
580 <    
581 <  return result;
578 >  Molecule* myMols;
579 >  Atom** myAtoms;
580 >  int numAtom;
581 >  double mtot;
582 >  int numMol;
583 >  int numCutoffGroups;
584 >  CutoffGroup* myCutoffGroup;
585 >  vector<CutoffGroup*>::iterator iterCutoff;
586 >  Atom* cutoffAtom;
587 >  vector<Atom*>::iterator iterAtom;
588 >  int atomIndex;
589 >  double totalMass;
590 >  
591 >  mfact.clear();
592 >  FglobalGroupMembership.clear();
593 >  
594 >
595 >  // Fix the silly fortran indexing problem
596 > #ifdef IS_MPI
597 >  numAtom = mpiSim->getNAtomsGlobal();
598 > #else
599 >  numAtom = n_atoms;
600 > #endif
601 >  for (int i = 0; i < numAtom; i++)
602 >    FglobalGroupMembership.push_back(globalGroupMembership[i] + 1);
603 >  
604 >
605 >  myMols = info->molecules;
606 >  numMol = info->n_mol;
607 >  for(int i  = 0; i < numMol; i++){
608 >    numCutoffGroups = myMols[i].getNCutoffGroups();
609 >    for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff);
610 >        myCutoffGroup != NULL;
611 >        myCutoffGroup =myMols[i].nextCutoffGroup(iterCutoff)){
612 >
613 >      totalMass = myCutoffGroup->getMass();
614 >      
615 >      for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom);
616 >          cutoffAtom != NULL;
617 >          cutoffAtom = myCutoffGroup->nextAtom(iterAtom)){
618 >        mfact.push_back(cutoffAtom->getMass()/totalMass);
619 >      }  
620 >    }
621 >  }
622 >
623   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines