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 665 by tim, Thu Oct 13 22:26:47 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 + 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  
62 #define DefineOptionalParameterWithDefaultValue(NAME,KEYWORD, DEFAULTVALUE)                              \
63  NAME.setKeyword(KEYWORD); NAME.setOptional(true); NAME.setDefaultValue(DEFAULTVALUE);                      \
64  parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME));
65
66 Globals::Globals(){
67
68  DefineParameter(ForceField, "forceField")
69  DefineParameter(NComponents, "nComponents")
70
71  DefineOptionalParameter(TargetTemp, "targetTemp");
72  DefineOptionalParameter(Ensemble, "ensemble");
73  DefineOptionalParameter(Dt, "dt");
74  DefineOptionalParameter(RunTime, "runTime");
75  DefineOptionalParameter(InitialConfig, "initialConfig");
76  DefineOptionalParameter(FinalConfig, "finalConfig");
77  DefineOptionalParameter(NMol, "nMol");
78  DefineOptionalParameter(Density, "density");
79  DefineOptionalParameter(Box, "box");
80  DefineOptionalParameter(BoxX, "boxX");
81  DefineOptionalParameter(BoxY, "boxY");
82  DefineOptionalParameter(BoxZ, "boxZ");
83  DefineOptionalParameter(SampleTime, "sampleTime");
84  DefineOptionalParameter(ResetTime, "resetTime");
85  DefineOptionalParameter(StatusTime, "statusTime");
86  DefineOptionalParameter(CutoffRadius, "cutoffRadius");
87  DefineOptionalParameter(SwitchingRadius, "switchingRadius");
88  DefineOptionalParameter(Dielectric, "dielectric");
89  DefineOptionalParameter(TempSet, "tempSet");
90  DefineOptionalParameter(ThermalTime, "thermalTime");
91  DefineOptionalParameter(TargetPressure, "targetPressure");
92  DefineOptionalParameter(TauThermostat, "tauThermostat");
93  DefineOptionalParameter(TauBarostat, "tauBarostat");
94  DefineOptionalParameter(ZconsTime, "zconsTime");
95  DefineOptionalParameter(NZconstraints, "nZconstraints");  
96  DefineOptionalParameter(ZconsTol, "zconsTol");
97  DefineOptionalParameter(ZconsForcePolicy, "zconsForcePolicy");
98  DefineOptionalParameter(Seed, "seed");
99  DefineOptionalParameter(Minimizer, "minimizer");
100  DefineOptionalParameter(MinimizerMaxIter,"minimizerMaxIter");
101  DefineOptionalParameter(MinimizerWriteFrq, "minimizerWriteFrq");
102  DefineOptionalParameter(MinimizerStepSize, "minimizerStepSize");
103  DefineOptionalParameter(MinimizerFTol, "minimizerFTol");
104  DefineOptionalParameter(MinimizerGTol, "minimizerGTol");
105  DefineOptionalParameter(MinimizerLSTol, "minimizerLSTol");
106  DefineOptionalParameter(MinimizerLSMaxIter, "minimizerLSMaxIter");
107  DefineOptionalParameter(ZconsGap, "zconsGap");
108  DefineOptionalParameter(ZconsFixtime, "zconsFixtime");
109  DefineOptionalParameter(ZconsUsingSMD, "zconsUsingSMD");
110  DefineOptionalParameter(ThermodynamicIntegrationLambda, "thermodynamicIntegrationLambda");
111  DefineOptionalParameter(ThermodynamicIntegrationK, "thermodynamicIntegrationK");
112  DefineOptionalParameter(ForceFieldVariant, "forceFieldVariant");
113  DefineOptionalParameter(ForceFieldFileName, "forceFieldFileName");
114  DefineOptionalParameter(ThermIntDistSpringConst, "thermIntDistSpringConst");
115  DefineOptionalParameter(ThermIntThetaSpringConst, "thermIntThetaSpringConst");
116  DefineOptionalParameter(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst");
117  DefineOptionalParameter(SurfaceTension, "surfaceTension");
118  DefineOptionalParameter(PrintPressureTensor, "printPressureTensor");
119  DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod");
120  DefineOptionalParameter(CutoffPolicy, "cutoffPolicy");
121  DefineOptionalParameter(StatFileFormat, "statFileFormat");    
123    
124 <  DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard");
125 <  DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true);
126 <  DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false);
127 <  DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState, "useInitialExtendedSystemState", false);
128 <  DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance, "orthoBoxTolerance", 1E-6);  
129 <  DefineOptionalParameterWithDefaultValue(UseSolidThermInt, "useSolidThermInt", false);
130 <  DefineOptionalParameterWithDefaultValue(UseLiquidThermInt, "useLiquidThermInt", false);
131 <  DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 1.5);
132 <  DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0);
133 <  DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0);
134 <  
135 < }
124 >    DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions,
125 >                                            "usePeriodicBoundaryConditions",
126 >                                            true);
127 >    DefineOptionalParameterWithDefaultValue(UseAtomicVirial, "useAtomicVirial",
128 >                                            true);
129 >    DefineOptionalParameterWithDefaultValue(UseLongRangeCorrections,
130 >                                            "useLongRangeCorrections", true);
131 >    DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime",
132 >                                            false);
133 >    DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState,
134 >                                            "useInitialExtendedSystemState",
135 >                                            false);
136 >    DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance,
137 >                                            "orthoBoxTolerance", 1E-6);  
138 >    DefineOptionalParameterWithDefaultValue(CutoffMethod, "cutoffMethod",
139 >                                            "SHIFTED_FORCE");
140 >    DefineOptionalParameterWithDefaultValue(ElectrostaticScreeningMethod,
141 >                                            "electrostaticScreeningMethod",
142 >                                            "DAMPED");
143 >    DefineOptionalParameterWithDefaultValue(Dielectric, "dielectric", 80.0);
144 >    DefineOptionalParameterWithDefaultValue(CompressDumpFile,
145 >                                            "compressDumpFile", false);
146 >    DefineOptionalParameterWithDefaultValue(PrintHeatFlux, "printHeatFlux",
147 >                                            false);
148 >    DefineOptionalParameterWithDefaultValue(OutputForceVector,
149 >                                            "outputForceVector", false);
150 >    DefineOptionalParameterWithDefaultValue(OutputParticlePotential,
151 >                                            "outputParticlePotential", false);
152 >    DefineOptionalParameterWithDefaultValue(OutputElectricField,
153 >                                            "outputElectricField", false);
154 >    DefineOptionalParameterWithDefaultValue(OutputFluctuatingCharges,
155 >                                            "outputFluctuatingCharges", false);
156 >    DefineOptionalParameterWithDefaultValue(OutputSitePotential,
157 >                                            "outputSitePotential", false);
158 >    DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness",
159 >                                            1.0);
160 >    DefineOptionalParameterWithDefaultValue(StatFileFormat,
161 >                                            "statFileFormat",
162 >                                            "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY");    
163 >    DefineOptionalParameterWithDefaultValue(UseSphericalBoundaryConditions,
164 >                                            "useSphericalBoundaryConditions",
165 >                                            false);
166 >    DefineOptionalParameterWithDefaultValue(AccumulateBoxDipole,
167 >                                            "accumulateBoxDipole", false);
168 >    DefineOptionalParameterWithDefaultValue(AccumulateBoxQuadrupole,
169 >                                            "accumulateBoxQuadrupole", false);
170 >    DefineOptionalParameterWithDefaultValue(UseRestraints, "useRestraints",
171 >                                            false);
172 >    DefineOptionalParameterWithDefaultValue(Restraint_file, "Restraint_file",
173 >                                            "idealCrystal.in");
174 >    DefineOptionalParameterWithDefaultValue(UseThermodynamicIntegration,
175 >                                            "useThermodynamicIntegration",
176 >                                            false);
177 >    DefineOptionalParameterWithDefaultValue(HULL_Method,"HULL_Method","Convex");
178  
179 < int Globals::globalAssign( event* the_event ){
180 <  
181 <  int key;
182 <  int token;
183 <  interface_assign_type the_type =  the_event->evt.asmt.asmt_type;
184 <  char* lhs = the_event->evt.asmt.lhs;
185 <  std::string keyword(lhs);
179 >    deprecatedKeywords_.insert("nComponents");
180 >    deprecatedKeywords_.insert("nZconstraints");
181 >    deprecatedKeywords_.insert("initialConfig");
182 >    deprecatedKeywords_.insert("thermIntDistSpringConst");
183 >    deprecatedKeywords_.insert("thermIntThetaSpringConst");
184 >    deprecatedKeywords_.insert("thermIntOmegaSpringConst");
185 >    deprecatedKeywords_.insert("useSolidThermInt");  
186 >    deprecatedKeywords_.insert("useLiquidThermInt");
187 >    deprecatedKeywords_.insert("minimizerMaxIter");
188 >    deprecatedKeywords_.insert("minimizerWriteFreq");
189 >    deprecatedKeywords_.insert("minimizerStepSize");
190 >    deprecatedKeywords_.insert("minimizerFTol");
191 >    deprecatedKeywords_.insert("minimizerGTol");
192 >    deprecatedKeywords_.insert("minimizerLSTol");
193 >    deprecatedKeywords_.insert("minimizerLSMaxIter");
194 >    deprecatedKeywords_.insert("electricField");
195  
144  bool result;
145
146
147  ParamMap::iterator i =parameters_.find(keyword);
148  if (i != parameters_.end()) {
149    if( the_type == STRING ){
150       result = i->second->setData(std::string(the_event->evt.asmt.rhs.sval));
151       if (!result ) {
152            sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a string.\n", keyword.c_str() );
153       }
154    } else if( the_type == DOUBLE ){
155      result = i->second->setData(the_event->evt.asmt.rhs.dval);
156       if (!result )
157         sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a double.\n", keyword.c_str() );
158    }      
159    else if (the_type == INT ){
160      result = i->second->setData(the_event->evt.asmt.rhs.ival);
161       if (!result )
162         sprintf(the_event->err_msg,  "Error in parsing meta-data file!\n\t%s must be an int.\n", keyword.c_str() );
163      
164    } else {
196      
166    }
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    }
174  
175  return result;
176 }
207  
208 < int Globals::newComponent( event* the_event ){
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 <  current_component = new Component;
277 <  int index = the_event->evt.blk_index;
278 <  char err[200];
279 <  
280 <  if( haveNComponents() && index < getNComponents() )
281 <    components[index] = current_component;
282 <  else{
283 <    if( haveNComponents()  ){
188 <      sprintf( err, "meta-data parsing error: %d out of nComponents range",
189 <               index );
190 <      the_event->err_msg = strdup( err );
191 <      return 0;
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 <    else{
286 <      the_event->err_msg = strdup("meta-data parsing error: nComponents not given before"
287 <                                  " first component declaration." );
288 <      return 0;
289 <    }
290 <  }  
199 <
200 <  return 1;
201 < }
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,
211 <                                            the_event->evt.asmt.rhs.sval,
212 <                                            &(the_event->err_msg));
213 <    break;
214 <    
215 <  case DOUBLE:
216 <    return current_component->assignDouble( the_event->evt.asmt.lhs,
217 <                                            the_event->evt.asmt.rhs.dval,
218 <                                            &(the_event->err_msg));
219 <    break;
220 <    
221 <  case INT:
222 <    return current_component->assignInt( the_event->evt.asmt.lhs,
223 <                                         the_event->evt.asmt.rhs.ival,
224 <                                         &(the_event->err_msg));
225 <    break;
226 <    
227 <  default:
228 <    the_event->err_msg = strdup( "Globals error. Invalid component"
229 <                                 " assignment type" );
230 <    return 0;
231 <    break;
314 >    rnemdPars_ = rnemdPars;
315 >    return true;
316    }
233  return 0;
234 }
317  
318 < int Globals::componentEnd( event* the_event ){
319 <
320 <  the_event->err_msg = current_component->checkMe();
239 <  if( the_event->err_msg != NULL ) return 0;
240 <
241 <  return 1;
242 < }
243 <
244 < int Globals::newZconstraint( event* the_event ){
245 <  
246 <
247 <  int index = the_event->evt.blk_index;
248 <  char err[200];
249 <  current_zConstraint = new ZconStamp( index );
250 <  
251 <  if( haveNZconstraints() && index < getNZconstraints() )
252 <    zConstraints[index] = current_zConstraint;
253 <  else{
254 <    if( haveNZconstraints() ){
255 <      sprintf( err, "meta-data parsing error: %d out of nZconstraints range",
256 <               index );
257 <      the_event->err_msg = strdup( err );
258 <      return 0;
259 <    }
260 <    else{
261 <      the_event->err_msg = strdup("meta-data parsing error: nZconstraints"
262 <                                  " not given before"
263 <                                  " first zConstraint declaration." );
264 <      return 0;
265 <    }
266 <  }  
267 <
268 <  return 1;
269 < }
270 <
271 <
272 <
273 < int Globals::zConstraintAssign( event* the_event ){
274 <
275 <  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,
279 <                                              the_event->evt.asmt.rhs.sval,
280 <                                              &(the_event->err_msg));
281 <    break;
282 <    
283 <  case DOUBLE:
284 <    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs,
285 <                                              the_event->evt.asmt.rhs.dval,
286 <                                              &(the_event->err_msg));
287 <    break;
288 <    
289 <  case INT:
290 <    return current_zConstraint->assignInt( the_event->evt.asmt.lhs,
291 <                                           the_event->evt.asmt.rhs.ival,
292 <                                           &(the_event->err_msg));
293 <    break;
294 <    
295 <  default:
296 <    the_event->err_msg = strdup( "Globals error. Invalid zConstraint"
297 <                                 " assignment type" );
298 <    return 0;
299 <    break;
322 >    minimizerPars_ = miniPars;
323 >    return true;
324    }
301  return 0;
302 }
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;
317 <
318 <  ParamMap::iterator i;
319 <  for (i = parameters_.begin(); i != parameters_.end(); ++i) {
320 <    if (!i->second->isOptional() && i->second->empty()) {
321 <        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    }
324
325  //@todo memory leak
326  if( have_err )
327    return strdup( err.c_str() );
328  
329  return NULL;
330
331
342   }
333
334 int Globals::globalEnd( event* the_event ){
335  
336  the_event->err_msg = checkMe();
337  if( the_event->err_msg != NULL ) return 0;
338
339  return 1;
340 }

Comparing trunk/src/io/Globals.cpp (property svn:keywords):
Revision 665 by tim, Thu Oct 13 22:26:47 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