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 749 by tim, Wed Nov 16 23:10:02 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 < using namespace oopse;
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");
77 <  DefineOptionalParameter(CutoffRadius, "cutoffRadius");
78 <  DefineOptionalParameter(SwitchingRadius, "switchingRadius");
79 <  DefineOptionalParameter(Dielectric, "dielectric");
80 <  DefineOptionalParameter(TempSet, "tempSet");
81 <  DefineOptionalParameter(ThermalTime, "thermalTime");
82 <  DefineOptionalParameter(TargetPressure, "targetPressure");
83 <  DefineOptionalParameter(TauThermostat, "tauThermostat");
84 <  DefineOptionalParameter(TauBarostat, "tauBarostat");
85 <  DefineOptionalParameter(ZconsTime, "zconsTime");
86 <  DefineOptionalParameter(NZconstraints, "nZconstraints");  
87 <  DefineOptionalParameter(ZconsTol, "zconsTol");
88 <  DefineOptionalParameter(ZconsForcePolicy, "zconsForcePolicy");
89 <  DefineOptionalParameter(Seed, "seed");
90 <  DefineOptionalParameter(Minimizer, "minimizer");
91 <  DefineOptionalParameter(MinimizerMaxIter,"minimizerMaxIter");
92 <  DefineOptionalParameter(MinimizerWriteFrq, "minimizerWriteFrq");
93 <  DefineOptionalParameter(MinimizerStepSize, "minimizerStepSize");
94 <  DefineOptionalParameter(MinimizerFTol, "minimizerFTol");
95 <  DefineOptionalParameter(MinimizerGTol, "minimizerGTol");
96 <  DefineOptionalParameter(MinimizerLSTol, "minimizerLSTol");
97 <  DefineOptionalParameter(MinimizerLSMaxIter, "minimizerLSMaxIter");
98 <  DefineOptionalParameter(ZconsGap, "zconsGap");
99 <  DefineOptionalParameter(ZconsFixtime, "zconsFixtime");
100 <  DefineOptionalParameter(ZconsUsingSMD, "zconsUsingSMD");
101 <  DefineOptionalParameter(ThermodynamicIntegrationLambda, "thermodynamicIntegrationLambda");
102 <  DefineOptionalParameter(ThermodynamicIntegrationK, "thermodynamicIntegrationK");
103 <  DefineOptionalParameter(ForceFieldVariant, "forceFieldVariant");
104 <  DefineOptionalParameter(ForceFieldFileName, "forceFieldFileName");
105 <  DefineOptionalParameter(ThermIntDistSpringConst, "thermIntDistSpringConst");
106 <  DefineOptionalParameter(ThermIntThetaSpringConst, "thermIntThetaSpringConst");
107 <  DefineOptionalParameter(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst");
108 <  DefineOptionalParameter(SurfaceTension, "surfaceTension");
109 <  DefineOptionalParameter(PrintPressureTensor, "printPressureTensor");
110 <  DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod");
111 <  DefineOptionalParameter(ElectrostaticScreeningMethod, "electrostaticScreeningMethod");
112 <  DefineOptionalParameter(CutoffPolicy, "cutoffPolicy");
113 <  DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType");
114 <  DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard");
115 <  DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true);
116 <  DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false);
117 <  DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState, "useInitialExtendedSystemState", false);
118 <  DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance, "orthoBoxTolerance", 1E-6);  
119 <  DefineOptionalParameterWithDefaultValue(UseSolidThermInt, "useSolidThermInt", false);
120 <  DefineOptionalParameterWithDefaultValue(UseLiquidThermInt, "useLiquidThermInt", false);
121 <  DefineOptionalParameterWithDefaultValue(ThermIntDistSpringConst, "thermIntDistSpringConst", 6.0);
122 <  DefineOptionalParameterWithDefaultValue(ThermIntThetaSpringConst, "thermIntThetaSpringConst", 7.5);
123 <  DefineOptionalParameterWithDefaultValue(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst", 13.5);
124 <  DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 0.2);
125 <  DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0);
126 <  DefineOptionalParameterWithDefaultValue(OutputForceVector, "outputForceVector", 0);
127 <  DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0);
128 <  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 < Globals::~Globals(){
180 <  int i;
181 <  if( components != NULL ){
182 <    for( i=0; i< getNComponents(); i++ ) delete components[i];
183 <    delete[] components;
184 <  }
185 <  
186 <  if( zConstraints != NULL ){
187 <    for( i=0; i< getNZconstraints(); i++ ) delete zConstraints[i];
188 <    delete[] zConstraints;
189 <  }
190 <  
191 < }
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 < int Globals::globalAssign( event* the_event ){
148 <  char errorMessage[65535];
149 <  int key;
150 <  interface_assign_type the_type =  the_event->evt.asmt.asmt_type;
151 <  char* lhs = the_event->evt.asmt.lhs;
152 <  std::string keyword(lhs);
153 <
154 <  bool result = false;
155 <
156 <  /**@todo fix memory leak */  
157 <  ParamMap::iterator i =parameters_.find(keyword);
158 <  if (i != parameters_.end()) {
159 <    if( the_type == STRING ){
160 <       result = i->second->setData(std::string(the_event->evt.asmt.rhs.sval));
161 <       if (!result ) {
162 <            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);
163 <            the_event->err_msg = strdup(errorMessage);
164 <       }
165 <    } else if( the_type == DOUBLE ){
166 <      result = i->second->setData(the_event->evt.asmt.rhs.dval);
167 <       if (!result )
168 <         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 );
169 <       the_event->err_msg = strdup(errorMessage);
170 <    }      
171 <    else if (the_type == INT ){
172 <      result = i->second->setData(the_event->evt.asmt.rhs.ival);
173 <       if (!result )
174 <         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 );
175 <       the_event->err_msg = strdup(errorMessage);
176 <      
177 <    } else {
178 <        sprintf(errorMessage,  "Internal error of parser\n");
179 <        the_event->err_msg = strdup(errorMessage);
180 <    }
181 <  } else {
182 <    sprintf(errorMessage,  "%s is an unrecognized keyword\n", keyword.c_str() );
183 <    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    }
191  
192  return result;
193 }
207  
208 < int Globals::newComponent( event* the_event ){
209 <  
210 <  current_component = new Component;
211 <  int index = the_event->evt.blk_index;
212 <  char err[200];
213 <  
214 <  if( haveNComponents() && index < getNComponents() )
215 <    components[index] = current_component;
216 <  else{
217 <    if( haveNComponents()  ){
218 <      sprintf( err, "meta-data parsing error: %d out of nComponents range",
219 <               index );
220 <      the_event->err_msg = strdup( err );
221 <      return 0;
222 <    }
223 <    else{
224 <      the_event->err_msg = strdup("meta-data parsing error: nComponents not given before"
225 <                                  " first component declaration." );
226 <      return 0;
227 <    }
228 <  }  
229 <
230 <  return 1;
231 < }
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 +  bool Globals::addRestraintStamp(RestraintStamp* rest) {
298 +    restraints_.push_back(rest);
299 +    return true;
300 +  }
301  
302 < int Globals::componentAssign( event* the_event ){
302 >  bool Globals::addFluctuatingChargeParameters(FluctuatingChargeParameters* fqp) {
303 >    if (flucQpars_ != NULL)
304 >      delete flucQpars_;
305 >    
306 >    flucQpars_ = fqp;
307 >    return true;
308 >  }
309  
310 <  switch( the_event->evt.asmt.asmt_type ){
310 >  bool Globals::addRNEMDParameters(RNEMDParameters* rnemdPars) {
311 >    if (rnemdPars_ != NULL)
312 >      delete rnemdPars_;
313      
314 <  case STRING:
315 <    return current_component->assignString( the_event->evt.asmt.lhs,
228 <                                            the_event->evt.asmt.rhs.sval,
229 <                                            &(the_event->err_msg));
230 <    break;
231 <    
232 <  case DOUBLE:
233 <    return current_component->assignDouble( the_event->evt.asmt.lhs,
234 <                                            the_event->evt.asmt.rhs.dval,
235 <                                            &(the_event->err_msg));
236 <    break;
237 <    
238 <  case INT:
239 <    return current_component->assignInt( the_event->evt.asmt.lhs,
240 <                                         the_event->evt.asmt.rhs.ival,
241 <                                         &(the_event->err_msg));
242 <    break;
243 <    
244 <  default:
245 <    the_event->err_msg = strdup( "Globals error. Invalid component"
246 <                                 " assignment type" );
247 <    return 0;
248 <    break;
314 >    rnemdPars_ = rnemdPars;
315 >    return true;
316    }
250  return 0;
251 }
317  
318 < int Globals::componentEnd( event* the_event ){
319 <
320 <  the_event->err_msg = current_component->checkMe();
256 <  if( the_event->err_msg != NULL ) return 0;
257 <
258 <  return 1;
259 < }
260 <
261 < int Globals::newZconstraint( event* the_event ){
262 <  
263 <
264 <  int index = the_event->evt.blk_index;
265 <  char err[200];
266 <  current_zConstraint = new ZconStamp( index );
267 <  
268 <  if( haveNZconstraints() && index < getNZconstraints() )
269 <    zConstraints[index] = current_zConstraint;
270 <  else{
271 <    if( haveNZconstraints() ){
272 <      sprintf( err, "meta-data parsing error: %d out of nZconstraints range",
273 <               index );
274 <      the_event->err_msg = strdup( err );
275 <      return 0;
276 <    }
277 <    else{
278 <      the_event->err_msg = strdup("meta-data parsing error: nZconstraints"
279 <                                  " not given before"
280 <                                  " first zConstraint declaration." );
281 <      return 0;
282 <    }
283 <  }  
284 <
285 <  return 1;
286 < }
287 <
288 <
289 <
290 < int Globals::zConstraintAssign( event* the_event ){
291 <
292 <  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,
296 <                                              the_event->evt.asmt.rhs.sval,
297 <                                              &(the_event->err_msg));
298 <    break;
299 <    
300 <  case DOUBLE:
301 <    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs,
302 <                                              the_event->evt.asmt.rhs.dval,
303 <                                              &(the_event->err_msg));
304 <    break;
305 <    
306 <  case INT:
307 <    return current_zConstraint->assignInt( the_event->evt.asmt.lhs,
308 <                                           the_event->evt.asmt.rhs.ival,
309 <                                           &(the_event->err_msg));
310 <    break;
311 <    
312 <  default:
313 <    the_event->err_msg = strdup( "Globals error. Invalid zConstraint"
314 <                                 " assignment type" );
315 <    return 0;
316 <    break;
322 >    minimizerPars_ = miniPars;
323 >    return true;
324    }
318  return 0;
319 }
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;
334 <
335 <  ParamMap::iterator i;
336 <  for (i = parameters_.begin(); i != parameters_.end(); ++i) {
337 <    if (!i->second->isOptional() && i->second->empty()) {
338 <        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    }
341
342  CheckParameter(ForceField, isNotEmpty());
343  CheckParameter(NComponents,isPositive());
344  CheckParameter(TargetTemp, isPositive());
345  CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) ||
346                 isEqualIgnoreCase(std::string("NVT")) ||
347                 isEqualIgnoreCase(std::string("NPTi")) ||
348                 isEqualIgnoreCase(std::string("NPTf")) ||
349                 isEqualIgnoreCase(std::string("NPTxyz")) );
350  CheckParameter(Dt, isPositive());
351  CheckParameter(RunTime, isPositive());
352  CheckParameter(InitialConfig, isNotEmpty());
353  CheckParameter(FinalConfig, isNotEmpty());
354  CheckParameter(NMol, isPositive());
355  CheckParameter(Density, isPositive());
356  CheckParameter(Box, isPositive());
357  CheckParameter(BoxX, isPositive());
358  CheckParameter(BoxY, isPositive());
359  CheckParameter(BoxZ, isPositive());
360  CheckParameter(SampleTime, isNonNegative());
361  CheckParameter(ResetTime, isNonNegative());
362  CheckParameter(StatusTime, isNonNegative());
363  CheckParameter(CutoffRadius, isPositive());
364  CheckParameter(SwitchingRadius, isNonNegative());
365  CheckParameter(Dielectric, isPositive());
366  CheckParameter(ThermalTime,  isNonNegative());
367  CheckParameter(TargetPressure,  isPositive());
368  CheckParameter(TauThermostat, isPositive());
369  CheckParameter(TauBarostat, isPositive());
370  CheckParameter(ZconsTime, isPositive());
371  CheckParameter(NZconstraints, isPositive());  
372  CheckParameter(ZconsTol, isPositive());
373  //CheckParameter(ZconsForcePolicy,);
374  CheckParameter(Seed, isPositive());
375  CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) ||
376                 isEqualIgnoreCase(std::string("CG")));
377  CheckParameter(MinimizerMaxIter, isPositive());
378  CheckParameter(MinimizerWriteFrq, isPositive());
379  CheckParameter(MinimizerStepSize, isPositive());
380  CheckParameter(MinimizerFTol, isPositive());
381  CheckParameter(MinimizerGTol, isPositive());
382  CheckParameter(MinimizerLSTol, isPositive());
383  CheckParameter(MinimizerLSMaxIter, isPositive());
384  CheckParameter(ZconsGap, isPositive());
385  CheckParameter(ZconsFixtime, isPositive());
386  CheckParameter(ThermodynamicIntegrationLambda, isPositive());
387  CheckParameter(ThermodynamicIntegrationK, isPositive());
388  CheckParameter(ForceFieldVariant, isNotEmpty());
389  CheckParameter(ForceFieldFileName, isNotEmpty());
390  CheckParameter(ThermIntDistSpringConst, isPositive());
391  CheckParameter(ThermIntThetaSpringConst, isPositive());
392  CheckParameter(ThermIntOmegaSpringConst, isPositive());
393  CheckParameter(SurfaceTension, isPositive());
394  CheckParameter(ElectrostaticSummationMethod,
395                 isEqualIgnoreCase(std::string("NONE")) ||
396                 isEqualIgnoreCase(std::string("SHIFTED_POTENTIAL")) ||
397                 isEqualIgnoreCase(std::string("SHIFTED_FORCE")) ||
398                 isEqualIgnoreCase(std::string("REACTION_FIELD")));
399  CheckParameter(ElectrostaticScreeningMethod,
400                 isEqualIgnoreCase(std::string("UNDAMPED")) ||
401                 isEqualIgnoreCase(std::string("DAMPED")));
402  CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) ||
403                 isEqualIgnoreCase(std::string("MAX")) ||
404                 isEqualIgnoreCase(std::string("TRADITIONAL")));
405  CheckParameter(SwitchingFunctionType,
406                 isEqualIgnoreCase(std::string("CUBIC")) ||
407                 isEqualIgnoreCase(std::string("FIFTH_ORDER_POLYNOMIAL")));
408  //CheckParameter(StatFileFormat,);    
409  //CheckParameter(MixingRule,);
410  CheckParameter(OrthoBoxTolerance, isPositive());  
411  CheckParameter(ThermIntDistSpringConst, isPositive());
412  CheckParameter(ThermIntThetaSpringConst, isPositive());
413  CheckParameter(ThermIntOmegaSpringConst, isPositive());
414  CheckParameter(DampingAlpha,isNonNegative());
415  CheckParameter(SkinThickness, isPositive());
416  
417  //@todo memory leak
418  if( have_err )
419    return strdup( err.c_str() );
420  
421  return NULL;
422
423
342   }
425
426 int Globals::globalEnd( event* the_event ){
427  
428  the_event->err_msg = checkMe();
429  if( the_event->err_msg != NULL ) return 0;
430
431  return 1;
432 }

Comparing trunk/src/io/Globals.cpp (property svn:keywords):
Revision 749 by tim, Wed Nov 16 23:10:02 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