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") |
121 |
|
} |
122 |
|
|
123 |
|
Globals::~Globals() { |
124 |
< |
|
125 |
< |
|
124 |
> |
MemoryUtils::deletePointers(components_); |
125 |
> |
MemoryUtils::deletePointers(zconstraints_); |
126 |
|
} |
127 |
|
|
128 |
|
void Globals::validate() { |
130 |
|
|
131 |
|
CheckParameter(ForceField, isNotEmpty()); |
132 |
|
CheckParameter(TargetTemp, isPositive()); |
133 |
< |
CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) || isEqualIgnoreCase(std::string("NVT")) || isEqualIgnoreCase(std::string("NPTi")) || isEqualIgnoreCase(std::string("NPTf")) || isEqualIgnoreCase(std::string("NPTxyz")) ); |
133 |
> |
CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) || |
134 |
> |
isEqualIgnoreCase(std::string("NVT")) || |
135 |
> |
isEqualIgnoreCase(std::string("NPTi")) || |
136 |
> |
isEqualIgnoreCase(std::string("NPTf")) || |
137 |
> |
isEqualIgnoreCase(std::string("NPTxyz")) ); |
138 |
|
CheckParameter(Dt, isPositive()); |
139 |
|
CheckParameter(RunTime, isPositive()); |
140 |
|
CheckParameter(InitialConfig, isNotEmpty()); |
152 |
|
CheckParameter(ZconsTime, isPositive()); |
153 |
|
CheckParameter(ZconsTol, isPositive()); |
154 |
|
CheckParameter(Seed, isPositive()); |
155 |
< |
CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) || isEqualIgnoreCase(std::string("CG"))); |
155 |
> |
CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) || |
156 |
> |
isEqualIgnoreCase(std::string("CG"))); |
157 |
|
CheckParameter(MinimizerMaxIter, isPositive()); |
158 |
|
CheckParameter(MinimizerWriteFrq, isPositive()); |
159 |
|
CheckParameter(MinimizerStepSize, isPositive()); |
171 |
|
CheckParameter(ThermIntThetaSpringConst, isPositive()); |
172 |
|
CheckParameter(ThermIntOmegaSpringConst, isPositive()); |
173 |
|
CheckParameter(SurfaceTension, isPositive()); |
174 |
< |
CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase(std::string("NONE")) || isEqualIgnoreCase(std::string("SHIFTED_POTENTIAL")) || isEqualIgnoreCase(std::string("SHIFTED_FORCE")) || isEqualIgnoreCase(std::string("REACTION_FIELD"))); |
175 |
< |
CheckParameter(ElectrostaticScreeningMethod, isEqualIgnoreCase(std::string("UNDAMPED")) || isEqualIgnoreCase(std::string("DAMPED"))); |
176 |
< |
CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) || isEqualIgnoreCase(std::string("MAX")) || isEqualIgnoreCase(std::string("TRADITIONAL"))); |
177 |
< |
CheckParameter(SwitchingFunctionType, isEqualIgnoreCase(std::string("CUBIC")) || isEqualIgnoreCase(std::string("FIFTH_ORDER_POLYNOMIAL"))); |
174 |
> |
CheckParameter(ElectrostaticSummationMethod, |
175 |
> |
isEqualIgnoreCase(std::string("NONE")) || |
176 |
> |
isEqualIgnoreCase(std::string("SHIFTED_POTENTIAL")) || |
177 |
> |
isEqualIgnoreCase(std::string("SHIFTED_FORCE")) || |
178 |
> |
isEqualIgnoreCase(std::string("REACTION_FIELD"))); |
179 |
> |
CheckParameter(ElectrostaticScreeningMethod, |
180 |
> |
isEqualIgnoreCase(std::string("UNDAMPED")) || |
181 |
> |
isEqualIgnoreCase(std::string("DAMPED"))); |
182 |
> |
CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) || |
183 |
> |
isEqualIgnoreCase(std::string("MAX")) || |
184 |
> |
isEqualIgnoreCase(std::string("TRADITIONAL"))); |
185 |
> |
CheckParameter(SwitchingFunctionType, |
186 |
> |
isEqualIgnoreCase(std::string("CUBIC")) || |
187 |
> |
isEqualIgnoreCase(std::string("FIFTH_ORDER_POLYNOMIAL"))); |
188 |
|
//CheckParameter(StatFileFormat,); |
189 |
|
//CheckParameter(MixingRule,); |
190 |
|
CheckParameter(OrthoBoxTolerance, isPositive()); |
196 |
|
|
197 |
|
for(std::vector<Component*>::iterator i = components_.begin(); i != components_.end(); ++i) { |
198 |
|
if (!(*i)->findMoleculeStamp(moleculeStamps_)) { |
199 |
< |
std::cout << "Globals Error: can not find molecule stamp for component" << std::endl; |
199 |
> |
std::ostringstream oss; |
200 |
> |
oss << "Globals Error: can not find molecule stamp for component " << (*i)->getType() << std::endl; |
201 |
> |
throw OOPSEException(oss.str()); |
202 |
|
} |
203 |
|
} |
204 |
|
} |
222 |
|
moleculeStamps_.insert(std::map<std::string, MoleculeStamp*>::value_type(molStampName, molStamp)); |
223 |
|
ret = true; |
224 |
|
} else { |
225 |
< |
|
225 |
> |
std::ostringstream oss; |
226 |
> |
oss << "Globals Error: Molecule Stamp " << molStamp->getName() << "appears multiple times\n"; |
227 |
> |
throw OOPSEException(oss.str()); |
228 |
|
} |
229 |
|
return ret; |
230 |
|
} |