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

Comparing trunk/src/io/Globals.cpp (property svn:keywords):
Revision 748 by chuckv, Wed Nov 16 21:37:45 2005 UTC vs.
Revision 1993 by gezelter, Tue Apr 29 17:32:31 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines