1 |
gezelter |
404 |
/* |
2 |
gezelter |
246 |
* 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 |
gezelter |
2 |
#include <stdlib.h> |
43 |
|
|
#include <stdio.h> |
44 |
|
|
#include <string.h> |
45 |
tim |
665 |
#include <string> |
46 |
gezelter |
2 |
|
47 |
tim |
3 |
#include "io/Globals.hpp" |
48 |
tim |
816 |
#include "io/ParamConstraint.hpp" |
49 |
|
|
#include "utils/MemoryUtils.hpp" |
50 |
tim |
3 |
#include "utils/simError.h" |
51 |
gezelter |
2 |
|
52 |
tim |
770 |
namespace oopse { |
53 |
|
|
Globals::Globals() { |
54 |
tim |
665 |
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 |
chrisfen |
716 |
DefineOptionalParameter(ElectrostaticScreeningMethod, "electrostaticScreeningMethod"); |
99 |
tim |
665 |
DefineOptionalParameter(CutoffPolicy, "cutoffPolicy"); |
100 |
chrisfen |
726 |
DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType"); |
101 |
tim |
665 |
DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true); |
102 |
|
|
DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false); |
103 |
|
|
DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState, "useInitialExtendedSystemState", false); |
104 |
|
|
DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance, "orthoBoxTolerance", 1E-6); |
105 |
|
|
DefineOptionalParameterWithDefaultValue(UseSolidThermInt, "useSolidThermInt", false); |
106 |
|
|
DefineOptionalParameterWithDefaultValue(UseLiquidThermInt, "useLiquidThermInt", false); |
107 |
chrisfen |
666 |
DefineOptionalParameterWithDefaultValue(ThermIntDistSpringConst, "thermIntDistSpringConst", 6.0); |
108 |
|
|
DefineOptionalParameterWithDefaultValue(ThermIntThetaSpringConst, "thermIntThetaSpringConst", 7.5); |
109 |
|
|
DefineOptionalParameterWithDefaultValue(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst", 13.5); |
110 |
chrisfen |
716 |
DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 0.2); |
111 |
tim |
665 |
DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0); |
112 |
chrisfen |
726 |
DefineOptionalParameterWithDefaultValue(OutputForceVector, "outputForceVector", 0); |
113 |
tim |
665 |
DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0); |
114 |
tim |
681 |
DefineOptionalParameterWithDefaultValue(StatFileFormat, "statFileFormat", "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY"); |
115 |
|
|
|
116 |
gezelter |
2 |
|
117 |
tim |
770 |
deprecatedKeywords_.insert("nComponents"); |
118 |
|
|
deprecatedKeywords_.insert("nZconstraints"); |
119 |
gezelter |
2 |
|
120 |
|
|
} |
121 |
|
|
|
122 |
tim |
770 |
Globals::~Globals() { |
123 |
tim |
816 |
MemoryUtils::deletePointers(components_); |
124 |
|
|
MemoryUtils::deletePointers(zconstraints_); |
125 |
gezelter |
2 |
} |
126 |
|
|
|
127 |
tim |
770 |
void Globals::validate() { |
128 |
|
|
DataHolder::validate(); |
129 |
gezelter |
2 |
|
130 |
tim |
672 |
CheckParameter(ForceField, isNotEmpty()); |
131 |
|
|
CheckParameter(TargetTemp, isPositive()); |
132 |
chuckv |
866 |
CheckParameter(Ensemble, isEqualIgnoreCase("NVE") || isEqualIgnoreCase("NVT") || isEqualIgnoreCase("NPTi") || isEqualIgnoreCase("NPTf") || isEqualIgnoreCase("NPTxyz") || isEqualIgnoreCase("NPAT") ); |
133 |
tim |
672 |
CheckParameter(Dt, isPositive()); |
134 |
|
|
CheckParameter(RunTime, isPositive()); |
135 |
|
|
CheckParameter(InitialConfig, isNotEmpty()); |
136 |
|
|
CheckParameter(FinalConfig, isNotEmpty()); |
137 |
|
|
CheckParameter(SampleTime, isNonNegative()); |
138 |
|
|
CheckParameter(ResetTime, isNonNegative()); |
139 |
|
|
CheckParameter(StatusTime, isNonNegative()); |
140 |
|
|
CheckParameter(CutoffRadius, isPositive()); |
141 |
|
|
CheckParameter(SwitchingRadius, isNonNegative()); |
142 |
|
|
CheckParameter(Dielectric, isPositive()); |
143 |
|
|
CheckParameter(ThermalTime, isNonNegative()); |
144 |
|
|
CheckParameter(TargetPressure, isPositive()); |
145 |
|
|
CheckParameter(TauThermostat, isPositive()); |
146 |
|
|
CheckParameter(TauBarostat, isPositive()); |
147 |
|
|
CheckParameter(ZconsTime, isPositive()); |
148 |
|
|
CheckParameter(ZconsTol, isPositive()); |
149 |
|
|
CheckParameter(Seed, isPositive()); |
150 |
tim |
850 |
CheckParameter(Minimizer, isEqualIgnoreCase("SD") || isEqualIgnoreCase("CG")); |
151 |
tim |
672 |
CheckParameter(MinimizerMaxIter, isPositive()); |
152 |
|
|
CheckParameter(MinimizerWriteFrq, isPositive()); |
153 |
|
|
CheckParameter(MinimizerStepSize, isPositive()); |
154 |
|
|
CheckParameter(MinimizerFTol, isPositive()); |
155 |
|
|
CheckParameter(MinimizerGTol, isPositive()); |
156 |
|
|
CheckParameter(MinimizerLSTol, isPositive()); |
157 |
|
|
CheckParameter(MinimizerLSMaxIter, isPositive()); |
158 |
|
|
CheckParameter(ZconsGap, isPositive()); |
159 |
|
|
CheckParameter(ZconsFixtime, isPositive()); |
160 |
|
|
CheckParameter(ThermodynamicIntegrationLambda, isPositive()); |
161 |
|
|
CheckParameter(ThermodynamicIntegrationK, isPositive()); |
162 |
|
|
CheckParameter(ForceFieldVariant, isNotEmpty()); |
163 |
|
|
CheckParameter(ForceFieldFileName, isNotEmpty()); |
164 |
|
|
CheckParameter(ThermIntDistSpringConst, isPositive()); |
165 |
|
|
CheckParameter(ThermIntThetaSpringConst, isPositive()); |
166 |
|
|
CheckParameter(ThermIntOmegaSpringConst, isPositive()); |
167 |
|
|
CheckParameter(SurfaceTension, isPositive()); |
168 |
tim |
850 |
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 |
tim |
672 |
//CheckParameter(StatFileFormat,); |
173 |
|
|
CheckParameter(OrthoBoxTolerance, isPositive()); |
174 |
|
|
CheckParameter(ThermIntDistSpringConst, isPositive()); |
175 |
|
|
CheckParameter(ThermIntThetaSpringConst, isPositive()); |
176 |
|
|
CheckParameter(ThermIntOmegaSpringConst, isPositive()); |
177 |
chrisfen |
716 |
CheckParameter(DampingAlpha,isNonNegative()); |
178 |
tim |
672 |
CheckParameter(SkinThickness, isPositive()); |
179 |
gezelter |
2 |
|
180 |
tim |
770 |
for(std::vector<Component*>::iterator i = components_.begin(); i != components_.end(); ++i) { |
181 |
|
|
if (!(*i)->findMoleculeStamp(moleculeStamps_)) { |
182 |
tim |
845 |
std::ostringstream oss; |
183 |
|
|
oss << "Globals Error: can not find molecule stamp for component " << (*i)->getType() << std::endl; |
184 |
|
|
throw OOPSEException(oss.str()); |
185 |
tim |
770 |
} |
186 |
|
|
} |
187 |
|
|
} |
188 |
|
|
|
189 |
|
|
bool Globals::addComponent(Component* comp) { |
190 |
|
|
components_.push_back(comp); |
191 |
|
|
return true; |
192 |
|
|
} |
193 |
gezelter |
2 |
|
194 |
tim |
770 |
bool Globals::addZConsStamp(ZConsStamp* zcons) { |
195 |
|
|
zconstraints_.push_back(zcons); |
196 |
|
|
return true; |
197 |
gezelter |
2 |
} |
198 |
|
|
|
199 |
tim |
770 |
bool Globals::addMoleculeStamp(MoleculeStamp* molStamp) { |
200 |
|
|
std::string molStampName = molStamp->getName(); |
201 |
|
|
std::map<std::string, MoleculeStamp*>::iterator i; |
202 |
|
|
bool ret = false; |
203 |
|
|
i = moleculeStamps_.find(molStampName); |
204 |
|
|
if (i == moleculeStamps_.end()) { |
205 |
|
|
moleculeStamps_.insert(std::map<std::string, MoleculeStamp*>::value_type(molStampName, molStamp)); |
206 |
|
|
ret = true; |
207 |
|
|
} else { |
208 |
tim |
845 |
std::ostringstream oss; |
209 |
|
|
oss << "Globals Error: Molecule Stamp " << molStamp->getName() << "appears multiple times\n"; |
210 |
|
|
throw OOPSEException(oss.str()); |
211 |
tim |
770 |
} |
212 |
|
|
return ret; |
213 |
gezelter |
2 |
} |
214 |
tim |
770 |
|
215 |
|
|
|
216 |
|
|
} |