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