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 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 +    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 < Globals::Globals(){
103 <
104 <  DefineParameter(ForceField, "forceField")
105 <  DefineParameter(NComponents, "nComponents")
106 <
107 <  DefineOptionalParameter(TargetTemp, "targetTemp");
108 <  DefineOptionalParameter(Ensemble, "ensemble");
109 <  DefineOptionalParameter(Dt, "dt");
110 <  DefineOptionalParameter(RunTime, "runTime");
111 <  DefineOptionalParameter(InitialConfig, "initialConfig");
112 <  DefineOptionalParameter(FinalConfig, "finalConfig");
113 <  DefineOptionalParameter(NMol, "nMol");
114 <  DefineOptionalParameter(Density, "density");
115 <  DefineOptionalParameter(Box, "box");
116 <  DefineOptionalParameter(BoxX, "boxX");
117 <  DefineOptionalParameter(BoxY, "boxY");
118 <  DefineOptionalParameter(BoxZ, "boxZ");
119 <  DefineOptionalParameter(SampleTime, "sampleTime");
120 <  DefineOptionalParameter(ResetTime, "resetTime");
121 <  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");    
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  
123    
124 < }
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 <  char errorMessage[65535];
181 <  int key;
182 <  interface_assign_type the_type =  the_event->evt.asmt.asmt_type;
183 <  char* lhs = the_event->evt.asmt.lhs;
184 <  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  
196 <  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);
196 >    
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    }
176  
177  return result;
178 }
207  
208 < int Globals::newComponent( event* the_event ){
209 <  
182 <  current_component = new Component;
183 <  int index = the_event->evt.blk_index;
184 <  char err[200];
185 <  
186 <  if( haveNComponents() && index < getNComponents() )
187 <    components[index] = current_component;
188 <  else{
189 <    if( haveNComponents()  ){
190 <      sprintf( err, "meta-data parsing error: %d out of nComponents range",
191 <               index );
192 <      the_event->err_msg = strdup( err );
193 <      return 0;
194 <    }
195 <    else{
196 <      the_event->err_msg = strdup("meta-data parsing error: nComponents not given before"
197 <                                  " first component declaration." );
198 <      return 0;
199 <    }
200 <  }  
201 <
202 <  return 1;
203 < }
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,
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;
314 >    rnemdPars_ = rnemdPars;
315 >    return true;
316    }
235  return 0;
236 }
317  
318 < int Globals::componentEnd( event* the_event ){
319 <
320 <  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 ){
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,
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;
322 >    minimizerPars_ = miniPars;
323 >    return true;
324    }
303  return 0;
304 }
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;
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";
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    }
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
342   }
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 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