| 1 | 
gezelter | 
404 | 
/* | 
| 2 | 
gezelter | 
246 | 
 * Copyright (c) 2005 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 | 
| 19 | 
  | 
  | 
 *    notice, this list of conditions and the following disclaimer. | 
| 20 | 
  | 
  | 
 * | 
| 21 | 
  | 
  | 
 * 3. Redistributions in binary form must reproduce the above copyright | 
| 22 | 
  | 
  | 
 *    notice, this list of conditions and the following disclaimer in the | 
| 23 | 
  | 
  | 
 *    documentation and/or other materials provided with the | 
| 24 | 
  | 
  | 
 *    distribution. | 
| 25 | 
  | 
  | 
 * | 
| 26 | 
  | 
  | 
 * This software is provided "AS IS," without a warranty of any | 
| 27 | 
  | 
  | 
 * kind. All express or implied conditions, representations and | 
| 28 | 
  | 
  | 
 * warranties, including any implied warranty of merchantability, | 
| 29 | 
  | 
  | 
 * fitness for a particular purpose or non-infringement, are hereby | 
| 30 | 
  | 
  | 
 * excluded.  The University of Notre Dame and its licensors shall not | 
| 31 | 
  | 
  | 
 * be liable for any damages suffered by licensee as a result of | 
| 32 | 
  | 
  | 
 * using, modifying or distributing the software or its | 
| 33 | 
  | 
  | 
 * derivatives. In no event will the University of Notre Dame or its | 
| 34 | 
  | 
  | 
 * licensors be liable for any lost revenue, profit or data, or for | 
| 35 | 
  | 
  | 
 * direct, indirect, special, consequential, incidental or punitive | 
| 36 | 
  | 
  | 
 * damages, however caused and regardless of the theory of liability, | 
| 37 | 
  | 
  | 
 * arising out of the use of or inability to use software, even if the | 
| 38 | 
  | 
  | 
 * University of Notre Dame has been advised of the possibility of | 
| 39 | 
  | 
  | 
 * such damages. | 
| 40 | 
  | 
  | 
 */ | 
| 41 | 
  | 
  | 
  | 
| 42 | 
gezelter | 
2 | 
#include <stdlib.h> | 
| 43 | 
  | 
  | 
#include <stdio.h> | 
| 44 | 
  | 
  | 
#include <string.h> | 
| 45 | 
tim | 
665 | 
#include <string> | 
| 46 | 
gezelter | 
2 | 
 | 
| 47 | 
tim | 
3 | 
#include "io/Globals.hpp" | 
| 48 | 
  | 
  | 
#include "utils/simError.h" | 
| 49 | 
gezelter | 
2 | 
#ifdef IS_MPI | 
| 50 | 
tim | 
3 | 
#include "io/mpiBASS.h" | 
| 51 | 
gezelter | 
2 | 
#endif // is_mpi | 
| 52 | 
  | 
  | 
 | 
| 53 | 
tim | 
672 | 
#include "io/ParamConstraint.hpp" | 
| 54 | 
gezelter | 
2 | 
 | 
| 55 | 
tim | 
665 | 
#define DefineParameter(NAME,KEYWORD)                              \ | 
| 56 | 
  | 
  | 
  NAME.setKeyword(KEYWORD);                  \ | 
| 57 | 
  | 
  | 
  parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME)); | 
| 58 | 
gezelter | 
2 | 
 | 
| 59 | 
tim | 
665 | 
#define DefineOptionalParameter(NAME,KEYWORD)                              \ | 
| 60 | 
  | 
  | 
  NAME.setKeyword(KEYWORD); NAME.setOptional(true);                    \ | 
| 61 | 
  | 
  | 
  parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME)); | 
| 62 | 
chrisfen | 
417 | 
 | 
| 63 | 
tim | 
665 | 
#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 | 
tim | 
672 | 
#define CheckParameter(NAME, CONSTRAINT)                              \ | 
| 68 | 
tim | 
674 | 
  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 | 
tim | 
672 | 
 | 
| 70 | 
gezelter | 
2 | 
Globals::Globals(){ | 
| 71 | 
tim | 
665 | 
  | 
| 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(CutoffPolicy, "cutoffPolicy"); | 
| 125 | 
  | 
  | 
  DefineOptionalParameter(StatFileFormat, "statFileFormat");     | 
| 126 | 
  | 
  | 
   | 
| 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 | 
chrisfen | 
666 | 
  DefineOptionalParameterWithDefaultValue(ThermIntDistSpringConst, "thermIntDistSpringConst", 6.0); | 
| 135 | 
  | 
  | 
  DefineOptionalParameterWithDefaultValue(ThermIntThetaSpringConst, "thermIntThetaSpringConst", 7.5); | 
| 136 | 
  | 
  | 
  DefineOptionalParameterWithDefaultValue(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst", 13.5); | 
| 137 | 
tim | 
665 | 
  DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 1.5); | 
| 138 | 
  | 
  | 
  DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0); | 
| 139 | 
  | 
  | 
  DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0); | 
| 140 | 
  | 
  | 
   | 
| 141 | 
gezelter | 
2 | 
} | 
| 142 | 
  | 
  | 
 | 
| 143 | 
tim | 
665 | 
int Globals::globalAssign( event* the_event ){ | 
| 144 | 
tim | 
674 | 
  char errorMessage[65535];  | 
| 145 | 
tim | 
665 | 
  int key; | 
| 146 | 
  | 
  | 
  interface_assign_type the_type =  the_event->evt.asmt.asmt_type; | 
| 147 | 
  | 
  | 
  char* lhs = the_event->evt.asmt.lhs; | 
| 148 | 
  | 
  | 
  std::string keyword(lhs); | 
| 149 | 
chrisfen | 
417 | 
 | 
| 150 | 
tim | 
673 | 
  bool result = false; | 
| 151 | 
gezelter | 
2 | 
 | 
| 152 | 
tim | 
674 | 
  /**@todo fix memory leak */   | 
| 153 | 
tim | 
665 | 
  ParamMap::iterator i =parameters_.find(keyword); | 
| 154 | 
  | 
  | 
  if (i != parameters_.end()) { | 
| 155 | 
  | 
  | 
    if( the_type == STRING ){ | 
| 156 | 
  | 
  | 
       result = i->second->setData(std::string(the_event->evt.asmt.rhs.sval)); | 
| 157 | 
  | 
  | 
       if (!result ) { | 
| 158 | 
tim | 
674 | 
            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); | 
| 159 | 
  | 
  | 
            the_event->err_msg = strdup(errorMessage); | 
| 160 | 
tim | 
665 | 
       } | 
| 161 | 
  | 
  | 
    } else if( the_type == DOUBLE ){ | 
| 162 | 
  | 
  | 
      result = i->second->setData(the_event->evt.asmt.rhs.dval); | 
| 163 | 
  | 
  | 
       if (!result ) | 
| 164 | 
tim | 
674 | 
         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 ); | 
| 165 | 
  | 
  | 
       the_event->err_msg = strdup(errorMessage); | 
| 166 | 
tim | 
665 | 
    }       | 
| 167 | 
  | 
  | 
    else if (the_type == INT ){ | 
| 168 | 
  | 
  | 
      result = i->second->setData(the_event->evt.asmt.rhs.ival); | 
| 169 | 
  | 
  | 
       if (!result ) | 
| 170 | 
tim | 
674 | 
         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 ); | 
| 171 | 
  | 
  | 
       the_event->err_msg = strdup(errorMessage); | 
| 172 | 
tim | 
665 | 
       | 
| 173 | 
  | 
  | 
    } else { | 
| 174 | 
tim | 
674 | 
        sprintf(errorMessage,  "Internal error of parser\n"); | 
| 175 | 
  | 
  | 
        the_event->err_msg = strdup(errorMessage); | 
| 176 | 
tim | 
665 | 
    } | 
| 177 | 
tim | 
674 | 
  } else { | 
| 178 | 
  | 
  | 
    sprintf(errorMessage,  "%s is an unrecognized keyword\n", keyword.c_str() ); | 
| 179 | 
  | 
  | 
    the_event->err_msg = strdup(errorMessage); | 
| 180 | 
tim | 
665 | 
  } | 
| 181 | 
  | 
  | 
 | 
| 182 | 
  | 
  | 
  if (keyword == "nComponents" && getNComponents() > 0) { | 
| 183 | 
  | 
  | 
    components = new Component*[getNComponents()]; | 
| 184 | 
  | 
  | 
  }else if (keyword == "nZconstraints" && getNZconstraints() > 0) { | 
| 185 | 
  | 
  | 
    zConstraints = new ZconStamp*[getNZconstraints()]; | 
| 186 | 
  | 
  | 
  } | 
| 187 | 
gezelter | 
2 | 
   | 
| 188 | 
tim | 
665 | 
  return result; | 
| 189 | 
gezelter | 
2 | 
} | 
| 190 | 
  | 
  | 
 | 
| 191 | 
  | 
  | 
int Globals::newComponent( event* the_event ){ | 
| 192 | 
  | 
  | 
   | 
| 193 | 
  | 
  | 
  current_component = new Component; | 
| 194 | 
  | 
  | 
  int index = the_event->evt.blk_index; | 
| 195 | 
  | 
  | 
  char err[200]; | 
| 196 | 
  | 
  | 
   | 
| 197 | 
tim | 
665 | 
  if( haveNComponents() && index < getNComponents() )  | 
| 198 | 
gezelter | 
2 | 
    components[index] = current_component; | 
| 199 | 
  | 
  | 
  else{ | 
| 200 | 
tim | 
665 | 
    if( haveNComponents()  ){ | 
| 201 | 
gezelter | 
2 | 
      sprintf( err, "meta-data parsing error: %d out of nComponents range",  | 
| 202 | 
  | 
  | 
               index ); | 
| 203 | 
  | 
  | 
      the_event->err_msg = strdup( err ); | 
| 204 | 
  | 
  | 
      return 0; | 
| 205 | 
  | 
  | 
    } | 
| 206 | 
  | 
  | 
    else{ | 
| 207 | 
  | 
  | 
      the_event->err_msg = strdup("meta-data parsing error: nComponents not given before" | 
| 208 | 
  | 
  | 
                                  " first component declaration." ); | 
| 209 | 
  | 
  | 
      return 0; | 
| 210 | 
  | 
  | 
    } | 
| 211 | 
  | 
  | 
  }   | 
| 212 | 
  | 
  | 
  | 
| 213 | 
  | 
  | 
  return 1; | 
| 214 | 
  | 
  | 
} | 
| 215 | 
  | 
  | 
 | 
| 216 | 
  | 
  | 
 | 
| 217 | 
  | 
  | 
 | 
| 218 | 
  | 
  | 
int Globals::componentAssign( event* the_event ){ | 
| 219 | 
  | 
  | 
 | 
| 220 | 
  | 
  | 
  switch( the_event->evt.asmt.asmt_type ){ | 
| 221 | 
  | 
  | 
     | 
| 222 | 
  | 
  | 
  case STRING: | 
| 223 | 
  | 
  | 
    return current_component->assignString( the_event->evt.asmt.lhs, | 
| 224 | 
  | 
  | 
                                            the_event->evt.asmt.rhs.sval, | 
| 225 | 
  | 
  | 
                                            &(the_event->err_msg)); | 
| 226 | 
  | 
  | 
    break; | 
| 227 | 
  | 
  | 
     | 
| 228 | 
  | 
  | 
  case DOUBLE: | 
| 229 | 
  | 
  | 
    return current_component->assignDouble( the_event->evt.asmt.lhs, | 
| 230 | 
  | 
  | 
                                            the_event->evt.asmt.rhs.dval, | 
| 231 | 
  | 
  | 
                                            &(the_event->err_msg)); | 
| 232 | 
  | 
  | 
    break; | 
| 233 | 
  | 
  | 
     | 
| 234 | 
  | 
  | 
  case INT: | 
| 235 | 
  | 
  | 
    return current_component->assignInt( the_event->evt.asmt.lhs, | 
| 236 | 
  | 
  | 
                                         the_event->evt.asmt.rhs.ival, | 
| 237 | 
  | 
  | 
                                         &(the_event->err_msg)); | 
| 238 | 
  | 
  | 
    break; | 
| 239 | 
  | 
  | 
     | 
| 240 | 
  | 
  | 
  default: | 
| 241 | 
  | 
  | 
    the_event->err_msg = strdup( "Globals error. Invalid component" | 
| 242 | 
  | 
  | 
                                 " assignment type" ); | 
| 243 | 
  | 
  | 
    return 0; | 
| 244 | 
  | 
  | 
    break; | 
| 245 | 
  | 
  | 
  } | 
| 246 | 
  | 
  | 
  return 0; | 
| 247 | 
  | 
  | 
} | 
| 248 | 
  | 
  | 
 | 
| 249 | 
  | 
  | 
int Globals::componentEnd( event* the_event ){ | 
| 250 | 
  | 
  | 
 | 
| 251 | 
  | 
  | 
  the_event->err_msg = current_component->checkMe(); | 
| 252 | 
  | 
  | 
  if( the_event->err_msg != NULL ) return 0; | 
| 253 | 
  | 
  | 
 | 
| 254 | 
  | 
  | 
  return 1; | 
| 255 | 
  | 
  | 
} | 
| 256 | 
  | 
  | 
 | 
| 257 | 
  | 
  | 
int Globals::newZconstraint( event* the_event ){ | 
| 258 | 
  | 
  | 
   | 
| 259 | 
  | 
  | 
 | 
| 260 | 
  | 
  | 
  int index = the_event->evt.blk_index; | 
| 261 | 
  | 
  | 
  char err[200]; | 
| 262 | 
  | 
  | 
  current_zConstraint = new ZconStamp( index ); | 
| 263 | 
  | 
  | 
   | 
| 264 | 
tim | 
665 | 
  if( haveNZconstraints() && index < getNZconstraints() )  | 
| 265 | 
gezelter | 
2 | 
    zConstraints[index] = current_zConstraint; | 
| 266 | 
  | 
  | 
  else{ | 
| 267 | 
tim | 
665 | 
    if( haveNZconstraints() ){ | 
| 268 | 
gezelter | 
2 | 
      sprintf( err, "meta-data parsing error: %d out of nZconstraints range",  | 
| 269 | 
  | 
  | 
               index ); | 
| 270 | 
  | 
  | 
      the_event->err_msg = strdup( err ); | 
| 271 | 
  | 
  | 
      return 0; | 
| 272 | 
  | 
  | 
    } | 
| 273 | 
  | 
  | 
    else{ | 
| 274 | 
  | 
  | 
      the_event->err_msg = strdup("meta-data parsing error: nZconstraints" | 
| 275 | 
  | 
  | 
                                  " not given before" | 
| 276 | 
  | 
  | 
                                  " first zConstraint declaration." ); | 
| 277 | 
  | 
  | 
      return 0; | 
| 278 | 
  | 
  | 
    } | 
| 279 | 
  | 
  | 
  }   | 
| 280 | 
tim | 
665 | 
 | 
| 281 | 
gezelter | 
2 | 
  return 1; | 
| 282 | 
  | 
  | 
} | 
| 283 | 
  | 
  | 
 | 
| 284 | 
  | 
  | 
 | 
| 285 | 
  | 
  | 
 | 
| 286 | 
  | 
  | 
int Globals::zConstraintAssign( event* the_event ){ | 
| 287 | 
  | 
  | 
 | 
| 288 | 
  | 
  | 
  switch( the_event->evt.asmt.asmt_type ){ | 
| 289 | 
  | 
  | 
     | 
| 290 | 
  | 
  | 
  case STRING: | 
| 291 | 
  | 
  | 
    return current_zConstraint->assignString( the_event->evt.asmt.lhs, | 
| 292 | 
  | 
  | 
                                              the_event->evt.asmt.rhs.sval, | 
| 293 | 
  | 
  | 
                                              &(the_event->err_msg)); | 
| 294 | 
  | 
  | 
    break; | 
| 295 | 
  | 
  | 
     | 
| 296 | 
  | 
  | 
  case DOUBLE: | 
| 297 | 
  | 
  | 
    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs, | 
| 298 | 
  | 
  | 
                                              the_event->evt.asmt.rhs.dval, | 
| 299 | 
  | 
  | 
                                              &(the_event->err_msg)); | 
| 300 | 
  | 
  | 
    break; | 
| 301 | 
  | 
  | 
     | 
| 302 | 
  | 
  | 
  case INT: | 
| 303 | 
  | 
  | 
    return current_zConstraint->assignInt( the_event->evt.asmt.lhs, | 
| 304 | 
  | 
  | 
                                           the_event->evt.asmt.rhs.ival, | 
| 305 | 
  | 
  | 
                                           &(the_event->err_msg)); | 
| 306 | 
  | 
  | 
    break; | 
| 307 | 
  | 
  | 
     | 
| 308 | 
  | 
  | 
  default: | 
| 309 | 
  | 
  | 
    the_event->err_msg = strdup( "Globals error. Invalid zConstraint" | 
| 310 | 
  | 
  | 
                                 " assignment type" ); | 
| 311 | 
  | 
  | 
    return 0; | 
| 312 | 
  | 
  | 
    break; | 
| 313 | 
  | 
  | 
  } | 
| 314 | 
  | 
  | 
  return 0; | 
| 315 | 
  | 
  | 
} | 
| 316 | 
  | 
  | 
 | 
| 317 | 
  | 
  | 
int Globals::zConstraintEnd( event* the_event ){ | 
| 318 | 
  | 
  | 
 | 
| 319 | 
  | 
  | 
  the_event->err_msg = current_zConstraint->checkMe(); | 
| 320 | 
  | 
  | 
  if( the_event->err_msg != NULL ) return 0; | 
| 321 | 
  | 
  | 
 | 
| 322 | 
  | 
  | 
  return 1; | 
| 323 | 
  | 
  | 
} | 
| 324 | 
  | 
  | 
 | 
| 325 | 
tim | 
665 | 
char* Globals::checkMe( void ){ | 
| 326 | 
tim | 
425 | 
 | 
| 327 | 
gezelter | 
2 | 
 | 
| 328 | 
tim | 
665 | 
  std::string err("The following required keywords are missing:\n"); | 
| 329 | 
  | 
  | 
  short int have_err = 0; | 
| 330 | 
gezelter | 
2 | 
 | 
| 331 | 
tim | 
665 | 
  ParamMap::iterator i; | 
| 332 | 
  | 
  | 
  for (i = parameters_.begin(); i != parameters_.end(); ++i) { | 
| 333 | 
  | 
  | 
    if (!i->second->isOptional() && i->second->empty()) { | 
| 334 | 
  | 
  | 
        err +=  i->second->getKeyword() + "\n"; | 
| 335 | 
gezelter | 
2 | 
    } | 
| 336 | 
  | 
  | 
  } | 
| 337 | 
  | 
  | 
 | 
| 338 | 
tim | 
672 | 
  CheckParameter(ForceField, isNotEmpty()); | 
| 339 | 
  | 
  | 
  CheckParameter(NComponents,isPositive());  | 
| 340 | 
  | 
  | 
  CheckParameter(TargetTemp, isPositive()); | 
| 341 | 
  | 
  | 
  CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) || isEqualIgnoreCase(std::string("NVT")) || | 
| 342 | 
  | 
  | 
                                          isEqualIgnoreCase(std::string("NPTi")) || isEqualIgnoreCase(std::string("NPTf"))||  | 
| 343 | 
  | 
  | 
                                          isEqualIgnoreCase(std::string("NPTxyz")) ); | 
| 344 | 
  | 
  | 
 | 
| 345 | 
  | 
  | 
  CheckParameter(Dt, isPositive()); | 
| 346 | 
  | 
  | 
  CheckParameter(RunTime, isPositive()); | 
| 347 | 
  | 
  | 
  CheckParameter(InitialConfig, isNotEmpty()); | 
| 348 | 
  | 
  | 
  CheckParameter(FinalConfig, isNotEmpty()); | 
| 349 | 
  | 
  | 
  CheckParameter(NMol, isPositive()); | 
| 350 | 
  | 
  | 
  CheckParameter(Density, isPositive()); | 
| 351 | 
  | 
  | 
  CheckParameter(Box, isPositive()); | 
| 352 | 
  | 
  | 
  CheckParameter(BoxX, isPositive()); | 
| 353 | 
  | 
  | 
  CheckParameter(BoxY, isPositive()); | 
| 354 | 
  | 
  | 
  CheckParameter(BoxZ, isPositive()); | 
| 355 | 
  | 
  | 
  CheckParameter(SampleTime, isNonNegative()); | 
| 356 | 
  | 
  | 
  CheckParameter(ResetTime, isNonNegative()); | 
| 357 | 
  | 
  | 
  CheckParameter(StatusTime, isNonNegative()); | 
| 358 | 
  | 
  | 
  CheckParameter(CutoffRadius, isPositive()); | 
| 359 | 
  | 
  | 
  CheckParameter(SwitchingRadius, isNonNegative()); | 
| 360 | 
  | 
  | 
  CheckParameter(Dielectric, isPositive()); | 
| 361 | 
  | 
  | 
  CheckParameter(ThermalTime,  isNonNegative()); | 
| 362 | 
  | 
  | 
  CheckParameter(TargetPressure,  isPositive()); | 
| 363 | 
  | 
  | 
  CheckParameter(TauThermostat, isPositive()); | 
| 364 | 
  | 
  | 
  CheckParameter(TauBarostat, isPositive()); | 
| 365 | 
  | 
  | 
  CheckParameter(ZconsTime, isPositive()); | 
| 366 | 
  | 
  | 
  CheckParameter(NZconstraints, isPositive());   | 
| 367 | 
  | 
  | 
  CheckParameter(ZconsTol, isPositive()); | 
| 368 | 
  | 
  | 
  //CheckParameter(ZconsForcePolicy,); | 
| 369 | 
  | 
  | 
  CheckParameter(Seed, isPositive()); | 
| 370 | 
  | 
  | 
  CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) || isEqualIgnoreCase(std::string("CG"))); | 
| 371 | 
  | 
  | 
  CheckParameter(MinimizerMaxIter, isPositive()); | 
| 372 | 
  | 
  | 
  CheckParameter(MinimizerWriteFrq, isPositive()); | 
| 373 | 
  | 
  | 
  CheckParameter(MinimizerStepSize, isPositive()); | 
| 374 | 
  | 
  | 
  CheckParameter(MinimizerFTol, isPositive()); | 
| 375 | 
  | 
  | 
  CheckParameter(MinimizerGTol, isPositive()); | 
| 376 | 
  | 
  | 
  CheckParameter(MinimizerLSTol, isPositive()); | 
| 377 | 
  | 
  | 
  CheckParameter(MinimizerLSMaxIter, isPositive()); | 
| 378 | 
  | 
  | 
  CheckParameter(ZconsGap, isPositive()); | 
| 379 | 
  | 
  | 
  CheckParameter(ZconsFixtime, isPositive()); | 
| 380 | 
  | 
  | 
  CheckParameter(ThermodynamicIntegrationLambda, isPositive()); | 
| 381 | 
  | 
  | 
  CheckParameter(ThermodynamicIntegrationK, isPositive()); | 
| 382 | 
  | 
  | 
  CheckParameter(ForceFieldVariant, isNotEmpty()); | 
| 383 | 
  | 
  | 
  CheckParameter(ForceFieldFileName, isNotEmpty()); | 
| 384 | 
  | 
  | 
  CheckParameter(ThermIntDistSpringConst, isPositive()); | 
| 385 | 
  | 
  | 
  CheckParameter(ThermIntThetaSpringConst, isPositive()); | 
| 386 | 
  | 
  | 
  CheckParameter(ThermIntOmegaSpringConst, isPositive()); | 
| 387 | 
  | 
  | 
  CheckParameter(SurfaceTension, isPositive()); | 
| 388 | 
  | 
  | 
  CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase(std::string("NONE")) || isEqualIgnoreCase(std::string("UNDAMPED_WOLF")) || isEqualIgnoreCase(std::string("DAMPED_WOLF")) || isEqualIgnoreCase(std::string("REACTION_FIELD")) ); | 
| 389 | 
  | 
  | 
  CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) || isEqualIgnoreCase(std::string("MAX")) || isEqualIgnoreCase(std::string("TRADITIONAL"))); | 
| 390 | 
  | 
  | 
  //CheckParameter(StatFileFormat,);      | 
| 391 | 
  | 
  | 
  //CheckParameter(MixingRule,); | 
| 392 | 
  | 
  | 
  CheckParameter(OrthoBoxTolerance, isPositive());   | 
| 393 | 
  | 
  | 
  CheckParameter(ThermIntDistSpringConst, isPositive()); | 
| 394 | 
  | 
  | 
  CheckParameter(ThermIntThetaSpringConst, isPositive()); | 
| 395 | 
  | 
  | 
  CheckParameter(ThermIntOmegaSpringConst, isPositive()); | 
| 396 | 
  | 
  | 
  CheckParameter(DampingAlpha,isPositive()); | 
| 397 | 
  | 
  | 
  CheckParameter(SkinThickness, isPositive()); | 
| 398 | 
  | 
  | 
   | 
| 399 | 
tim | 
665 | 
  //@todo memory leak | 
| 400 | 
  | 
  | 
  if( have_err ) | 
| 401 | 
  | 
  | 
    return strdup( err.c_str() ); | 
| 402 | 
gezelter | 
2 | 
   | 
| 403 | 
tim | 
665 | 
  return NULL; | 
| 404 | 
gezelter | 
2 | 
 | 
| 405 | 
  | 
  | 
 | 
| 406 | 
  | 
  | 
} | 
| 407 | 
  | 
  | 
 | 
| 408 | 
  | 
  | 
int Globals::globalEnd( event* the_event ){ | 
| 409 | 
  | 
  | 
   | 
| 410 | 
  | 
  | 
  the_event->err_msg = checkMe(); | 
| 411 | 
  | 
  | 
  if( the_event->err_msg != NULL ) return 0; | 
| 412 | 
  | 
  | 
 | 
| 413 | 
  | 
  | 
  return 1; | 
| 414 | 
  | 
  | 
} |