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" |
82 |
|
return result; |
83 |
|
} |
84 |
|
|
85 |
< |
SimInfo::SimInfo(MakeStamps* stamps, std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
86 |
< |
ForceField* ff, Globals* simParams) : |
86 |
< |
stamps_(stamps), forceField_(ff), simParams_(simParams), |
85 |
> |
SimInfo::SimInfo(ForceField* ff, Globals* simParams) : |
86 |
> |
forceField_(ff), simParams_(simParams), |
87 |
|
ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
88 |
|
nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), |
89 |
|
nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
91 |
|
nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), |
92 |
|
sman_(NULL), fortranInitialized_(false) { |
93 |
|
|
94 |
– |
|
95 |
– |
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 |
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 |
|
|
113 |
– |
|
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 |
|
|
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 |
|
|
166 |
|
} |
167 |
|
molecules_.clear(); |
168 |
|
|
171 |
– |
delete stamps_; |
169 |
|
delete sman_; |
170 |
|
delete simParams_; |
171 |
|
delete forceField_; |
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_; |
920 |
|
|
921 |
|
#endif |
922 |
|
|
923 |
< |
double SimInfo::calcMaxCutoffRadius() { |
923 |
> |
void SimInfo::setupCutoff() { |
924 |
> |
|
925 |
> |
ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); |
926 |
|
|
927 |
+ |
// Check the cutoff policy |
928 |
+ |
int cp = TRADITIONAL_CUTOFF_POLICY; // Set to traditional by default |
929 |
|
|
930 |
< |
std::set<AtomType*> atomTypes; |
931 |
< |
std::set<AtomType*>::iterator i; |
932 |
< |
std::vector<double> cutoffRadius; |
933 |
< |
|
934 |
< |
//get the unique atom types |
934 |
< |
atomTypes = getUniqueAtomTypes(); |
935 |
< |
|
936 |
< |
//query the max cutoff radius among these atom types |
937 |
< |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
938 |
< |
cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); |
939 |
< |
} |
940 |
< |
|
941 |
< |
double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end())); |
942 |
< |
#ifdef IS_MPI |
943 |
< |
//pick the max cutoff radius among the processors |
944 |
< |
#endif |
945 |
< |
|
946 |
< |
return maxCutoffRadius; |
947 |
< |
} |
948 |
< |
|
949 |
< |
void SimInfo::getCutoff(double& rcut, double& rsw) { |
950 |
< |
|
951 |
< |
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
952 |
< |
|
953 |
< |
if (!simParams_->haveCutoffRadius()){ |
954 |
< |
sprintf(painCave.errMsg, |
955 |
< |
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
956 |
< |
"\tOOPSE will use a default value of 15.0 angstroms" |
957 |
< |
"\tfor the cutoffRadius.\n"); |
958 |
< |
painCave.isFatal = 0; |
959 |
< |
simError(); |
960 |
< |
rcut = 15.0; |
961 |
< |
} else{ |
962 |
< |
rcut = simParams_->getCutoffRadius(); |
963 |
< |
} |
964 |
< |
|
965 |
< |
if (!simParams_->haveSwitchingRadius()){ |
966 |
< |
sprintf(painCave.errMsg, |
967 |
< |
"SimCreator Warning: No value was set for switchingRadius.\n" |
968 |
< |
"\tOOPSE will use a default value of\n" |
969 |
< |
"\t0.85 * cutoffRadius for the switchingRadius\n"); |
970 |
< |
painCave.isFatal = 0; |
971 |
< |
simError(); |
972 |
< |
rsw = 0.85 * rcut; |
973 |
< |
} else{ |
974 |
< |
rsw = simParams_->getSwitchingRadius(); |
975 |
< |
} |
976 |
< |
|
977 |
< |
} else { |
978 |
< |
// if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
979 |
< |
//meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
980 |
< |
|
981 |
< |
if (simParams_->haveCutoffRadius()) { |
982 |
< |
rcut = simParams_->getCutoffRadius(); |
983 |
< |
} else { |
984 |
< |
//set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
985 |
< |
rcut = calcMaxCutoffRadius(); |
986 |
< |
} |
987 |
< |
|
988 |
< |
if (simParams_->haveSwitchingRadius()) { |
989 |
< |
rsw = simParams_->getSwitchingRadius(); |
990 |
< |
} else { |
991 |
< |
rsw = rcut; |
992 |
< |
} |
993 |
< |
|
930 |
> |
std::string myPolicy; |
931 |
> |
if (forceFieldOptions_.haveCutoffPolicy()){ |
932 |
> |
myPolicy = forceFieldOptions_.getCutoffPolicy(); |
933 |
> |
}else if (simParams_->haveCutoffPolicy()) { |
934 |
> |
myPolicy = simParams_->getCutoffPolicy(); |
935 |
|
} |
995 |
– |
} |
936 |
|
|
937 |
< |
void SimInfo::setupCutoff() { |
998 |
< |
getCutoff(rcut_, rsw_); |
999 |
< |
double rnblist = rcut_ + 1; // skin of neighbor list |
1000 |
< |
|
1001 |
< |
//Pass these cutoff radius etc. to fortran. This function should be called once and only once |
1002 |
< |
|
1003 |
< |
int cp = TRADITIONAL_CUTOFF_POLICY; |
1004 |
< |
if (simParams_->haveCutoffPolicy()) { |
1005 |
< |
std::string myPolicy = simParams_->getCutoffPolicy(); |
937 |
> |
if (!myPolicy.empty()){ |
938 |
|
toUpper(myPolicy); |
939 |
|
if (myPolicy == "MIX") { |
940 |
|
cp = MIX_CUTOFF_POLICY; |
953 |
|
} |
954 |
|
} |
955 |
|
} |
956 |
< |
} |
956 |
> |
} |
957 |
> |
notifyFortranCutoffPolicy(&cp); |
958 |
|
|
959 |
< |
|
959 |
> |
// Check the Skin Thickness for neighborlists |
960 |
> |
double skin; |
961 |
|
if (simParams_->haveSkinThickness()) { |
962 |
< |
double skinThickness = simParams_->getSkinThickness(); |
963 |
< |
} |
962 |
> |
skin = simParams_->getSkinThickness(); |
963 |
> |
notifyFortranSkinThickness(&skin); |
964 |
> |
} |
965 |
> |
|
966 |
> |
// Check if the cutoff was set explicitly: |
967 |
> |
if (simParams_->haveCutoffRadius()) { |
968 |
> |
rcut_ = simParams_->getCutoffRadius(); |
969 |
> |
if (simParams_->haveSwitchingRadius()) { |
970 |
> |
rsw_ = simParams_->getSwitchingRadius(); |
971 |
> |
} else { |
972 |
> |
if (fInfo_.SIM_uses_Charges | |
973 |
> |
fInfo_.SIM_uses_Dipoles | |
974 |
> |
fInfo_.SIM_uses_RF) { |
975 |
> |
|
976 |
> |
rsw_ = 0.85 * rcut_; |
977 |
> |
sprintf(painCave.errMsg, |
978 |
> |
"SimCreator Warning: No value was set for the switchingRadius.\n" |
979 |
> |
"\tOOPSE will use a default value of 85\% of the cutoffRadius" |
980 |
> |
"\tswitchingRadius = %f. for this simulation\n", rsw_); |
981 |
> |
painCave.isFatal = 0; |
982 |
> |
simError(); |
983 |
> |
} else { |
984 |
> |
rsw_ = rcut_; |
985 |
> |
sprintf(painCave.errMsg, |
986 |
> |
"SimCreator Warning: No value was set for the switchingRadius.\n" |
987 |
> |
"\tOOPSE will use the same value as the cutoffRadius.\n" |
988 |
> |
"\tswitchingRadius = %f. for this simulation\n", rsw_); |
989 |
> |
painCave.isFatal = 0; |
990 |
> |
simError(); |
991 |
> |
} |
992 |
> |
|
993 |
> |
notifyFortranCutoffs(&rcut_, &rsw_); |
994 |
> |
|
995 |
> |
} else { |
996 |
> |
|
997 |
> |
// For electrostatic atoms, we'll assume a large safe value: |
998 |
> |
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
999 |
> |
sprintf(painCave.errMsg, |
1000 |
> |
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
1001 |
> |
"\tOOPSE will use a default value of 15.0 angstroms" |
1002 |
> |
"\tfor the cutoffRadius.\n"); |
1003 |
> |
painCave.isFatal = 0; |
1004 |
> |
simError(); |
1005 |
> |
rcut_ = 15.0; |
1006 |
> |
|
1007 |
> |
if (simParams_->haveElectrostaticSummationMethod()) { |
1008 |
> |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
1009 |
> |
toUpper(myMethod); |
1010 |
> |
if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") { |
1011 |
> |
if (simParams_->haveSwitchingRadius()){ |
1012 |
> |
sprintf(painCave.errMsg, |
1013 |
> |
"SimInfo Warning: A value was set for the switchingRadius\n" |
1014 |
> |
"\teven though the electrostaticSummationMethod was\n" |
1015 |
> |
"\tset to %s\n", myMethod.c_str()); |
1016 |
> |
painCave.isFatal = 1; |
1017 |
> |
simError(); |
1018 |
> |
} |
1019 |
> |
} |
1020 |
> |
} |
1021 |
> |
|
1022 |
> |
if (simParams_->haveSwitchingRadius()){ |
1023 |
> |
rsw_ = simParams_->getSwitchingRadius(); |
1024 |
> |
} else { |
1025 |
> |
sprintf(painCave.errMsg, |
1026 |
> |
"SimCreator Warning: No value was set for switchingRadius.\n" |
1027 |
> |
"\tOOPSE will use a default value of\n" |
1028 |
> |
"\t0.85 * cutoffRadius for the switchingRadius\n"); |
1029 |
> |
painCave.isFatal = 0; |
1030 |
> |
simError(); |
1031 |
> |
rsw_ = 0.85 * rcut_; |
1032 |
> |
} |
1033 |
> |
notifyFortranCutoffs(&rcut_, &rsw_); |
1034 |
> |
} else { |
1035 |
> |
// We didn't set rcut explicitly, and we don't have electrostatic atoms, so |
1036 |
> |
// We'll punt and let fortran figure out the cutoffs later. |
1037 |
> |
|
1038 |
> |
notifyFortranYouAreOnYourOwn(); |
1039 |
|
|
1040 |
< |
notifyFortranCutoffs(&rcut_, &rsw_, &rnblist, &cp); |
1041 |
< |
// also send cutoff notification to electrostatics |
1033 |
< |
setElectrostaticCutoffRadius(&rcut_, &rsw_); |
1040 |
> |
} |
1041 |
> |
} |
1042 |
|
} |
1043 |
|
|
1044 |
|
void SimInfo::setupElectrostaticSummationMethod( int isError ) { |
1073 |
|
} else { |
1074 |
|
// throw error |
1075 |
|
sprintf( painCave.errMsg, |
1076 |
< |
"SimInfo error: Unknown electrostaticSummationMethod. (Input file specified %s .)\n\telectrostaticSummationMethod must be one of: \"none\", \"shifted_potential\", \"shifted_force\", or \"reaction_field\".", myMethod.c_str() ); |
1076 |
> |
"SimInfo error: Unknown electrostaticSummationMethod.\n" |
1077 |
> |
"\t(Input file specified %s .)\n" |
1078 |
> |
"\telectrostaticSummationMethod must be one of: \"none\",\n" |
1079 |
> |
"\t\"shifted_potential\", \"shifted_force\", or \n" |
1080 |
> |
"\t\"reaction_field\".\n", myMethod.c_str() ); |
1081 |
|
painCave.isFatal = 1; |
1082 |
|
simError(); |
1083 |
|
} |
1098 |
|
if (!simParams_->haveDampingAlpha()) { |
1099 |
|
//throw error |
1100 |
|
sprintf( painCave.errMsg, |
1101 |
< |
"SimInfo warning: dampingAlpha was not specified in the input file. A default value of %f (1/ang) will be used.", alphaVal); |
1101 |
> |
"SimInfo warning: dampingAlpha was not specified in the input file.\n" |
1102 |
> |
"\tA default value of %f (1/ang) will be used.\n", alphaVal); |
1103 |
|
painCave.isFatal = 0; |
1104 |
|
simError(); |
1105 |
|
} |
1106 |
|
} else { |
1107 |
|
// throw error |
1108 |
|
sprintf( painCave.errMsg, |
1109 |
< |
"SimInfo error: Unknown electrostaticScreeningMethod. (Input file specified %s .)\n\telectrostaticScreeningMethod must be one of: \"undamped\" or \"damped\".", myScreen.c_str() ); |
1109 |
> |
"SimInfo error: Unknown electrostaticScreeningMethod.\n" |
1110 |
> |
"\t(Input file specified %s .)\n" |
1111 |
> |
"\telectrostaticScreeningMethod must be one of: \"undamped\"\n" |
1112 |
> |
"or \"damped\".\n", myScreen.c_str() ); |
1113 |
|
painCave.isFatal = 1; |
1114 |
|
simError(); |
1115 |
|
} |
1118 |
|
|
1119 |
|
// let's pass some summation method variables to fortran |
1120 |
|
setElectrostaticSummationMethod( &esm ); |
1121 |
+ |
setFortranElectrostaticMethod( &esm ); |
1122 |
|
setScreeningMethod( &sm ); |
1123 |
|
setDampingAlpha( &alphaVal ); |
1124 |
|
setReactionFieldDielectric( &dielectric ); |
1125 |
< |
initFortranFF( &esm, &errorOut ); |
1125 |
> |
initFortranFF( &errorOut ); |
1126 |
|
} |
1127 |
|
|
1128 |
|
void SimInfo::setupSwitchingFunction() { |