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

Comparing trunk/src/io/Globals.cpp (file contents):
Revision 672 by tim, Fri Oct 14 21:43:13 2005 UTC vs.
Revision 2034 by gezelter, Mon Nov 3 16:49:03 2014 UTC

# Line 1 | Line 1
1   /*
2 < * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
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. 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, 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>
# Line 45 | Line 46
46   #include <string>
47  
48   #include "io/Globals.hpp"
49 + #include "io/ParamConstraint.hpp"
50 + #include "utils/MemoryUtils.hpp"
51   #include "utils/simError.h"
49 #ifdef IS_MPI
50 #include "io/mpiBASS.h"
51 #endif // is_mpi
52  
53 < #include "io/ParamConstraint.hpp"
53 > namespace OpenMD {
54 >  Globals::Globals() {
55 >  
56 >    flucQpars_ = new FluctuatingChargeParameters();
57 >    rnemdPars_ = new RNEMDParameters();
58 >    minimizerPars_ = new MinimizerParameters();
59  
60 < #define DefineParameter(NAME,KEYWORD)                              \
61 <  NAME.setKeyword(KEYWORD);                  \
62 <  parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME));
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(UniformGradientStrength, "uniformGradientStrength");
96 >    DefineOptionalParameter(UniformGradientDirection1, "uniformGradientDirection1");
97 >    DefineOptionalParameter(UniformGradientDirection2, "uniformGradientDirection2");
98 >    //DefineOptionalParameter(PeriodicField, "periodicField");
99 >    //DefineOptionalParameter(PeriodicFieldStrength, "periodicFieldStrength");
100 >    
101  
102 < #define DefineOptionalParameter(NAME,KEYWORD)                              \
103 <  NAME.setKeyword(KEYWORD); NAME.setOptional(true);                    \
104 <  parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME));
102 >    DefineOptionalParameter(TaggedAtomPair, "taggedAtomPair");
103 >    DefineOptionalParameter(PrintTaggedPairDistance, "printTaggedPairDistance");
104 >    DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType");
105 >    DefineOptionalParameter(HydroPropFile, "HydroPropFile");
106 >    DefineOptionalParameter(Viscosity, "viscosity");
107 >    DefineOptionalParameter(BeadSize, "beadSize");
108 >    DefineOptionalParameter(FrozenBufferRadius, "frozenBufferRadius");
109 >    DefineOptionalParameter(LangevinBufferRadius, "langevinBufferRadius");
110 >    DefineOptionalParameter(NeighborListNeighbors,"NeighborListNeighbors");
111 >    DefineOptionalParameter(UseMultipleTemperatureMethod,
112 >                            "useMultipleTemperatureMethod");
113 >    DefineOptionalParameter(ElectrostaticSummationMethod,
114 >                            "electrostaticSummationMethod");
115 >    DefineOptionalParameter(MTM_Ce, "MTM_Ce");
116 >    DefineOptionalParameter(MTM_G, "MTM_G");
117 >    DefineOptionalParameter(MTM_Io, "MTM_Io");
118 >    DefineOptionalParameter(MTM_Sigma, "MTM_Sigma");
119 >    DefineOptionalParameter(MTM_R, "MTM_R");
120 >    DefineOptionalParameter(Alpha, "alpha");
121 >    DefineOptionalParameter(ConstraintTime, "constraintTime");
122  
63 #define DefineOptionalParameterWithDefaultValue(NAME,KEYWORD, DEFAULTVALUE)                              \
64  NAME.setKeyword(KEYWORD); NAME.setOptional(true); NAME.setDefaultValue(DEFAULTVALUE);                      \
65  parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME));
66
67 #define CheckParameter(NAME, CONSTRAINT)                              \
68  if (!NAME.empty()) { if (!(CONSTRAINT)(NAME.getData())) std::cout <<"Error in parsing " << NAME.getKeyword() << " : "<< (CONSTRAINT).getConstraintDescription() << std::endl; }                
69
70
71 Globals::Globals(){
72
73  DefineParameter(ForceField, "forceField")
74  DefineParameter(NComponents, "nComponents")
75
76  DefineOptionalParameter(TargetTemp, "targetTemp");
77  DefineOptionalParameter(Ensemble, "ensemble");
78  DefineOptionalParameter(Dt, "dt");
79  DefineOptionalParameter(RunTime, "runTime");
80  DefineOptionalParameter(InitialConfig, "initialConfig");
81  DefineOptionalParameter(FinalConfig, "finalConfig");
82  DefineOptionalParameter(NMol, "nMol");
83  DefineOptionalParameter(Density, "density");
84  DefineOptionalParameter(Box, "box");
85  DefineOptionalParameter(BoxX, "boxX");
86  DefineOptionalParameter(BoxY, "boxY");
87  DefineOptionalParameter(BoxZ, "boxZ");
88  DefineOptionalParameter(SampleTime, "sampleTime");
89  DefineOptionalParameter(ResetTime, "resetTime");
90  DefineOptionalParameter(StatusTime, "statusTime");
91  DefineOptionalParameter(CutoffRadius, "cutoffRadius");
92  DefineOptionalParameter(SwitchingRadius, "switchingRadius");
93  DefineOptionalParameter(Dielectric, "dielectric");
94  DefineOptionalParameter(TempSet, "tempSet");
95  DefineOptionalParameter(ThermalTime, "thermalTime");
96  DefineOptionalParameter(TargetPressure, "targetPressure");
97  DefineOptionalParameter(TauThermostat, "tauThermostat");
98  DefineOptionalParameter(TauBarostat, "tauBarostat");
99  DefineOptionalParameter(ZconsTime, "zconsTime");
100  DefineOptionalParameter(NZconstraints, "nZconstraints");  
101  DefineOptionalParameter(ZconsTol, "zconsTol");
102  DefineOptionalParameter(ZconsForcePolicy, "zconsForcePolicy");
103  DefineOptionalParameter(Seed, "seed");
104  DefineOptionalParameter(Minimizer, "minimizer");
105  DefineOptionalParameter(MinimizerMaxIter,"minimizerMaxIter");
106  DefineOptionalParameter(MinimizerWriteFrq, "minimizerWriteFrq");
107  DefineOptionalParameter(MinimizerStepSize, "minimizerStepSize");
108  DefineOptionalParameter(MinimizerFTol, "minimizerFTol");
109  DefineOptionalParameter(MinimizerGTol, "minimizerGTol");
110  DefineOptionalParameter(MinimizerLSTol, "minimizerLSTol");
111  DefineOptionalParameter(MinimizerLSMaxIter, "minimizerLSMaxIter");
112  DefineOptionalParameter(ZconsGap, "zconsGap");
113  DefineOptionalParameter(ZconsFixtime, "zconsFixtime");
114  DefineOptionalParameter(ZconsUsingSMD, "zconsUsingSMD");
115  DefineOptionalParameter(ThermodynamicIntegrationLambda, "thermodynamicIntegrationLambda");
116  DefineOptionalParameter(ThermodynamicIntegrationK, "thermodynamicIntegrationK");
117  DefineOptionalParameter(ForceFieldVariant, "forceFieldVariant");
118  DefineOptionalParameter(ForceFieldFileName, "forceFieldFileName");
119  DefineOptionalParameter(ThermIntDistSpringConst, "thermIntDistSpringConst");
120  DefineOptionalParameter(ThermIntThetaSpringConst, "thermIntThetaSpringConst");
121  DefineOptionalParameter(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst");
122  DefineOptionalParameter(SurfaceTension, "surfaceTension");
123  DefineOptionalParameter(PrintPressureTensor, "printPressureTensor");
124  DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod");
125  DefineOptionalParameter(CutoffPolicy, "cutoffPolicy");
126  DefineOptionalParameter(StatFileFormat, "statFileFormat");    
123    
124 <  DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard");
125 <  DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true);
126 <  DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false);
127 <  DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState, "useInitialExtendedSystemState", false);
128 <  DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance, "orthoBoxTolerance", 1E-6);  
129 <  DefineOptionalParameterWithDefaultValue(UseSolidThermInt, "useSolidThermInt", false);
130 <  DefineOptionalParameterWithDefaultValue(UseLiquidThermInt, "useLiquidThermInt", false);
131 <  DefineOptionalParameterWithDefaultValue(ThermIntDistSpringConst, "thermIntDistSpringConst", 6.0);
132 <  DefineOptionalParameterWithDefaultValue(ThermIntThetaSpringConst, "thermIntThetaSpringConst", 7.5);
133 <  DefineOptionalParameterWithDefaultValue(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst", 13.5);
134 <  DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 1.5);
135 <  DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0);
136 <  DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0);
137 <  
138 < }
124 >    DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions,
125 >                                            "usePeriodicBoundaryConditions",
126 >                                            true);
127 >    DefineOptionalParameterWithDefaultValue(UseAtomicVirial, "useAtomicVirial",
128 >                                            true);
129 >    DefineOptionalParameterWithDefaultValue(UseLongRangeCorrections,
130 >                                            "useLongRangeCorrections", true);
131 >    DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime",
132 >                                            false);
133 >    DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState,
134 >                                            "useInitialExtendedSystemState",
135 >                                            false);
136 >    DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance,
137 >                                            "orthoBoxTolerance", 1E-6);  
138 >    DefineOptionalParameterWithDefaultValue(CutoffMethod, "cutoffMethod",
139 >                                            "SHIFTED_FORCE");
140 >    DefineOptionalParameterWithDefaultValue(ElectrostaticScreeningMethod,
141 >                                            "electrostaticScreeningMethod",
142 >                                            "DAMPED");
143 >    DefineOptionalParameterWithDefaultValue(Dielectric, "dielectric", 80.0);
144 >    DefineOptionalParameterWithDefaultValue(CompressDumpFile,
145 >                                            "compressDumpFile", false);
146 >    DefineOptionalParameterWithDefaultValue(PrintHeatFlux, "printHeatFlux",
147 >                                            false);
148 >    DefineOptionalParameterWithDefaultValue(OutputForceVector,
149 >                                            "outputForceVector", false);
150 >    DefineOptionalParameterWithDefaultValue(OutputParticlePotential,
151 >                                            "outputParticlePotential", false);
152 >    DefineOptionalParameterWithDefaultValue(OutputElectricField,
153 >                                            "outputElectricField", false);
154 >    DefineOptionalParameterWithDefaultValue(OutputFluctuatingCharges,
155 >                                            "outputFluctuatingCharges", false);
156 >    DefineOptionalParameterWithDefaultValue(OutputSitePotential,
157 >                                            "outputSitePotential", false);
158 >    DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness",
159 >                                            1.0);
160 >    DefineOptionalParameterWithDefaultValue(StatFileFormat,
161 >                                            "statFileFormat",
162 >                                            "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY");    
163 >    DefineOptionalParameterWithDefaultValue(UseSphericalBoundaryConditions,
164 >                                            "useSphericalBoundaryConditions",
165 >                                            false);
166 >    DefineOptionalParameterWithDefaultValue(AccumulateBoxDipole,
167 >                                            "accumulateBoxDipole", false);
168 >    DefineOptionalParameterWithDefaultValue(AccumulateBoxQuadrupole,
169 >                                            "accumulateBoxQuadrupole", false);
170 >    DefineOptionalParameterWithDefaultValue(UseRestraints, "useRestraints",
171 >                                            false);
172 >    DefineOptionalParameterWithDefaultValue(Restraint_file, "Restraint_file",
173 >                                            "idealCrystal.in");
174 >    DefineOptionalParameterWithDefaultValue(UseThermodynamicIntegration,
175 >                                            "useThermodynamicIntegration",
176 >                                            false);
177 >    DefineOptionalParameterWithDefaultValue(HULL_Method,"HULL_Method","Convex");
178  
179 < int Globals::globalAssign( event* the_event ){
180 <  
181 <  int key;
182 <  int token;
183 <  interface_assign_type the_type =  the_event->evt.asmt.asmt_type;
184 <  char* lhs = the_event->evt.asmt.lhs;
185 <  std::string keyword(lhs);
179 >    deprecatedKeywords_.insert("nComponents");
180 >    deprecatedKeywords_.insert("nZconstraints");
181 >    deprecatedKeywords_.insert("initialConfig");
182 >    deprecatedKeywords_.insert("thermIntDistSpringConst");
183 >    deprecatedKeywords_.insert("thermIntThetaSpringConst");
184 >    deprecatedKeywords_.insert("thermIntOmegaSpringConst");
185 >    deprecatedKeywords_.insert("useSolidThermInt");  
186 >    deprecatedKeywords_.insert("useLiquidThermInt");
187 >    deprecatedKeywords_.insert("minimizerMaxIter");
188 >    deprecatedKeywords_.insert("minimizerWriteFreq");
189 >    deprecatedKeywords_.insert("minimizerStepSize");
190 >    deprecatedKeywords_.insert("minimizerFTol");
191 >    deprecatedKeywords_.insert("minimizerGTol");
192 >    deprecatedKeywords_.insert("minimizerLSTol");
193 >    deprecatedKeywords_.insert("minimizerLSMaxIter");
194 >    deprecatedKeywords_.insert("electricField");
195  
152  bool result;
153
154
155  ParamMap::iterator i =parameters_.find(keyword);
156  if (i != parameters_.end()) {
157    if( the_type == STRING ){
158       result = i->second->setData(std::string(the_event->evt.asmt.rhs.sval));
159       if (!result ) {
160            sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a string.\n", keyword.c_str() );
161       }
162    } else if( the_type == DOUBLE ){
163      result = i->second->setData(the_event->evt.asmt.rhs.dval);
164       if (!result )
165         sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a double.\n", keyword.c_str() );
166    }      
167    else if (the_type == INT ){
168      result = i->second->setData(the_event->evt.asmt.rhs.ival);
169       if (!result )
170         sprintf(the_event->err_msg,  "Error in parsing meta-data file!\n\t%s must be an int.\n", keyword.c_str() );
171      
172    } else {
196      
174    }
197    }
198  
199 <  if (keyword == "nComponents" && getNComponents() > 0) {
200 <    components = new Component*[getNComponents()];
201 <  }else if (keyword == "nZconstraints" && getNZconstraints() > 0) {
202 <    zConstraints = new ZconStamp*[getNZconstraints()];
199 >  Globals::~Globals() {
200 >    MemoryUtils::deletePointers(components_);
201 >    MemoryUtils::deletePointers(zconstraints_);
202 >    MemoryUtils::deletePointers(restraints_);
203 >    delete flucQpars_;
204 >    delete rnemdPars_;
205 >    delete minimizerPars_;
206    }
182  
183  return result;
184 }
207  
208 < int Globals::newComponent( event* the_event ){
209 <  
188 <  current_component = new Component;
189 <  int index = the_event->evt.blk_index;
190 <  char err[200];
191 <  
192 <  if( haveNComponents() && index < getNComponents() )
193 <    components[index] = current_component;
194 <  else{
195 <    if( haveNComponents()  ){
196 <      sprintf( err, "meta-data parsing error: %d out of nComponents range",
197 <               index );
198 <      the_event->err_msg = strdup( err );
199 <      return 0;
200 <    }
201 <    else{
202 <      the_event->err_msg = strdup("meta-data parsing error: nComponents not given before"
203 <                                  " first component declaration." );
204 <      return 0;
205 <    }
206 <  }  
207 <
208 <  return 1;
209 < }
208 >  void Globals::validate() {
209 >    DataHolder::validate();
210  
211 +    CheckParameter(ForceField, isNotEmpty());
212 +    CheckParameter(TargetTemp, isPositive());
213 +    CheckParameter(Ensemble, isEqualIgnoreCase("NVE") ||
214 +                   isEqualIgnoreCase("NVT") || isEqualIgnoreCase("NPTi") ||
215 +                   isEqualIgnoreCase("NPTf") || isEqualIgnoreCase("NPTxyz") ||
216 +                   isEqualIgnoreCase("NPTsz") || isEqualIgnoreCase("NPAT")  ||
217 +                   isEqualIgnoreCase("NPA") ||
218 +                   isEqualIgnoreCase("LANGEVINDYNAMICS") ||
219 +                   isEqualIgnoreCase("LD") || isEqualIgnoreCase("NPRT") ||
220 +                   isEqualIgnoreCase("NPGT") || isEqualIgnoreCase("NGammaT") ||
221 +                   isEqualIgnoreCase("NGT") ||
222 +                   isEqualIgnoreCase("LANGEVINHULL") ||
223 +                   isEqualIgnoreCase("LHULL") || isEqualIgnoreCase("SMIPD"));
224 +    CheckParameter(Dt, isPositive());
225 +    CheckParameter(RunTime, isPositive());
226 +    CheckParameter(FinalConfig, isNotEmpty());
227 +    CheckParameter(SampleTime, isNonNegative());
228 +    CheckParameter(ResetTime, isNonNegative());
229 +    CheckParameter(StatusTime, isNonNegative());
230 +    CheckParameter(CutoffRadius, isPositive());
231 +    CheckParameter(SwitchingRadius, isNonNegative());
232 +    CheckParameter(Dielectric, isPositive());
233 +    CheckParameter(ThermalTime,  isNonNegative());
234 +    CheckParameter(TauThermostat, isPositive());
235 +    CheckParameter(TauBarostat, isPositive());
236 +    CheckParameter(ZconsTime, isPositive());
237 +    CheckParameter(ZconsTol, isPositive());
238 +    CheckParameter(Seed, isPositive());
239 +    CheckParameter(ZconsGap, isPositive());
240 +    CheckParameter(ZconsFixtime, isPositive());
241 +    CheckParameter(ThermodynamicIntegrationLambda, isNonNegative());
242 +    CheckParameter(ThermodynamicIntegrationK, isPositive());
243 +    CheckParameter(ForceFieldVariant, isNotEmpty());
244 +    CheckParameter(ForceFieldFileName, isNotEmpty());
245 +    CheckParameter(CutoffMethod, isEqualIgnoreCase("HARD") ||
246 +                   isEqualIgnoreCase("SWITCHED") ||
247 +                   isEqualIgnoreCase("SHIFTED_POTENTIAL") ||
248 +                   isEqualIgnoreCase("SHIFTED_FORCE") ||
249 +                   isEqualIgnoreCase("TAYLOR_SHIFTED") ||
250 +                   isEqualIgnoreCase("EWALD_FULL"));
251 +    CheckParameter(CutoffPolicy, isEqualIgnoreCase("MIX") ||
252 +                   isEqualIgnoreCase("MAX") ||
253 +                   isEqualIgnoreCase("TRADITIONAL"));
254 +    CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase("NONE") ||
255 +                   isEqualIgnoreCase("HARD") || isEqualIgnoreCase("SWITCHED") ||
256 +                   isEqualIgnoreCase("SHIFTED_POTENTIAL") ||
257 +                   isEqualIgnoreCase("SHIFTED_FORCE") ||
258 +                   isEqualIgnoreCase("REACTION_FIELD") ||
259 +                   isEqualIgnoreCase("TAYLOR_SHIFTED"));
260 +    CheckParameter(ElectrostaticScreeningMethod,
261 +                   isEqualIgnoreCase("UNDAMPED") || isEqualIgnoreCase("DAMPED"));
262 +    CheckParameter(SwitchingFunctionType, isEqualIgnoreCase("CUBIC") ||
263 +                   isEqualIgnoreCase("FIFTH_ORDER_POLYNOMIAL"));
264 +    CheckParameter(OrthoBoxTolerance, isPositive());  
265 +    CheckParameter(DampingAlpha,isNonNegative());
266 +    CheckParameter(SkinThickness, isPositive());
267 +    CheckParameter(Viscosity, isNonNegative());
268 +    CheckParameter(BeadSize, isPositive());
269 +    CheckParameter(FrozenBufferRadius, isPositive());
270 +    CheckParameter(LangevinBufferRadius, isPositive());
271 +    CheckParameter(NeighborListNeighbors, isPositive());
272 +    CheckParameter(HULL_Method, isEqualIgnoreCase("Convex") ||
273 +                   isEqualIgnoreCase("AlphaShape"));
274 +    CheckParameter(Alpha, isPositive());
275 +  
276 +    for(std::vector<Component*>::iterator i = components_.begin();
277 +        i != components_.end(); ++i) {
278 +      if (!(*i)->findMoleculeStamp(moleculeStamps_)) {
279 +        std::ostringstream oss;
280 +        oss << "Globals Error: can not find molecule stamp for component "
281 +            << (*i)->getType() << std::endl;
282 +        throw OpenMDException(oss.str());          
283 +      }
284 +    }
285 +  }
286 +  
287 +  bool Globals::addComponent(Component* comp) {
288 +    components_.push_back(comp);
289 +    return true;
290 +  }
291  
292 +  bool Globals::addZConsStamp(ZConsStamp* zcons) {
293 +    zconstraints_.push_back(zcons);
294 +    return true;
295 +  }
296  
297 < int Globals::componentAssign( event* the_event ){
297 >  bool Globals::addRestraintStamp(RestraintStamp* rest) {
298 >    restraints_.push_back(rest);
299 >    return true;
300 >  }
301  
302 <  switch( the_event->evt.asmt.asmt_type ){
302 >  bool Globals::addFluctuatingChargeParameters(FluctuatingChargeParameters* fqp) {
303 >    if (flucQpars_ != NULL)
304 >      delete flucQpars_;
305      
306 <  case STRING:
307 <    return current_component->assignString( the_event->evt.asmt.lhs,
308 <                                            the_event->evt.asmt.rhs.sval,
309 <                                            &(the_event->err_msg));
310 <    break;
306 >    flucQpars_ = fqp;
307 >    return true;
308 >  }
309 >
310 >  bool Globals::addRNEMDParameters(RNEMDParameters* rnemdPars) {
311 >    if (rnemdPars_ != NULL)
312 >      delete rnemdPars_;
313      
314 <  case DOUBLE:
315 <    return current_component->assignDouble( the_event->evt.asmt.lhs,
225 <                                            the_event->evt.asmt.rhs.dval,
226 <                                            &(the_event->err_msg));
227 <    break;
228 <    
229 <  case INT:
230 <    return current_component->assignInt( the_event->evt.asmt.lhs,
231 <                                         the_event->evt.asmt.rhs.ival,
232 <                                         &(the_event->err_msg));
233 <    break;
234 <    
235 <  default:
236 <    the_event->err_msg = strdup( "Globals error. Invalid component"
237 <                                 " assignment type" );
238 <    return 0;
239 <    break;
314 >    rnemdPars_ = rnemdPars;
315 >    return true;
316    }
241  return 0;
242 }
317  
318 < int Globals::componentEnd( event* the_event ){
319 <
320 <  the_event->err_msg = current_component->checkMe();
247 <  if( the_event->err_msg != NULL ) return 0;
248 <
249 <  return 1;
250 < }
251 <
252 < int Globals::newZconstraint( event* the_event ){
253 <  
254 <
255 <  int index = the_event->evt.blk_index;
256 <  char err[200];
257 <  current_zConstraint = new ZconStamp( index );
258 <  
259 <  if( haveNZconstraints() && index < getNZconstraints() )
260 <    zConstraints[index] = current_zConstraint;
261 <  else{
262 <    if( haveNZconstraints() ){
263 <      sprintf( err, "meta-data parsing error: %d out of nZconstraints range",
264 <               index );
265 <      the_event->err_msg = strdup( err );
266 <      return 0;
267 <    }
268 <    else{
269 <      the_event->err_msg = strdup("meta-data parsing error: nZconstraints"
270 <                                  " not given before"
271 <                                  " first zConstraint declaration." );
272 <      return 0;
273 <    }
274 <  }  
275 <
276 <  return 1;
277 < }
278 <
279 <
280 <
281 < int Globals::zConstraintAssign( event* the_event ){
282 <
283 <  switch( the_event->evt.asmt.asmt_type ){
318 >  bool Globals::addMinimizerParameters(MinimizerParameters* miniPars) {
319 >    if (minimizerPars_ != NULL)
320 >      delete minimizerPars_;
321      
322 <  case STRING:
323 <    return current_zConstraint->assignString( the_event->evt.asmt.lhs,
287 <                                              the_event->evt.asmt.rhs.sval,
288 <                                              &(the_event->err_msg));
289 <    break;
290 <    
291 <  case DOUBLE:
292 <    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs,
293 <                                              the_event->evt.asmt.rhs.dval,
294 <                                              &(the_event->err_msg));
295 <    break;
296 <    
297 <  case INT:
298 <    return current_zConstraint->assignInt( the_event->evt.asmt.lhs,
299 <                                           the_event->evt.asmt.rhs.ival,
300 <                                           &(the_event->err_msg));
301 <    break;
302 <    
303 <  default:
304 <    the_event->err_msg = strdup( "Globals error. Invalid zConstraint"
305 <                                 " assignment type" );
306 <    return 0;
307 <    break;
322 >    minimizerPars_ = miniPars;
323 >    return true;
324    }
309  return 0;
310 }
325  
326 < int Globals::zConstraintEnd( event* the_event ){
327 <
328 <  the_event->err_msg = current_zConstraint->checkMe();
329 <  if( the_event->err_msg != NULL ) return 0;
330 <
331 <  return 1;
332 < }
333 <
334 < char* Globals::checkMe( void ){
335 <
336 <
337 <  std::string err("The following required keywords are missing:\n");
338 <  short int have_err = 0;
325 <
326 <  ParamMap::iterator i;
327 <  for (i = parameters_.begin(); i != parameters_.end(); ++i) {
328 <    if (!i->second->isOptional() && i->second->empty()) {
329 <        err +=  i->second->getKeyword() + "\n";
326 >  bool Globals::addMoleculeStamp(MoleculeStamp* molStamp) {
327 >    std::string molStampName = molStamp->getName();
328 >    std::map<std::string, MoleculeStamp*>::iterator i;
329 >    bool ret = false;
330 >    i = moleculeStamps_.find(molStampName);
331 >    if (i == moleculeStamps_.end()) {
332 >      moleculeStamps_.insert(std::map<std::string, MoleculeStamp*>::value_type(molStampName, molStamp));
333 >      ret = true;
334 >    } else {
335 >      std::ostringstream oss;
336 >      oss << "Globals Error: Molecule Stamp " << molStamp->getName()
337 >          << "appears multiple times\n";
338 >      throw OpenMDException(oss.str());  
339      }
340 +    return ret;
341    }
332
333  CheckParameter(ForceField, isNotEmpty());
334  CheckParameter(NComponents,isPositive());
335  CheckParameter(TargetTemp, isPositive());
336  CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) || isEqualIgnoreCase(std::string("NVT")) ||
337                                          isEqualIgnoreCase(std::string("NPTi")) || isEqualIgnoreCase(std::string("NPTf"))||
338                                          isEqualIgnoreCase(std::string("NPTxyz")) );
339
340  CheckParameter(Dt, isPositive());
341  CheckParameter(RunTime, isPositive());
342  CheckParameter(InitialConfig, isNotEmpty());
343  CheckParameter(FinalConfig, isNotEmpty());
344  CheckParameter(NMol, isPositive());
345  CheckParameter(Density, isPositive());
346  CheckParameter(Box, isPositive());
347  CheckParameter(BoxX, isPositive());
348  CheckParameter(BoxY, isPositive());
349  CheckParameter(BoxZ, isPositive());
350  CheckParameter(SampleTime, isNonNegative());
351  CheckParameter(ResetTime, isNonNegative());
352  CheckParameter(StatusTime, isNonNegative());
353  CheckParameter(CutoffRadius, isPositive());
354  CheckParameter(SwitchingRadius, isNonNegative());
355  CheckParameter(Dielectric, isPositive());
356  CheckParameter(ThermalTime,  isNonNegative());
357  CheckParameter(TargetPressure,  isPositive());
358  CheckParameter(TauThermostat, isPositive());
359  CheckParameter(TauBarostat, isPositive());
360  CheckParameter(ZconsTime, isPositive());
361  CheckParameter(NZconstraints, isPositive());  
362  CheckParameter(ZconsTol, isPositive());
363  //CheckParameter(ZconsForcePolicy,);
364  CheckParameter(Seed, isPositive());
365  CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) || isEqualIgnoreCase(std::string("CG")));
366  CheckParameter(MinimizerMaxIter, isPositive());
367  CheckParameter(MinimizerWriteFrq, isPositive());
368  CheckParameter(MinimizerStepSize, isPositive());
369  CheckParameter(MinimizerFTol, isPositive());
370  CheckParameter(MinimizerGTol, isPositive());
371  CheckParameter(MinimizerLSTol, isPositive());
372  CheckParameter(MinimizerLSMaxIter, isPositive());
373  CheckParameter(ZconsGap, isPositive());
374  CheckParameter(ZconsFixtime, isPositive());
375  CheckParameter(ThermodynamicIntegrationLambda, isPositive());
376  CheckParameter(ThermodynamicIntegrationK, isPositive());
377  CheckParameter(ForceFieldVariant, isNotEmpty());
378  CheckParameter(ForceFieldFileName, isNotEmpty());
379  CheckParameter(ThermIntDistSpringConst, isPositive());
380  CheckParameter(ThermIntThetaSpringConst, isPositive());
381  CheckParameter(ThermIntOmegaSpringConst, isPositive());
382  CheckParameter(SurfaceTension, isPositive());
383  CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase(std::string("NONE")) || isEqualIgnoreCase(std::string("UNDAMPED_WOLF")) || isEqualIgnoreCase(std::string("DAMPED_WOLF")) || isEqualIgnoreCase(std::string("REACTION_FIELD")) );
384  CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) || isEqualIgnoreCase(std::string("MAX")) || isEqualIgnoreCase(std::string("TRADITIONAL")));
385  //CheckParameter(StatFileFormat,);    
386  //CheckParameter(MixingRule,);
387  CheckParameter(OrthoBoxTolerance, isPositive());  
388  CheckParameter(ThermIntDistSpringConst, isPositive());
389  CheckParameter(ThermIntThetaSpringConst, isPositive());
390  CheckParameter(ThermIntOmegaSpringConst, isPositive());
391  CheckParameter(DampingAlpha,isPositive());
392  CheckParameter(SkinThickness, isPositive());
393  
394  //@todo memory leak
395  if( have_err )
396    return strdup( err.c_str() );
397  
398  return NULL;
399
400
342   }
402
403 int Globals::globalEnd( event* the_event ){
404  
405  the_event->err_msg = checkMe();
406  if( the_event->err_msg != NULL ) return 0;
407
408  return 1;
409 }

Comparing trunk/src/io/Globals.cpp (property svn:keywords):
Revision 672 by tim, Fri Oct 14 21:43:13 2005 UTC vs.
Revision 2034 by gezelter, Mon Nov 3 16:49:03 2014 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines