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 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 70 | Line 69 | SimInfo::SimInfo(){
69  
70    has_minimizer = false;
71    the_minimizer =NULL;
72 +
73 +  ngroup = 0;
74  
75    wrapMeSimInfo( this );
76   }
# Line 83 | 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 322 | Line 323 | int SimInfo::getNDF(){
323   int SimInfo::getNDF(){
324    int ndf_local;
325  
326 +  ndf_local = 0;
327 +  
328    for(int i = 0; i < integrableObjects.size(); i++){
329      ndf_local += 3;
330 <    if (integrableObjects[i]->isDirectional())
331 <      ndf_local += 3;
330 >    if (integrableObjects[i]->isDirectional()) {
331 >      if (integrableObjects[i]->isLinear())
332 >        ndf_local += 2;
333 >      else
334 >        ndf_local += 3;
335 >    }
336    }
337  
338    // n_constraints is local, so subtract them on each processor:
# Line 350 | Line 357 | int SimInfo::getNDFraw() {
357    int ndfRaw_local;
358  
359    // Raw degrees of freedom that we have to set
360 +  ndfRaw_local = 0;
361  
362    for(int i = 0; i < integrableObjects.size(); i++){
363      ndfRaw_local += 3;
364 <    if (integrableObjects[i]->isDirectional())
365 <      ndfRaw_local += 3;
364 >    if (integrableObjects[i]->isDirectional()) {
365 >       if (integrableObjects[i]->isLinear())
366 >        ndfRaw_local += 2;
367 >      else
368 >        ndfRaw_local += 3;
369 >    }
370    }
371      
372   #ifdef IS_MPI
# Line 383 | Line 395 | int SimInfo::getNDFtranslational() {
395    return ndfTrans;
396   }
397  
398 + int SimInfo::getTotIntegrableObjects() {
399 +  int nObjs_local;
400 +  int nObjs;
401 +
402 +  nObjs_local =  integrableObjects.size();
403 +
404 +
405 + #ifdef IS_MPI
406 +  MPI_Allreduce(&nObjs_local,&nObjs,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
407 + #else
408 +  nObjs = nObjs_local;
409 + #endif
410 +
411 +
412 +  return nObjs;
413 + }
414 +
415   void SimInfo::refreshSim(){
416  
417    simtype fInfo;
# Line 411 | Line 440 | void SimInfo::refreshSim(){
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 <
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 <                  &isError );
457 <
455 >                  &nGlobalExcludes, globalExcludes, molMembershipArray,
456 >                  &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError);
457 >  
458    if( isError ){
459 <
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 <
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;
481 >  rList = rCut + 1.0;
482    
483 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
462 <
463 <  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 478 | 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, %G"
505 >               "\n"
506                 "\t[ %G %G %G ]\n"
507                 "\t[ %G %G %G ]\n"
508                 "\t[ %G %G %G ]\n",
509 <               rCut, currentTime, maxCutoff,
509 >               rCut, 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 <    }
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 <    }
515 >    }    
516    } else {
517      // initialize this stuff before using it, OK?
518      sprintf( painCave.errMsg,
# Line 561 | Line 560 | GenericData* SimInfo::getProperty(const string& propNa
560      return NULL;  
561   }
562  
564 vector<GenericData*> SimInfo::getProperties(){
563  
564 <  vector<GenericData*> result;
565 <  map<string, GenericData*>::iterator i;
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 <  for(i = properties.begin(); i != properties.end(); i++)
577 <    result.push_back((*i).second);
576 >  //Be careful, fortran array begin at 1
577 >  curIndex = 1;
578 >  
579 >  if(info->useMolecularCutoffs){
580      
581 <  return result;
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