| 1 |
gezelter |
2088 |
/* |
| 2 |
gezelter |
1930 |
* 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 |
1490 |
#include <stdlib.h> |
| 43 |
|
|
#include <stdio.h> |
| 44 |
|
|
#include <string.h> |
| 45 |
tim |
2364 |
#include <string> |
| 46 |
gezelter |
1490 |
|
| 47 |
tim |
1492 |
#include "io/Globals.hpp" |
| 48 |
tim |
2515 |
#include "io/ParamConstraint.hpp" |
| 49 |
|
|
#include "utils/MemoryUtils.hpp" |
| 50 |
tim |
1492 |
#include "utils/simError.h" |
| 51 |
gezelter |
1490 |
|
| 52 |
tim |
2469 |
namespace oopse { |
| 53 |
|
|
Globals::Globals() { |
| 54 |
tim |
2364 |
DefineParameter(ForceField, "forceField") |
| 55 |
|
|
|
| 56 |
|
|
DefineOptionalParameter(TargetTemp, "targetTemp"); |
| 57 |
|
|
DefineOptionalParameter(Ensemble, "ensemble"); |
| 58 |
|
|
DefineOptionalParameter(Dt, "dt"); |
| 59 |
|
|
DefineOptionalParameter(RunTime, "runTime"); |
| 60 |
tim |
2982 |
//DefineOptionalParameter(InitialConfig, "initialConfig"); |
| 61 |
tim |
2364 |
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 |
2415 |
DefineOptionalParameter(ElectrostaticScreeningMethod, "electrostaticScreeningMethod"); |
| 99 |
tim |
2364 |
DefineOptionalParameter(CutoffPolicy, "cutoffPolicy"); |
| 100 |
chrisfen |
2425 |
DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType"); |
| 101 |
tim |
2611 |
DefineOptionalParameter(HydroPropFile, "HydroPropFile"); |
| 102 |
tim |
2634 |
DefineOptionalParameter(Viscosity, "viscosity"); |
| 103 |
|
|
DefineOptionalParameter(BeadSize, "beadSize"); |
| 104 |
gezelter |
2733 |
DefineOptionalParameter(FrozenBufferRadius, "frozenBufferRadius"); |
| 105 |
|
|
DefineOptionalParameter(LangevinBufferRadius, "langevinBufferRadius"); |
| 106 |
tim |
2634 |
|
| 107 |
tim |
2364 |
DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true); |
| 108 |
|
|
DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false); |
| 109 |
|
|
DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState, "useInitialExtendedSystemState", false); |
| 110 |
|
|
DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance, "orthoBoxTolerance", 1E-6); |
| 111 |
|
|
DefineOptionalParameterWithDefaultValue(UseSolidThermInt, "useSolidThermInt", false); |
| 112 |
|
|
DefineOptionalParameterWithDefaultValue(UseLiquidThermInt, "useLiquidThermInt", false); |
| 113 |
chrisfen |
2365 |
DefineOptionalParameterWithDefaultValue(ThermIntDistSpringConst, "thermIntDistSpringConst", 6.0); |
| 114 |
|
|
DefineOptionalParameterWithDefaultValue(ThermIntThetaSpringConst, "thermIntThetaSpringConst", 7.5); |
| 115 |
|
|
DefineOptionalParameterWithDefaultValue(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst", 13.5); |
| 116 |
chrisfen |
3013 |
DefineOptionalParameter(DampingAlpha, "dampingAlpha"); |
| 117 |
tim |
2364 |
DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0); |
| 118 |
chrisfen |
2425 |
DefineOptionalParameterWithDefaultValue(OutputForceVector, "outputForceVector", 0); |
| 119 |
tim |
2364 |
DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0); |
| 120 |
tim |
2380 |
DefineOptionalParameterWithDefaultValue(StatFileFormat, "statFileFormat", "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY"); |
| 121 |
gezelter |
2733 |
DefineOptionalParameterWithDefaultValue(UseSphericalBoundaryConditions, "useSphericalBoundaryConditions", false); |
| 122 |
chrisfen |
2917 |
DefineOptionalParameterWithDefaultValue(AccumulateBoxDipole, "accumulateBoxDipole", false); |
| 123 |
tim |
2380 |
|
| 124 |
gezelter |
1490 |
|
| 125 |
tim |
2469 |
deprecatedKeywords_.insert("nComponents"); |
| 126 |
|
|
deprecatedKeywords_.insert("nZconstraints"); |
| 127 |
tim |
2982 |
deprecatedKeywords_.insert("initialConfig"); |
| 128 |
gezelter |
1490 |
|
| 129 |
|
|
} |
| 130 |
|
|
|
| 131 |
tim |
2469 |
Globals::~Globals() { |
| 132 |
tim |
2515 |
MemoryUtils::deletePointers(components_); |
| 133 |
|
|
MemoryUtils::deletePointers(zconstraints_); |
| 134 |
gezelter |
1490 |
} |
| 135 |
|
|
|
| 136 |
tim |
2469 |
void Globals::validate() { |
| 137 |
|
|
DataHolder::validate(); |
| 138 |
gezelter |
1490 |
|
| 139 |
tim |
2371 |
CheckParameter(ForceField, isNotEmpty()); |
| 140 |
|
|
CheckParameter(TargetTemp, isPositive()); |
| 141 |
gezelter |
2994 |
CheckParameter(Ensemble, isEqualIgnoreCase("NVE") || isEqualIgnoreCase("NVT") || isEqualIgnoreCase("NPTi") || isEqualIgnoreCase("NPTf") || isEqualIgnoreCase("NPTxyz") || isEqualIgnoreCase("NPAT") || isEqualIgnoreCase("LANGEVINDYNAMICS") || isEqualIgnoreCase("LD") || isEqualIgnoreCase("NPRT") || isEqualIgnoreCase("NPGT") || isEqualIgnoreCase("NGammaT") || isEqualIgnoreCase("NGT")); |
| 142 |
tim |
2371 |
CheckParameter(Dt, isPositive()); |
| 143 |
|
|
CheckParameter(RunTime, isPositive()); |
| 144 |
tim |
2982 |
//CheckParameter(InitialConfig, isNotEmpty()); |
| 145 |
tim |
2371 |
CheckParameter(FinalConfig, isNotEmpty()); |
| 146 |
|
|
CheckParameter(SampleTime, isNonNegative()); |
| 147 |
|
|
CheckParameter(ResetTime, isNonNegative()); |
| 148 |
|
|
CheckParameter(StatusTime, isNonNegative()); |
| 149 |
|
|
CheckParameter(CutoffRadius, isPositive()); |
| 150 |
|
|
CheckParameter(SwitchingRadius, isNonNegative()); |
| 151 |
|
|
CheckParameter(Dielectric, isPositive()); |
| 152 |
|
|
CheckParameter(ThermalTime, isNonNegative()); |
| 153 |
xsun |
2976 |
// CheckParameter(TargetPressure, isPositive()); |
| 154 |
tim |
2371 |
CheckParameter(TauThermostat, isPositive()); |
| 155 |
|
|
CheckParameter(TauBarostat, isPositive()); |
| 156 |
|
|
CheckParameter(ZconsTime, isPositive()); |
| 157 |
|
|
CheckParameter(ZconsTol, isPositive()); |
| 158 |
|
|
CheckParameter(Seed, isPositive()); |
| 159 |
tim |
2549 |
CheckParameter(Minimizer, isEqualIgnoreCase("SD") || isEqualIgnoreCase("CG")); |
| 160 |
tim |
2371 |
CheckParameter(MinimizerMaxIter, isPositive()); |
| 161 |
|
|
CheckParameter(MinimizerWriteFrq, isPositive()); |
| 162 |
|
|
CheckParameter(MinimizerStepSize, isPositive()); |
| 163 |
|
|
CheckParameter(MinimizerFTol, isPositive()); |
| 164 |
|
|
CheckParameter(MinimizerGTol, isPositive()); |
| 165 |
|
|
CheckParameter(MinimizerLSTol, isPositive()); |
| 166 |
|
|
CheckParameter(MinimizerLSMaxIter, isPositive()); |
| 167 |
|
|
CheckParameter(ZconsGap, isPositive()); |
| 168 |
|
|
CheckParameter(ZconsFixtime, isPositive()); |
| 169 |
chrisfen |
2777 |
CheckParameter(ThermodynamicIntegrationLambda, isNonNegative()); |
| 170 |
tim |
2371 |
CheckParameter(ThermodynamicIntegrationK, isPositive()); |
| 171 |
|
|
CheckParameter(ForceFieldVariant, isNotEmpty()); |
| 172 |
|
|
CheckParameter(ForceFieldFileName, isNotEmpty()); |
| 173 |
|
|
CheckParameter(ThermIntDistSpringConst, isPositive()); |
| 174 |
|
|
CheckParameter(ThermIntThetaSpringConst, isPositive()); |
| 175 |
|
|
CheckParameter(ThermIntOmegaSpringConst, isPositive()); |
| 176 |
xsun |
2976 |
// CheckParameter(SurfaceTension, isNonNegative()); |
| 177 |
tim |
2549 |
CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase("NONE") || isEqualIgnoreCase("SHIFTED_POTENTIAL") || isEqualIgnoreCase("SHIFTED_FORCE") || isEqualIgnoreCase("REACTION_FIELD")); |
| 178 |
|
|
CheckParameter(ElectrostaticScreeningMethod, isEqualIgnoreCase("UNDAMPED") || isEqualIgnoreCase("DAMPED")); |
| 179 |
|
|
CheckParameter(CutoffPolicy, isEqualIgnoreCase("MIX") || isEqualIgnoreCase("MAX") || isEqualIgnoreCase("TRADITIONAL")); |
| 180 |
|
|
CheckParameter(SwitchingFunctionType, isEqualIgnoreCase("CUBIC") || isEqualIgnoreCase("FIFTH_ORDER_POLYNOMIAL")); |
| 181 |
tim |
2371 |
//CheckParameter(StatFileFormat,); |
| 182 |
|
|
CheckParameter(OrthoBoxTolerance, isPositive()); |
| 183 |
|
|
CheckParameter(ThermIntDistSpringConst, isPositive()); |
| 184 |
|
|
CheckParameter(ThermIntThetaSpringConst, isPositive()); |
| 185 |
|
|
CheckParameter(ThermIntOmegaSpringConst, isPositive()); |
| 186 |
chrisfen |
2415 |
CheckParameter(DampingAlpha,isNonNegative()); |
| 187 |
tim |
2371 |
CheckParameter(SkinThickness, isPositive()); |
| 188 |
gezelter |
2733 |
CheckParameter(Viscosity, isNonNegative()); |
| 189 |
|
|
CheckParameter(BeadSize, isPositive()); |
| 190 |
|
|
CheckParameter(FrozenBufferRadius, isPositive()); |
| 191 |
|
|
CheckParameter(LangevinBufferRadius, isPositive()); |
| 192 |
tim |
2469 |
for(std::vector<Component*>::iterator i = components_.begin(); i != components_.end(); ++i) { |
| 193 |
|
|
if (!(*i)->findMoleculeStamp(moleculeStamps_)) { |
| 194 |
tim |
2544 |
std::ostringstream oss; |
| 195 |
|
|
oss << "Globals Error: can not find molecule stamp for component " << (*i)->getType() << std::endl; |
| 196 |
|
|
throw OOPSEException(oss.str()); |
| 197 |
tim |
2469 |
} |
| 198 |
|
|
} |
| 199 |
|
|
} |
| 200 |
|
|
|
| 201 |
|
|
bool Globals::addComponent(Component* comp) { |
| 202 |
|
|
components_.push_back(comp); |
| 203 |
|
|
return true; |
| 204 |
|
|
} |
| 205 |
gezelter |
1490 |
|
| 206 |
tim |
2469 |
bool Globals::addZConsStamp(ZConsStamp* zcons) { |
| 207 |
|
|
zconstraints_.push_back(zcons); |
| 208 |
|
|
return true; |
| 209 |
gezelter |
1490 |
} |
| 210 |
|
|
|
| 211 |
tim |
2469 |
bool Globals::addMoleculeStamp(MoleculeStamp* molStamp) { |
| 212 |
|
|
std::string molStampName = molStamp->getName(); |
| 213 |
|
|
std::map<std::string, MoleculeStamp*>::iterator i; |
| 214 |
|
|
bool ret = false; |
| 215 |
|
|
i = moleculeStamps_.find(molStampName); |
| 216 |
|
|
if (i == moleculeStamps_.end()) { |
| 217 |
|
|
moleculeStamps_.insert(std::map<std::string, MoleculeStamp*>::value_type(molStampName, molStamp)); |
| 218 |
|
|
ret = true; |
| 219 |
|
|
} else { |
| 220 |
tim |
2544 |
std::ostringstream oss; |
| 221 |
|
|
oss << "Globals Error: Molecule Stamp " << molStamp->getName() << "appears multiple times\n"; |
| 222 |
|
|
throw OOPSEException(oss.str()); |
| 223 |
tim |
2469 |
} |
| 224 |
|
|
return ret; |
| 225 |
gezelter |
1490 |
} |
| 226 |
tim |
2469 |
|
| 227 |
|
|
|
| 228 |
|
|
} |