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 726 by chrisfen, Fri Nov 11 15:22:11 2005 UTC vs.
Revision 2034 by gezelter, Mon Nov 3 16:49:03 2014 UTC

# Line 1 | Line 1
1   /*
2 < * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
2 > * Copyright (c) 2005, 2010 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
5   * non-exclusive, royalty free, license to use, modify and
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
36 + * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 + * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 + * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39 + * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   #include <stdlib.h>
# Line 45 | Line 46
46   #include <string>
47  
48   #include "io/Globals.hpp"
49 + #include "io/ParamConstraint.hpp"
50 + #include "utils/MemoryUtils.hpp"
51   #include "utils/simError.h"
49 #ifdef IS_MPI
50 #include "io/mpiBASS.h"
51 #endif // is_mpi
52  
53 < #include "io/ParamConstraint.hpp"
53 > namespace OpenMD {
54 >  Globals::Globals() {
55 >  
56 >    flucQpars_ = new FluctuatingChargeParameters();
57 >    rnemdPars_ = new RNEMDParameters();
58 >    minimizerPars_ = new MinimizerParameters();
59  
60 < #define DefineParameter(NAME,KEYWORD)                              \
61 <  NAME.setKeyword(KEYWORD);                  \
62 <  parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME));
60 >    DefineParameter(ForceField, "forceField");
61 >    
62 >    DefineOptionalParameter(TargetTemp, "targetTemp");
63 >    DefineOptionalParameter(Ensemble, "ensemble");
64 >    DefineOptionalParameter(Dt, "dt");
65 >    DefineOptionalParameter(RunTime, "runTime");
66 >    DefineOptionalParameter(FinalConfig, "finalConfig");
67 >    DefineOptionalParameter(SampleTime, "sampleTime");
68 >    DefineOptionalParameter(ResetTime, "resetTime");
69 >    DefineOptionalParameter(StatusTime, "statusTime");
70 >    DefineOptionalParameter(CutoffRadius, "cutoffRadius");
71 >    DefineOptionalParameter(SwitchingRadius, "switchingRadius");
72 >    DefineOptionalParameter(TempSet, "tempSet");
73 >    DefineOptionalParameter(ThermalTime, "thermalTime");
74 >    DefineOptionalParameter(TargetPressure, "targetPressure");  
75 >    DefineOptionalParameter(TauThermostat, "tauThermostat");
76 >    DefineOptionalParameter(TauBarostat, "tauBarostat");
77 >    DefineOptionalParameter(ZconsTime, "zconsTime");
78 >    DefineOptionalParameter(ZconsTol, "zconsTol");
79 >    DefineOptionalParameter(ZconsForcePolicy, "zconsForcePolicy");
80 >    DefineOptionalParameter(Seed, "seed");
81 >    DefineOptionalParameter(ZconsGap, "zconsGap");
82 >    DefineOptionalParameter(ZconsFixtime, "zconsFixtime");
83 >    DefineOptionalParameter(ZconsUsingSMD, "zconsUsingSMD");
84 >    DefineOptionalParameter(ThermodynamicIntegrationLambda,
85 >                            "thermodynamicIntegrationLambda");
86 >    DefineOptionalParameter(ThermodynamicIntegrationK,
87 >                            "thermodynamicIntegrationK");
88 >    DefineOptionalParameter(ForceFieldVariant, "forceFieldVariant");
89 >    DefineOptionalParameter(ForceFieldFileName, "forceFieldFileName");
90 >    DefineOptionalParameter(DampingAlpha, "dampingAlpha");
91 >    DefineOptionalParameter(SurfaceTension, "surfaceTension");
92 >    DefineOptionalParameter(PrintPressureTensor, "printPressureTensor");
93 >    DefineOptionalParameter(ElectricField, "electricField");
94 >    DefineOptionalParameter(UniformField, "uniformField");
95 >    DefineOptionalParameter(UniformGradientStrength, "uniformGradientStrength");
96 >    DefineOptionalParameter(UniformGradientDirection1, "uniformGradientDirection1");
97 >    DefineOptionalParameter(UniformGradientDirection2, "uniformGradientDirection2");
98 >    //DefineOptionalParameter(PeriodicField, "periodicField");
99 >    //DefineOptionalParameter(PeriodicFieldStrength, "periodicFieldStrength");
100 >    
101  
102 < #define DefineOptionalParameter(NAME,KEYWORD)                              \
103 <  NAME.setKeyword(KEYWORD); NAME.setOptional(true);                    \
104 <  parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME));
102 >    DefineOptionalParameter(TaggedAtomPair, "taggedAtomPair");
103 >    DefineOptionalParameter(PrintTaggedPairDistance, "printTaggedPairDistance");
104 >    DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType");
105 >    DefineOptionalParameter(HydroPropFile, "HydroPropFile");
106 >    DefineOptionalParameter(Viscosity, "viscosity");
107 >    DefineOptionalParameter(BeadSize, "beadSize");
108 >    DefineOptionalParameter(FrozenBufferRadius, "frozenBufferRadius");
109 >    DefineOptionalParameter(LangevinBufferRadius, "langevinBufferRadius");
110 >    DefineOptionalParameter(NeighborListNeighbors,"NeighborListNeighbors");
111 >    DefineOptionalParameter(UseMultipleTemperatureMethod,
112 >                            "useMultipleTemperatureMethod");
113 >    DefineOptionalParameter(ElectrostaticSummationMethod,
114 >                            "electrostaticSummationMethod");
115 >    DefineOptionalParameter(MTM_Ce, "MTM_Ce");
116 >    DefineOptionalParameter(MTM_G, "MTM_G");
117 >    DefineOptionalParameter(MTM_Io, "MTM_Io");
118 >    DefineOptionalParameter(MTM_Sigma, "MTM_Sigma");
119 >    DefineOptionalParameter(MTM_R, "MTM_R");
120 >    DefineOptionalParameter(Alpha, "alpha");
121 >    DefineOptionalParameter(ConstraintTime, "constraintTime");
122  
63 #define DefineOptionalParameterWithDefaultValue(NAME,KEYWORD, DEFAULTVALUE)                              \
64  NAME.setKeyword(KEYWORD); NAME.setOptional(true); NAME.setDefaultValue(DEFAULTVALUE);                      \
65  parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME));
66
67 #define CheckParameter(NAME, CONSTRAINT)                              \
68  if (!NAME.empty()) { if (!(CONSTRAINT)(NAME.getData())) { sprintf(painCave.errMsg,"Error in checking %s : should be %s\n",NAME.getKeyword().c_str(),(CONSTRAINT).getConstraintDescription().c_str()); painCave.isFatal = 1; painCave.severity = OOPSE_ERROR; simError();} }                
69
70 Globals::Globals(){
71
72  DefineParameter(ForceField, "forceField")
73  DefineParameter(NComponents, "nComponents")
74
75  DefineOptionalParameter(TargetTemp, "targetTemp");
76  DefineOptionalParameter(Ensemble, "ensemble");
77  DefineOptionalParameter(Dt, "dt");
78  DefineOptionalParameter(RunTime, "runTime");
79  DefineOptionalParameter(InitialConfig, "initialConfig");
80  DefineOptionalParameter(FinalConfig, "finalConfig");
81  DefineOptionalParameter(NMol, "nMol");
82  DefineOptionalParameter(Density, "density");
83  DefineOptionalParameter(Box, "box");
84  DefineOptionalParameter(BoxX, "boxX");
85  DefineOptionalParameter(BoxY, "boxY");
86  DefineOptionalParameter(BoxZ, "boxZ");
87  DefineOptionalParameter(SampleTime, "sampleTime");
88  DefineOptionalParameter(ResetTime, "resetTime");
89  DefineOptionalParameter(StatusTime, "statusTime");
90  DefineOptionalParameter(CutoffRadius, "cutoffRadius");
91  DefineOptionalParameter(SwitchingRadius, "switchingRadius");
92  DefineOptionalParameter(Dielectric, "dielectric");
93  DefineOptionalParameter(TempSet, "tempSet");
94  DefineOptionalParameter(ThermalTime, "thermalTime");
95  DefineOptionalParameter(TargetPressure, "targetPressure");
96  DefineOptionalParameter(TauThermostat, "tauThermostat");
97  DefineOptionalParameter(TauBarostat, "tauBarostat");
98  DefineOptionalParameter(ZconsTime, "zconsTime");
99  DefineOptionalParameter(NZconstraints, "nZconstraints");  
100  DefineOptionalParameter(ZconsTol, "zconsTol");
101  DefineOptionalParameter(ZconsForcePolicy, "zconsForcePolicy");
102  DefineOptionalParameter(Seed, "seed");
103  DefineOptionalParameter(Minimizer, "minimizer");
104  DefineOptionalParameter(MinimizerMaxIter,"minimizerMaxIter");
105  DefineOptionalParameter(MinimizerWriteFrq, "minimizerWriteFrq");
106  DefineOptionalParameter(MinimizerStepSize, "minimizerStepSize");
107  DefineOptionalParameter(MinimizerFTol, "minimizerFTol");
108  DefineOptionalParameter(MinimizerGTol, "minimizerGTol");
109  DefineOptionalParameter(MinimizerLSTol, "minimizerLSTol");
110  DefineOptionalParameter(MinimizerLSMaxIter, "minimizerLSMaxIter");
111  DefineOptionalParameter(ZconsGap, "zconsGap");
112  DefineOptionalParameter(ZconsFixtime, "zconsFixtime");
113  DefineOptionalParameter(ZconsUsingSMD, "zconsUsingSMD");
114  DefineOptionalParameter(ThermodynamicIntegrationLambda, "thermodynamicIntegrationLambda");
115  DefineOptionalParameter(ThermodynamicIntegrationK, "thermodynamicIntegrationK");
116  DefineOptionalParameter(ForceFieldVariant, "forceFieldVariant");
117  DefineOptionalParameter(ForceFieldFileName, "forceFieldFileName");
118  DefineOptionalParameter(ThermIntDistSpringConst, "thermIntDistSpringConst");
119  DefineOptionalParameter(ThermIntThetaSpringConst, "thermIntThetaSpringConst");
120  DefineOptionalParameter(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst");
121  DefineOptionalParameter(SurfaceTension, "surfaceTension");
122  DefineOptionalParameter(PrintPressureTensor, "printPressureTensor");
123  DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod");
124  DefineOptionalParameter(ElectrostaticScreeningMethod, "electrostaticScreeningMethod");
125  DefineOptionalParameter(CutoffPolicy, "cutoffPolicy");
126  DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType");
127  DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard");
128  DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true);
129  DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false);
130  DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState, "useInitialExtendedSystemState", false);
131  DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance, "orthoBoxTolerance", 1E-6);  
132  DefineOptionalParameterWithDefaultValue(UseSolidThermInt, "useSolidThermInt", false);
133  DefineOptionalParameterWithDefaultValue(UseLiquidThermInt, "useLiquidThermInt", false);
134  DefineOptionalParameterWithDefaultValue(ThermIntDistSpringConst, "thermIntDistSpringConst", 6.0);
135  DefineOptionalParameterWithDefaultValue(ThermIntThetaSpringConst, "thermIntThetaSpringConst", 7.5);
136  DefineOptionalParameterWithDefaultValue(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst", 13.5);
137  DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 0.2);
138  DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0);
139  DefineOptionalParameterWithDefaultValue(OutputForceVector, "outputForceVector", 0);
140  DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0);
141  DefineOptionalParameterWithDefaultValue(StatFileFormat, "statFileFormat", "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY");    
142
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;
154 <
155 <  /**@todo fix memory leak */  
156 <  ParamMap::iterator i =parameters_.find(keyword);
157 <  if (i != parameters_.end()) {
158 <    if( the_type == STRING ){
159 <       result = i->second->setData(std::string(the_event->evt.asmt.rhs.sval));
160 <       if (!result ) {
161 <            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);
162 <            the_event->err_msg = strdup(errorMessage);
163 <       }
164 <    } else if( the_type == DOUBLE ){
165 <      result = i->second->setData(the_event->evt.asmt.rhs.dval);
166 <       if (!result )
167 <         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 );
168 <       the_event->err_msg = strdup(errorMessage);
169 <    }      
170 <    else if (the_type == INT ){
171 <      result = i->second->setData(the_event->evt.asmt.rhs.ival);
172 <       if (!result )
173 <         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 );
174 <       the_event->err_msg = strdup(errorMessage);
175 <      
176 <    } else {
177 <        sprintf(errorMessage,  "Internal error of parser\n");
178 <        the_event->err_msg = strdup(errorMessage);
179 <    }
180 <  } else {
181 <    sprintf(errorMessage,  "%s is an unrecognized keyword\n", keyword.c_str() );
182 <    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    }
190  
191  return result;
192 }
207  
208 < int Globals::newComponent( event* the_event ){
209 <  
196 <  current_component = new Component;
197 <  int index = the_event->evt.blk_index;
198 <  char err[200];
199 <  
200 <  if( haveNComponents() && index < getNComponents() )
201 <    components[index] = current_component;
202 <  else{
203 <    if( haveNComponents()  ){
204 <      sprintf( err, "meta-data parsing error: %d out of nComponents range",
205 <               index );
206 <      the_event->err_msg = strdup( err );
207 <      return 0;
208 <    }
209 <    else{
210 <      the_event->err_msg = strdup("meta-data parsing error: nComponents not given before"
211 <                                  " first component declaration." );
212 <      return 0;
213 <    }
214 <  }  
215 <
216 <  return 1;
217 < }
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,
233 <                                            the_event->evt.asmt.rhs.dval,
234 <                                            &(the_event->err_msg));
235 <    break;
236 <    
237 <  case INT:
238 <    return current_component->assignInt( the_event->evt.asmt.lhs,
239 <                                         the_event->evt.asmt.rhs.ival,
240 <                                         &(the_event->err_msg));
241 <    break;
242 <    
243 <  default:
244 <    the_event->err_msg = strdup( "Globals error. Invalid component"
245 <                                 " assignment type" );
246 <    return 0;
247 <    break;
314 >    rnemdPars_ = rnemdPars;
315 >    return true;
316    }
249  return 0;
250 }
317  
318 < int Globals::componentEnd( event* the_event ){
319 <
320 <  the_event->err_msg = current_component->checkMe();
255 <  if( the_event->err_msg != NULL ) return 0;
256 <
257 <  return 1;
258 < }
259 <
260 < int Globals::newZconstraint( event* the_event ){
261 <  
262 <
263 <  int index = the_event->evt.blk_index;
264 <  char err[200];
265 <  current_zConstraint = new ZconStamp( index );
266 <  
267 <  if( haveNZconstraints() && index < getNZconstraints() )
268 <    zConstraints[index] = current_zConstraint;
269 <  else{
270 <    if( haveNZconstraints() ){
271 <      sprintf( err, "meta-data parsing error: %d out of nZconstraints range",
272 <               index );
273 <      the_event->err_msg = strdup( err );
274 <      return 0;
275 <    }
276 <    else{
277 <      the_event->err_msg = strdup("meta-data parsing error: nZconstraints"
278 <                                  " not given before"
279 <                                  " first zConstraint declaration." );
280 <      return 0;
281 <    }
282 <  }  
283 <
284 <  return 1;
285 < }
286 <
287 <
288 <
289 < int Globals::zConstraintAssign( event* the_event ){
290 <
291 <  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,
295 <                                              the_event->evt.asmt.rhs.sval,
296 <                                              &(the_event->err_msg));
297 <    break;
298 <    
299 <  case DOUBLE:
300 <    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs,
301 <                                              the_event->evt.asmt.rhs.dval,
302 <                                              &(the_event->err_msg));
303 <    break;
304 <    
305 <  case INT:
306 <    return current_zConstraint->assignInt( the_event->evt.asmt.lhs,
307 <                                           the_event->evt.asmt.rhs.ival,
308 <                                           &(the_event->err_msg));
309 <    break;
310 <    
311 <  default:
312 <    the_event->err_msg = strdup( "Globals error. Invalid zConstraint"
313 <                                 " assignment type" );
314 <    return 0;
315 <    break;
322 >    minimizerPars_ = miniPars;
323 >    return true;
324    }
317  return 0;
318 }
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;
333 <
334 <  ParamMap::iterator i;
335 <  for (i = parameters_.begin(); i != parameters_.end(); ++i) {
336 <    if (!i->second->isOptional() && i->second->empty()) {
337 <        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    }
340
341  CheckParameter(ForceField, isNotEmpty());
342  CheckParameter(NComponents,isPositive());
343  CheckParameter(TargetTemp, isPositive());
344  CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) ||
345                 isEqualIgnoreCase(std::string("NVT")) ||
346                 isEqualIgnoreCase(std::string("NPTi")) ||
347                 isEqualIgnoreCase(std::string("NPTf")) ||
348                 isEqualIgnoreCase(std::string("NPTxyz")) );
349  CheckParameter(Dt, isPositive());
350  CheckParameter(RunTime, isPositive());
351  CheckParameter(InitialConfig, isNotEmpty());
352  CheckParameter(FinalConfig, isNotEmpty());
353  CheckParameter(NMol, isPositive());
354  CheckParameter(Density, isPositive());
355  CheckParameter(Box, isPositive());
356  CheckParameter(BoxX, isPositive());
357  CheckParameter(BoxY, isPositive());
358  CheckParameter(BoxZ, isPositive());
359  CheckParameter(SampleTime, isNonNegative());
360  CheckParameter(ResetTime, isNonNegative());
361  CheckParameter(StatusTime, isNonNegative());
362  CheckParameter(CutoffRadius, isPositive());
363  CheckParameter(SwitchingRadius, isNonNegative());
364  CheckParameter(Dielectric, isPositive());
365  CheckParameter(ThermalTime,  isNonNegative());
366  CheckParameter(TargetPressure,  isPositive());
367  CheckParameter(TauThermostat, isPositive());
368  CheckParameter(TauBarostat, isPositive());
369  CheckParameter(ZconsTime, isPositive());
370  CheckParameter(NZconstraints, isPositive());  
371  CheckParameter(ZconsTol, isPositive());
372  //CheckParameter(ZconsForcePolicy,);
373  CheckParameter(Seed, isPositive());
374  CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) ||
375                 isEqualIgnoreCase(std::string("CG")));
376  CheckParameter(MinimizerMaxIter, isPositive());
377  CheckParameter(MinimizerWriteFrq, isPositive());
378  CheckParameter(MinimizerStepSize, isPositive());
379  CheckParameter(MinimizerFTol, isPositive());
380  CheckParameter(MinimizerGTol, isPositive());
381  CheckParameter(MinimizerLSTol, isPositive());
382  CheckParameter(MinimizerLSMaxIter, isPositive());
383  CheckParameter(ZconsGap, isPositive());
384  CheckParameter(ZconsFixtime, isPositive());
385  CheckParameter(ThermodynamicIntegrationLambda, isPositive());
386  CheckParameter(ThermodynamicIntegrationK, isPositive());
387  CheckParameter(ForceFieldVariant, isNotEmpty());
388  CheckParameter(ForceFieldFileName, isNotEmpty());
389  CheckParameter(ThermIntDistSpringConst, isPositive());
390  CheckParameter(ThermIntThetaSpringConst, isPositive());
391  CheckParameter(ThermIntOmegaSpringConst, isPositive());
392  CheckParameter(SurfaceTension, isPositive());
393  CheckParameter(ElectrostaticSummationMethod,
394                 isEqualIgnoreCase(std::string("NONE")) ||
395                 isEqualIgnoreCase(std::string("SHIFTED_POTENTIAL")) ||
396                 isEqualIgnoreCase(std::string("SHIFTED_FORCE")) ||
397                 isEqualIgnoreCase(std::string("REACTION_FIELD")));
398  CheckParameter(ElectrostaticScreeningMethod,
399                 isEqualIgnoreCase(std::string("UNDAMPED")) ||
400                 isEqualIgnoreCase(std::string("DAMPED")));
401  CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) ||
402                 isEqualIgnoreCase(std::string("MAX")) ||
403                 isEqualIgnoreCase(std::string("TRADITIONAL")));
404  CheckParameter(SwitchingFunctionType,
405                 isEqualIgnoreCase(std::string("CUBIC")) ||
406                 isEqualIgnoreCase(std::string("FIFTH_ORDER_POLYNOMIAL")));
407  //CheckParameter(StatFileFormat,);    
408  //CheckParameter(MixingRule,);
409  CheckParameter(OrthoBoxTolerance, isPositive());  
410  CheckParameter(ThermIntDistSpringConst, isPositive());
411  CheckParameter(ThermIntThetaSpringConst, isPositive());
412  CheckParameter(ThermIntOmegaSpringConst, isPositive());
413  CheckParameter(DampingAlpha,isNonNegative());
414  CheckParameter(SkinThickness, isPositive());
415  
416  //@todo memory leak
417  if( have_err )
418    return strdup( err.c_str() );
419  
420  return NULL;
421
422
342   }
424
425 int Globals::globalEnd( event* the_event ){
426  
427  the_event->err_msg = checkMe();
428  if( the_event->err_msg != NULL ) return 0;
429
430  return 1;
431 }

Comparing trunk/src/io/Globals.cpp (property svn:keywords):
Revision 726 by chrisfen, Fri Nov 11 15:22:11 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