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 2022 by gezelter, Fri Sep 26 22:22:28 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(PeriodicField, "periodicField");
96 >    //DefineOptionalParameter(PeriodicFieldStrength, "periodicFieldStrength");
97 >    
98  
99 < Globals::Globals(){
100 <
101 <  DefineParameter(ForceField, "forceField")
102 <  DefineParameter(NComponents, "nComponents")
103 <
104 <  DefineOptionalParameter(TargetTemp, "targetTemp");
105 <  DefineOptionalParameter(Ensemble, "ensemble");
106 <  DefineOptionalParameter(Dt, "dt");
107 <  DefineOptionalParameter(RunTime, "runTime");
108 <  DefineOptionalParameter(InitialConfig, "initialConfig");
109 <  DefineOptionalParameter(FinalConfig, "finalConfig");
110 <  DefineOptionalParameter(NMol, "nMol");
111 <  DefineOptionalParameter(Density, "density");
112 <  DefineOptionalParameter(Box, "box");
113 <  DefineOptionalParameter(BoxX, "boxX");
114 <  DefineOptionalParameter(BoxY, "boxY");
115 <  DefineOptionalParameter(BoxZ, "boxZ");
116 <  DefineOptionalParameter(SampleTime, "sampleTime");
117 <  DefineOptionalParameter(ResetTime, "resetTime");
118 <  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");    
99 >    DefineOptionalParameter(TaggedAtomPair, "taggedAtomPair");
100 >    DefineOptionalParameter(PrintTaggedPairDistance, "printTaggedPairDistance");
101 >    DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType");
102 >    DefineOptionalParameter(HydroPropFile, "HydroPropFile");
103 >    DefineOptionalParameter(Viscosity, "viscosity");
104 >    DefineOptionalParameter(BeadSize, "beadSize");
105 >    DefineOptionalParameter(FrozenBufferRadius, "frozenBufferRadius");
106 >    DefineOptionalParameter(LangevinBufferRadius, "langevinBufferRadius");
107 >    DefineOptionalParameter(NeighborListNeighbors,"NeighborListNeighbors");
108 >    DefineOptionalParameter(UseMultipleTemperatureMethod,
109 >                            "useMultipleTemperatureMethod");
110 >    DefineOptionalParameter(ElectrostaticSummationMethod,
111 >                            "electrostaticSummationMethod");
112 >    DefineOptionalParameter(MTM_Ce, "MTM_Ce");
113 >    DefineOptionalParameter(MTM_G, "MTM_G");
114 >    DefineOptionalParameter(MTM_Io, "MTM_Io");
115 >    DefineOptionalParameter(MTM_Sigma, "MTM_Sigma");
116 >    DefineOptionalParameter(MTM_R, "MTM_R");
117 >    DefineOptionalParameter(Alpha, "alpha");
118 >    DefineOptionalParameter(ConstraintTime, "constraintTime");
119  
120    
121 < }
121 >    DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions,
122 >                                            "usePeriodicBoundaryConditions",
123 >                                            true);
124 >    DefineOptionalParameterWithDefaultValue(UseAtomicVirial, "useAtomicVirial",
125 >                                            true);
126 >    DefineOptionalParameterWithDefaultValue(UseLongRangeCorrections,
127 >                                            "useLongRangeCorrections", true);
128 >    DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime",
129 >                                            false);
130 >    DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState,
131 >                                            "useInitialExtendedSystemState",
132 >                                            false);
133 >    DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance,
134 >                                            "orthoBoxTolerance", 1E-6);  
135 >    DefineOptionalParameterWithDefaultValue(CutoffMethod, "cutoffMethod",
136 >                                            "SHIFTED_FORCE");
137 >    DefineOptionalParameterWithDefaultValue(ElectrostaticScreeningMethod,
138 >                                            "electrostaticScreeningMethod",
139 >                                            "DAMPED");
140 >    DefineOptionalParameterWithDefaultValue(Dielectric, "dielectric", 80.0);
141 >    DefineOptionalParameterWithDefaultValue(CompressDumpFile,
142 >                                            "compressDumpFile", false);
143 >    DefineOptionalParameterWithDefaultValue(PrintHeatFlux, "printHeatFlux",
144 >                                            false);
145 >    DefineOptionalParameterWithDefaultValue(OutputForceVector,
146 >                                            "outputForceVector", false);
147 >    DefineOptionalParameterWithDefaultValue(OutputParticlePotential,
148 >                                            "outputParticlePotential", false);
149 >    DefineOptionalParameterWithDefaultValue(OutputElectricField,
150 >                                            "outputElectricField", false);
151 >    DefineOptionalParameterWithDefaultValue(OutputFluctuatingCharges,
152 >                                            "outputFluctuatingCharges", false);
153 >    DefineOptionalParameterWithDefaultValue(OutputSitePotential,
154 >                                            "outputSitePotential", false);
155 >    DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness",
156 >                                            1.0);
157 >    DefineOptionalParameterWithDefaultValue(StatFileFormat,
158 >                                            "statFileFormat",
159 >                                            "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY");    
160 >    DefineOptionalParameterWithDefaultValue(UseSphericalBoundaryConditions,
161 >                                            "useSphericalBoundaryConditions",
162 >                                            false);
163 >    DefineOptionalParameterWithDefaultValue(AccumulateBoxDipole,
164 >                                            "accumulateBoxDipole", false);
165 >    DefineOptionalParameterWithDefaultValue(AccumulateBoxQuadrupole,
166 >                                            "accumulateBoxQuadrupole", false);
167 >    DefineOptionalParameterWithDefaultValue(UseRestraints, "useRestraints",
168 >                                            false);
169 >    DefineOptionalParameterWithDefaultValue(Restraint_file, "Restraint_file",
170 >                                            "idealCrystal.in");
171 >    DefineOptionalParameterWithDefaultValue(UseThermodynamicIntegration,
172 >                                            "useThermodynamicIntegration",
173 >                                            false);
174 >    DefineOptionalParameterWithDefaultValue(HULL_Method,"HULL_Method","Convex");
175  
176 < Globals::~Globals(){
177 <  int i;
178 <  if( components != NULL ){
179 <    for( i=0; i< getNComponents(); i++ ) delete components[i];
180 <    delete[] components;
181 <  }
182 <  
183 <  if( zConstraints != NULL ){
184 <    for( i=0; i< getNZconstraints(); i++ ) delete zConstraints[i];
185 <    delete[] zConstraints;
186 <  }
187 <  
188 < }
176 >    deprecatedKeywords_.insert("nComponents");
177 >    deprecatedKeywords_.insert("nZconstraints");
178 >    deprecatedKeywords_.insert("initialConfig");
179 >    deprecatedKeywords_.insert("thermIntDistSpringConst");
180 >    deprecatedKeywords_.insert("thermIntThetaSpringConst");
181 >    deprecatedKeywords_.insert("thermIntOmegaSpringConst");
182 >    deprecatedKeywords_.insert("useSolidThermInt");  
183 >    deprecatedKeywords_.insert("useLiquidThermInt");
184 >    deprecatedKeywords_.insert("minimizerMaxIter");
185 >    deprecatedKeywords_.insert("minimizerWriteFreq");
186 >    deprecatedKeywords_.insert("minimizerStepSize");
187 >    deprecatedKeywords_.insert("minimizerFTol");
188 >    deprecatedKeywords_.insert("minimizerGTol");
189 >    deprecatedKeywords_.insert("minimizerLSTol");
190 >    deprecatedKeywords_.insert("minimizerLSMaxIter");
191 >    deprecatedKeywords_.insert("electricField");
192  
193 < 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);
193 >    
194    }
195  
196 <  if (keyword == "nComponents" && getNComponents() > 0) {
197 <    components = new Component*[getNComponents()];
198 <  }else if (keyword == "nZconstraints" && getNZconstraints() > 0) {
199 <    zConstraints = new ZconStamp*[getNZconstraints()];
196 >  Globals::~Globals() {
197 >    MemoryUtils::deletePointers(components_);
198 >    MemoryUtils::deletePointers(zconstraints_);
199 >    MemoryUtils::deletePointers(restraints_);
200 >    delete flucQpars_;
201 >    delete rnemdPars_;
202 >    delete minimizerPars_;
203    }
191  
192  return result;
193 }
204  
205 < int Globals::newComponent( event* the_event ){
206 <  
197 <  current_component = new Component;
198 <  int index = the_event->evt.blk_index;
199 <  char err[200];
200 <  
201 <  if( haveNComponents() && index < getNComponents() )
202 <    components[index] = current_component;
203 <  else{
204 <    if( haveNComponents()  ){
205 <      sprintf( err, "meta-data parsing error: %d out of nComponents range",
206 <               index );
207 <      the_event->err_msg = strdup( err );
208 <      return 0;
209 <    }
210 <    else{
211 <      the_event->err_msg = strdup("meta-data parsing error: nComponents not given before"
212 <                                  " first component declaration." );
213 <      return 0;
214 <    }
215 <  }  
216 <
217 <  return 1;
218 < }
205 >  void Globals::validate() {
206 >    DataHolder::validate();
207  
208 +    CheckParameter(ForceField, isNotEmpty());
209 +    CheckParameter(TargetTemp, isPositive());
210 +    CheckParameter(Ensemble, isEqualIgnoreCase("NVE") ||
211 +                   isEqualIgnoreCase("NVT") || isEqualIgnoreCase("NPTi") ||
212 +                   isEqualIgnoreCase("NPTf") || isEqualIgnoreCase("NPTxyz") ||
213 +                   isEqualIgnoreCase("NPTsz") || isEqualIgnoreCase("NPAT")  ||
214 +                   isEqualIgnoreCase("NPA") ||
215 +                   isEqualIgnoreCase("LANGEVINDYNAMICS") ||
216 +                   isEqualIgnoreCase("LD") || isEqualIgnoreCase("NPRT") ||
217 +                   isEqualIgnoreCase("NPGT") || isEqualIgnoreCase("NGammaT") ||
218 +                   isEqualIgnoreCase("NGT") ||
219 +                   isEqualIgnoreCase("LANGEVINHULL") ||
220 +                   isEqualIgnoreCase("LHULL") || isEqualIgnoreCase("SMIPD"));
221 +    CheckParameter(Dt, isPositive());
222 +    CheckParameter(RunTime, isPositive());
223 +    CheckParameter(FinalConfig, isNotEmpty());
224 +    CheckParameter(SampleTime, isNonNegative());
225 +    CheckParameter(ResetTime, isNonNegative());
226 +    CheckParameter(StatusTime, isNonNegative());
227 +    CheckParameter(CutoffRadius, isPositive());
228 +    CheckParameter(SwitchingRadius, isNonNegative());
229 +    CheckParameter(Dielectric, isPositive());
230 +    CheckParameter(ThermalTime,  isNonNegative());
231 +    CheckParameter(TauThermostat, isPositive());
232 +    CheckParameter(TauBarostat, isPositive());
233 +    CheckParameter(ZconsTime, isPositive());
234 +    CheckParameter(ZconsTol, isPositive());
235 +    CheckParameter(Seed, isPositive());
236 +    CheckParameter(ZconsGap, isPositive());
237 +    CheckParameter(ZconsFixtime, isPositive());
238 +    CheckParameter(ThermodynamicIntegrationLambda, isNonNegative());
239 +    CheckParameter(ThermodynamicIntegrationK, isPositive());
240 +    CheckParameter(ForceFieldVariant, isNotEmpty());
241 +    CheckParameter(ForceFieldFileName, isNotEmpty());
242 +    CheckParameter(CutoffMethod, isEqualIgnoreCase("HARD") ||
243 +                   isEqualIgnoreCase("SWITCHED") ||
244 +                   isEqualIgnoreCase("SHIFTED_POTENTIAL") ||
245 +                   isEqualIgnoreCase("SHIFTED_FORCE") ||
246 +                   isEqualIgnoreCase("TAYLOR_SHIFTED") ||
247 +                   isEqualIgnoreCase("EWALD_FULL"));
248 +    CheckParameter(CutoffPolicy, isEqualIgnoreCase("MIX") ||
249 +                   isEqualIgnoreCase("MAX") ||
250 +                   isEqualIgnoreCase("TRADITIONAL"));
251 +    CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase("NONE") ||
252 +                   isEqualIgnoreCase("HARD") || isEqualIgnoreCase("SWITCHED") ||
253 +                   isEqualIgnoreCase("SHIFTED_POTENTIAL") ||
254 +                   isEqualIgnoreCase("SHIFTED_FORCE") ||
255 +                   isEqualIgnoreCase("REACTION_FIELD") ||
256 +                   isEqualIgnoreCase("TAYLOR_SHIFTED"));
257 +    CheckParameter(ElectrostaticScreeningMethod,
258 +                   isEqualIgnoreCase("UNDAMPED") || isEqualIgnoreCase("DAMPED"));
259 +    CheckParameter(SwitchingFunctionType, isEqualIgnoreCase("CUBIC") ||
260 +                   isEqualIgnoreCase("FIFTH_ORDER_POLYNOMIAL"));
261 +    CheckParameter(OrthoBoxTolerance, isPositive());  
262 +    CheckParameter(DampingAlpha,isNonNegative());
263 +    CheckParameter(SkinThickness, isPositive());
264 +    CheckParameter(Viscosity, isNonNegative());
265 +    CheckParameter(BeadSize, isPositive());
266 +    CheckParameter(FrozenBufferRadius, isPositive());
267 +    CheckParameter(LangevinBufferRadius, isPositive());
268 +    CheckParameter(NeighborListNeighbors, isPositive());
269 +    CheckParameter(HULL_Method, isEqualIgnoreCase("Convex") ||
270 +                   isEqualIgnoreCase("AlphaShape"));
271 +    CheckParameter(Alpha, isPositive());
272 +  
273 +    for(std::vector<Component*>::iterator i = components_.begin();
274 +        i != components_.end(); ++i) {
275 +      if (!(*i)->findMoleculeStamp(moleculeStamps_)) {
276 +        std::ostringstream oss;
277 +        oss << "Globals Error: can not find molecule stamp for component "
278 +            << (*i)->getType() << std::endl;
279 +        throw OpenMDException(oss.str());          
280 +      }
281 +    }
282 +  }
283 +  
284 +  bool Globals::addComponent(Component* comp) {
285 +    components_.push_back(comp);
286 +    return true;
287 +  }
288  
289 +  bool Globals::addZConsStamp(ZConsStamp* zcons) {
290 +    zconstraints_.push_back(zcons);
291 +    return true;
292 +  }
293  
294 < int Globals::componentAssign( event* the_event ){
294 >  bool Globals::addRestraintStamp(RestraintStamp* rest) {
295 >    restraints_.push_back(rest);
296 >    return true;
297 >  }
298  
299 <  switch( the_event->evt.asmt.asmt_type ){
299 >  bool Globals::addFluctuatingChargeParameters(FluctuatingChargeParameters* fqp) {
300 >    if (flucQpars_ != NULL)
301 >      delete flucQpars_;
302      
303 <  case STRING:
304 <    return current_component->assignString( the_event->evt.asmt.lhs,
305 <                                            the_event->evt.asmt.rhs.sval,
306 <                                            &(the_event->err_msg));
307 <    break;
303 >    flucQpars_ = fqp;
304 >    return true;
305 >  }
306 >
307 >  bool Globals::addRNEMDParameters(RNEMDParameters* rnemdPars) {
308 >    if (rnemdPars_ != NULL)
309 >      delete rnemdPars_;
310      
311 <  case DOUBLE:
312 <    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;
311 >    rnemdPars_ = rnemdPars;
312 >    return true;
313    }
250  return 0;
251 }
314  
315 < int Globals::componentEnd( event* the_event ){
316 <
317 <  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 ){
315 >  bool Globals::addMinimizerParameters(MinimizerParameters* miniPars) {
316 >    if (minimizerPars_ != NULL)
317 >      delete minimizerPars_;
318      
319 <  case STRING:
320 <    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;
319 >    minimizerPars_ = miniPars;
320 >    return true;
321    }
318  return 0;
319 }
322  
323 < int Globals::zConstraintEnd( event* the_event ){
324 <
325 <  the_event->err_msg = current_zConstraint->checkMe();
326 <  if( the_event->err_msg != NULL ) return 0;
327 <
328 <  return 1;
329 < }
330 <
331 < char* Globals::checkMe( void ){
332 <
333 <
334 <  std::string err("The following required keywords are missing:\n");
335 <  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";
323 >  bool Globals::addMoleculeStamp(MoleculeStamp* molStamp) {
324 >    std::string molStampName = molStamp->getName();
325 >    std::map<std::string, MoleculeStamp*>::iterator i;
326 >    bool ret = false;
327 >    i = moleculeStamps_.find(molStampName);
328 >    if (i == moleculeStamps_.end()) {
329 >      moleculeStamps_.insert(std::map<std::string, MoleculeStamp*>::value_type(molStampName, molStamp));
330 >      ret = true;
331 >    } else {
332 >      std::ostringstream oss;
333 >      oss << "Globals Error: Molecule Stamp " << molStamp->getName()
334 >          << "appears multiple times\n";
335 >      throw OpenMDException(oss.str());  
336      }
337 +    return ret;
338    }
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
339   }
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 2022 by gezelter, Fri Sep 26 22:22:28 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines