ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/SimInfo.cpp
(Generate patch)

Comparing trunk/src/brains/SimInfo.cpp (file contents):
Revision 691 by chrisfen, Wed Oct 19 19:24:40 2005 UTC vs.
Revision 998 by chrisfen, Mon Jul 3 13:18:43 2006 UTC

# Line 48 | Line 48
48  
49   #include <algorithm>
50   #include <set>
51 + #include <map>
52  
53   #include "brains/SimInfo.hpp"
54   #include "math/Vector3.hpp"
55   #include "primitives/Molecule.hpp"
56   #include "UseTheForce/fCutoffPolicy.h"
57   #include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h"
58 + #include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h"
59 + #include "UseTheForce/DarkSide/fSwitchingFunctionType.h"
60   #include "UseTheForce/doForces_interface.h"
61   #include "UseTheForce/DarkSide/electrostatic_interface.h"
62 < #include "UseTheForce/notifyCutoffs_interface.h"
62 > #include "UseTheForce/DarkSide/switcheroo_interface.h"
63   #include "utils/MemoryUtils.hpp"
64   #include "utils/simError.h"
65   #include "selection/SelectionManager.hpp"
66 + #include "io/ForceFieldOptions.hpp"
67 + #include "UseTheForce/ForceField.hpp"
68  
69   #ifdef IS_MPI
70   #include "UseTheForce/mpiComponentPlan.h"
# Line 67 | Line 72 | namespace oopse {
72   #endif
73  
74   namespace oopse {
75 +  std::set<int> getRigidSet(int index, std::map<int, std::set<int> >& container) {
76 +    std::map<int, std::set<int> >::iterator i = container.find(index);
77 +    std::set<int> result;
78 +    if (i != container.end()) {
79 +        result = i->second;
80 +    }
81  
82 <  SimInfo::SimInfo(MakeStamps* stamps, std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs,
83 <                   ForceField* ff, Globals* simParams) :
84 <    stamps_(stamps), forceField_(ff), simParams_(simParams),
85 <    ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0),
82 >    return result;
83 >  }
84 >  
85 >  SimInfo::SimInfo(ForceField* ff, Globals* simParams) :
86 >    forceField_(ff), simParams_(simParams),
87 >    ndf_(0), fdf_local(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0),
88      nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0),
89      nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0),
90      nAtoms_(0), nBonds_(0),  nBends_(0), nTorsions_(0), nRigidBodies_(0),
91      nIntegrableObjects_(0),  nCutoffGroups_(0), nConstraints_(0),
92 <    sman_(NULL), fortranInitialized_(false) {
92 >    sman_(NULL), fortranInitialized_(false), calcBoxDipole_(false) {
93  
81            
82      std::vector<std::pair<MoleculeStamp*, int> >::iterator i;
94        MoleculeStamp* molStamp;
95        int nMolWithSameStamp;
96        int nCutoffAtoms = 0; // number of atoms belong to cutoff groups
# Line 87 | Line 98 | namespace oopse {
98        CutoffGroupStamp* cgStamp;    
99        RigidBodyStamp* rbStamp;
100        int nRigidAtoms = 0;
101 <    
102 <      for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) {
103 <        molStamp = i->first;
104 <        nMolWithSameStamp = i->second;
101 >      std::vector<Component*> components = simParams->getComponents();
102 >      
103 >      for (std::vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) {
104 >        molStamp = (*i)->getMoleculeStamp();
105 >        nMolWithSameStamp = (*i)->getNMol();
106          
107          addMoleculeStamp(molStamp, nMolWithSameStamp);
108  
109          //calculate atoms in molecules
110          nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp;  
111  
100
112          //calculate atoms in cutoff groups
113          int nAtomsInGroups = 0;
114          int nCutoffGroupsInStamp = molStamp->getNCutoffGroups();
115          
116          for (int j=0; j < nCutoffGroupsInStamp; j++) {
117 <          cgStamp = molStamp->getCutoffGroup(j);
117 >          cgStamp = molStamp->getCutoffGroupStamp(j);
118            nAtomsInGroups += cgStamp->getNMembers();
119          }
120  
# Line 116 | Line 127 | namespace oopse {
127          int nRigidBodiesInStamp = molStamp->getNRigidBodies();
128          
129          for (int j=0; j < nRigidBodiesInStamp; j++) {
130 <          rbStamp = molStamp->getRigidBody(j);
130 >          rbStamp = molStamp->getRigidBodyStamp(j);
131            nAtomsInRigidBodies += rbStamp->getNMembers();
132          }
133  
# Line 155 | Line 166 | namespace oopse {
166      }
167      molecules_.clear();
168        
158    delete stamps_;
169      delete sman_;
170      delete simParams_;
171      delete forceField_;
# Line 262 | Line 272 | namespace oopse {
272            }
273          }
274              
275 <      }//end for (integrableObject)
276 <    }// end for (mol)
275 >      }
276 >    }
277      
278      // n_constraints is local, so subtract them on each processor
279      ndf_local -= nConstraints_;
# Line 280 | Line 290 | namespace oopse {
290  
291    }
292  
293 +  int SimInfo::getFdf() {
294 + #ifdef IS_MPI
295 +    MPI_Allreduce(&fdf_local,&fdf_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
296 + #else
297 +    fdf_ = fdf_local;
298 + #endif
299 +    return fdf_;
300 +  }
301 +    
302    void SimInfo::calcNdfRaw() {
303      int ndfRaw_local;
304  
# Line 342 | Line 361 | namespace oopse {
361      int b;
362      int c;
363      int d;
364 +
365 +    std::map<int, std::set<int> > atomGroups;
366 +
367 +    Molecule::RigidBodyIterator rbIter;
368 +    RigidBody* rb;
369 +    Molecule::IntegrableObjectIterator ii;
370 +    StuntDouble* integrableObject;
371      
372 +    for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
373 +           integrableObject = mol->nextIntegrableObject(ii)) {
374 +
375 +      if (integrableObject->isRigidBody()) {
376 +          rb = static_cast<RigidBody*>(integrableObject);
377 +          std::vector<Atom*> atoms = rb->getAtoms();
378 +          std::set<int> rigidAtoms;
379 +          for (int i = 0; i < atoms.size(); ++i) {
380 +            rigidAtoms.insert(atoms[i]->getGlobalIndex());
381 +          }
382 +          for (int i = 0; i < atoms.size(); ++i) {
383 +            atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
384 +          }      
385 +      } else {
386 +        std::set<int> oneAtomSet;
387 +        oneAtomSet.insert(integrableObject->getGlobalIndex());
388 +        atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet));        
389 +      }
390 +    }  
391 +
392 +    
393 +    
394      for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) {
395        a = bond->getAtomA()->getGlobalIndex();
396        b = bond->getAtomB()->getGlobalIndex();        
# Line 353 | Line 401 | namespace oopse {
401        a = bend->getAtomA()->getGlobalIndex();
402        b = bend->getAtomB()->getGlobalIndex();        
403        c = bend->getAtomC()->getGlobalIndex();
404 +      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
405 +      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
406 +      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
407  
408 <      exclude_.addPair(a, b);
409 <      exclude_.addPair(a, c);
410 <      exclude_.addPair(b, c);        
408 >      exclude_.addPairs(rigidSetA, rigidSetB);
409 >      exclude_.addPairs(rigidSetA, rigidSetC);
410 >      exclude_.addPairs(rigidSetB, rigidSetC);
411 >      
412 >      //exclude_.addPair(a, b);
413 >      //exclude_.addPair(a, c);
414 >      //exclude_.addPair(b, c);        
415      }
416  
417      for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) {
# Line 364 | Line 419 | namespace oopse {
419        b = torsion->getAtomB()->getGlobalIndex();        
420        c = torsion->getAtomC()->getGlobalIndex();        
421        d = torsion->getAtomD()->getGlobalIndex();        
422 +      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
423 +      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
424 +      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
425 +      std::set<int> rigidSetD = getRigidSet(d, atomGroups);
426  
427 +      exclude_.addPairs(rigidSetA, rigidSetB);
428 +      exclude_.addPairs(rigidSetA, rigidSetC);
429 +      exclude_.addPairs(rigidSetA, rigidSetD);
430 +      exclude_.addPairs(rigidSetB, rigidSetC);
431 +      exclude_.addPairs(rigidSetB, rigidSetD);
432 +      exclude_.addPairs(rigidSetC, rigidSetD);
433 +
434 +      /*
435 +      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end());
436 +      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end());
437 +      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end());
438 +      exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end());
439 +      exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end());
440 +      exclude_.addPairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end());
441 +        
442 +      
443        exclude_.addPair(a, b);
444        exclude_.addPair(a, c);
445        exclude_.addPair(a, d);
446        exclude_.addPair(b, c);
447        exclude_.addPair(b, d);
448        exclude_.addPair(c, d);        
449 +      */
450      }
451  
376    Molecule::RigidBodyIterator rbIter;
377    RigidBody* rb;
452      for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
453        std::vector<Atom*> atoms = rb->getAtoms();
454        for (int i = 0; i < atoms.size() -1 ; ++i) {
# Line 399 | Line 473 | namespace oopse {
473      int b;
474      int c;
475      int d;
476 +
477 +    std::map<int, std::set<int> > atomGroups;
478 +
479 +    Molecule::RigidBodyIterator rbIter;
480 +    RigidBody* rb;
481 +    Molecule::IntegrableObjectIterator ii;
482 +    StuntDouble* integrableObject;
483      
484 +    for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
485 +           integrableObject = mol->nextIntegrableObject(ii)) {
486 +
487 +      if (integrableObject->isRigidBody()) {
488 +          rb = static_cast<RigidBody*>(integrableObject);
489 +          std::vector<Atom*> atoms = rb->getAtoms();
490 +          std::set<int> rigidAtoms;
491 +          for (int i = 0; i < atoms.size(); ++i) {
492 +            rigidAtoms.insert(atoms[i]->getGlobalIndex());
493 +          }
494 +          for (int i = 0; i < atoms.size(); ++i) {
495 +            atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
496 +          }      
497 +      } else {
498 +        std::set<int> oneAtomSet;
499 +        oneAtomSet.insert(integrableObject->getGlobalIndex());
500 +        atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet));        
501 +      }
502 +    }  
503 +
504 +    
505      for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) {
506        a = bond->getAtomA()->getGlobalIndex();
507        b = bond->getAtomB()->getGlobalIndex();        
# Line 411 | Line 513 | namespace oopse {
513        b = bend->getAtomB()->getGlobalIndex();        
514        c = bend->getAtomC()->getGlobalIndex();
515  
516 <      exclude_.removePair(a, b);
517 <      exclude_.removePair(a, c);
518 <      exclude_.removePair(b, c);        
516 >      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
517 >      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
518 >      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
519 >
520 >      exclude_.removePairs(rigidSetA, rigidSetB);
521 >      exclude_.removePairs(rigidSetA, rigidSetC);
522 >      exclude_.removePairs(rigidSetB, rigidSetC);
523 >      
524 >      //exclude_.removePair(a, b);
525 >      //exclude_.removePair(a, c);
526 >      //exclude_.removePair(b, c);        
527      }
528  
529      for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) {
# Line 422 | Line 532 | namespace oopse {
532        c = torsion->getAtomC()->getGlobalIndex();        
533        d = torsion->getAtomD()->getGlobalIndex();        
534  
535 +      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
536 +      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
537 +      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
538 +      std::set<int> rigidSetD = getRigidSet(d, atomGroups);
539 +
540 +      exclude_.removePairs(rigidSetA, rigidSetB);
541 +      exclude_.removePairs(rigidSetA, rigidSetC);
542 +      exclude_.removePairs(rigidSetA, rigidSetD);
543 +      exclude_.removePairs(rigidSetB, rigidSetC);
544 +      exclude_.removePairs(rigidSetB, rigidSetD);
545 +      exclude_.removePairs(rigidSetC, rigidSetD);
546 +
547 +      /*
548 +      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end());
549 +      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end());
550 +      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end());
551 +      exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end());
552 +      exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end());
553 +      exclude_.removePairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end());
554 +
555 +      
556        exclude_.removePair(a, b);
557        exclude_.removePair(a, c);
558        exclude_.removePair(a, d);
559        exclude_.removePair(b, c);
560        exclude_.removePair(b, d);
561        exclude_.removePair(c, d);        
562 +      */
563      }
564  
433    Molecule::RigidBodyIterator rbIter;
434    RigidBody* rb;
565      for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
566        std::vector<Atom*> atoms = rb->getAtoms();
567        for (int i = 0; i < atoms.size() -1 ; ++i) {
# Line 471 | Line 601 | namespace oopse {
601      int isError = 0;
602      
603      setupElectrostaticSummationMethod( isError );
604 +    setupSwitchingFunction();
605 +    setupAccumulateBoxDipole();
606  
607      if(isError){
608        sprintf( painCave.errMsg,
# Line 515 | Line 647 | namespace oopse {
647      int useLennardJones = 0;
648      int useElectrostatic = 0;
649      int useEAM = 0;
650 +    int useSC = 0;
651      int useCharge = 0;
652      int useDirectional = 0;
653      int useDipole = 0;
# Line 528 | Line 661 | namespace oopse {
661      //usePBC and useRF are from simParams
662      int usePBC = simParams_->getUsePeriodicBoundaryConditions();
663      int useRF;
664 +    int useSF;
665 +    int useSP;
666 +    int useBoxDipole;
667      std::string myMethod;
668  
669      // set the useRF logical
670      useRF = 0;
671 +    useSF = 0;
672  
673  
674      if (simParams_->haveElectrostaticSummationMethod()) {
675        std::string myMethod = simParams_->getElectrostaticSummationMethod();
676        toUpper(myMethod);
677 <      if (myMethod == "REACTION_FIELD") {
677 >      if (myMethod == "REACTION_FIELD"){
678          useRF=1;
679 +      } else if (myMethod == "SHIFTED_FORCE"){
680 +        useSF = 1;
681 +      } else if (myMethod == "SHIFTED_POTENTIAL"){
682 +        useSP = 1;
683        }
684      }
685 +    
686 +    if (simParams_->haveAccumulateBoxDipole())
687 +      if (simParams_->getAccumulateBoxDipole())
688 +        useBoxDipole = 1;
689  
690      //loop over all of the atom types
691      for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
692        useLennardJones |= (*i)->isLennardJones();
693        useElectrostatic |= (*i)->isElectrostatic();
694        useEAM |= (*i)->isEAM();
695 +      useSC |= (*i)->isSC();
696        useCharge |= (*i)->isCharge();
697        useDirectional |= (*i)->isDirectional();
698        useDipole |= (*i)->isDipole();
# Line 597 | Line 743 | namespace oopse {
743      temp = useEAM;
744      MPI_Allreduce(&temp, &useEAM, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
745  
746 +    temp = useSC;
747 +    MPI_Allreduce(&temp, &useSC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
748 +    
749      temp = useShape;
750      MPI_Allreduce(&temp, &useShape, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);  
751  
# Line 606 | Line 755 | namespace oopse {
755      temp = useRF;
756      MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
757  
758 +    temp = useSF;
759 +    MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);  
760 +
761 +    temp = useSP;
762 +    MPI_Allreduce(&temp, &useSP, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
763 +
764 +    temp = useBoxDipole;
765 +    MPI_Allreduce(&temp, &useBoxDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
766 +
767   #endif
768  
769      fInfo_.SIM_uses_PBC = usePBC;    
# Line 618 | Line 776 | namespace oopse {
776      fInfo_.SIM_uses_StickyPower = useStickyPower;
777      fInfo_.SIM_uses_GayBerne = useGayBerne;
778      fInfo_.SIM_uses_EAM = useEAM;
779 +    fInfo_.SIM_uses_SC = useSC;
780      fInfo_.SIM_uses_Shapes = useShape;
781      fInfo_.SIM_uses_FLARB = useFLARB;
782      fInfo_.SIM_uses_RF = useRF;
783 +    fInfo_.SIM_uses_SF = useSF;
784 +    fInfo_.SIM_uses_SP = useSP;
785 +    fInfo_.SIM_uses_BoxDipole = useBoxDipole;
786  
787      if( myMethod == "REACTION_FIELD") {
788        
# Line 635 | Line 797 | namespace oopse {
797          simError();
798        }      
799      }
800 +
801    }
802  
803    void SimInfo::setupFortranSim() {
# Line 651 | Line 814 | namespace oopse {
814      }
815  
816      //calculate mass ratio of cutoff group
817 <    std::vector<double> mfact;
817 >    std::vector<RealType> mfact;
818      SimInfo::MoleculeIterator mi;
819      Molecule* mol;
820      Molecule::CutoffGroupIterator ci;
821      CutoffGroup* cg;
822      Molecule::AtomIterator ai;
823      Atom* atom;
824 <    double totalMass;
824 >    RealType totalMass;
825  
826      //to avoid memory reallocation, reserve enough space for mfact
827      mfact.reserve(getNCutoffGroups());
# Line 781 | Line 944 | namespace oopse {
944  
945   #endif
946  
947 <  double SimInfo::calcMaxCutoffRadius() {
785 <
786 <
787 <    std::set<AtomType*> atomTypes;
788 <    std::set<AtomType*>::iterator i;
789 <    std::vector<double> cutoffRadius;
790 <
791 <    //get the unique atom types
792 <    atomTypes = getUniqueAtomTypes();
793 <
794 <    //query the max cutoff radius among these atom types
795 <    for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
796 <      cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i));
797 <    }
798 <
799 <    double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end()));
800 < #ifdef IS_MPI
801 <    //pick the max cutoff radius among the processors
802 < #endif
803 <
804 <    return maxCutoffRadius;
805 <  }
806 <
807 <  void SimInfo::getCutoff(double& rcut, double& rsw) {
947 >  void SimInfo::setupCutoff() {          
948      
949 <    if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) {
810 <        
811 <      if (!simParams_->haveCutoffRadius()){
812 <        sprintf(painCave.errMsg,
813 <                "SimCreator Warning: No value was set for the cutoffRadius.\n"
814 <                "\tOOPSE will use a default value of 15.0 angstroms"
815 <                "\tfor the cutoffRadius.\n");
816 <        painCave.isFatal = 0;
817 <        simError();
818 <        rcut = 15.0;
819 <      } else{
820 <        rcut = simParams_->getCutoffRadius();
821 <      }
949 >    ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions();
950  
951 <      if (!simParams_->haveSwitchingRadius()){
952 <        sprintf(painCave.errMsg,
825 <                "SimCreator Warning: No value was set for switchingRadius.\n"
826 <                "\tOOPSE will use a default value of\n"
827 <                "\t0.95 * cutoffRadius for the switchingRadius\n");
828 <        painCave.isFatal = 0;
829 <        simError();
830 <        rsw = 0.95 * rcut;
831 <      } else{
832 <        rsw = simParams_->getSwitchingRadius();
833 <      }
951 >    // Check the cutoff policy
952 >    int cp =  TRADITIONAL_CUTOFF_POLICY; // Set to traditional by default
953  
954 <    } else {
955 <      // if charge, dipole or reaction field is not used and the cutofff radius is not specified in
956 <      //meta-data file, the maximum cutoff radius calculated from forcefiled will be used
957 <        
958 <      if (simParams_->haveCutoffRadius()) {
959 <        rcut = simParams_->getCutoffRadius();
841 <      } else {
842 <        //set cutoff radius to the maximum cutoff radius based on atom types in the whole system
843 <        rcut = calcMaxCutoffRadius();
844 <      }
845 <
846 <      if (simParams_->haveSwitchingRadius()) {
847 <        rsw  = simParams_->getSwitchingRadius();
848 <      } else {
849 <        rsw = rcut;
850 <      }
851 <    
852 <    }
853 <  }
954 >    std::string myPolicy;
955 >    if (forceFieldOptions_.haveCutoffPolicy()){
956 >      myPolicy = forceFieldOptions_.getCutoffPolicy();
957 >    }else if (simParams_->haveCutoffPolicy()) {
958 >      myPolicy = simParams_->getCutoffPolicy();
959 >    }
960  
961 <  void SimInfo::setupCutoff() {    
856 <    getCutoff(rcut_, rsw_);    
857 <    double rnblist = rcut_ + 1; // skin of neighbor list
858 <
859 <    //Pass these cutoff radius etc. to fortran. This function should be called once and only once
860 <    
861 <    int cp =  TRADITIONAL_CUTOFF_POLICY;
862 <    if (simParams_->haveCutoffPolicy()) {
863 <      std::string myPolicy = simParams_->getCutoffPolicy();
961 >    if (!myPolicy.empty()){
962        toUpper(myPolicy);
963        if (myPolicy == "MIX") {
964          cp = MIX_CUTOFF_POLICY;
# Line 879 | Line 977 | namespace oopse {
977            }    
978          }          
979        }
980 <    }
980 >    }          
981 >    notifyFortranCutoffPolicy(&cp);
982  
983 <
983 >    // Check the Skin Thickness for neighborlists
984 >    RealType skin;
985      if (simParams_->haveSkinThickness()) {
986 <      double skinThickness = simParams_->getSkinThickness();
987 <    }
986 >      skin = simParams_->getSkinThickness();
987 >      notifyFortranSkinThickness(&skin);
988 >    }            
989 >        
990 >    // Check if the cutoff was set explicitly:
991 >    if (simParams_->haveCutoffRadius()) {
992 >      rcut_ = simParams_->getCutoffRadius();
993 >      if (simParams_->haveSwitchingRadius()) {
994 >        rsw_  = simParams_->getSwitchingRadius();
995 >      } else {
996 >        if (fInfo_.SIM_uses_Charges |
997 >            fInfo_.SIM_uses_Dipoles |
998 >            fInfo_.SIM_uses_RF) {
999 >          
1000 >          rsw_ = 0.85 * rcut_;
1001 >          sprintf(painCave.errMsg,
1002 >                  "SimCreator Warning: No value was set for the switchingRadius.\n"
1003 >                  "\tOOPSE will use a default value of 85 percent of the cutoffRadius.\n"
1004 >                  "\tswitchingRadius = %f. for this simulation\n", rsw_);
1005 >        painCave.isFatal = 0;
1006 >        simError();
1007 >        } else {
1008 >          rsw_ = rcut_;
1009 >          sprintf(painCave.errMsg,
1010 >                  "SimCreator Warning: No value was set for the switchingRadius.\n"
1011 >                  "\tOOPSE will use the same value as the cutoffRadius.\n"
1012 >                  "\tswitchingRadius = %f. for this simulation\n", rsw_);
1013 >          painCave.isFatal = 0;
1014 >          simError();
1015 >        }
1016 >      }
1017 >      
1018 >      notifyFortranCutoffs(&rcut_, &rsw_);
1019 >      
1020 >    } else {
1021 >      
1022 >      // For electrostatic atoms, we'll assume a large safe value:
1023 >      if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) {
1024 >        sprintf(painCave.errMsg,
1025 >                "SimCreator Warning: No value was set for the cutoffRadius.\n"
1026 >                "\tOOPSE will use a default value of 15.0 angstroms"
1027 >                "\tfor the cutoffRadius.\n");
1028 >        painCave.isFatal = 0;
1029 >        simError();
1030 >        rcut_ = 15.0;
1031 >      
1032 >        if (simParams_->haveElectrostaticSummationMethod()) {
1033 >          std::string myMethod = simParams_->getElectrostaticSummationMethod();
1034 >          toUpper(myMethod);
1035 >          if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") {
1036 >            if (simParams_->haveSwitchingRadius()){
1037 >              sprintf(painCave.errMsg,
1038 >                      "SimInfo Warning: A value was set for the switchingRadius\n"
1039 >                      "\teven though the electrostaticSummationMethod was\n"
1040 >                      "\tset to %s\n", myMethod.c_str());
1041 >              painCave.isFatal = 1;
1042 >              simError();            
1043 >            }
1044 >          }
1045 >        }
1046 >      
1047 >        if (simParams_->haveSwitchingRadius()){
1048 >          rsw_ = simParams_->getSwitchingRadius();
1049 >        } else {        
1050 >          sprintf(painCave.errMsg,
1051 >                  "SimCreator Warning: No value was set for switchingRadius.\n"
1052 >                  "\tOOPSE will use a default value of\n"
1053 >                  "\t0.85 * cutoffRadius for the switchingRadius\n");
1054 >          painCave.isFatal = 0;
1055 >          simError();
1056 >          rsw_ = 0.85 * rcut_;
1057 >        }
1058 >        notifyFortranCutoffs(&rcut_, &rsw_);
1059 >      } else {
1060 >        // We didn't set rcut explicitly, and we don't have electrostatic atoms, so
1061 >        // We'll punt and let fortran figure out the cutoffs later.
1062 >        
1063 >        notifyFortranYouAreOnYourOwn();
1064  
1065 <    notifyFortranCutoffs(&rcut_, &rsw_, &rnblist, &cp);
1066 <    // also send cutoff notification to electrostatics
891 <    setElectrostaticCutoffRadius(&rcut_, &rsw_);
1065 >      }
1066 >    }
1067    }
1068  
1069    void SimInfo::setupElectrostaticSummationMethod( int isError ) {    
1070      
1071      int errorOut;
1072      int esm =  NONE;
1073 <    double alphaVal;
1074 <    double dielectric;
1073 >    int sm = UNDAMPED;
1074 >    RealType alphaVal;
1075 >    RealType dielectric;
1076  
1077      errorOut = isError;
1078      alphaVal = simParams_->getDampingAlpha();
# Line 908 | Line 1084 | namespace oopse {
1084        if (myMethod == "NONE") {
1085          esm = NONE;
1086        } else {
1087 <        if (myMethod == "UNDAMPED_WOLF") {
1088 <          esm = UNDAMPED_WOLF;
1087 >        if (myMethod == "SWITCHING_FUNCTION") {
1088 >          esm = SWITCHING_FUNCTION;
1089          } else {
1090 <          if (myMethod == "DAMPED_WOLF") {            
1091 <            esm = DAMPED_WOLF;
1092 <            if (!simParams_->haveDampingAlpha()) {
1093 <              //throw error
1094 <              sprintf( painCave.errMsg,
919 <                       "SimInfo warning: dampingAlpha was not specified in the input file. A default value of %f (1/ang) will be used for the Damped Wolf Method.", alphaVal);
920 <              painCave.isFatal = 0;
921 <              simError();
922 <            }
923 <          } else {
924 <            if (myMethod == "REACTION_FIELD") {      
925 <              esm = REACTION_FIELD;
1090 >          if (myMethod == "SHIFTED_POTENTIAL") {
1091 >            esm = SHIFTED_POTENTIAL;
1092 >          } else {
1093 >            if (myMethod == "SHIFTED_FORCE") {            
1094 >              esm = SHIFTED_FORCE;
1095              } else {
1096 <              // throw error        
1097 <              sprintf( painCave.errMsg,
1098 <                       "SimInfo error: Unknown electrostaticSummationMethod. (Input file specified %s .)\n\telectrostaticSummationMethod must be one of: \"none\", \"undamped_wolf\", \"damped_wolf\", or \"reaction_field\".", myMethod.c_str() );
1099 <              painCave.isFatal = 1;
1100 <              simError();
1101 <            }    
1102 <          }          
1096 >              if (myMethod == "REACTION_FIELD") {            
1097 >                esm = REACTION_FIELD;
1098 >              } else {
1099 >                // throw error        
1100 >                sprintf( painCave.errMsg,
1101 >                         "SimInfo error: Unknown electrostaticSummationMethod.\n"
1102 >                         "\t(Input file specified %s .)\n"
1103 >                         "\telectrostaticSummationMethod must be one of: \"none\",\n"
1104 >                         "\t\"shifted_potential\", \"shifted_force\", or \n"
1105 >                         "\t\"reaction_field\".\n", myMethod.c_str() );
1106 >                painCave.isFatal = 1;
1107 >                simError();
1108 >              }    
1109 >            }          
1110 >          }
1111          }
1112        }
1113      }
1114 +    
1115 +    if (simParams_->haveElectrostaticScreeningMethod()) {
1116 +      std::string myScreen = simParams_->getElectrostaticScreeningMethod();
1117 +      toUpper(myScreen);
1118 +      if (myScreen == "UNDAMPED") {
1119 +        sm = UNDAMPED;
1120 +      } else {
1121 +        if (myScreen == "DAMPED") {
1122 +          sm = DAMPED;
1123 +          if (!simParams_->haveDampingAlpha()) {
1124 +            //throw error
1125 +            sprintf( painCave.errMsg,
1126 +                     "SimInfo warning: dampingAlpha was not specified in the input file.\n"
1127 +                     "\tA default value of %f (1/ang) will be used.\n", alphaVal);
1128 +            painCave.isFatal = 0;
1129 +            simError();
1130 +          }
1131 +        } else {
1132 +          // throw error        
1133 +          sprintf( painCave.errMsg,
1134 +                   "SimInfo error: Unknown electrostaticScreeningMethod.\n"
1135 +                   "\t(Input file specified %s .)\n"
1136 +                   "\telectrostaticScreeningMethod must be one of: \"undamped\"\n"
1137 +                   "or \"damped\".\n", myScreen.c_str() );
1138 +          painCave.isFatal = 1;
1139 +          simError();
1140 +        }
1141 +      }
1142 +    }
1143 +    
1144      // let's pass some summation method variables to fortran
1145      setElectrostaticSummationMethod( &esm );
1146 <    setDampedWolfAlpha( &alphaVal );
1146 >    setFortranElectrostaticMethod( &esm );
1147 >    setScreeningMethod( &sm );
1148 >    setDampingAlpha( &alphaVal );
1149      setReactionFieldDielectric( &dielectric );
1150 <    initFortranFF( &esm, &errorOut );
1150 >    initFortranFF( &errorOut );
1151    }
1152  
1153 +  void SimInfo::setupSwitchingFunction() {    
1154 +    int ft = CUBIC;
1155 +
1156 +    if (simParams_->haveSwitchingFunctionType()) {
1157 +      std::string funcType = simParams_->getSwitchingFunctionType();
1158 +      toUpper(funcType);
1159 +      if (funcType == "CUBIC") {
1160 +        ft = CUBIC;
1161 +      } else {
1162 +        if (funcType == "FIFTH_ORDER_POLYNOMIAL") {
1163 +          ft = FIFTH_ORDER_POLY;
1164 +        } else {
1165 +          // throw error        
1166 +          sprintf( painCave.errMsg,
1167 +                   "SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() );
1168 +          painCave.isFatal = 1;
1169 +          simError();
1170 +        }          
1171 +      }
1172 +    }
1173 +
1174 +    // send switching function notification to switcheroo
1175 +    setFunctionType(&ft);
1176 +
1177 +  }
1178 +
1179 +  void SimInfo::setupAccumulateBoxDipole() {    
1180 +
1181 +    // we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true
1182 +    if ( simParams_->haveAccumulateBoxDipole() )
1183 +      if ( simParams_->getAccumulateBoxDipole() ) {
1184 +        setAccumulateBoxDipole();
1185 +        calcBoxDipole_ = true;
1186 +      }
1187 +
1188 +  }
1189 +
1190    void SimInfo::addProperty(GenericData* genData) {
1191      properties_.addProperty(genData);  
1192    }
# Line 997 | Line 1243 | namespace oopse {
1243      Molecule* mol;
1244  
1245      Vector3d comVel(0.0);
1246 <    double totalMass = 0.0;
1246 >    RealType totalMass = 0.0;
1247      
1248  
1249      for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
1250 <      double mass = mol->getMass();
1250 >      RealType mass = mol->getMass();
1251        totalMass += mass;
1252        comVel += mass * mol->getComVel();
1253      }  
1254  
1255   #ifdef IS_MPI
1256 <    double tmpMass = totalMass;
1256 >    RealType tmpMass = totalMass;
1257      Vector3d tmpComVel(comVel);    
1258 <    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1259 <    MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1258 >    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1259 >    MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1260   #endif
1261  
1262      comVel /= totalMass;
# Line 1023 | Line 1269 | namespace oopse {
1269      Molecule* mol;
1270  
1271      Vector3d com(0.0);
1272 <    double totalMass = 0.0;
1272 >    RealType totalMass = 0.0;
1273      
1274      for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
1275 <      double mass = mol->getMass();
1275 >      RealType mass = mol->getMass();
1276        totalMass += mass;
1277        com += mass * mol->getCom();
1278      }  
1279  
1280   #ifdef IS_MPI
1281 <    double tmpMass = totalMass;
1281 >    RealType tmpMass = totalMass;
1282      Vector3d tmpCom(com);    
1283 <    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1284 <    MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1283 >    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1284 >    MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1285   #endif
1286  
1287      com /= totalMass;
# Line 1059 | Line 1305 | namespace oopse {
1305        Molecule* mol;
1306        
1307      
1308 <      double totalMass = 0.0;
1308 >      RealType totalMass = 0.0;
1309      
1310  
1311        for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
1312 <         double mass = mol->getMass();
1312 >         RealType mass = mol->getMass();
1313           totalMass += mass;
1314           com += mass * mol->getCom();
1315           comVel += mass * mol->getComVel();          
1316        }  
1317        
1318   #ifdef IS_MPI
1319 <      double tmpMass = totalMass;
1319 >      RealType tmpMass = totalMass;
1320        Vector3d tmpCom(com);  
1321        Vector3d tmpComVel(comVel);
1322 <      MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1323 <      MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1324 <      MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1322 >      MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1323 >      MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1324 >      MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1325   #endif
1326        
1327        com /= totalMass;
# Line 1094 | Line 1340 | namespace oopse {
1340     void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){
1341        
1342  
1343 <      double xx = 0.0;
1344 <      double yy = 0.0;
1345 <      double zz = 0.0;
1346 <      double xy = 0.0;
1347 <      double xz = 0.0;
1348 <      double yz = 0.0;
1343 >      RealType xx = 0.0;
1344 >      RealType yy = 0.0;
1345 >      RealType zz = 0.0;
1346 >      RealType xy = 0.0;
1347 >      RealType xz = 0.0;
1348 >      RealType yz = 0.0;
1349        Vector3d com(0.0);
1350        Vector3d comVel(0.0);
1351        
# Line 1111 | Line 1357 | namespace oopse {
1357        Vector3d thisq(0.0);
1358        Vector3d thisv(0.0);
1359  
1360 <      double thisMass = 0.0;
1360 >      RealType thisMass = 0.0;
1361      
1362        
1363        
# Line 1149 | Line 1395 | namespace oopse {
1395   #ifdef IS_MPI
1396        Mat3x3d tmpI(inertiaTensor);
1397        Vector3d tmpAngMom;
1398 <      MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1399 <      MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1398 >      MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1399 >      MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1400   #endif
1401                
1402        return;
# Line 1171 | Line 1417 | namespace oopse {
1417        Vector3d thisr(0.0);
1418        Vector3d thisp(0.0);
1419        
1420 <      double thisMass;
1420 >      RealType thisMass;
1421        
1422        for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {        
1423          thisMass = mol->getMass();
# Line 1184 | Line 1430 | namespace oopse {
1430        
1431   #ifdef IS_MPI
1432        Vector3d tmpAngMom;
1433 <      MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1433 >      MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1434   #endif
1435        
1436        return angularMomentum;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines