# | 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 684 | Line 686 | namespace OpenMD { | |
686 | Atom* atom; | |
687 | set<AtomType*> atomTypes; | |
688 | ||
689 | < | for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
688 | < | |
689 | > | for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
690 | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { | |
691 | atomTypes.insert(atom->getAtomType()); | |
692 | < | } |
693 | < | |
693 | < | } |
694 | < | |
692 | > | } |
693 | > | } |
694 | return atomTypes; | |
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 728 | 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(); | |
758 | – | |
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() { |
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(); |
796 | < | |
797 | < | useAtomicVirial_ = simParams_->getUseAtomicVirial(); |
798 | < | |
865 | > | atomTypes = getSimulatedAtomTypes(); |
866 | int usesElectrostatic = 0; | |
867 | int usesMetallic = 0; | |
868 | int usesDirectional = 0; | |
# | Line 991 | Line 1058 | namespace OpenMD { | |
1058 | } | |
1059 | ||
1060 | ||
994 | – | 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 | – | } |
1014 | – | |
1015 | – | // send switching function notification to switcheroo |
1016 | – | setFunctionType(&ft); |
1017 | – | |
1018 | – | } |
1019 | – | |
1061 | void SimInfo::setupAccumulateBoxDipole() { | |
1062 | ||
1022 | – | // we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true |
1023 | – | if ( simParams_->haveAccumulateBoxDipole() ) |
1024 | – | if ( simParams_->getAccumulateBoxDipole() ) { |
1025 | – | calcBoxDipole_ = true; |
1026 | – | } |
1063 | ||
1064 | } | |
1065 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |