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 1529 by gezelter, Mon Dec 27 18:35:59 2010 UTC vs.
Revision 1534 by gezelter, Wed Dec 29 21:53:28 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  
69
66   #ifdef IS_MPI
67   #include "UseTheForce/mpiComponentPlan.h"
68   #include "UseTheForce/DarkSide/simParallel_interface.h"
# Line 656 | Line 652 | namespace OpenMD {
652      molStampIds_.insert(molStampIds_.end(), nmol, curStampId);
653    }
654  
659  void SimInfo::update() {
655  
656 <    setupSimType();
657 <    setupCutoffRadius();
658 <    setupSwitchingRadius();
659 <    setupCutoffMethod();
660 <    setupSkinThickness();
661 <    setupSwitchingFunction();
662 <    setupAccumulateBoxDipole();
656 >  /**
657 >   * update
658 >   *
659 >   *  Performs the global checks and variable settings after the objects have been
660 >   *  created.
661 >   *
662 >   */
663 >  void SimInfo::update() {
664 >    
665 >    setupSimVariables();
666 >    setupCutoffs();
667 >    setupSwitching();
668 >    setupElectrostatics();
669 >    setupNeighborlists();
670  
671   #ifdef IS_MPI
672      setupFortranParallel();
# Line 693 | Line 695 | namespace OpenMD {
695    }
696  
697    /**
698 <   * setupCutoffRadius
698 >   * setupCutoffs
699     *
700 +   * Sets the values of cutoffRadius and cutoffMethod
701 +   *
702 +   * cutoffRadius : realType
703     *  If the cutoffRadius was explicitly set, use that value.
704     *  If the cutoffRadius was not explicitly set:
705     *      Are there electrostatic atoms?  Use 12.0 Angstroms.
706     *      No electrostatic atoms?  Poll the atom types present in the
707     *      simulation for suggested cutoff values (e.g. 2.5 * sigma).
708     *      Use the maximum suggested value that was found.
709 +   *
710 +   * cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE, SHIFTED_POTENTIAL)
711 +   *      If cutoffMethod was explicitly set, use that choice.
712 +   *      If cutoffMethod was not explicitly set, use SHIFTED_FORCE
713     */
714 <  void SimInfo::setupCutoffRadius() {
714 >  void SimInfo::setupCutoffs() {
715      
716      if (simParams_->haveCutoffRadius()) {
717        cutoffRadius_ = simParams_->getCutoffRadius();
718      } else {      
719        if (usesElectrostaticAtoms_) {
720          sprintf(painCave.errMsg,
721 <                "SimInfo Warning: No value was set for the cutoffRadius.\n"
721 >                "SimInfo: No value was set for the cutoffRadius.\n"
722                  "\tOpenMD will use a default value of 12.0 angstroms"
723                  "\tfor the cutoffRadius.\n");
724          painCave.isFatal = 0;
725 +        painCave.severity = OPENMD_INFO;
726          simError();
727          cutoffRadius_ = 12.0;
728        } else {
# Line 725 | Line 735 | namespace OpenMD {
735            cutoffRadius_ = max(thisCut, cutoffRadius_);
736          }
737          sprintf(painCave.errMsg,
738 <                "SimInfo Warning: No value was set for the cutoffRadius.\n"
738 >                "SimInfo: No value was set for the cutoffRadius.\n"
739                  "\tOpenMD will use %lf angstroms.\n",
740                  cutoffRadius_);
741          painCave.isFatal = 0;
742 +        painCave.severity = OPENMD_INFO;
743          simError();
744        }            
745      }
746  
747 <    InteractionManager::Instance()->setCutoffRadius(cutoffRadius_);
747 >    map<string, CutoffMethod> stringToCutoffMethod;
748 >    stringToCutoffMethod["HARD"] = HARD;
749 >    stringToCutoffMethod["SWITCHING_FUNCTION"] = SWITCHING_FUNCTION;
750 >    stringToCutoffMethod["SHIFTED_POTENTIAL"] = SHIFTED_POTENTIAL;    
751 >    stringToCutoffMethod["SHIFTED_FORCE"] = SHIFTED_FORCE;
752 >  
753 >    if (simParams_->haveCutoffMethod()) {
754 >      string cutMeth = toUpperCopy(simParams_->getCutoffMethod());
755 >      map<string, CutoffMethod>::iterator i;
756 >      i = stringToCutoffMethod.find(cutMeth);
757 >      if (i == stringToCutoffMethod.end()) {
758 >        sprintf(painCave.errMsg,
759 >                "SimInfo: Could not find chosen cutoffMethod %s\n"
760 >                "\tShould be one of: "
761 >                "HARD, SWITCHING_FUNCTION, SHIFTED_POTENTIAL, or SHIFTED_FORCE\n",
762 >                cutMeth.c_str());
763 >        painCave.isFatal = 1;
764 >        painCave.severity = OPENMD_ERROR;
765 >        simError();
766 >      } else {
767 >        cutoffMethod_ = i->second;
768 >      }
769 >    } else {
770 >      sprintf(painCave.errMsg,
771 >              "SimInfo: No value was set for the cutoffMethod.\n"
772 >              "\tOpenMD will use SHIFTED_FORCE.\n");
773 >        painCave.isFatal = 0;
774 >        painCave.severity = OPENMD_INFO;
775 >        simError();
776 >        cutoffMethod_ = SHIFTED_FORCE;        
777 >    }
778    }
779    
780    /**
781 <   * setupSwitchingRadius
781 >   * setupSwitching
782     *
783 +   * Sets the values of switchingRadius and
784     *  If the switchingRadius was explicitly set, use that value (but check it)
785     *  If the switchingRadius was not explicitly set: use 0.85 * cutoffRadius_
786     */
787 <  void SimInfo::setupSwitchingRadius() {
787 >  void SimInfo::setupSwitching() {
788      
789      if (simParams_->haveSwitchingRadius()) {
790        switchingRadius_ = simParams_->getSwitchingRadius();
791        if (switchingRadius_ > cutoffRadius_) {        
792          sprintf(painCave.errMsg,
793 <                "SimInfo Error: switchingRadius (%f) is larger than cutoffRadius(%f)\n",
793 >                "SimInfo: switchingRadius (%f) is larger than cutoffRadius(%f)\n",
794                  switchingRadius_, cutoffRadius_);
795          painCave.isFatal = 1;
796 +        painCave.severity = OPENMD_ERROR;
797          simError();
755
798        }
799      } else {      
800        switchingRadius_ = 0.85 * cutoffRadius_;
801        sprintf(painCave.errMsg,
802 <              "SimInfo Warning: No value was set for the switchingRadius.\n"
802 >              "SimInfo: No value was set for the switchingRadius.\n"
803                "\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n"
804                "\tswitchingRadius = %f. for this simulation\n", switchingRadius_);
805        painCave.isFatal = 0;
806 +      painCave.severity = OPENMD_WARNING;
807        simError();
808 <    }            
809 <    InteractionManager::Instance()->setSwitchingRadius(switchingRadius_);
808 >    }          
809 >    
810 >    if (simParams_->haveSwitchingFunctionType()) {
811 >      string funcType = simParams_->getSwitchingFunctionType();
812 >      toUpper(funcType);
813 >      if (funcType == "CUBIC") {
814 >        sft_ = cubic;
815 >      } else {
816 >        if (funcType == "FIFTH_ORDER_POLYNOMIAL") {
817 >          sft_ = fifth_order_poly;
818 >        } else {
819 >          // throw error        
820 >          sprintf( painCave.errMsg,
821 >                   "SimInfo : Unknown switchingFunctionType. (Input file specified %s .)\n"
822 >                   "\tswitchingFunctionType must be one of: "
823 >                   "\"cubic\" or \"fifth_order_polynomial\".",
824 >                   funcType.c_str() );
825 >          painCave.isFatal = 1;
826 >          painCave.severity = OPENMD_ERROR;
827 >          simError();
828 >        }          
829 >      }
830 >    }
831    }
832  
833    /**
834 <   * setupSkinThickness
834 >   * setupNeighborlists
835     *
836     *  If the skinThickness was explicitly set, use that value (but check it)
837     *  If the skinThickness was not explicitly set: use 1.0 angstroms
838     */
839 <  void SimInfo::setupSkinThickness() {    
839 >  void SimInfo::setupNeighborlists() {    
840      if (simParams_->haveSkinThickness()) {
841        skinThickness_ = simParams_->getSkinThickness();
842      } else {      
843        skinThickness_ = 1.0;
844        sprintf(painCave.errMsg,
845 <              "SimInfo Warning: No value was set for the skinThickness.\n"
845 >              "SimInfo: No value was set for the skinThickness.\n"
846                "\tOpenMD will use a default value of %f Angstroms\n"
847                "\tfor this simulation\n", skinThickness_);
848 +      painCave.severity = OPENMD_INFO;
849        painCave.isFatal = 0;
850        simError();
851      }            
852    }
853  
854 <  void SimInfo::setupSimType() {
790 <    set<AtomType*>::iterator i;
791 <    set<AtomType*> atomTypes;
792 <    atomTypes = getSimulatedAtomTypes();
793 <
854 >  void SimInfo::setupSimVariables() {
855      useAtomicVirial_ = simParams_->getUseAtomicVirial();
856 +    // we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true
857 +    calcBoxDipole_ = false;
858 +    if ( simParams_->haveAccumulateBoxDipole() )
859 +      if ( simParams_->getAccumulateBoxDipole() ) {
860 +        calcBoxDipole_ = true;      
861 +      }
862  
863 +    set<AtomType*>::iterator i;
864 +    set<AtomType*> atomTypes;
865 +    atomTypes = getSimulatedAtomTypes();    
866      int usesElectrostatic = 0;
867      int usesMetallic = 0;
868      int usesDirectional = 0;
# Line 986 | Line 1056 | namespace OpenMD {
1056  
1057   #endif
1058    }
989
990
991  void SimInfo::setupSwitchingFunction() {    
992    int ft = CUBIC;
993    
994    if (simParams_->haveSwitchingFunctionType()) {
995      string funcType = simParams_->getSwitchingFunctionType();
996      toUpper(funcType);
997      if (funcType == "CUBIC") {
998        ft = CUBIC;
999      } else {
1000        if (funcType == "FIFTH_ORDER_POLYNOMIAL") {
1001          ft = FIFTH_ORDER_POLY;
1002        } else {
1003          // throw error        
1004          sprintf( painCave.errMsg,
1005                   "SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n"
1006                   "\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".",
1007                   funcType.c_str() );
1008          painCave.isFatal = 1;
1009          simError();
1010        }          
1011      }
1012    }
1059  
1014    // send switching function notification to switcheroo
1015    setFunctionType(&ft);
1060  
1017  }
1018
1061    void SimInfo::setupAccumulateBoxDipole() {    
1062  
1021    // we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true
1022    if ( simParams_->haveAccumulateBoxDipole() )
1023      if ( simParams_->getAccumulateBoxDipole() ) {
1024        calcBoxDipole_ = true;
1025      }
1063  
1064    }
1065  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines