--- trunk/src/io/Globals.cpp 2005/11/16 23:10:02 749 +++ branches/development/src/io/Globals.cpp 2012/05/22 21:55:31 1715 @@ -1,24 +1,15 @@ /* - * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. + * Copyright (c) 2005, 2010 The University of Notre Dame. All Rights Reserved. * * The University of Notre Dame grants you ("Licensee") a * non-exclusive, royalty free, license to use, modify and * redistribute this software in source and binary code form, provided * that the following conditions are met: * - * 1. Acknowledgement of the program authors must be made in any - * publication of scientific results based in part on use of the - * program. An acceptable form of acknowledgement is citation of - * the article in which the program was described (Matthew - * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher - * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented - * Parallel Simulation Engine for Molecular Dynamics," - * J. Comput. Chem. 26, pp. 252-271 (2005)) - * - * 2. Redistributions of source code must retain the above copyright + * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - * 3. Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. @@ -37,6 +28,16 @@ * arising out of the use of or inability to use software, even if the * University of Notre Dame has been advised of the possibility of * such damages. + * + * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your + * research, please cite the appropriate papers when you publish your + * work. Good starting points are: + * + * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). + * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ #include @@ -45,51 +46,36 @@ #include #include "io/Globals.hpp" +#include "io/ParamConstraint.hpp" +#include "utils/MemoryUtils.hpp" #include "utils/simError.h" -#ifdef IS_MPI -#include "io/mpiBASS.h" -#endif // is_mpi -#include "io/ParamConstraint.hpp" - -using namespace oopse; - -Globals::Globals(){ - +namespace OpenMD { +Globals::Globals() { DefineParameter(ForceField, "forceField") - DefineParameter(NComponents, "nComponents") DefineOptionalParameter(TargetTemp, "targetTemp"); DefineOptionalParameter(Ensemble, "ensemble"); DefineOptionalParameter(Dt, "dt"); DefineOptionalParameter(RunTime, "runTime"); - DefineOptionalParameter(InitialConfig, "initialConfig"); DefineOptionalParameter(FinalConfig, "finalConfig"); - DefineOptionalParameter(NMol, "nMol"); - DefineOptionalParameter(Density, "density"); - DefineOptionalParameter(Box, "box"); - DefineOptionalParameter(BoxX, "boxX"); - DefineOptionalParameter(BoxY, "boxY"); - DefineOptionalParameter(BoxZ, "boxZ"); DefineOptionalParameter(SampleTime, "sampleTime"); DefineOptionalParameter(ResetTime, "resetTime"); DefineOptionalParameter(StatusTime, "statusTime"); DefineOptionalParameter(CutoffRadius, "cutoffRadius"); DefineOptionalParameter(SwitchingRadius, "switchingRadius"); - DefineOptionalParameter(Dielectric, "dielectric"); DefineOptionalParameter(TempSet, "tempSet"); DefineOptionalParameter(ThermalTime, "thermalTime"); - DefineOptionalParameter(TargetPressure, "targetPressure"); + DefineOptionalParameter(TargetPressure, "targetPressure"); DefineOptionalParameter(TauThermostat, "tauThermostat"); DefineOptionalParameter(TauBarostat, "tauBarostat"); DefineOptionalParameter(ZconsTime, "zconsTime"); - DefineOptionalParameter(NZconstraints, "nZconstraints"); DefineOptionalParameter(ZconsTol, "zconsTol"); DefineOptionalParameter(ZconsForcePolicy, "zconsForcePolicy"); DefineOptionalParameter(Seed, "seed"); DefineOptionalParameter(Minimizer, "minimizer"); DefineOptionalParameter(MinimizerMaxIter,"minimizerMaxIter"); - DefineOptionalParameter(MinimizerWriteFrq, "minimizerWriteFrq"); + DefineOptionalParameter(MinimizerWriteFreq, "minimizerWriteFreq"); DefineOptionalParameter(MinimizerStepSize, "minimizerStepSize"); DefineOptionalParameter(MinimizerFTol, "minimizerFTol"); DefineOptionalParameter(MinimizerGTol, "minimizerGTol"); @@ -102,261 +88,92 @@ Globals::Globals(){ DefineOptionalParameter(ThermodynamicIntegrationK, "thermodynamicIntegrationK"); DefineOptionalParameter(ForceFieldVariant, "forceFieldVariant"); DefineOptionalParameter(ForceFieldFileName, "forceFieldFileName"); - DefineOptionalParameter(ThermIntDistSpringConst, "thermIntDistSpringConst"); - DefineOptionalParameter(ThermIntThetaSpringConst, "thermIntThetaSpringConst"); - DefineOptionalParameter(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst"); + DefineOptionalParameter(DampingAlpha, "dampingAlpha"); DefineOptionalParameter(SurfaceTension, "surfaceTension"); DefineOptionalParameter(PrintPressureTensor, "printPressureTensor"); - DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod"); - DefineOptionalParameter(ElectrostaticScreeningMethod, "electrostaticScreeningMethod"); - DefineOptionalParameter(CutoffPolicy, "cutoffPolicy"); + DefineOptionalParameter(TaggedAtomPair, "taggedAtomPair"); + DefineOptionalParameter(PrintTaggedPairDistance, "printTaggedPairDistance"); DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType"); - DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard"); + DefineOptionalParameter(HydroPropFile, "HydroPropFile"); + DefineOptionalParameter(Viscosity, "viscosity"); + DefineOptionalParameter(BeadSize, "beadSize"); + DefineOptionalParameter(FrozenBufferRadius, "frozenBufferRadius"); + DefineOptionalParameter(LangevinBufferRadius, "langevinBufferRadius"); + DefineOptionalParameter(NeighborListNeighbors,"NeighborListNeighbors"); + DefineOptionalParameter(UseMultipleTemperatureMethod, "useMultipleTemperatureMethod"); + DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod"); + DefineOptionalParameter(MTM_Ce, "MTM_Ce"); + DefineOptionalParameter(MTM_G, "MTM_G"); + DefineOptionalParameter(MTM_Io, "MTM_Io"); + DefineOptionalParameter(MTM_Sigma, "MTM_Sigma"); + DefineOptionalParameter(MTM_R, "MTM_R"); + DefineOptionalParameter(Alpha, "alpha"); + + DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true); + DefineOptionalParameterWithDefaultValue(UseAtomicVirial, "useAtomicVirial", true); DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false); DefineOptionalParameterWithDefaultValue(UseIntialExtendedSystemState, "useInitialExtendedSystemState", false); DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance, "orthoBoxTolerance", 1E-6); - DefineOptionalParameterWithDefaultValue(UseSolidThermInt, "useSolidThermInt", false); - DefineOptionalParameterWithDefaultValue(UseLiquidThermInt, "useLiquidThermInt", false); - DefineOptionalParameterWithDefaultValue(ThermIntDistSpringConst, "thermIntDistSpringConst", 6.0); - DefineOptionalParameterWithDefaultValue(ThermIntThetaSpringConst, "thermIntThetaSpringConst", 7.5); - DefineOptionalParameterWithDefaultValue(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst", 13.5); - DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 0.2); - DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0); - DefineOptionalParameterWithDefaultValue(OutputForceVector, "outputForceVector", 0); + DefineOptionalParameterWithDefaultValue(CutoffMethod, "cutoffMethod", "SHIFTED_FORCE"); + DefineOptionalParameterWithDefaultValue(ElectrostaticScreeningMethod, "electrostaticScreeningMethod", "DAMPED"); + DefineOptionalParameterWithDefaultValue(Dielectric, "dielectric", 80.0); + DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", false); + DefineOptionalParameterWithDefaultValue(OutputForceVector, "outputForceVector", false); + DefineOptionalParameterWithDefaultValue(OutputParticlePotential, "outputParticlePotential", false); + DefineOptionalParameterWithDefaultValue(OutputElectricField, "outputElectricField", false); + DefineOptionalParameterWithDefaultValue(OutputFluctuatingCharges, "outputFluctuatingCharges", false); DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0); DefineOptionalParameterWithDefaultValue(StatFileFormat, "statFileFormat", "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY"); + DefineOptionalParameterWithDefaultValue(UseSphericalBoundaryConditions, "useSphericalBoundaryConditions", false); + DefineOptionalParameterWithDefaultValue(AccumulateBoxDipole, "accumulateBoxDipole", false); - -} - -Globals::~Globals(){ - int i; - if( components != NULL ){ - for( i=0; i< getNComponents(); i++ ) delete components[i]; - delete[] components; - } - - if( zConstraints != NULL ){ - for( i=0; i< getNZconstraints(); i++ ) delete zConstraints[i]; - delete[] zConstraints; - } - -} - -int Globals::globalAssign( event* the_event ){ - char errorMessage[65535]; - int key; - interface_assign_type the_type = the_event->evt.asmt.asmt_type; - char* lhs = the_event->evt.asmt.lhs; - std::string keyword(lhs); - - bool result = false; - - /**@todo fix memory leak */ - ParamMap::iterator i =parameters_.find(keyword); - if (i != parameters_.end()) { - if( the_type == STRING ){ - result = i->second->setData(std::string(the_event->evt.asmt.rhs.sval)); - if (!result ) { - 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); - the_event->err_msg = strdup(errorMessage); - } - } else if( the_type == DOUBLE ){ - result = i->second->setData(the_event->evt.asmt.rhs.dval); - if (!result ) - 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 ); - the_event->err_msg = strdup(errorMessage); - } - else if (the_type == INT ){ - result = i->second->setData(the_event->evt.asmt.rhs.ival); - if (!result ) - 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 ); - the_event->err_msg = strdup(errorMessage); - - } else { - sprintf(errorMessage, "Internal error of parser\n"); - the_event->err_msg = strdup(errorMessage); - } - } else { - sprintf(errorMessage, "%s is an unrecognized keyword\n", keyword.c_str() ); - the_event->err_msg = strdup(errorMessage); - } - - if (keyword == "nComponents" && getNComponents() > 0) { - components = new Component*[getNComponents()]; - }else if (keyword == "nZconstraints" && getNZconstraints() > 0) { - zConstraints = new ZconStamp*[getNZconstraints()]; - } - - return result; -} - -int Globals::newComponent( event* the_event ){ - - current_component = new Component; - int index = the_event->evt.blk_index; - char err[200]; - - if( haveNComponents() && index < getNComponents() ) - components[index] = current_component; - else{ - if( haveNComponents() ){ - sprintf( err, "meta-data parsing error: %d out of nComponents range", - index ); - the_event->err_msg = strdup( err ); - return 0; - } - else{ - the_event->err_msg = strdup("meta-data parsing error: nComponents not given before" - " first component declaration." ); - return 0; - } - } - - return 1; -} - - - -int Globals::componentAssign( event* the_event ){ - - switch( the_event->evt.asmt.asmt_type ){ - - case STRING: - return current_component->assignString( the_event->evt.asmt.lhs, - the_event->evt.asmt.rhs.sval, - &(the_event->err_msg)); - break; - - case DOUBLE: - return current_component->assignDouble( the_event->evt.asmt.lhs, - the_event->evt.asmt.rhs.dval, - &(the_event->err_msg)); - break; - - case INT: - return current_component->assignInt( the_event->evt.asmt.lhs, - the_event->evt.asmt.rhs.ival, - &(the_event->err_msg)); - break; - - default: - the_event->err_msg = strdup( "Globals error. Invalid component" - " assignment type" ); - return 0; - break; - } - return 0; -} - -int Globals::componentEnd( event* the_event ){ - - the_event->err_msg = current_component->checkMe(); - if( the_event->err_msg != NULL ) return 0; - - return 1; -} - -int Globals::newZconstraint( event* the_event ){ - + DefineOptionalParameterWithDefaultValue(UseRNEMD, "useRNEMD", false); + DefineOptionalParameterWithDefaultValue(RNEMD_exchangeTime, "RNEMD_exchangeTime", 100.0); + DefineOptionalParameterWithDefaultValue(RNEMD_nBins, "RNEMD_nBins", 16); + DefineOptionalParameterWithDefaultValue(RNEMD_logWidth, "RNEMD_logWidth", 16); + DefineOptionalParameterWithDefaultValue(RNEMD_exchangeType, "RNEMD_exchangeType", "KineticScale"); + DefineOptionalParameterWithDefaultValue(RNEMD_targetFlux, "RNEMD_targetFlux", 0.0); + DefineOptionalParameterWithDefaultValue(RNEMD_objectSelection, "RNEMD_objectSelection", "select all"); + DefineOptionalParameterWithDefaultValue(RNEMD_binShift, "RNEMD_binShift", false); + DefineOptionalParameterWithDefaultValue(RNEMD_outputDimensionalTemperature, "RNEMD_outputDimensionalTemperature", false); + DefineOptionalParameterWithDefaultValue(UseRestraints, "useRestraints", false); + DefineOptionalParameterWithDefaultValue(Restraint_file, "Restraint_file", "idealCrystal.in"); + DefineOptionalParameterWithDefaultValue(UseThermodynamicIntegration, "useThermodynamicIntegration", false); + DefineOptionalParameterWithDefaultValue(HULL_Method,"HULL_Method","Convex"); + DefineOptionalParameterWithDefaultValue(FlucQPropagator, "flucQ.propagator", "NVT"); + DefineOptionalParameterWithDefaultValue(FlucQFriction, "flucQ.friction", 1600.0); + DefineOptionalParameterWithDefaultValue(FlucQTolerance, "flucQ.tolerance", 1.0e-6); + DefineOptionalParameterWithDefaultValue(FlucQMaxIterations, "flucQ.maxIterations", 100); + DefineOptionalParameterWithDefaultValue(FlucQTargetTemp, "flucQ.targetTemp", 1.0e-6); + DefineOptionalParameterWithDefaultValue(FlucQtauThermostat, "flucQ.tauThermostat", 10.0); - int index = the_event->evt.blk_index; - char err[200]; - current_zConstraint = new ZconStamp( index ); - - if( haveNZconstraints() && index < getNZconstraints() ) - zConstraints[index] = current_zConstraint; - else{ - if( haveNZconstraints() ){ - sprintf( err, "meta-data parsing error: %d out of nZconstraints range", - index ); - the_event->err_msg = strdup( err ); - return 0; - } - else{ - the_event->err_msg = strdup("meta-data parsing error: nZconstraints" - " not given before" - " first zConstraint declaration." ); - return 0; - } - } - - return 1; -} - - - -int Globals::zConstraintAssign( event* the_event ){ - - switch( the_event->evt.asmt.asmt_type ){ + deprecatedKeywords_.insert("nComponents"); + deprecatedKeywords_.insert("nZconstraints"); + deprecatedKeywords_.insert("initialConfig"); + deprecatedKeywords_.insert("thermIntDistSpringConst"); + deprecatedKeywords_.insert("thermIntThetaSpringConst"); + deprecatedKeywords_.insert("thermIntOmegaSpringConst"); + deprecatedKeywords_.insert("useSolidThermInt"); + deprecatedKeywords_.insert("useLiquidThermInt"); - case STRING: - return current_zConstraint->assignString( the_event->evt.asmt.lhs, - the_event->evt.asmt.rhs.sval, - &(the_event->err_msg)); - break; - - case DOUBLE: - return current_zConstraint->assignDouble( the_event->evt.asmt.lhs, - the_event->evt.asmt.rhs.dval, - &(the_event->err_msg)); - break; - - case INT: - return current_zConstraint->assignInt( the_event->evt.asmt.lhs, - the_event->evt.asmt.rhs.ival, - &(the_event->err_msg)); - break; - - default: - the_event->err_msg = strdup( "Globals error. Invalid zConstraint" - " assignment type" ); - return 0; - break; - } - return 0; } -int Globals::zConstraintEnd( event* the_event ){ - - the_event->err_msg = current_zConstraint->checkMe(); - if( the_event->err_msg != NULL ) return 0; - - return 1; +Globals::~Globals() { + MemoryUtils::deletePointers(components_); + MemoryUtils::deletePointers(zconstraints_); + MemoryUtils::deletePointers(restraints_); } -char* Globals::checkMe( void ){ +void Globals::validate() { + DataHolder::validate(); - - std::string err("The following required keywords are missing:\n"); - short int have_err = 0; - - ParamMap::iterator i; - for (i = parameters_.begin(); i != parameters_.end(); ++i) { - if (!i->second->isOptional() && i->second->empty()) { - err += i->second->getKeyword() + "\n"; - } - } - CheckParameter(ForceField, isNotEmpty()); - CheckParameter(NComponents,isPositive()); CheckParameter(TargetTemp, isPositive()); - CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) || - isEqualIgnoreCase(std::string("NVT")) || - isEqualIgnoreCase(std::string("NPTi")) || - isEqualIgnoreCase(std::string("NPTf")) || - isEqualIgnoreCase(std::string("NPTxyz")) ); + CheckParameter(Ensemble, isEqualIgnoreCase("NVE") || isEqualIgnoreCase("NVT") || isEqualIgnoreCase("NPTi") || isEqualIgnoreCase("NPTf") || isEqualIgnoreCase("NPTxyz") || isEqualIgnoreCase("NPTsz") || isEqualIgnoreCase("NPAT") || isEqualIgnoreCase("LANGEVINDYNAMICS") || isEqualIgnoreCase("LD") || isEqualIgnoreCase("NPRT") || isEqualIgnoreCase("NPGT") || isEqualIgnoreCase("NGammaT") || isEqualIgnoreCase("NGT") || isEqualIgnoreCase("LANGEVINHULL") || isEqualIgnoreCase("LHULL") || isEqualIgnoreCase("SMIPD")); CheckParameter(Dt, isPositive()); CheckParameter(RunTime, isPositive()); - CheckParameter(InitialConfig, isNotEmpty()); CheckParameter(FinalConfig, isNotEmpty()); - CheckParameter(NMol, isPositive()); - CheckParameter(Density, isPositive()); - CheckParameter(Box, isPositive()); - CheckParameter(BoxX, isPositive()); - CheckParameter(BoxY, isPositive()); - CheckParameter(BoxZ, isPositive()); CheckParameter(SampleTime, isNonNegative()); CheckParameter(ResetTime, isNonNegative()); CheckParameter(StatusTime, isNonNegative()); @@ -364,18 +181,14 @@ char* Globals::checkMe( void ){ CheckParameter(SwitchingRadius, isNonNegative()); CheckParameter(Dielectric, isPositive()); CheckParameter(ThermalTime, isNonNegative()); - CheckParameter(TargetPressure, isPositive()); CheckParameter(TauThermostat, isPositive()); CheckParameter(TauBarostat, isPositive()); CheckParameter(ZconsTime, isPositive()); - CheckParameter(NZconstraints, isPositive()); CheckParameter(ZconsTol, isPositive()); - //CheckParameter(ZconsForcePolicy,); CheckParameter(Seed, isPositive()); - CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) || - isEqualIgnoreCase(std::string("CG"))); + CheckParameter(Minimizer, isEqualIgnoreCase("SD") || isEqualIgnoreCase("CG")); CheckParameter(MinimizerMaxIter, isPositive()); - CheckParameter(MinimizerWriteFrq, isPositive()); + CheckParameter(MinimizerWriteFreq, isPositive()); CheckParameter(MinimizerStepSize, isPositive()); CheckParameter(MinimizerFTol, isPositive()); CheckParameter(MinimizerGTol, isPositive()); @@ -383,50 +196,74 @@ char* Globals::checkMe( void ){ CheckParameter(MinimizerLSMaxIter, isPositive()); CheckParameter(ZconsGap, isPositive()); CheckParameter(ZconsFixtime, isPositive()); - CheckParameter(ThermodynamicIntegrationLambda, isPositive()); + CheckParameter(ThermodynamicIntegrationLambda, isNonNegative()); CheckParameter(ThermodynamicIntegrationK, isPositive()); CheckParameter(ForceFieldVariant, isNotEmpty()); CheckParameter(ForceFieldFileName, isNotEmpty()); - CheckParameter(ThermIntDistSpringConst, isPositive()); - CheckParameter(ThermIntThetaSpringConst, isPositive()); - CheckParameter(ThermIntOmegaSpringConst, isPositive()); - CheckParameter(SurfaceTension, isPositive()); - CheckParameter(ElectrostaticSummationMethod, - isEqualIgnoreCase(std::string("NONE")) || - isEqualIgnoreCase(std::string("SHIFTED_POTENTIAL")) || - isEqualIgnoreCase(std::string("SHIFTED_FORCE")) || - isEqualIgnoreCase(std::string("REACTION_FIELD"))); - CheckParameter(ElectrostaticScreeningMethod, - isEqualIgnoreCase(std::string("UNDAMPED")) || - isEqualIgnoreCase(std::string("DAMPED"))); - CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) || - isEqualIgnoreCase(std::string("MAX")) || - isEqualIgnoreCase(std::string("TRADITIONAL"))); - CheckParameter(SwitchingFunctionType, - isEqualIgnoreCase(std::string("CUBIC")) || - isEqualIgnoreCase(std::string("FIFTH_ORDER_POLYNOMIAL"))); - //CheckParameter(StatFileFormat,); - //CheckParameter(MixingRule,); + CheckParameter(CutoffMethod, isEqualIgnoreCase("HARD") || isEqualIgnoreCase("SWITCHED") || isEqualIgnoreCase("SHIFTED_POTENTIAL") || isEqualIgnoreCase("SHIFTED_FORCE")); + CheckParameter(CutoffPolicy, isEqualIgnoreCase("MIX") || isEqualIgnoreCase("MAX") || isEqualIgnoreCase("TRADITIONAL")); + CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase("NONE") || isEqualIgnoreCase("HARD") || isEqualIgnoreCase("SWITCHED") || isEqualIgnoreCase("SHIFTED_POTENTIAL") || isEqualIgnoreCase("SHIFTED_FORCE") || isEqualIgnoreCase("REACTION_FIELD")); + CheckParameter(ElectrostaticScreeningMethod, isEqualIgnoreCase("UNDAMPED") || isEqualIgnoreCase("DAMPED")); + CheckParameter(SwitchingFunctionType, isEqualIgnoreCase("CUBIC") || isEqualIgnoreCase("FIFTH_ORDER_POLYNOMIAL")); CheckParameter(OrthoBoxTolerance, isPositive()); - CheckParameter(ThermIntDistSpringConst, isPositive()); - CheckParameter(ThermIntThetaSpringConst, isPositive()); - CheckParameter(ThermIntOmegaSpringConst, isPositive()); CheckParameter(DampingAlpha,isNonNegative()); CheckParameter(SkinThickness, isPositive()); + CheckParameter(Viscosity, isNonNegative()); + CheckParameter(BeadSize, isPositive()); + CheckParameter(FrozenBufferRadius, isPositive()); + CheckParameter(LangevinBufferRadius, isPositive()); + CheckParameter(NeighborListNeighbors, isPositive()); + CheckParameter(RNEMD_exchangeTime, isPositive()); + CheckParameter(RNEMD_nBins, isPositive() && isEven()); + CheckParameter(RNEMD_exchangeType, isEqualIgnoreCase("KineticSwap") || isEqualIgnoreCase("KineticScale") || isEqualIgnoreCase("Px") || isEqualIgnoreCase("Py") || isEqualIgnoreCase("Pz") || isEqualIgnoreCase("PxScale") || isEqualIgnoreCase("PyScale") || isEqualIgnoreCase("PzScale")); + CheckParameter(HULL_Method, isEqualIgnoreCase("Convex") || isEqualIgnoreCase("AlphaShape")); + CheckParameter(Alpha, isPositive()); + CheckParameter(FlucQPropagator, isEqualIgnoreCase("NVT") || isEqualIgnoreCase("Langevin") || isEqualIgnoreCase("Minimizer") || isEqualIgnoreCase("Exact") ); + CheckParameter(FlucQFriction, isNonNegative()); + CheckParameter(FlucQTolerance, isPositive()); + CheckParameter(FlucQMaxIterations, isPositive()); + CheckParameter(FlucQTargetTemp, isNonNegative()); + CheckParameter(FlucQtauThermostat, isPositive()); - //@todo memory leak - if( have_err ) - return strdup( err.c_str() ); - - return NULL; + for(std::vector::iterator i = components_.begin(); i != components_.end(); ++i) { + if (!(*i)->findMoleculeStamp(moleculeStamps_)) { + std::ostringstream oss; + oss << "Globals Error: can not find molecule stamp for component " << (*i)->getType() << std::endl; + throw OpenMDException(oss.str()); + } + } +} +bool Globals::addComponent(Component* comp) { + components_.push_back(comp); + return true; +} +bool Globals::addZConsStamp(ZConsStamp* zcons) { + zconstraints_.push_back(zcons); + return true; } -int Globals::globalEnd( event* the_event ){ - - the_event->err_msg = checkMe(); - if( the_event->err_msg != NULL ) return 0; +bool Globals::addRestraintStamp(RestraintStamp* rest) { + restraints_.push_back(rest); + return true; +} - return 1; +bool Globals::addMoleculeStamp(MoleculeStamp* molStamp) { + std::string molStampName = molStamp->getName(); + std::map::iterator i; + bool ret = false; + i = moleculeStamps_.find(molStampName); + if (i == moleculeStamps_.end()) { + moleculeStamps_.insert(std::map::value_type(molStampName, molStamp)); + ret = true; + } else { + std::ostringstream oss; + oss << "Globals Error: Molecule Stamp " << molStamp->getName() << "appears multiple times\n"; + throw OpenMDException(oss.str()); + } + return ret; } + + +}