| 1 |
gezelter |
507 |
/* |
| 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 |
|
|
#ifndef IO_GLOBALS_HPP |
| 43 |
|
|
#define IO_GLOBALS_HPP |
| 44 |
gezelter |
2 |
|
| 45 |
|
|
#include <iostream> |
| 46 |
|
|
|
| 47 |
|
|
#include <stdlib.h> |
| 48 |
|
|
#include <vector> |
| 49 |
tim |
425 |
#include <string> |
| 50 |
|
|
#include <map> |
| 51 |
gezelter |
2 |
|
| 52 |
tim |
3 |
#include "io/BASS_interface.h" |
| 53 |
|
|
#include "types/Component.hpp" |
| 54 |
|
|
#include "types/MakeStamps.hpp" |
| 55 |
|
|
#include "types/ZconStamp.hpp" |
| 56 |
tim |
665 |
#include "utils/CaseConversion.hpp" |
| 57 |
gezelter |
2 |
|
| 58 |
tim |
665 |
template<typename T> |
| 59 |
|
|
struct ParameterTraits; |
| 60 |
gezelter |
2 |
|
| 61 |
tim |
665 |
//string |
| 62 |
|
|
template<> |
| 63 |
|
|
struct ParameterTraits<std::string>{ |
| 64 |
|
|
typedef std::string RepType; // Representation type of the value |
| 65 |
gezelter |
246 |
|
| 66 |
tim |
665 |
template<typename T> static bool convert(T v, RepType& r){return false;} // !NB everything is ok |
| 67 |
|
|
template<typename T> static RepType convert(T v) {RepType tmp; convert(v,tmp);return tmp;} |
| 68 |
|
|
static bool convert(RepType v, RepType& r) { r = v; return true;} |
| 69 |
tim |
674 |
static std::string getParamType() { return "string";} |
| 70 |
tim |
665 |
}; |
| 71 |
|
|
//bool |
| 72 |
|
|
template<> |
| 73 |
|
|
struct ParameterTraits<bool>{ |
| 74 |
|
|
typedef bool RepType; |
| 75 |
|
|
template<typename T> static bool convert(T, RepType&){return false;} |
| 76 |
|
|
template<typename T> static RepType convert(T v) {RepType tmp; convert(v,tmp);return tmp;} |
| 77 |
|
|
static bool convert(std::string v, RepType& r) { |
| 78 |
|
|
oopse::toLower(v); |
| 79 |
|
|
bool result = false; |
| 80 |
|
|
if (v == "true") { |
| 81 |
|
|
r = true; |
| 82 |
|
|
result = true; |
| 83 |
|
|
} else if (v == "false") { |
| 84 |
|
|
r = false; |
| 85 |
|
|
result = true; |
| 86 |
|
|
} |
| 87 |
|
|
|
| 88 |
|
|
return result; |
| 89 |
|
|
} |
| 90 |
tim |
674 |
static std::string getParamType() { return "bool";} |
| 91 |
tim |
665 |
}; |
| 92 |
gezelter |
2 |
|
| 93 |
tim |
665 |
//int |
| 94 |
|
|
template<> |
| 95 |
|
|
struct ParameterTraits<int>{ |
| 96 |
|
|
typedef int RepType; |
| 97 |
|
|
template<typename T> static bool convert(T, RepType&){return false;} |
| 98 |
|
|
template<typename T> static RepType convert(T v) {RepType tmp; convert(v,tmp);return tmp;} |
| 99 |
|
|
static bool convert(RepType v, RepType& r) { r=v; return true;} |
| 100 |
tim |
674 |
static std::string getParamType() { return "int";} |
| 101 |
tim |
665 |
}; |
| 102 |
gezelter |
2 |
|
| 103 |
tim |
665 |
//double |
| 104 |
|
|
template<> |
| 105 |
|
|
struct ParameterTraits<double>{ |
| 106 |
|
|
typedef double RepType; |
| 107 |
|
|
template<typename T> static bool convert(T, RepType&){return false;} |
| 108 |
|
|
template<typename T> static RepType convert(T v) {RepType tmp; convert(v,tmp);return tmp;} |
| 109 |
|
|
static bool convert(RepType v, RepType& r) {r=v; return true;} |
| 110 |
|
|
static bool convert(int v, RepType& r) {r = static_cast<double>(v); return true;} |
| 111 |
tim |
674 |
static std::string getParamType() { return "double";} |
| 112 |
tim |
665 |
}; |
| 113 |
gezelter |
586 |
|
| 114 |
tim |
425 |
|
| 115 |
tim |
665 |
class ParameterBase { |
| 116 |
|
|
public: |
| 117 |
|
|
ParameterBase() : keyword_(), optional_(false), defaultValue_(false), empty_(true) {} |
| 118 |
tim |
677 |
virtual ~ParameterBase() {} |
| 119 |
tim |
665 |
bool isOptional() {return optional_;} |
| 120 |
|
|
void setOptional(bool optional) {optional_ = optional;} |
| 121 |
|
|
bool hasDefaultValue() {return defaultValue_;} |
| 122 |
|
|
virtual bool isValid() { return true;} |
| 123 |
|
|
const std::string& getKeyword() {return keyword_;} |
| 124 |
|
|
void setKeyword(const std::string& keyword) { keyword_ = keyword;} |
| 125 |
|
|
bool empty() {return empty_;} |
| 126 |
|
|
virtual bool setData(std::string) = 0; |
| 127 |
|
|
virtual bool setData(int) = 0; |
| 128 |
|
|
virtual bool setData(double) = 0; |
| 129 |
tim |
674 |
virtual std::string getParamType() = 0; |
| 130 |
tim |
665 |
protected: |
| 131 |
|
|
std::string keyword_; |
| 132 |
|
|
bool optional_; |
| 133 |
|
|
bool defaultValue_; |
| 134 |
|
|
bool empty_; |
| 135 |
|
|
}; |
| 136 |
tim |
425 |
|
| 137 |
tim |
665 |
template<class ParamType> |
| 138 |
|
|
class Parameter : public ParameterBase{ |
| 139 |
|
|
public: |
| 140 |
|
|
typedef ParameterTraits<ParamType> ValueType; |
| 141 |
|
|
void setDefaultValue(const ParamType& value) {data_ = value; defaultValue_ = true;} |
| 142 |
|
|
ParamType getData() { return data_;} |
| 143 |
gezelter |
2 |
|
| 144 |
tim |
665 |
virtual bool setData(std::string sval) { |
| 145 |
|
|
return internalSetData<std::string>(sval); |
| 146 |
|
|
} |
| 147 |
tim |
673 |
virtual bool setData(int ival) { |
| 148 |
|
|
return internalSetData<int>(ival); |
| 149 |
tim |
665 |
} |
| 150 |
|
|
|
| 151 |
|
|
virtual bool setData(double dval) { |
| 152 |
|
|
return internalSetData<double>(dval); |
| 153 |
|
|
} |
| 154 |
gezelter |
2 |
|
| 155 |
tim |
674 |
virtual std::string getParamType() { return ParameterTraits<ParamType>::getParamType();} |
| 156 |
tim |
665 |
private: |
| 157 |
|
|
template<class T> bool internalSetData(T data) { |
| 158 |
|
|
ParamType tmp; |
| 159 |
|
|
bool result = ValueType::convert(data, tmp); |
| 160 |
|
|
if (result) { |
| 161 |
|
|
empty_ = false; |
| 162 |
|
|
data_ = tmp; |
| 163 |
|
|
} |
| 164 |
|
|
return result; |
| 165 |
|
|
} |
| 166 |
|
|
|
| 167 |
|
|
private: |
| 168 |
|
|
ParamType data_; |
| 169 |
|
|
|
| 170 |
|
|
}; |
| 171 |
|
|
|
| 172 |
|
|
#define DeclareParameter(NAME, TYPE) \ |
| 173 |
|
|
private: \ |
| 174 |
|
|
Parameter<TYPE> NAME; \ |
| 175 |
|
|
public: \ |
| 176 |
|
|
bool have##NAME() { return !NAME.empty();} \ |
| 177 |
|
|
TYPE get##NAME() { return NAME.getData();} |
| 178 |
|
|
|
| 179 |
|
|
|
| 180 |
|
|
class Globals { |
| 181 |
|
|
public: |
| 182 |
|
|
Globals(); |
| 183 |
|
|
|
| 184 |
|
|
DeclareParameter(ForceField, std::string); |
| 185 |
|
|
DeclareParameter(NComponents, int); |
| 186 |
|
|
DeclareParameter(TargetTemp, double); |
| 187 |
|
|
DeclareParameter(Ensemble, std::string); |
| 188 |
|
|
DeclareParameter(Dt, double); |
| 189 |
|
|
DeclareParameter(RunTime, double); |
| 190 |
|
|
DeclareParameter(InitialConfig, std::string); |
| 191 |
|
|
DeclareParameter(FinalConfig, std::string); |
| 192 |
|
|
DeclareParameter(NMol, int); |
| 193 |
|
|
DeclareParameter(Density, double); |
| 194 |
|
|
DeclareParameter(Box, double); |
| 195 |
|
|
DeclareParameter(BoxX, double); |
| 196 |
|
|
DeclareParameter(BoxY, double); |
| 197 |
|
|
DeclareParameter(BoxZ, double); |
| 198 |
|
|
DeclareParameter(SampleTime, double); |
| 199 |
|
|
DeclareParameter(ResetTime, double); |
| 200 |
|
|
DeclareParameter(StatusTime, double); |
| 201 |
|
|
DeclareParameter(CutoffRadius, double); |
| 202 |
|
|
DeclareParameter(SwitchingRadius, double); |
| 203 |
|
|
DeclareParameter(Dielectric, double); |
| 204 |
|
|
DeclareParameter(TempSet, bool); |
| 205 |
|
|
DeclareParameter(ThermalTime, double); |
| 206 |
|
|
DeclareParameter(MixingRule, std::string); |
| 207 |
|
|
DeclareParameter(UsePeriodicBoundaryConditions, bool); |
| 208 |
|
|
DeclareParameter(TargetPressure, double); |
| 209 |
|
|
DeclareParameter(TauThermostat, double); |
| 210 |
|
|
DeclareParameter(TauBarostat, double); |
| 211 |
|
|
DeclareParameter(ZconsTime, double); |
| 212 |
|
|
DeclareParameter(NZconstraints, int); |
| 213 |
|
|
DeclareParameter(ZconsTol, double); |
| 214 |
|
|
DeclareParameter(ZconsForcePolicy, std::string); |
| 215 |
|
|
DeclareParameter(Seed, int); |
| 216 |
|
|
DeclareParameter(UseInitalTime, bool); |
| 217 |
|
|
DeclareParameter(UseIntialExtendedSystemState, bool); |
| 218 |
|
|
DeclareParameter(OrthoBoxTolerance, double); |
| 219 |
|
|
DeclareParameter(Minimizer, std::string); |
| 220 |
|
|
DeclareParameter(MinimizerMaxIter, double); |
| 221 |
|
|
DeclareParameter(MinimizerWriteFrq, int); |
| 222 |
|
|
DeclareParameter(MinimizerStepSize, double); |
| 223 |
|
|
DeclareParameter(MinimizerFTol, double); |
| 224 |
|
|
DeclareParameter(MinimizerGTol, double); |
| 225 |
|
|
DeclareParameter(MinimizerLSTol, double); |
| 226 |
|
|
DeclareParameter(MinimizerLSMaxIter, int); |
| 227 |
|
|
DeclareParameter(ZconsGap, double); |
| 228 |
|
|
DeclareParameter(ZconsFixtime, double); |
| 229 |
|
|
DeclareParameter(ZconsUsingSMD, bool); |
| 230 |
|
|
DeclareParameter(UseSolidThermInt, bool); |
| 231 |
|
|
DeclareParameter(UseLiquidThermInt, bool); |
| 232 |
|
|
DeclareParameter(ThermodynamicIntegrationLambda, double); |
| 233 |
|
|
DeclareParameter(ThermodynamicIntegrationK, double); |
| 234 |
|
|
DeclareParameter(ForceFieldVariant, std::string); |
| 235 |
|
|
DeclareParameter(ForceFieldFileName, std::string); |
| 236 |
|
|
DeclareParameter(ThermIntDistSpringConst, double); |
| 237 |
|
|
DeclareParameter(ThermIntThetaSpringConst, double); |
| 238 |
|
|
DeclareParameter(ThermIntOmegaSpringConst, double); |
| 239 |
|
|
DeclareParameter(SurfaceTension, double); |
| 240 |
|
|
DeclareParameter(PrintPressureTensor, bool); |
| 241 |
|
|
DeclareParameter(ElectrostaticSummationMethod, std::string); |
| 242 |
chrisfen |
716 |
DeclareParameter(ElectrostaticScreeningMethod, std::string); |
| 243 |
tim |
665 |
DeclareParameter(DampingAlpha, double); |
| 244 |
|
|
DeclareParameter(CutoffPolicy, std::string); |
| 245 |
|
|
DeclareParameter(CompressDumpFile, bool); |
| 246 |
chrisfen |
721 |
DeclareParameter(DumpForceVector, bool); |
| 247 |
tim |
665 |
DeclareParameter(SkinThickness, double); |
| 248 |
|
|
DeclareParameter(StatFileFormat, std::string); |
| 249 |
|
|
|
| 250 |
|
|
private: |
| 251 |
|
|
typedef std::map<std::string, ParameterBase*> ParamMap; |
| 252 |
|
|
ParamMap parameters_; |
| 253 |
|
|
|
| 254 |
|
|
Component* current_component; |
| 255 |
|
|
Component** components; // the array of components |
| 256 |
|
|
|
| 257 |
|
|
ZconStamp* current_zConstraint; |
| 258 |
|
|
ZconStamp** zConstraints; // the array of zConstraints |
| 259 |
|
|
|
| 260 |
|
|
char* checkMe(); |
| 261 |
|
|
|
| 262 |
|
|
public: |
| 263 |
|
|
int newComponent( event* the_event ); |
| 264 |
|
|
int componentAssign( event* the_event ); |
| 265 |
|
|
int componentEnd( event* the_event ); |
| 266 |
|
|
|
| 267 |
|
|
int newZconstraint( event* the_event ); |
| 268 |
|
|
int zConstraintAssign( event* the_event ); |
| 269 |
|
|
int zConstraintEnd( event* the_event ); |
| 270 |
gezelter |
2 |
|
| 271 |
tim |
665 |
int globalAssign( event* the_event ); |
| 272 |
|
|
int globalEnd( event* the_event ); |
| 273 |
|
|
|
| 274 |
|
|
ZconStamp** getZconStamp() {return zConstraints;} |
| 275 |
|
|
Component** getComponents() {return components;} |
| 276 |
gezelter |
2 |
}; |
| 277 |
tim |
665 |
#endif |
| 278 |
gezelter |
2 |
|