ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/io/Globals.cpp
Revision: 2026
Committed: Wed Oct 22 12:23:59 2014 UTC (10 years, 6 months ago) by gezelter
File size: 16410 byte(s)
Log Message:
Starting to add support for UniformGradient. 
Changed Vector3d input type to a more general std::vector<RealType> input.  This change alters RNEMD and UniformField inputs.

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(UniformGradient, "uniformGradient");
96 //DefineOptionalParameter(PeriodicField, "periodicField");
97 //DefineOptionalParameter(PeriodicFieldStrength, "periodicFieldStrength");
98
99
100 DefineOptionalParameter(TaggedAtomPair, "taggedAtomPair");
101 DefineOptionalParameter(PrintTaggedPairDistance, "printTaggedPairDistance");
102 DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType");
103 DefineOptionalParameter(HydroPropFile, "HydroPropFile");
104 DefineOptionalParameter(Viscosity, "viscosity");
105 DefineOptionalParameter(BeadSize, "beadSize");
106 DefineOptionalParameter(FrozenBufferRadius, "frozenBufferRadius");
107 DefineOptionalParameter(LangevinBufferRadius, "langevinBufferRadius");
108 DefineOptionalParameter(NeighborListNeighbors,"NeighborListNeighbors");
109 DefineOptionalParameter(UseMultipleTemperatureMethod,
110 "useMultipleTemperatureMethod");
111 DefineOptionalParameter(ElectrostaticSummationMethod,
112 "electrostaticSummationMethod");
113 DefineOptionalParameter(MTM_Ce, "MTM_Ce");
114 DefineOptionalParameter(MTM_G, "MTM_G");
115 DefineOptionalParameter(MTM_Io, "MTM_Io");
116 DefineOptionalParameter(MTM_Sigma, "MTM_Sigma");
117 DefineOptionalParameter(MTM_R, "MTM_R");
118 DefineOptionalParameter(Alpha, "alpha");
119 DefineOptionalParameter(ConstraintTime, "constraintTime");
120
121
122 DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions,
123 "usePeriodicBoundaryConditions",
124 true);
125 DefineOptionalParameterWithDefaultValue(UseAtomicVirial, "useAtomicVirial",
126 true);
127 DefineOptionalParameterWithDefaultValue(UseLongRangeCorrections,
128 "useLongRangeCorrections", true);
129 DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime",
130 false);
131 DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState,
132 "useInitialExtendedSystemState",
133 false);
134 DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance,
135 "orthoBoxTolerance", 1E-6);
136 DefineOptionalParameterWithDefaultValue(CutoffMethod, "cutoffMethod",
137 "SHIFTED_FORCE");
138 DefineOptionalParameterWithDefaultValue(ElectrostaticScreeningMethod,
139 "electrostaticScreeningMethod",
140 "DAMPED");
141 DefineOptionalParameterWithDefaultValue(Dielectric, "dielectric", 80.0);
142 DefineOptionalParameterWithDefaultValue(CompressDumpFile,
143 "compressDumpFile", false);
144 DefineOptionalParameterWithDefaultValue(PrintHeatFlux, "printHeatFlux",
145 false);
146 DefineOptionalParameterWithDefaultValue(OutputForceVector,
147 "outputForceVector", false);
148 DefineOptionalParameterWithDefaultValue(OutputParticlePotential,
149 "outputParticlePotential", false);
150 DefineOptionalParameterWithDefaultValue(OutputElectricField,
151 "outputElectricField", false);
152 DefineOptionalParameterWithDefaultValue(OutputFluctuatingCharges,
153 "outputFluctuatingCharges", false);
154 DefineOptionalParameterWithDefaultValue(OutputSitePotential,
155 "outputSitePotential", false);
156 DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness",
157 1.0);
158 DefineOptionalParameterWithDefaultValue(StatFileFormat,
159 "statFileFormat",
160 "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY");
161 DefineOptionalParameterWithDefaultValue(UseSphericalBoundaryConditions,
162 "useSphericalBoundaryConditions",
163 false);
164 DefineOptionalParameterWithDefaultValue(AccumulateBoxDipole,
165 "accumulateBoxDipole", false);
166 DefineOptionalParameterWithDefaultValue(AccumulateBoxQuadrupole,
167 "accumulateBoxQuadrupole", false);
168 DefineOptionalParameterWithDefaultValue(UseRestraints, "useRestraints",
169 false);
170 DefineOptionalParameterWithDefaultValue(Restraint_file, "Restraint_file",
171 "idealCrystal.in");
172 DefineOptionalParameterWithDefaultValue(UseThermodynamicIntegration,
173 "useThermodynamicIntegration",
174 false);
175 DefineOptionalParameterWithDefaultValue(HULL_Method,"HULL_Method","Convex");
176
177 deprecatedKeywords_.insert("nComponents");
178 deprecatedKeywords_.insert("nZconstraints");
179 deprecatedKeywords_.insert("initialConfig");
180 deprecatedKeywords_.insert("thermIntDistSpringConst");
181 deprecatedKeywords_.insert("thermIntThetaSpringConst");
182 deprecatedKeywords_.insert("thermIntOmegaSpringConst");
183 deprecatedKeywords_.insert("useSolidThermInt");
184 deprecatedKeywords_.insert("useLiquidThermInt");
185 deprecatedKeywords_.insert("minimizerMaxIter");
186 deprecatedKeywords_.insert("minimizerWriteFreq");
187 deprecatedKeywords_.insert("minimizerStepSize");
188 deprecatedKeywords_.insert("minimizerFTol");
189 deprecatedKeywords_.insert("minimizerGTol");
190 deprecatedKeywords_.insert("minimizerLSTol");
191 deprecatedKeywords_.insert("minimizerLSMaxIter");
192 deprecatedKeywords_.insert("electricField");
193
194
195 }
196
197 Globals::~Globals() {
198 MemoryUtils::deletePointers(components_);
199 MemoryUtils::deletePointers(zconstraints_);
200 MemoryUtils::deletePointers(restraints_);
201 delete flucQpars_;
202 delete rnemdPars_;
203 delete minimizerPars_;
204 }
205
206 void Globals::validate() {
207 DataHolder::validate();
208
209 CheckParameter(ForceField, isNotEmpty());
210 CheckParameter(TargetTemp, isPositive());
211 CheckParameter(Ensemble, isEqualIgnoreCase("NVE") ||
212 isEqualIgnoreCase("NVT") || isEqualIgnoreCase("NPTi") ||
213 isEqualIgnoreCase("NPTf") || isEqualIgnoreCase("NPTxyz") ||
214 isEqualIgnoreCase("NPTsz") || isEqualIgnoreCase("NPAT") ||
215 isEqualIgnoreCase("NPA") ||
216 isEqualIgnoreCase("LANGEVINDYNAMICS") ||
217 isEqualIgnoreCase("LD") || isEqualIgnoreCase("NPRT") ||
218 isEqualIgnoreCase("NPGT") || isEqualIgnoreCase("NGammaT") ||
219 isEqualIgnoreCase("NGT") ||
220 isEqualIgnoreCase("LANGEVINHULL") ||
221 isEqualIgnoreCase("LHULL") || isEqualIgnoreCase("SMIPD"));
222 CheckParameter(Dt, isPositive());
223 CheckParameter(RunTime, isPositive());
224 CheckParameter(FinalConfig, isNotEmpty());
225 CheckParameter(SampleTime, isNonNegative());
226 CheckParameter(ResetTime, isNonNegative());
227 CheckParameter(StatusTime, isNonNegative());
228 CheckParameter(CutoffRadius, isPositive());
229 CheckParameter(SwitchingRadius, isNonNegative());
230 CheckParameter(Dielectric, isPositive());
231 CheckParameter(ThermalTime, isNonNegative());
232 CheckParameter(TauThermostat, isPositive());
233 CheckParameter(TauBarostat, isPositive());
234 CheckParameter(ZconsTime, isPositive());
235 CheckParameter(ZconsTol, isPositive());
236 CheckParameter(Seed, isPositive());
237 CheckParameter(ZconsGap, isPositive());
238 CheckParameter(ZconsFixtime, isPositive());
239 CheckParameter(ThermodynamicIntegrationLambda, isNonNegative());
240 CheckParameter(ThermodynamicIntegrationK, isPositive());
241 CheckParameter(ForceFieldVariant, isNotEmpty());
242 CheckParameter(ForceFieldFileName, isNotEmpty());
243 CheckParameter(CutoffMethod, isEqualIgnoreCase("HARD") ||
244 isEqualIgnoreCase("SWITCHED") ||
245 isEqualIgnoreCase("SHIFTED_POTENTIAL") ||
246 isEqualIgnoreCase("SHIFTED_FORCE") ||
247 isEqualIgnoreCase("TAYLOR_SHIFTED") ||
248 isEqualIgnoreCase("EWALD_FULL"));
249 CheckParameter(CutoffPolicy, isEqualIgnoreCase("MIX") ||
250 isEqualIgnoreCase("MAX") ||
251 isEqualIgnoreCase("TRADITIONAL"));
252 CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase("NONE") ||
253 isEqualIgnoreCase("HARD") || isEqualIgnoreCase("SWITCHED") ||
254 isEqualIgnoreCase("SHIFTED_POTENTIAL") ||
255 isEqualIgnoreCase("SHIFTED_FORCE") ||
256 isEqualIgnoreCase("REACTION_FIELD") ||
257 isEqualIgnoreCase("TAYLOR_SHIFTED"));
258 CheckParameter(ElectrostaticScreeningMethod,
259 isEqualIgnoreCase("UNDAMPED") || isEqualIgnoreCase("DAMPED"));
260 CheckParameter(SwitchingFunctionType, isEqualIgnoreCase("CUBIC") ||
261 isEqualIgnoreCase("FIFTH_ORDER_POLYNOMIAL"));
262 CheckParameter(OrthoBoxTolerance, isPositive());
263 CheckParameter(DampingAlpha,isNonNegative());
264 CheckParameter(SkinThickness, isPositive());
265 CheckParameter(Viscosity, isNonNegative());
266 CheckParameter(BeadSize, isPositive());
267 CheckParameter(FrozenBufferRadius, isPositive());
268 CheckParameter(LangevinBufferRadius, isPositive());
269 CheckParameter(NeighborListNeighbors, isPositive());
270 CheckParameter(HULL_Method, isEqualIgnoreCase("Convex") ||
271 isEqualIgnoreCase("AlphaShape"));
272 CheckParameter(Alpha, isPositive());
273
274 for(std::vector<Component*>::iterator i = components_.begin();
275 i != components_.end(); ++i) {
276 if (!(*i)->findMoleculeStamp(moleculeStamps_)) {
277 std::ostringstream oss;
278 oss << "Globals Error: can not find molecule stamp for component "
279 << (*i)->getType() << std::endl;
280 throw OpenMDException(oss.str());
281 }
282 }
283 }
284
285 bool Globals::addComponent(Component* comp) {
286 components_.push_back(comp);
287 return true;
288 }
289
290 bool Globals::addZConsStamp(ZConsStamp* zcons) {
291 zconstraints_.push_back(zcons);
292 return true;
293 }
294
295 bool Globals::addRestraintStamp(RestraintStamp* rest) {
296 restraints_.push_back(rest);
297 return true;
298 }
299
300 bool Globals::addFluctuatingChargeParameters(FluctuatingChargeParameters* fqp) {
301 if (flucQpars_ != NULL)
302 delete flucQpars_;
303
304 flucQpars_ = fqp;
305 return true;
306 }
307
308 bool Globals::addRNEMDParameters(RNEMDParameters* rnemdPars) {
309 if (rnemdPars_ != NULL)
310 delete rnemdPars_;
311
312 rnemdPars_ = rnemdPars;
313 return true;
314 }
315
316 bool Globals::addMinimizerParameters(MinimizerParameters* miniPars) {
317 if (minimizerPars_ != NULL)
318 delete minimizerPars_;
319
320 minimizerPars_ = miniPars;
321 return true;
322 }
323
324 bool Globals::addMoleculeStamp(MoleculeStamp* molStamp) {
325 std::string molStampName = molStamp->getName();
326 std::map<std::string, MoleculeStamp*>::iterator i;
327 bool ret = false;
328 i = moleculeStamps_.find(molStampName);
329 if (i == moleculeStamps_.end()) {
330 moleculeStamps_.insert(std::map<std::string, MoleculeStamp*>::value_type(molStampName, molStamp));
331 ret = true;
332 } else {
333 std::ostringstream oss;
334 oss << "Globals Error: Molecule Stamp " << molStamp->getName()
335 << "appears multiple times\n";
336 throw OpenMDException(oss.str());
337 }
338 return ret;
339 }
340 }

Properties

Name Value
svn:keywords Author Id Revision Date