1 |
/* |
2 |
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
* |
4 |
* The University of Notre Dame grants you ("Licensee") a |
5 |
* non-exclusive, royalty free, license to use, modify and |
6 |
* redistribute this software in source and binary code form, provided |
7 |
* that the following conditions are met: |
8 |
* |
9 |
* 1. Acknowledgement of the program authors must be made in any |
10 |
* publication of scientific results based in part on use of the |
11 |
* program. An acceptable form of acknowledgement is citation of |
12 |
* the article in which the program was described (Matthew |
13 |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
* |
18 |
* 2. Redistributions of source code must retain the above copyright |
19 |
* notice, this list of conditions and the following disclaimer. |
20 |
* |
21 |
* 3. Redistributions in binary form must reproduce the above copyright |
22 |
* notice, this list of conditions and the following disclaimer in the |
23 |
* documentation and/or other materials provided with the |
24 |
* distribution. |
25 |
* |
26 |
* This software is provided "AS IS," without a warranty of any |
27 |
* kind. All express or implied conditions, representations and |
28 |
* warranties, including any implied warranty of merchantability, |
29 |
* fitness for a particular purpose or non-infringement, are hereby |
30 |
* excluded. The University of Notre Dame and its licensors shall not |
31 |
* be liable for any damages suffered by licensee as a result of |
32 |
* using, modifying or distributing the software or its |
33 |
* derivatives. In no event will the University of Notre Dame or its |
34 |
* licensors be liable for any lost revenue, profit or data, or for |
35 |
* direct, indirect, special, consequential, incidental or punitive |
36 |
* damages, however caused and regardless of the theory of liability, |
37 |
* arising out of the use of or inability to use software, even if the |
38 |
* University of Notre Dame has been advised of the possibility of |
39 |
* such damages. |
40 |
*/ |
41 |
|
42 |
#include <stdlib.h> |
43 |
#include <stdio.h> |
44 |
#include <string.h> |
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 |
|
52 |
namespace oopse { |
53 |
Globals::Globals() { |
54 |
DefineParameter(ForceField, "forceField") |
55 |
|
56 |
DefineOptionalParameter(TargetTemp, "targetTemp"); |
57 |
DefineOptionalParameter(Ensemble, "ensemble"); |
58 |
DefineOptionalParameter(Dt, "dt"); |
59 |
DefineOptionalParameter(RunTime, "runTime"); |
60 |
DefineOptionalParameter(InitialConfig, "initialConfig"); |
61 |
DefineOptionalParameter(FinalConfig, "finalConfig"); |
62 |
DefineOptionalParameter(SampleTime, "sampleTime"); |
63 |
DefineOptionalParameter(ResetTime, "resetTime"); |
64 |
DefineOptionalParameter(StatusTime, "statusTime"); |
65 |
DefineOptionalParameter(CutoffRadius, "cutoffRadius"); |
66 |
DefineOptionalParameter(SwitchingRadius, "switchingRadius"); |
67 |
DefineOptionalParameter(Dielectric, "dielectric"); |
68 |
DefineOptionalParameter(TempSet, "tempSet"); |
69 |
DefineOptionalParameter(ThermalTime, "thermalTime"); |
70 |
DefineOptionalParameter(TargetPressure, "targetPressure"); |
71 |
DefineOptionalParameter(TauThermostat, "tauThermostat"); |
72 |
DefineOptionalParameter(TauBarostat, "tauBarostat"); |
73 |
DefineOptionalParameter(ZconsTime, "zconsTime"); |
74 |
DefineOptionalParameter(ZconsTol, "zconsTol"); |
75 |
DefineOptionalParameter(ZconsForcePolicy, "zconsForcePolicy"); |
76 |
DefineOptionalParameter(Seed, "seed"); |
77 |
DefineOptionalParameter(Minimizer, "minimizer"); |
78 |
DefineOptionalParameter(MinimizerMaxIter,"minimizerMaxIter"); |
79 |
DefineOptionalParameter(MinimizerWriteFrq, "minimizerWriteFrq"); |
80 |
DefineOptionalParameter(MinimizerStepSize, "minimizerStepSize"); |
81 |
DefineOptionalParameter(MinimizerFTol, "minimizerFTol"); |
82 |
DefineOptionalParameter(MinimizerGTol, "minimizerGTol"); |
83 |
DefineOptionalParameter(MinimizerLSTol, "minimizerLSTol"); |
84 |
DefineOptionalParameter(MinimizerLSMaxIter, "minimizerLSMaxIter"); |
85 |
DefineOptionalParameter(ZconsGap, "zconsGap"); |
86 |
DefineOptionalParameter(ZconsFixtime, "zconsFixtime"); |
87 |
DefineOptionalParameter(ZconsUsingSMD, "zconsUsingSMD"); |
88 |
DefineOptionalParameter(ThermodynamicIntegrationLambda, "thermodynamicIntegrationLambda"); |
89 |
DefineOptionalParameter(ThermodynamicIntegrationK, "thermodynamicIntegrationK"); |
90 |
DefineOptionalParameter(ForceFieldVariant, "forceFieldVariant"); |
91 |
DefineOptionalParameter(ForceFieldFileName, "forceFieldFileName"); |
92 |
DefineOptionalParameter(ThermIntDistSpringConst, "thermIntDistSpringConst"); |
93 |
DefineOptionalParameter(ThermIntThetaSpringConst, "thermIntThetaSpringConst"); |
94 |
DefineOptionalParameter(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst"); |
95 |
DefineOptionalParameter(SurfaceTension, "surfaceTension"); |
96 |
DefineOptionalParameter(PrintPressureTensor, "printPressureTensor"); |
97 |
DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod"); |
98 |
DefineOptionalParameter(ElectrostaticScreeningMethod, "electrostaticScreeningMethod"); |
99 |
DefineOptionalParameter(CutoffPolicy, "cutoffPolicy"); |
100 |
DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType"); |
101 |
DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard"); |
102 |
DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true); |
103 |
DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false); |
104 |
DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState, "useInitialExtendedSystemState", false); |
105 |
DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance, "orthoBoxTolerance", 1E-6); |
106 |
DefineOptionalParameterWithDefaultValue(UseSolidThermInt, "useSolidThermInt", false); |
107 |
DefineOptionalParameterWithDefaultValue(UseLiquidThermInt, "useLiquidThermInt", false); |
108 |
DefineOptionalParameterWithDefaultValue(ThermIntDistSpringConst, "thermIntDistSpringConst", 6.0); |
109 |
DefineOptionalParameterWithDefaultValue(ThermIntThetaSpringConst, "thermIntThetaSpringConst", 7.5); |
110 |
DefineOptionalParameterWithDefaultValue(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst", 13.5); |
111 |
DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 0.2); |
112 |
DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0); |
113 |
DefineOptionalParameterWithDefaultValue(OutputForceVector, "outputForceVector", 0); |
114 |
DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0); |
115 |
DefineOptionalParameterWithDefaultValue(StatFileFormat, "statFileFormat", "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY"); |
116 |
|
117 |
|
118 |
deprecatedKeywords_.insert("nComponents"); |
119 |
deprecatedKeywords_.insert("nZconstraints"); |
120 |
|
121 |
} |
122 |
|
123 |
Globals::~Globals() { |
124 |
MemoryUtils::deletePointers(components_); |
125 |
MemoryUtils::deletePointers(zconstraints_); |
126 |
} |
127 |
|
128 |
void Globals::validate() { |
129 |
DataHolder::validate(); |
130 |
|
131 |
CheckParameter(ForceField, isNotEmpty()); |
132 |
CheckParameter(TargetTemp, isPositive()); |
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()); |
141 |
CheckParameter(FinalConfig, isNotEmpty()); |
142 |
CheckParameter(SampleTime, isNonNegative()); |
143 |
CheckParameter(ResetTime, isNonNegative()); |
144 |
CheckParameter(StatusTime, isNonNegative()); |
145 |
CheckParameter(CutoffRadius, isPositive()); |
146 |
CheckParameter(SwitchingRadius, isNonNegative()); |
147 |
CheckParameter(Dielectric, isPositive()); |
148 |
CheckParameter(ThermalTime, isNonNegative()); |
149 |
CheckParameter(TargetPressure, isPositive()); |
150 |
CheckParameter(TauThermostat, isPositive()); |
151 |
CheckParameter(TauBarostat, isPositive()); |
152 |
CheckParameter(ZconsTime, isPositive()); |
153 |
CheckParameter(ZconsTol, isPositive()); |
154 |
CheckParameter(Seed, isPositive()); |
155 |
CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) || |
156 |
isEqualIgnoreCase(std::string("CG"))); |
157 |
CheckParameter(MinimizerMaxIter, isPositive()); |
158 |
CheckParameter(MinimizerWriteFrq, isPositive()); |
159 |
CheckParameter(MinimizerStepSize, isPositive()); |
160 |
CheckParameter(MinimizerFTol, isPositive()); |
161 |
CheckParameter(MinimizerGTol, isPositive()); |
162 |
CheckParameter(MinimizerLSTol, isPositive()); |
163 |
CheckParameter(MinimizerLSMaxIter, isPositive()); |
164 |
CheckParameter(ZconsGap, isPositive()); |
165 |
CheckParameter(ZconsFixtime, isPositive()); |
166 |
CheckParameter(ThermodynamicIntegrationLambda, isPositive()); |
167 |
CheckParameter(ThermodynamicIntegrationK, isPositive()); |
168 |
CheckParameter(ForceFieldVariant, isNotEmpty()); |
169 |
CheckParameter(ForceFieldFileName, isNotEmpty()); |
170 |
CheckParameter(ThermIntDistSpringConst, isPositive()); |
171 |
CheckParameter(ThermIntThetaSpringConst, isPositive()); |
172 |
CheckParameter(ThermIntOmegaSpringConst, isPositive()); |
173 |
CheckParameter(SurfaceTension, isPositive()); |
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()); |
191 |
CheckParameter(ThermIntDistSpringConst, isPositive()); |
192 |
CheckParameter(ThermIntThetaSpringConst, isPositive()); |
193 |
CheckParameter(ThermIntOmegaSpringConst, isPositive()); |
194 |
CheckParameter(DampingAlpha,isNonNegative()); |
195 |
CheckParameter(SkinThickness, isPositive()); |
196 |
|
197 |
for(std::vector<Component*>::iterator i = components_.begin(); i != components_.end(); ++i) { |
198 |
if (!(*i)->findMoleculeStamp(moleculeStamps_)) { |
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 |
} |
205 |
|
206 |
bool Globals::addComponent(Component* comp) { |
207 |
components_.push_back(comp); |
208 |
return true; |
209 |
} |
210 |
|
211 |
bool Globals::addZConsStamp(ZConsStamp* zcons) { |
212 |
zconstraints_.push_back(zcons); |
213 |
return true; |
214 |
} |
215 |
|
216 |
bool Globals::addMoleculeStamp(MoleculeStamp* molStamp) { |
217 |
std::string molStampName = molStamp->getName(); |
218 |
std::map<std::string, MoleculeStamp*>::iterator i; |
219 |
bool ret = false; |
220 |
i = moleculeStamps_.find(molStampName); |
221 |
if (i == moleculeStamps_.end()) { |
222 |
moleculeStamps_.insert(std::map<std::string, MoleculeStamp*>::value_type(molStampName, molStamp)); |
223 |
ret = true; |
224 |
} else { |
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 |
} |
231 |
|
232 |
|
233 |
} |