ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/io/Globals.hpp
(Generate patch)

Comparing trunk/src/io/Globals.hpp (file contents):
Revision 674 by tim, Mon Oct 17 03:06:29 2005 UTC vs.
Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC

# Line 6 | Line 6
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
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
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.
# Line 37 | Line 28
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, 24107 (2008).          
39 + * [4]  Vardeman & Gezelter, in progress (2009).                        
40   */
41  
42   #ifndef IO_GLOBALS_HPP
# Line 49 | Line 49
49   #include <string>
50   #include <map>
51  
52 #include "io/BASS_interface.h"
52   #include "types/Component.hpp"
53 < #include "types/MakeStamps.hpp"
54 < #include "types/ZconStamp.hpp"
55 < #include "utils/CaseConversion.hpp"
53 > #include "types/ZconsStamp.hpp"
54 > #include "types/RestraintStamp.hpp"
55 > #include "types/MoleculeStamp.hpp"
56 > #include "utils/ParameterManager.hpp"
57  
58 < template<typename T>
59 < struct ParameterTraits;
58 > namespace OpenMD {
59 >  class Globals : public DataHolder {
60 >  public:
61 >    typedef std::pair<int, int> intPair;
62  
63 < //string
64 < template<>                    
63 < struct ParameterTraits<std::string>{
64 <  typedef std::string RepType;       // Representation type of the value
65 <
66 < 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 <  static std::string getParamType() { return "string";}  
70 < };
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 <    }
63 >    Globals();
64 >    virtual ~Globals();
65      
66 <     return result;
67 <  }
68 <  static std::string getParamType() { return "bool";}  
69 < };
70 <
71 < //int  
72 < template<>
73 < struct ParameterTraits<int>{
74 <    typedef int 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(RepType v, RepType& r)            { r=v; return true;}
78 <    static std::string getParamType() { return "int";}  
79 < };
80 <
81 < //double
82 < template<>                    
83 < struct ParameterTraits<double>{
84 <    typedef double RepType;
85 <    template<typename T> static bool    convert(T, RepType&){return false;}
86 <    template<typename T> static RepType convert(T v)        {RepType tmp; convert(v,tmp);return tmp;}
87 <    static bool convert(RepType v, RepType& r)            {r=v; return true;}
88 <    static bool convert(int v, RepType& r)                {r = static_cast<double>(v); return true;}
89 <    static std::string getParamType() { return "double";}    
90 < };
91 <
92 <
93 < class ParameterBase {
94 <  public:    
95 <    ParameterBase() : keyword_(), optional_(false), defaultValue_(false), empty_(true) {}
96 <    bool isOptional() {return optional_;}
97 <    void setOptional(bool optional) {optional_ = optional;}
98 <    bool hasDefaultValue() {return defaultValue_;}
99 <    virtual bool isValid() { return true;}
100 <    const std::string& getKeyword() {return keyword_;}
101 <    void setKeyword(const std::string& keyword) { keyword_ = keyword;}
102 <    bool empty() {return empty_;}
103 <    virtual bool setData(std::string) = 0;
104 <    virtual bool setData(int) = 0;
105 <    virtual bool setData(double) = 0;
106 <    virtual std::string getParamType() = 0;
107 <  protected:
108 <    std::string keyword_;
109 <    bool optional_;
110 <    bool defaultValue_;
111 <    bool empty_;
112 < };
113 <
114 < template<class ParamType>
115 < class Parameter : public ParameterBase{
116 <   public:    
117 <    typedef ParameterTraits<ParamType> ValueType;
118 <     void setDefaultValue(const ParamType& value) {data_ = value; defaultValue_ = true;}
119 <     ParamType getData() { return data_;}
120 <
121 <    virtual bool setData(std::string sval) {
122 <        return internalSetData<std::string>(sval);
123 <    }
124 <    virtual bool setData(int ival) {
125 <        return internalSetData<int>(ival);
126 <    }
66 >    DeclareParameter(ForceField, std::string);
67 >    DeclareParameter(TargetTemp, RealType);
68 >    DeclareParameter(Ensemble, std::string);
69 >    DeclareParameter(Dt, RealType);
70 >    DeclareParameter(RunTime, RealType);
71 >    DeclareParameter(FinalConfig, std::string);
72 >    DeclareParameter(SampleTime, RealType);
73 >    DeclareParameter(ResetTime, RealType);
74 >    DeclareParameter(StatusTime, RealType);
75 >    DeclareParameter(CutoffRadius, RealType);
76 >    DeclareParameter(SwitchingRadius, RealType);
77 >    DeclareParameter(TempSet, bool);
78 >    DeclareParameter(ThermalTime, RealType);
79 >    DeclareParameter(UsePeriodicBoundaryConditions, bool);
80 >    DeclareParameter(TargetPressure, RealType);
81 >    DeclareParameter(UseAtomicVirial, bool);
82 >    DeclareParameter(TauThermostat, RealType);
83 >    DeclareParameter(TauBarostat, RealType);
84 >    DeclareParameter(ZconsTime, RealType);
85 >    DeclareParameter(ZconsTol, RealType);
86 >    DeclareParameter(ZconsForcePolicy, std::string);
87 >    DeclareParameter(Seed, unsigned long int);
88 >    DeclareParameter(UseInitalTime, bool);
89 >    DeclareParameter(UseIntialExtendedSystemState, bool);
90 >    DeclareParameter(OrthoBoxTolerance, RealType);
91 >    DeclareParameter(Minimizer, std::string);
92 >    DeclareParameter(MinimizerMaxIter, RealType);
93 >    DeclareParameter(MinimizerWriteFrq, int);
94 >    DeclareParameter(MinimizerStepSize, RealType);
95 >    DeclareParameter(MinimizerFTol, RealType);
96 >    DeclareParameter(MinimizerGTol, RealType);
97 >    DeclareParameter(MinimizerLSTol, RealType);
98 >    DeclareParameter(MinimizerLSMaxIter, int);
99 >    DeclareParameter(ZconsGap, RealType);
100 >    DeclareParameter(ZconsFixtime, RealType);
101 >    DeclareParameter(ZconsUsingSMD, bool);
102 >    DeclareParameter(UseThermodynamicIntegration, bool);
103 >    DeclareParameter(ThermodynamicIntegrationLambda, RealType);
104 >    DeclareParameter(ThermodynamicIntegrationK, RealType);
105 >    DeclareParameter(ForceFieldVariant, std::string);
106 >    DeclareParameter(ForceFieldFileName, std::string);
107 >    DeclareParameter(SurfaceTension, RealType);
108 >    DeclareParameter(PrintPressureTensor, bool);
109 >    DeclareParameter(TaggedAtomPair, intPair);
110 >    DeclareParameter(PrintTaggedPairDistance, bool);
111 >    DeclareParameter(ElectrostaticSummationMethod, std::string);
112 >    DeclareParameter(ElectrostaticScreeningMethod, std::string);
113 >    DeclareParameter(DampingAlpha, RealType);
114 >    DeclareParameter(Dielectric, RealType);
115 >    DeclareParameter(CutoffPolicy, std::string);
116 >    DeclareParameter(SwitchingFunctionType, std::string);
117 >    DeclareParameter(CompressDumpFile, bool);
118 >    DeclareParameter(OutputForceVector, bool);
119 >    DeclareParameter(SkinThickness, RealType);
120 >    DeclareParameter(StatFileFormat, std::string);    
121 >    DeclareParameter(HydroPropFile, std::string);
122 >    DeclareParameter(Viscosity, RealType);
123 >    DeclareParameter(BeadSize, RealType);  
124 >    DeclareParameter(ThermalConductivity, RealType);
125 >    DeclareParameter(ThermalLength, RealType);
126 >    DeclareParameter(UseSphericalBoundaryConditions, bool);
127 >    DeclareParameter(FrozenBufferRadius, RealType);
128 >    DeclareParameter(LangevinBufferRadius, RealType);
129 >    DeclareParameter(AccumulateBoxDipole, bool);
130 >    DeclareParameter(NeighborListNeighbors, int);
131 >    DeclareParameter(UseMultipleTemperatureMethod, bool);
132 >    DeclareParameter(MTM_Ce, RealType);
133 >    DeclareParameter(MTM_G, RealType);
134 >    DeclareParameter(MTM_Io, RealType);
135 >    DeclareParameter(MTM_Sigma, RealType);    
136 >    DeclareParameter(MTM_R, RealType);    
137 >    DeclareParameter(UseRNEMD, bool);
138 >    DeclareParameter(RNEMD_exchangeTime, RealType);
139 >    DeclareParameter(RNEMD_nBins, int);
140 >    DeclareParameter(RNEMD_logWidth, int);
141 >    DeclareParameter(RNEMD_exchangeType, std::string);
142 >    DeclareParameter(RNEMD_objectSelection, std::string);
143 >    DeclareParameter(RNEMD_targetFlux, RealType);
144 >    DeclareParameter(UseRestraints, bool);
145 >    DeclareParameter(Restraint_file, std::string);
146      
150    virtual bool setData(double dval) {
151        return internalSetData<double>(dval);
152    }
153
154    virtual std::string getParamType() { return ParameterTraits<ParamType>::getParamType();}
155   private:
156     template<class T> bool internalSetData(T data) {
157        ParamType tmp;
158        bool result = ValueType::convert(data, tmp);
159        if (result) {
160            empty_ = false;
161            data_ = tmp;
162        }
163        return result;
164     }
165    
166   private:
167     ParamType data_;
168      
169 };
170
171 #define DeclareParameter(NAME, TYPE)         \
172    private:                                                   \
173      Parameter<TYPE> NAME;                                     \
174    public:                                                      \
175      bool have##NAME() { return !NAME.empty();}  \
176      TYPE get##NAME() { return NAME.getData();}
177
178
179 class Globals {
147    public:
148 <    Globals();
148 >    bool addComponent(Component* comp);
149 >    bool addZConsStamp(ZConsStamp* zcons);
150 >    bool addRestraintStamp(RestraintStamp* rest);
151 >    bool addMoleculeStamp(MoleculeStamp* molStamp);
152 >    int getNComponents() {return components_.size();}
153 >    std::vector<Component*> getComponents() {return components_;}
154 >    Component* getComponentAt(int index) {return components_.at(index);}    
155      
156 <  DeclareParameter(ForceField, std::string);
157 <  DeclareParameter(NComponents, int);  
158 <  DeclareParameter(TargetTemp, double);
186 <  DeclareParameter(Ensemble, std::string);
187 <  DeclareParameter(Dt, double);
188 <  DeclareParameter(RunTime, double);
189 <  DeclareParameter(InitialConfig, std::string);
190 <  DeclareParameter(FinalConfig, std::string);
191 <  DeclareParameter(NMol, int);
192 <  DeclareParameter(Density, double);
193 <  DeclareParameter(Box, double);
194 <  DeclareParameter(BoxX, double);
195 <  DeclareParameter(BoxY, double);
196 <  DeclareParameter(BoxZ, double);
197 <  DeclareParameter(SampleTime, double);
198 <  DeclareParameter(ResetTime, double);
199 <  DeclareParameter(StatusTime, double);
200 <  DeclareParameter(CutoffRadius, double);
201 <  DeclareParameter(SwitchingRadius, double);
202 <  DeclareParameter(Dielectric, double);
203 <  DeclareParameter(TempSet, bool);
204 <  DeclareParameter(ThermalTime, double);
205 <  DeclareParameter(MixingRule, std::string);
206 <  DeclareParameter(UsePeriodicBoundaryConditions, bool);
207 <  DeclareParameter(TargetPressure, double);
208 <  DeclareParameter(TauThermostat, double);
209 <  DeclareParameter(TauBarostat, double);
210 <  DeclareParameter(ZconsTime, double);
211 <  DeclareParameter(NZconstraints, int);
212 <  DeclareParameter(ZconsTol, double);
213 <  DeclareParameter(ZconsForcePolicy, std::string);
214 <  DeclareParameter(Seed, int);
215 <  DeclareParameter(UseInitalTime, bool);
216 <  DeclareParameter(UseIntialExtendedSystemState, bool);
217 <  DeclareParameter(OrthoBoxTolerance, double);
218 <  DeclareParameter(Minimizer, std::string);
219 <  DeclareParameter(MinimizerMaxIter, double);
220 <  DeclareParameter(MinimizerWriteFrq, int);
221 <  DeclareParameter(MinimizerStepSize, double);
222 <  DeclareParameter(MinimizerFTol, double);
223 <  DeclareParameter(MinimizerGTol, double);
224 <  DeclareParameter(MinimizerLSTol, double);
225 <  DeclareParameter(MinimizerLSMaxIter, int);
226 <  DeclareParameter(ZconsGap, double);
227 <  DeclareParameter(ZconsFixtime, double);
228 <  DeclareParameter(ZconsUsingSMD, bool);
229 <  DeclareParameter(UseSolidThermInt, bool);
230 <  DeclareParameter(UseLiquidThermInt, bool);
231 <  DeclareParameter(ThermodynamicIntegrationLambda, double);
232 <  DeclareParameter(ThermodynamicIntegrationK, double);
233 <  DeclareParameter(ForceFieldVariant, std::string);
234 <  DeclareParameter(ForceFieldFileName, std::string);
235 <  DeclareParameter(ThermIntDistSpringConst, double);
236 <  DeclareParameter(ThermIntThetaSpringConst, double);
237 <  DeclareParameter(ThermIntOmegaSpringConst, double);
238 <  DeclareParameter(SurfaceTension, double);
239 <  DeclareParameter(PrintPressureTensor, bool);
240 <  DeclareParameter(ElectrostaticSummationMethod, std::string);
241 <  DeclareParameter(DampingAlpha, double);
242 <  DeclareParameter(CutoffPolicy, std::string);
243 <  DeclareParameter(CompressDumpFile, bool);
244 <  DeclareParameter(SkinThickness, double);
245 <  DeclareParameter(StatFileFormat, std::string);    
156 >    int getNZconsStamps() {return zconstraints_.size();}
157 >    std::vector<ZConsStamp*> getZconsStamps() {return zconstraints_;}
158 >    ZConsStamp* getZconsStampAt(int index) {return zconstraints_.at(index);}    
159  
160 +    int getNRestraintStamps() {return restraints_.size();}
161 +    std::vector<RestraintStamp*> getRestraintStamps() {return restraints_;}
162 +    RestraintStamp* getRestraintStampAt(int index) {return restraints_.at(index);}    
163 +
164 +    //std::string getRestraint_file(){
165 +    
166 +    virtual void validate();
167    private:
248    typedef std::map<std::string, ParameterBase*> ParamMap;
249    ParamMap parameters_;
168      
169 <    Component* current_component;
170 <    Component** components; // the array of components
171 <
172 <    ZconStamp* current_zConstraint;
173 <    ZconStamp** zConstraints; // the array of zConstraints
256 <
257 <    char* checkMe();
258 <
259 <  public:
260 <    int newComponent( event* the_event );
261 <    int componentAssign( event* the_event );
262 <    int componentEnd( event* the_event );
263 <
264 <    int newZconstraint( event* the_event );
265 <    int zConstraintAssign( event* the_event );
266 <    int zConstraintEnd( event* the_event );
267 <  
268 <    int globalAssign( event* the_event );
269 <    int globalEnd( event* the_event );    
270 <
271 <    ZconStamp** getZconStamp() {return zConstraints;}
272 <    Component** getComponents() {return components;}
169 >    std::vector<Component*> components_;
170 >    std::vector<ZConsStamp*> zconstraints_;    
171 >    std::vector<RestraintStamp*> restraints_;    
172 >    std::map<std::string, MoleculeStamp*> moleculeStamps_;
173 >    std::pair<int, int> taggedAtomPair_;
174   };
175 + }
176   #endif
275

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines