ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/io/Globals.cpp
Revision: 2020
Committed: Mon Sep 22 19:18:35 2014 UTC (10 years, 7 months ago) by gezelter
File size: 16196 byte(s)
Log Message:
Fixes for restraints, renaming of UniformField

File Contents

# Content
1 /*
2 * Copyright (c) 2005, 2010 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. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * This software is provided "AS IS," without a warranty of any
18 * kind. All express or implied conditions, representations and
19 * warranties, including any implied warranty of merchantability,
20 * fitness for a particular purpose or non-infringement, are hereby
21 * excluded. The University of Notre Dame and its licensors shall not
22 * be liable for any damages suffered by licensee as a result of
23 * using, modifying or distributing the software or its
24 * derivatives. In no event will the University of Notre Dame or its
25 * licensors be liable for any lost revenue, profit or data, or for
26 * direct, indirect, special, consequential, incidental or punitive
27 * damages, however caused and regardless of the theory of liability,
28 * arising out of the use of or inability to use software, even if the
29 * University of Notre Dame has been advised of the possibility of
30 * such damages.
31 *
32 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
33 * research, please cite the appropriate papers when you publish your
34 * work. Good starting points are:
35 *
36 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
37 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
38 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
39 * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 */
42
43 #include <stdlib.h>
44 #include <stdio.h>
45 #include <string.h>
46 #include <string>
47
48 #include "io/Globals.hpp"
49 #include "io/ParamConstraint.hpp"
50 #include "utils/MemoryUtils.hpp"
51 #include "utils/simError.h"
52
53 namespace OpenMD {
54 Globals::Globals() {
55
56 flucQpars_ = new FluctuatingChargeParameters();
57 rnemdPars_ = new RNEMDParameters();
58 minimizerPars_ = new MinimizerParameters();
59
60 DefineParameter(ForceField, "forceField");
61
62 DefineOptionalParameter(TargetTemp, "targetTemp");
63 DefineOptionalParameter(Ensemble, "ensemble");
64 DefineOptionalParameter(Dt, "dt");
65 DefineOptionalParameter(RunTime, "runTime");
66 DefineOptionalParameter(FinalConfig, "finalConfig");
67 DefineOptionalParameter(SampleTime, "sampleTime");
68 DefineOptionalParameter(ResetTime, "resetTime");
69 DefineOptionalParameter(StatusTime, "statusTime");
70 DefineOptionalParameter(CutoffRadius, "cutoffRadius");
71 DefineOptionalParameter(SwitchingRadius, "switchingRadius");
72 DefineOptionalParameter(TempSet, "tempSet");
73 DefineOptionalParameter(ThermalTime, "thermalTime");
74 DefineOptionalParameter(TargetPressure, "targetPressure");
75 DefineOptionalParameter(TauThermostat, "tauThermostat");
76 DefineOptionalParameter(TauBarostat, "tauBarostat");
77 DefineOptionalParameter(ZconsTime, "zconsTime");
78 DefineOptionalParameter(ZconsTol, "zconsTol");
79 DefineOptionalParameter(ZconsForcePolicy, "zconsForcePolicy");
80 DefineOptionalParameter(Seed, "seed");
81 DefineOptionalParameter(ZconsGap, "zconsGap");
82 DefineOptionalParameter(ZconsFixtime, "zconsFixtime");
83 DefineOptionalParameter(ZconsUsingSMD, "zconsUsingSMD");
84 DefineOptionalParameter(ThermodynamicIntegrationLambda,
85 "thermodynamicIntegrationLambda");
86 DefineOptionalParameter(ThermodynamicIntegrationK,
87 "thermodynamicIntegrationK");
88 DefineOptionalParameter(ForceFieldVariant, "forceFieldVariant");
89 DefineOptionalParameter(ForceFieldFileName, "forceFieldFileName");
90 DefineOptionalParameter(DampingAlpha, "dampingAlpha");
91 DefineOptionalParameter(SurfaceTension, "surfaceTension");
92 DefineOptionalParameter(PrintPressureTensor, "printPressureTensor");
93 DefineOptionalParameter(ElectricField, "electricField");
94 DefineOptionalParameter(UniformField, "uniformField");
95 //DefineOptionalParameter(PeriodicField, "periodicField");
96 //DefineOptionalParameter(PeriodicFieldStrength, "periodicFieldStrength");
97
98
99 DefineOptionalParameter(TaggedAtomPair, "taggedAtomPair");
100 DefineOptionalParameter(PrintTaggedPairDistance, "printTaggedPairDistance");
101 DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType");
102 DefineOptionalParameter(HydroPropFile, "HydroPropFile");
103 DefineOptionalParameter(Viscosity, "viscosity");
104 DefineOptionalParameter(BeadSize, "beadSize");
105 DefineOptionalParameter(FrozenBufferRadius, "frozenBufferRadius");
106 DefineOptionalParameter(LangevinBufferRadius, "langevinBufferRadius");
107 DefineOptionalParameter(NeighborListNeighbors,"NeighborListNeighbors");
108 DefineOptionalParameter(UseMultipleTemperatureMethod,
109 "useMultipleTemperatureMethod");
110 DefineOptionalParameter(ElectrostaticSummationMethod,
111 "electrostaticSummationMethod");
112 DefineOptionalParameter(MTM_Ce, "MTM_Ce");
113 DefineOptionalParameter(MTM_G, "MTM_G");
114 DefineOptionalParameter(MTM_Io, "MTM_Io");
115 DefineOptionalParameter(MTM_Sigma, "MTM_Sigma");
116 DefineOptionalParameter(MTM_R, "MTM_R");
117 DefineOptionalParameter(Alpha, "alpha");
118 DefineOptionalParameter(ConstraintTime, "constraintTime");
119
120
121 DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions,
122 "usePeriodicBoundaryConditions",
123 true);
124 DefineOptionalParameterWithDefaultValue(UseAtomicVirial, "useAtomicVirial",
125 true);
126 DefineOptionalParameterWithDefaultValue(UseLongRangeCorrections,
127 "useLongRangeCorrections", true);
128 DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime",
129 false);
130 DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState,
131 "useInitialExtendedSystemState",
132 false);
133 DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance,
134 "orthoBoxTolerance", 1E-6);
135 DefineOptionalParameterWithDefaultValue(CutoffMethod, "cutoffMethod",
136 "SHIFTED_FORCE");
137 DefineOptionalParameterWithDefaultValue(ElectrostaticScreeningMethod,
138 "electrostaticScreeningMethod",
139 "DAMPED");
140 DefineOptionalParameterWithDefaultValue(Dielectric, "dielectric", 80.0);
141 DefineOptionalParameterWithDefaultValue(CompressDumpFile,
142 "compressDumpFile", false);
143 DefineOptionalParameterWithDefaultValue(PrintHeatFlux, "printHeatFlux",
144 false);
145 DefineOptionalParameterWithDefaultValue(OutputForceVector,
146 "outputForceVector", false);
147 DefineOptionalParameterWithDefaultValue(OutputParticlePotential,
148 "outputParticlePotential", false);
149 DefineOptionalParameterWithDefaultValue(OutputElectricField,
150 "outputElectricField", false);
151 DefineOptionalParameterWithDefaultValue(OutputFluctuatingCharges,
152 "outputFluctuatingCharges", false);
153 DefineOptionalParameterWithDefaultValue(OutputSitePotential,
154 "outputSitePotential", false);
155 DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness",
156 1.0);
157 DefineOptionalParameterWithDefaultValue(StatFileFormat,
158 "statFileFormat",
159 "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY");
160 DefineOptionalParameterWithDefaultValue(UseSphericalBoundaryConditions,
161 "useSphericalBoundaryConditions",
162 false);
163 DefineOptionalParameterWithDefaultValue(AccumulateBoxDipole,
164 "accumulateBoxDipole", false);
165 DefineOptionalParameterWithDefaultValue(UseRestraints, "useRestraints",
166 false);
167 DefineOptionalParameterWithDefaultValue(Restraint_file, "Restraint_file",
168 "idealCrystal.in");
169 DefineOptionalParameterWithDefaultValue(UseThermodynamicIntegration,
170 "useThermodynamicIntegration",
171 false);
172 DefineOptionalParameterWithDefaultValue(HULL_Method,"HULL_Method","Convex");
173
174 deprecatedKeywords_.insert("nComponents");
175 deprecatedKeywords_.insert("nZconstraints");
176 deprecatedKeywords_.insert("initialConfig");
177 deprecatedKeywords_.insert("thermIntDistSpringConst");
178 deprecatedKeywords_.insert("thermIntThetaSpringConst");
179 deprecatedKeywords_.insert("thermIntOmegaSpringConst");
180 deprecatedKeywords_.insert("useSolidThermInt");
181 deprecatedKeywords_.insert("useLiquidThermInt");
182 deprecatedKeywords_.insert("minimizerMaxIter");
183 deprecatedKeywords_.insert("minimizerWriteFreq");
184 deprecatedKeywords_.insert("minimizerStepSize");
185 deprecatedKeywords_.insert("minimizerFTol");
186 deprecatedKeywords_.insert("minimizerGTol");
187 deprecatedKeywords_.insert("minimizerLSTol");
188 deprecatedKeywords_.insert("minimizerLSMaxIter");
189 deprecatedKeywords_.insert("electricField");
190
191
192 }
193
194 Globals::~Globals() {
195 MemoryUtils::deletePointers(components_);
196 MemoryUtils::deletePointers(zconstraints_);
197 MemoryUtils::deletePointers(restraints_);
198 delete flucQpars_;
199 delete rnemdPars_;
200 delete minimizerPars_;
201 }
202
203 void Globals::validate() {
204 DataHolder::validate();
205
206 CheckParameter(ForceField, isNotEmpty());
207 CheckParameter(TargetTemp, isPositive());
208 CheckParameter(Ensemble, isEqualIgnoreCase("NVE") ||
209 isEqualIgnoreCase("NVT") || isEqualIgnoreCase("NPTi") ||
210 isEqualIgnoreCase("NPTf") || isEqualIgnoreCase("NPTxyz") ||
211 isEqualIgnoreCase("NPTsz") || isEqualIgnoreCase("NPAT") ||
212 isEqualIgnoreCase("NPA") ||
213 isEqualIgnoreCase("LANGEVINDYNAMICS") ||
214 isEqualIgnoreCase("LD") || isEqualIgnoreCase("NPRT") ||
215 isEqualIgnoreCase("NPGT") || isEqualIgnoreCase("NGammaT") ||
216 isEqualIgnoreCase("NGT") ||
217 isEqualIgnoreCase("LANGEVINHULL") ||
218 isEqualIgnoreCase("LHULL") || isEqualIgnoreCase("SMIPD"));
219 CheckParameter(Dt, isPositive());
220 CheckParameter(RunTime, isPositive());
221 CheckParameter(FinalConfig, isNotEmpty());
222 CheckParameter(SampleTime, isNonNegative());
223 CheckParameter(ResetTime, isNonNegative());
224 CheckParameter(StatusTime, isNonNegative());
225 CheckParameter(CutoffRadius, isPositive());
226 CheckParameter(SwitchingRadius, isNonNegative());
227 CheckParameter(Dielectric, isPositive());
228 CheckParameter(ThermalTime, isNonNegative());
229 CheckParameter(TauThermostat, isPositive());
230 CheckParameter(TauBarostat, isPositive());
231 CheckParameter(ZconsTime, isPositive());
232 CheckParameter(ZconsTol, isPositive());
233 CheckParameter(Seed, isPositive());
234 CheckParameter(ZconsGap, isPositive());
235 CheckParameter(ZconsFixtime, isPositive());
236 CheckParameter(ThermodynamicIntegrationLambda, isNonNegative());
237 CheckParameter(ThermodynamicIntegrationK, isPositive());
238 CheckParameter(ForceFieldVariant, isNotEmpty());
239 CheckParameter(ForceFieldFileName, isNotEmpty());
240 CheckParameter(CutoffMethod, isEqualIgnoreCase("HARD") ||
241 isEqualIgnoreCase("SWITCHED") ||
242 isEqualIgnoreCase("SHIFTED_POTENTIAL") ||
243 isEqualIgnoreCase("SHIFTED_FORCE") ||
244 isEqualIgnoreCase("TAYLOR_SHIFTED") ||
245 isEqualIgnoreCase("EWALD_FULL"));
246 CheckParameter(CutoffPolicy, isEqualIgnoreCase("MIX") ||
247 isEqualIgnoreCase("MAX") ||
248 isEqualIgnoreCase("TRADITIONAL"));
249 CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase("NONE") ||
250 isEqualIgnoreCase("HARD") || isEqualIgnoreCase("SWITCHED") ||
251 isEqualIgnoreCase("SHIFTED_POTENTIAL") ||
252 isEqualIgnoreCase("SHIFTED_FORCE") ||
253 isEqualIgnoreCase("REACTION_FIELD") ||
254 isEqualIgnoreCase("TAYLOR_SHIFTED"));
255 CheckParameter(ElectrostaticScreeningMethod,
256 isEqualIgnoreCase("UNDAMPED") || isEqualIgnoreCase("DAMPED"));
257 CheckParameter(SwitchingFunctionType, isEqualIgnoreCase("CUBIC") ||
258 isEqualIgnoreCase("FIFTH_ORDER_POLYNOMIAL"));
259 CheckParameter(OrthoBoxTolerance, isPositive());
260 CheckParameter(DampingAlpha,isNonNegative());
261 CheckParameter(SkinThickness, isPositive());
262 CheckParameter(Viscosity, isNonNegative());
263 CheckParameter(BeadSize, isPositive());
264 CheckParameter(FrozenBufferRadius, isPositive());
265 CheckParameter(LangevinBufferRadius, isPositive());
266 CheckParameter(NeighborListNeighbors, isPositive());
267 CheckParameter(HULL_Method, isEqualIgnoreCase("Convex") ||
268 isEqualIgnoreCase("AlphaShape"));
269 CheckParameter(Alpha, isPositive());
270
271 for(std::vector<Component*>::iterator i = components_.begin();
272 i != components_.end(); ++i) {
273 if (!(*i)->findMoleculeStamp(moleculeStamps_)) {
274 std::ostringstream oss;
275 oss << "Globals Error: can not find molecule stamp for component "
276 << (*i)->getType() << std::endl;
277 throw OpenMDException(oss.str());
278 }
279 }
280 }
281
282 bool Globals::addComponent(Component* comp) {
283 components_.push_back(comp);
284 return true;
285 }
286
287 bool Globals::addZConsStamp(ZConsStamp* zcons) {
288 zconstraints_.push_back(zcons);
289 return true;
290 }
291
292 bool Globals::addRestraintStamp(RestraintStamp* rest) {
293 restraints_.push_back(rest);
294 return true;
295 }
296
297 bool Globals::addFluctuatingChargeParameters(FluctuatingChargeParameters* fqp) {
298 if (flucQpars_ != NULL)
299 delete flucQpars_;
300
301 flucQpars_ = fqp;
302 return true;
303 }
304
305 bool Globals::addRNEMDParameters(RNEMDParameters* rnemdPars) {
306 if (rnemdPars_ != NULL)
307 delete rnemdPars_;
308
309 rnemdPars_ = rnemdPars;
310 return true;
311 }
312
313 bool Globals::addMinimizerParameters(MinimizerParameters* miniPars) {
314 if (minimizerPars_ != NULL)
315 delete minimizerPars_;
316
317 minimizerPars_ = miniPars;
318 return true;
319 }
320
321 bool Globals::addMoleculeStamp(MoleculeStamp* molStamp) {
322 std::string molStampName = molStamp->getName();
323 std::map<std::string, MoleculeStamp*>::iterator i;
324 bool ret = false;
325 i = moleculeStamps_.find(molStampName);
326 if (i == moleculeStamps_.end()) {
327 moleculeStamps_.insert(std::map<std::string, MoleculeStamp*>::value_type(molStampName, molStamp));
328 ret = true;
329 } else {
330 std::ostringstream oss;
331 oss << "Globals Error: Molecule Stamp " << molStamp->getName()
332 << "appears multiple times\n";
333 throw OpenMDException(oss.str());
334 }
335 return ret;
336 }
337 }

Properties

Name Value
svn:keywords Author Id Revision Date