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" |
80 |
|
return result; |
81 |
|
} |
82 |
|
|
83 |
< |
SimInfo::SimInfo(MakeStamps* stamps, std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
84 |
< |
ForceField* ff, Globals* simParams) : |
86 |
< |
stamps_(stamps), forceField_(ff), simParams_(simParams), |
83 |
> |
SimInfo::SimInfo(ForceField* ff, Globals* simParams) : |
84 |
> |
forceField_(ff), simParams_(simParams), |
85 |
|
ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
86 |
|
nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), |
87 |
|
nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
89 |
|
nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), |
90 |
|
sman_(NULL), fortranInitialized_(false) { |
91 |
|
|
94 |
– |
|
95 |
– |
std::vector<std::pair<MoleculeStamp*, int> >::iterator i; |
92 |
|
MoleculeStamp* molStamp; |
93 |
|
int nMolWithSameStamp; |
94 |
|
int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
96 |
|
CutoffGroupStamp* cgStamp; |
97 |
|
RigidBodyStamp* rbStamp; |
98 |
|
int nRigidAtoms = 0; |
99 |
< |
|
100 |
< |
for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) { |
101 |
< |
molStamp = i->first; |
102 |
< |
nMolWithSameStamp = i->second; |
99 |
> |
std::vector<Component*> components = simParams->getComponents(); |
100 |
> |
|
101 |
> |
for (std::vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) { |
102 |
> |
molStamp = (*i)->getMoleculeStamp(); |
103 |
> |
nMolWithSameStamp = (*i)->getNMol(); |
104 |
|
|
105 |
|
addMoleculeStamp(molStamp, nMolWithSameStamp); |
106 |
|
|
107 |
|
//calculate atoms in molecules |
108 |
|
nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp; |
109 |
|
|
113 |
– |
|
110 |
|
//calculate atoms in cutoff groups |
111 |
|
int nAtomsInGroups = 0; |
112 |
|
int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); |
113 |
|
|
114 |
|
for (int j=0; j < nCutoffGroupsInStamp; j++) { |
115 |
< |
cgStamp = molStamp->getCutoffGroup(j); |
115 |
> |
cgStamp = molStamp->getCutoffGroupStamp(j); |
116 |
|
nAtomsInGroups += cgStamp->getNMembers(); |
117 |
|
} |
118 |
|
|
125 |
|
int nRigidBodiesInStamp = molStamp->getNRigidBodies(); |
126 |
|
|
127 |
|
for (int j=0; j < nRigidBodiesInStamp; j++) { |
128 |
< |
rbStamp = molStamp->getRigidBody(j); |
128 |
> |
rbStamp = molStamp->getRigidBodyStamp(j); |
129 |
|
nAtomsInRigidBodies += rbStamp->getNMembers(); |
130 |
|
} |
131 |
|
|
164 |
|
} |
165 |
|
molecules_.clear(); |
166 |
|
|
171 |
– |
delete stamps_; |
167 |
|
delete sman_; |
168 |
|
delete simParams_; |
169 |
|
delete forceField_; |
270 |
|
} |
271 |
|
} |
272 |
|
|
273 |
< |
}//end for (integrableObject) |
274 |
< |
}// end for (mol) |
273 |
> |
} |
274 |
> |
} |
275 |
|
|
276 |
|
// n_constraints is local, so subtract them on each processor |
277 |
|
ndf_local -= nConstraints_; |
915 |
|
|
916 |
|
|
917 |
|
} |
923 |
– |
|
924 |
– |
#endif |
925 |
– |
|
926 |
– |
double SimInfo::calcMaxCutoffRadius() { |
927 |
– |
|
928 |
– |
|
929 |
– |
std::set<AtomType*> atomTypes; |
930 |
– |
std::set<AtomType*>::iterator i; |
931 |
– |
std::vector<double> cutoffRadius; |
932 |
– |
|
933 |
– |
//get the unique atom types |
934 |
– |
atomTypes = getUniqueAtomTypes(); |
918 |
|
|
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 |
919 |
|
#endif |
920 |
|
|
921 |
< |
return maxCutoffRadius; |
947 |
< |
} |
948 |
< |
|
949 |
< |
void SimInfo::getCutoff(double& rcut, double& rsw) { |
921 |
> |
void SimInfo::setupCutoff() { |
922 |
|
|
923 |
< |
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 |
< |
|
994 |
< |
} |
995 |
< |
} |
996 |
< |
|
997 |
< |
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 |
< |
|
923 |
> |
// Check the cutoff policy |
924 |
|
int cp = TRADITIONAL_CUTOFF_POLICY; |
925 |
|
if (simParams_->haveCutoffPolicy()) { |
926 |
|
std::string myPolicy = simParams_->getCutoffPolicy(); |
942 |
|
} |
943 |
|
} |
944 |
|
} |
945 |
< |
} |
945 |
> |
} |
946 |
> |
notifyFortranCutoffPolicy(&cp); |
947 |
|
|
948 |
< |
|
948 |
> |
// Check the Skin Thickness for neighborlists |
949 |
> |
double skin; |
950 |
|
if (simParams_->haveSkinThickness()) { |
951 |
< |
double skinThickness = simParams_->getSkinThickness(); |
952 |
< |
} |
951 |
> |
skin = simParams_->getSkinThickness(); |
952 |
> |
notifyFortranSkinThickness(&skin); |
953 |
> |
} |
954 |
> |
|
955 |
> |
// Check if the cutoff was set explicitly: |
956 |
> |
if (simParams_->haveCutoffRadius()) { |
957 |
> |
rcut_ = simParams_->getCutoffRadius(); |
958 |
> |
if (simParams_->haveSwitchingRadius()) { |
959 |
> |
rsw_ = simParams_->getSwitchingRadius(); |
960 |
> |
} else { |
961 |
> |
rsw_ = rcut_; |
962 |
> |
} |
963 |
> |
notifyFortranCutoffs(&rcut_, &rsw_); |
964 |
> |
|
965 |
> |
} else { |
966 |
> |
|
967 |
> |
// For electrostatic atoms, we'll assume a large safe value: |
968 |
> |
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
969 |
> |
sprintf(painCave.errMsg, |
970 |
> |
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
971 |
> |
"\tOOPSE will use a default value of 15.0 angstroms" |
972 |
> |
"\tfor the cutoffRadius.\n"); |
973 |
> |
painCave.isFatal = 0; |
974 |
> |
simError(); |
975 |
> |
rcut_ = 15.0; |
976 |
> |
|
977 |
> |
if (simParams_->haveElectrostaticSummationMethod()) { |
978 |
> |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
979 |
> |
toUpper(myMethod); |
980 |
> |
if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") { |
981 |
> |
if (simParams_->haveSwitchingRadius()){ |
982 |
> |
sprintf(painCave.errMsg, |
983 |
> |
"SimInfo Warning: A value was set for the switchingRadius\n" |
984 |
> |
"\teven though the electrostaticSummationMethod was\n" |
985 |
> |
"\tset to %s\n", myMethod.c_str()); |
986 |
> |
painCave.isFatal = 1; |
987 |
> |
simError(); |
988 |
> |
} |
989 |
> |
} |
990 |
> |
} |
991 |
> |
|
992 |
> |
if (simParams_->haveSwitchingRadius()){ |
993 |
> |
rsw_ = simParams_->getSwitchingRadius(); |
994 |
> |
} else { |
995 |
> |
sprintf(painCave.errMsg, |
996 |
> |
"SimCreator Warning: No value was set for switchingRadius.\n" |
997 |
> |
"\tOOPSE will use a default value of\n" |
998 |
> |
"\t0.85 * cutoffRadius for the switchingRadius\n"); |
999 |
> |
painCave.isFatal = 0; |
1000 |
> |
simError(); |
1001 |
> |
rsw_ = 0.85 * rcut_; |
1002 |
> |
} |
1003 |
> |
notifyFortranCutoffs(&rcut_, &rsw_); |
1004 |
> |
} else { |
1005 |
> |
// We didn't set rcut explicitly, and we don't have electrostatic atoms, so |
1006 |
> |
// We'll punt and let fortran figure out the cutoffs later. |
1007 |
> |
|
1008 |
> |
notifyFortranYouAreOnYourOwn(); |
1009 |
|
|
1010 |
< |
notifyFortranCutoffs(&rcut_, &rsw_, &rnblist, &cp); |
1011 |
< |
// also send cutoff notification to electrostatics |
1033 |
< |
setElectrostaticCutoffRadius(&rcut_, &rsw_); |
1010 |
> |
} |
1011 |
> |
} |
1012 |
|
} |
1013 |
|
|
1014 |
|
void SimInfo::setupElectrostaticSummationMethod( int isError ) { |
1043 |
|
} else { |
1044 |
|
// throw error |
1045 |
|
sprintf( painCave.errMsg, |
1046 |
< |
"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() ); |
1046 |
> |
"SimInfo error: Unknown electrostaticSummationMethod.\n" |
1047 |
> |
"\t(Input file specified %s .)\n" |
1048 |
> |
"\telectrostaticSummationMethod must be one of: \"none\",\n" |
1049 |
> |
"\t\"shifted_potential\", \"shifted_force\", or \n" |
1050 |
> |
"\t\"reaction_field\".\n", myMethod.c_str() ); |
1051 |
|
painCave.isFatal = 1; |
1052 |
|
simError(); |
1053 |
|
} |
1068 |
|
if (!simParams_->haveDampingAlpha()) { |
1069 |
|
//throw error |
1070 |
|
sprintf( painCave.errMsg, |
1071 |
< |
"SimInfo warning: dampingAlpha was not specified in the input file. A default value of %f (1/ang) will be used.", alphaVal); |
1071 |
> |
"SimInfo warning: dampingAlpha was not specified in the input file.\n" |
1072 |
> |
"\tA default value of %f (1/ang) will be used.\n", alphaVal); |
1073 |
|
painCave.isFatal = 0; |
1074 |
|
simError(); |
1075 |
|
} |
1076 |
|
} else { |
1077 |
|
// throw error |
1078 |
|
sprintf( painCave.errMsg, |
1079 |
< |
"SimInfo error: Unknown electrostaticScreeningMethod. (Input file specified %s .)\n\telectrostaticScreeningMethod must be one of: \"undamped\" or \"damped\".", myScreen.c_str() ); |
1079 |
> |
"SimInfo error: Unknown electrostaticScreeningMethod.\n" |
1080 |
> |
"\t(Input file specified %s .)\n" |
1081 |
> |
"\telectrostaticScreeningMethod must be one of: \"undamped\"\n" |
1082 |
> |
"or \"damped\".\n", myScreen.c_str() ); |
1083 |
|
painCave.isFatal = 1; |
1084 |
|
simError(); |
1085 |
|
} |
1088 |
|
|
1089 |
|
// let's pass some summation method variables to fortran |
1090 |
|
setElectrostaticSummationMethod( &esm ); |
1091 |
+ |
notifyFortranElectrostaticMethod( &esm ); |
1092 |
|
setScreeningMethod( &sm ); |
1093 |
|
setDampingAlpha( &alphaVal ); |
1094 |
|
setReactionFieldDielectric( &dielectric ); |
1095 |
< |
initFortranFF( &esm, &errorOut ); |
1095 |
> |
initFortranFF( &errorOut ); |
1096 |
|
} |
1097 |
|
|
1098 |
|
void SimInfo::setupSwitchingFunction() { |