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

Comparing branches/development/src/brains/SimInfo.cpp (file contents):
Revision 1528 by gezelter, Fri Dec 17 20:11:05 2010 UTC vs.
Revision 1532 by gezelter, Wed Dec 29 19:59:21 2010 UTC

# Line 54 | Line 54
54   #include "math/Vector3.hpp"
55   #include "primitives/Molecule.hpp"
56   #include "primitives/StuntDouble.hpp"
57 #include "UseTheForce/fCutoffPolicy.h"
58 #include "UseTheForce/DarkSide/fSwitchingFunctionType.h"
57   #include "UseTheForce/doForces_interface.h"
58   #include "UseTheForce/DarkSide/neighborLists_interface.h"
61 #include "UseTheForce/DarkSide/switcheroo_interface.h"
59   #include "utils/MemoryUtils.hpp"
60   #include "utils/simError.h"
61   #include "selection/SelectionManager.hpp"
62   #include "io/ForceFieldOptions.hpp"
63   #include "UseTheForce/ForceField.hpp"
64 < #include "nonbonded/InteractionManager.hpp"
64 > #include "nonbonded/SwitchingFunction.hpp"
65  
66  
67   #ifdef IS_MPI
# Line 656 | Line 653 | namespace OpenMD {
653      molStampIds_.insert(molStampIds_.end(), nmol, curStampId);
654    }
655  
659  void SimInfo::update() {
656  
657 <    setupSimType();
658 <    setupCutoffRadius();
659 <    setupSwitchingRadius();
660 <    setupCutoffMethod();
661 <    setupSkinThickness();
662 <    setupSwitchingFunction();
663 <    setupAccumulateBoxDipole();
657 >  /**
658 >   * update
659 >   *
660 >   *  Performs the global checks and variable settings after the objects have been
661 >   *  created.
662 >   *
663 >   */
664 >  void SimInfo::update() {
665 >    
666 >    setupSimVariables();
667 >    setupCutoffs();
668 >    setupSwitching();
669 >    setupElectrostatics();
670 >    setupNeighborlists();
671  
672   #ifdef IS_MPI
673      setupFortranParallel();
# Line 684 | Line 687 | namespace OpenMD {
687      Atom* atom;
688      set<AtomType*> atomTypes;
689      
690 <    for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {
688 <      
690 >    for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {      
691        for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
692          atomTypes.insert(atom->getAtomType());
693 <      }
694 <      
693 <    }
694 <    
693 >      }      
694 >    }    
695      return atomTypes;        
696    }
697  
698    /**
699 <   * setupCutoffRadius
699 >   * setupCutoffs
700     *
701 +   * Sets the values of cutoffRadius and cutoffMethod
702 +   *
703 +   * cutoffRadius : realType
704     *  If the cutoffRadius was explicitly set, use that value.
705     *  If the cutoffRadius was not explicitly set:
706     *      Are there electrostatic atoms?  Use 12.0 Angstroms.
707     *      No electrostatic atoms?  Poll the atom types present in the
708     *      simulation for suggested cutoff values (e.g. 2.5 * sigma).
709     *      Use the maximum suggested value that was found.
710 +   *
711 +   * cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE, SHIFTED_POTENTIAL)
712 +   *      If cutoffMethod was explicitly set, use that choice.
713 +   *      If cutoffMethod was not explicitly set, use SHIFTED_FORCE
714     */
715 <  void SimInfo::setupCutoffRadius() {
715 >  void SimInfo::setupCutoffs() {
716      
717      if (simParams_->haveCutoffRadius()) {
718        cutoffRadius_ = simParams_->getCutoffRadius();
719      } else {      
720        if (usesElectrostaticAtoms_) {
721          sprintf(painCave.errMsg,
722 <                "SimInfo Warning: No value was set for the cutoffRadius.\n"
722 >                "SimInfo: No value was set for the cutoffRadius.\n"
723                  "\tOpenMD will use a default value of 12.0 angstroms"
724                  "\tfor the cutoffRadius.\n");
725          painCave.isFatal = 0;
726 +        painCave.severity = OPENMD_INFO;
727          simError();
728          cutoffRadius_ = 12.0;
729        } else {
# Line 728 | Line 736 | namespace OpenMD {
736            cutoffRadius_ = max(thisCut, cutoffRadius_);
737          }
738          sprintf(painCave.errMsg,
739 <                "SimInfo Warning: No value was set for the cutoffRadius.\n"
739 >                "SimInfo: No value was set for the cutoffRadius.\n"
740                  "\tOpenMD will use %lf angstroms.\n",
741                  cutoffRadius_);
742          painCave.isFatal = 0;
743 +        painCave.severity = OPENMD_INFO;
744          simError();
745        }            
746      }
747  
748      InteractionManager::Instance()->setCutoffRadius(cutoffRadius_);
749 +
750 +    map<string, CutoffMethod> stringToCutoffMethod;
751 +    stringToCutoffMethod["HARD"] = HARD;
752 +    stringToCutoffMethod["SWITCHING_FUNCTION"] = SWITCHING_FUNCTION;
753 +    stringToCutoffMethod["SHIFTED_POTENTIAL"] = SHIFTED_POTENTIAL;    
754 +    stringToCutoffMethod["SHIFTED_FORCE"] = SHIFTED_FORCE;
755 +  
756 +    if (simParams_->haveCutoffMethod()) {
757 +      string cutMeth = toUpperCopy(simParams_->getCutoffMethod());
758 +      map<string, CutoffMethod>::iterator i;
759 +      i = stringToCutoffMethod.find(cutMeth);
760 +      if (i == stringToCutoffMethod.end()) {
761 +        sprintf(painCave.errMsg,
762 +                "SimInfo: Could not find chosen cutoffMethod %s\n"
763 +                "\tShould be one of: "
764 +                "HARD, SWITCHING_FUNCTION, SHIFTED_POTENTIAL, or SHIFTED_FORCE\n",
765 +                cutMeth.c_str());
766 +        painCave.isFatal = 1;
767 +        painCave.severity = OPENMD_ERROR;
768 +        simError();
769 +      } else {
770 +        cutoffMethod_ = i->second;
771 +      }
772 +    } else {
773 +      sprintf(painCave.errMsg,
774 +              "SimInfo: No value was set for the cutoffMethod.\n"
775 +              "\tOpenMD will use SHIFTED_FORCE.\n");
776 +        painCave.isFatal = 0;
777 +        painCave.severity = OPENMD_INFO;
778 +        simError();
779 +        cutoffMethod_ = SHIFTED_FORCE;        
780 +    }
781 +
782 +    InteractionManager::Instance()->setCutoffMethod(cutoffMethod_);
783    }
784    
785    /**
786 <   * setupSwitchingRadius
786 >   * setupSwitching
787     *
788 +   * Sets the values of switchingRadius and
789     *  If the switchingRadius was explicitly set, use that value (but check it)
790     *  If the switchingRadius was not explicitly set: use 0.85 * cutoffRadius_
791     */
792 <  void SimInfo::setupSwitchingRadius() {
792 >  void SimInfo::setupSwitching() {
793      
794      if (simParams_->haveSwitchingRadius()) {
795        switchingRadius_ = simParams_->getSwitchingRadius();
796        if (switchingRadius_ > cutoffRadius_) {        
797          sprintf(painCave.errMsg,
798 <                "SimInfo Error: switchingRadius (%f) is larger than cutoffRadius(%f)\n",
798 >                "SimInfo: switchingRadius (%f) is larger than cutoffRadius(%f)\n",
799                  switchingRadius_, cutoffRadius_);
800          painCave.isFatal = 1;
801 +        painCave.severity = OPENMD_ERROR;
802          simError();
758
803        }
804      } else {      
805        switchingRadius_ = 0.85 * cutoffRadius_;
806        sprintf(painCave.errMsg,
807 <              "SimInfo Warning: No value was set for the switchingRadius.\n"
807 >              "SimInfo: No value was set for the switchingRadius.\n"
808                "\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n"
809                "\tswitchingRadius = %f. for this simulation\n", switchingRadius_);
810        painCave.isFatal = 0;
811 +      painCave.severity = OPENMD_WARNING;
812        simError();
813 <    }            
813 >    }          
814 >  
815      InteractionManager::Instance()->setSwitchingRadius(switchingRadius_);
816 +
817 +    SwitchingFunctionType ft;
818 +    
819 +    if (simParams_->haveSwitchingFunctionType()) {
820 +      string funcType = simParams_->getSwitchingFunctionType();
821 +      toUpper(funcType);
822 +      if (funcType == "CUBIC") {
823 +        ft = cubic;
824 +      } else {
825 +        if (funcType == "FIFTH_ORDER_POLYNOMIAL") {
826 +          ft = fifth_order_poly;
827 +        } else {
828 +          // throw error        
829 +          sprintf( painCave.errMsg,
830 +                   "SimInfo : Unknown switchingFunctionType. (Input file specified %s .)\n"
831 +                   "\tswitchingFunctionType must be one of: "
832 +                   "\"cubic\" or \"fifth_order_polynomial\".",
833 +                   funcType.c_str() );
834 +          painCave.isFatal = 1;
835 +          painCave.severity = OPENMD_ERROR;
836 +          simError();
837 +        }          
838 +      }
839 +    }
840 +
841 +    InteractionManager::Instance()->setSwitchingFunctionType(ft);
842    }
843  
844    /**
# Line 992 | Line 1064 | namespace OpenMD {
1064  
1065  
1066    void SimInfo::setupSwitchingFunction() {    
995    int ft = CUBIC;
996    
997    if (simParams_->haveSwitchingFunctionType()) {
998      string funcType = simParams_->getSwitchingFunctionType();
999      toUpper(funcType);
1000      if (funcType == "CUBIC") {
1001        ft = CUBIC;
1002      } else {
1003        if (funcType == "FIFTH_ORDER_POLYNOMIAL") {
1004          ft = FIFTH_ORDER_POLY;
1005        } else {
1006          // throw error        
1007          sprintf( painCave.errMsg,
1008                   "SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() );
1009          painCave.isFatal = 1;
1010          simError();
1011        }          
1012      }
1013    }
1067  
1015    // send switching function notification to switcheroo
1016    setFunctionType(&ft);
1017
1068    }
1069  
1070    void SimInfo::setupAccumulateBoxDipole() {    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines