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 1139 by gezelter, Wed Apr 28 22:06:29 2004 UTC vs.
Revision 1154 by gezelter, Tue May 11 16:00:22 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;
66  useMolecularCutoffs = 0;
65  
66    excludes = Exclude::Instance();
67  
# Line 72 | Line 70 | SimInfo::SimInfo(){
70    has_minimizer = false;
71    the_minimizer =NULL;
72  
73 +  ngroup = 0;
74 +
75    wrapMeSimInfo( this );
76   }
77  
# Line 84 | Line 84 | SimInfo::~SimInfo(){
84    
85    for(i = properties.begin(); i != properties.end(); i++)
86      delete (*i).second;
87 <    
87 >  
88   }
89  
90   void SimInfo::setBox(double newBox[3]) {
# Line 437 | Line 437 | void SimInfo::refreshSim(){
437    //fInfo.SIM_uses_RF = 0;
438    fInfo.SIM_uses_GB = useGB;
439    fInfo.SIM_uses_EAM = useEAM;
440  fInfo.SIM_uses_molecular_cutoffs = useMolecularCutoffs;
440  
441    n_exclude = excludes->getSize();
442    excl = excludes->getFortranArray();
443 <
443 >  
444   #ifdef IS_MPI
445    n_global = mpiSim->getTotAtoms();
446   #else
447    n_global = n_atoms;
448   #endif
449 <
449 >  
450    isError = 0;
451 <
452 <  setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl,
453 <                  &nGlobalExcludes, globalExcludes, molMembershipArray,
454 <                  &isError );
455 <
456 <  if( isError ){
457 <
451 >  
452 >  getFortranGroupArray(this, mfact, ngroup, groupList, groupStart);
453 >  
454 >  setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl,
455 >                  &nGlobalExcludes, globalExcludes, molMembershipArray,
456 >                  &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError);
457 >  
458 >  if( isError ){
459 >    
460      sprintf( painCave.errMsg,
461 <             "There was an error setting the simulation information in fortran.\n" );
461 >             "There was an error setting the simulation information in fortran.\n" );
462      painCave.isFatal = 1;
463      simError();
464    }
465 <
465 >  
466   #ifdef IS_MPI
467    sprintf( checkPointMsg,
468             "succesfully sent the simulation information to fortran.\n");
469    MPIcheckPoint();
470   #endif // is_mpi
471 <
471 >  
472    this->ndf = this->getNDF();
473    this->ndfRaw = this->getNDFraw();
474    this->ndfTrans = this->getNDFtranslational();
475   }
476  
477   void SimInfo::setDefaultRcut( double theRcut ){
478 <
478 >  
479    haveRcut = 1;
480    rCut = theRcut;
481 <
481 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
482 <
483 <  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
484 < }
485 <
486 < void SimInfo::setDefaultEcr( double theEcr ){
487 <
488 <  haveEcr = 1;
489 <  ecr = theEcr;
481 >  rList = rCut + 1.0;
482    
483 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
492 <
493 <  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
483 >  notifyFortranCutOffs( &rCut, &rSw, &rList );
484   }
485  
486 < void SimInfo::setDefaultEcr( double theEcr, double theEst ){
486 > void SimInfo::setDefaultRcut( double theRcut, double theRsw ){
487  
488 <  est = theEst;
489 <  setDefaultEcr( theEcr );
488 >  rSw = theRsw;
489 >  setDefaultRcut( theRcut );
490   }
491  
492  
# Line 508 | Line 498 | void SimInfo::checkCutOffs( void ){
498      
499      if( rCut > maxCutoff ){
500        sprintf( painCave.errMsg,
501 <               "LJrcut is too large for the current periodic box.\n"
502 <               "\tCurrent Value of LJrcut = %G at time %G\n "
501 >               "cutoffRadius is too large for the current periodic box.\n"
502 >               "\tCurrent Value of cutoffRadius = %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"
# Line 522 | Line 512 | void SimInfo::checkCutOffs( void ){
512                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
513        painCave.isFatal = 1;
514        simError();
515 <    }
526 <    
527 <    if( haveEcr ){
528 <      if( ecr > maxCutoff ){
529 <        sprintf( painCave.errMsg,
530 <                 "electrostaticCutoffRadius is too large for the current\n"
531 <                 "\tperiodic box.\n\n"
532 <                 "\tCurrent Value of ECR = %G at time %G\n "
533 <                 "\tThis is larger than half of at least one of the\n"
534 <                 "\tperiodic box vectors.  Right now, the Box matrix is:\n"
535 <                 "\n"
536 <                 "\t[ %G %G %G ]\n"
537 <                 "\t[ %G %G %G ]\n"
538 <                 "\t[ %G %G %G ]\n",
539 <                 ecr, currentTime,
540 <                 Hmat[0][0], Hmat[0][1], Hmat[0][2],
541 <                 Hmat[1][0], Hmat[1][1], Hmat[1][2],
542 <                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
543 <        painCave.isFatal = 1;
544 <        simError();
545 <      }
546 <    }
515 >    }    
516    } else {
517      // initialize this stuff before using it, OK?
518      sprintf( painCave.errMsg,
# Line 591 | Line 560 | GenericData* SimInfo::getProperty(const string& propNa
560      return NULL;  
561   }
562  
563 +
564 + void getFortranGroupArray(SimInfo* info, vector<double>& mfact, int& ngroup,
565 +                          vector<int>& groupList, vector<int>& groupStart){
566 +  Molecule* mol;
567 +  Atom** myAtoms;
568 +  int numAtom;
569 +  int curIndex;
570 +  double mtot;
571 +
572 +  mfact.clear();
573 +  groupList.clear();
574 +  groupStart.clear();
575 +  
576 +  //Be careful, fortran array begin at 1
577 +  curIndex = 1;
578 +  
579 +  if(info->useMolecularCutoffs){
580 +    
581 + #ifdef IS_MPI
582 +    ngroup = mpiSim->getMyNMol();
583 + #else
584 +    ngroup = info->n_mol;
585 + #endif
586 +    
587 +    for(int i = 0; i < ngroup; i ++){
588 +      mol = &(info->molecules[i]);
589 +      numAtom = mol->getNAtoms();
590 +      myAtoms = mol->getMyAtoms();
591 +      mtot = 0.0;
592 +
593 +      for(int j=0; j < numAtom; j++)
594 +        mtot += myAtoms[j]->getMass();                
595 +      
596 +      for(int j=0; j < numAtom; j++){
597 +              
598 +        // We want the local Index:
599 +        groupList.push_back(myAtoms[j]->getIndex() + 1);
600 +        mfact.push_back(myAtoms[j]->getMass() / mtot);
601 +
602 +      }
603 +      
604 +      groupStart.push_back(curIndex);
605 +      curIndex += numAtom;
606 +      
607 +    } //end for(int i =0 ; i < ngroup; i++)    
608 +  }
609 +  else{
610 +    //using atomic cutoff, every single atom is just a group
611 +    
612 + #ifdef IS_MPI
613 +    ngroup = mpiSim->getMyNlocal();
614 + #else
615 +    ngroup = info->n_atoms;
616 + #endif
617 +    
618 +    for(int i =0 ; i < ngroup; i++){
619 +      groupStart.push_back(curIndex++);      
620 +      groupList.push_back((info->atoms[i])->getIndex() + 1);
621 +      mfact.push_back(1.0);
622 +      
623 +    }//end for(int i =0 ; i < ngroup; i++)
624 +    
625 +  }//end if (info->useMolecularCutoffs)
626 +  
627 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines