45 |
|
#include <string> |
46 |
|
|
47 |
|
#include "io/Globals.hpp" |
48 |
+ |
#include "io/ParamConstraint.hpp" |
49 |
+ |
#include "utils/MemoryUtils.hpp" |
50 |
|
#include "utils/simError.h" |
51 |
|
|
50 |
– |
#include "io/ParamConstraint.hpp" |
51 |
– |
|
52 |
|
namespace oopse { |
53 |
|
Globals::Globals() { |
54 |
|
DefineParameter(ForceField, "forceField") |
98 |
|
DefineOptionalParameter(ElectrostaticScreeningMethod, "electrostaticScreeningMethod"); |
99 |
|
DefineOptionalParameter(CutoffPolicy, "cutoffPolicy"); |
100 |
|
DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType"); |
101 |
– |
DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard"); |
101 |
|
DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true); |
102 |
|
DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false); |
103 |
|
DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState, "useInitialExtendedSystemState", false); |
120 |
|
} |
121 |
|
|
122 |
|
Globals::~Globals() { |
123 |
< |
|
124 |
< |
|
123 |
> |
MemoryUtils::deletePointers(components_); |
124 |
> |
MemoryUtils::deletePointers(zconstraints_); |
125 |
|
} |
126 |
|
|
127 |
|
void Globals::validate() { |
129 |
|
|
130 |
|
CheckParameter(ForceField, isNotEmpty()); |
131 |
|
CheckParameter(TargetTemp, isPositive()); |
132 |
< |
CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) || isEqualIgnoreCase(std::string("NVT")) || isEqualIgnoreCase(std::string("NPTi")) || isEqualIgnoreCase(std::string("NPTf")) || isEqualIgnoreCase(std::string("NPTxyz")) ); |
132 |
> |
CheckParameter(Ensemble, isEqualIgnoreCase("NVE") || isEqualIgnoreCase("NVT") || isEqualIgnoreCase("NPTi") || isEqualIgnoreCase("NPTf") || isEqualIgnoreCase("NPTxyz") || isEqualIgnoreCase("NPAT") ); |
133 |
|
CheckParameter(Dt, isPositive()); |
134 |
|
CheckParameter(RunTime, isPositive()); |
135 |
|
CheckParameter(InitialConfig, isNotEmpty()); |
147 |
|
CheckParameter(ZconsTime, isPositive()); |
148 |
|
CheckParameter(ZconsTol, isPositive()); |
149 |
|
CheckParameter(Seed, isPositive()); |
150 |
< |
CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) || isEqualIgnoreCase(std::string("CG"))); |
150 |
> |
CheckParameter(Minimizer, isEqualIgnoreCase("SD") || isEqualIgnoreCase("CG")); |
151 |
|
CheckParameter(MinimizerMaxIter, isPositive()); |
152 |
|
CheckParameter(MinimizerWriteFrq, isPositive()); |
153 |
|
CheckParameter(MinimizerStepSize, isPositive()); |
165 |
|
CheckParameter(ThermIntThetaSpringConst, isPositive()); |
166 |
|
CheckParameter(ThermIntOmegaSpringConst, isPositive()); |
167 |
|
CheckParameter(SurfaceTension, isPositive()); |
168 |
< |
CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase(std::string("NONE")) || isEqualIgnoreCase(std::string("SHIFTED_POTENTIAL")) || isEqualIgnoreCase(std::string("SHIFTED_FORCE")) || isEqualIgnoreCase(std::string("REACTION_FIELD"))); |
169 |
< |
CheckParameter(ElectrostaticScreeningMethod, isEqualIgnoreCase(std::string("UNDAMPED")) || isEqualIgnoreCase(std::string("DAMPED"))); |
170 |
< |
CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) || isEqualIgnoreCase(std::string("MAX")) || isEqualIgnoreCase(std::string("TRADITIONAL"))); |
171 |
< |
CheckParameter(SwitchingFunctionType, isEqualIgnoreCase(std::string("CUBIC")) || isEqualIgnoreCase(std::string("FIFTH_ORDER_POLYNOMIAL"))); |
168 |
> |
CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase("NONE") || isEqualIgnoreCase("SHIFTED_POTENTIAL") || isEqualIgnoreCase("SHIFTED_FORCE") || isEqualIgnoreCase("REACTION_FIELD")); |
169 |
> |
CheckParameter(ElectrostaticScreeningMethod, isEqualIgnoreCase("UNDAMPED") || isEqualIgnoreCase("DAMPED")); |
170 |
> |
CheckParameter(CutoffPolicy, isEqualIgnoreCase("MIX") || isEqualIgnoreCase("MAX") || isEqualIgnoreCase("TRADITIONAL")); |
171 |
> |
CheckParameter(SwitchingFunctionType, isEqualIgnoreCase("CUBIC") || isEqualIgnoreCase("FIFTH_ORDER_POLYNOMIAL")); |
172 |
|
//CheckParameter(StatFileFormat,); |
174 |
– |
//CheckParameter(MixingRule,); |
173 |
|
CheckParameter(OrthoBoxTolerance, isPositive()); |
174 |
|
CheckParameter(ThermIntDistSpringConst, isPositive()); |
175 |
|
CheckParameter(ThermIntThetaSpringConst, isPositive()); |
179 |
|
|
180 |
|
for(std::vector<Component*>::iterator i = components_.begin(); i != components_.end(); ++i) { |
181 |
|
if (!(*i)->findMoleculeStamp(moleculeStamps_)) { |
182 |
< |
std::cout << "Globals Error: can not find molecule stamp for component" << std::endl; |
182 |
> |
std::ostringstream oss; |
183 |
> |
oss << "Globals Error: can not find molecule stamp for component " << (*i)->getType() << std::endl; |
184 |
> |
throw OOPSEException(oss.str()); |
185 |
|
} |
186 |
|
} |
187 |
|
} |
205 |
|
moleculeStamps_.insert(std::map<std::string, MoleculeStamp*>::value_type(molStampName, molStamp)); |
206 |
|
ret = true; |
207 |
|
} else { |
208 |
< |
|
208 |
> |
std::ostringstream oss; |
209 |
> |
oss << "Globals Error: Molecule Stamp " << molStamp->getName() << "appears multiple times\n"; |
210 |
> |
throw OOPSEException(oss.str()); |
211 |
|
} |
212 |
|
return ret; |
213 |
|
} |