| 50 |
|
#include "io/mpiBASS.h" |
| 51 |
|
#endif // is_mpi |
| 52 |
|
|
| 53 |
+ |
#include "io/ParamConstraint.hpp" |
| 54 |
|
|
| 55 |
< |
#define DefineParameter(NAME,KEYWORD) \ |
| 55 |
< |
NAME.setKeyword(KEYWORD); \ |
| 56 |
< |
parameters_.insert(std::make_pair(std::string(KEYWORD), &NAME)); |
| 55 |
> |
using namespace oopse; |
| 56 |
|
|
| 58 |
– |
#define DefineOptionalParameter(NAME,KEYWORD) \ |
| 59 |
– |
NAME.setKeyword(KEYWORD); NAME.setOptional(true); \ |
| 60 |
– |
parameters_.insert(std::make_pair(std::string(KEYWORD), &NAME)); |
| 61 |
– |
|
| 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 |
– |
|
| 57 |
|
Globals::Globals(){ |
| 58 |
|
|
| 59 |
|
DefineParameter(ForceField, "forceField") |
| 108 |
|
DefineOptionalParameter(SurfaceTension, "surfaceTension"); |
| 109 |
|
DefineOptionalParameter(PrintPressureTensor, "printPressureTensor"); |
| 110 |
|
DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod"); |
| 111 |
+ |
DefineOptionalParameter(ElectrostaticScreeningMethod, "electrostaticScreeningMethod"); |
| 112 |
|
DefineOptionalParameter(CutoffPolicy, "cutoffPolicy"); |
| 113 |
< |
DefineOptionalParameter(StatFileFormat, "statFileFormat"); |
| 122 |
< |
|
| 113 |
> |
DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType"); |
| 114 |
|
DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard"); |
| 115 |
|
DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true); |
| 116 |
|
DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false); |
| 118 |
|
DefineOptionalParameterWithDefaultValue(OrthoBoxTolerance, "orthoBoxTolerance", 1E-6); |
| 119 |
|
DefineOptionalParameterWithDefaultValue(UseSolidThermInt, "useSolidThermInt", false); |
| 120 |
|
DefineOptionalParameterWithDefaultValue(UseLiquidThermInt, "useLiquidThermInt", false); |
| 121 |
< |
DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 1.5); |
| 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"); |
| 129 |
+ |
|
| 130 |
|
|
| 131 |
|
} |
| 132 |
|
|
| 133 |
< |
int Globals::globalAssign( event* the_event ){ |
| 133 |
> |
Globals::~Globals(){ |
| 134 |
> |
int i; |
| 135 |
> |
if( components != NULL ){ |
| 136 |
> |
for( i=0; i< getNComponents(); i++ ) delete components[i]; |
| 137 |
> |
delete[] components; |
| 138 |
> |
} |
| 139 |
> |
|
| 140 |
> |
if( zConstraints != NULL ){ |
| 141 |
> |
for( i=0; i< getNZconstraints(); i++ ) delete zConstraints[i]; |
| 142 |
> |
delete[] zConstraints; |
| 143 |
> |
} |
| 144 |
|
|
| 145 |
+ |
} |
| 146 |
+ |
|
| 147 |
+ |
int Globals::globalAssign( event* the_event ){ |
| 148 |
+ |
char errorMessage[65535]; |
| 149 |
|
int key; |
| 139 |
– |
int token; |
| 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; |
| 154 |
> |
bool result = false; |
| 155 |
|
|
| 156 |
< |
|
| 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(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a string.\n", keyword.c_str() ); |
| 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(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a double.\n", keyword.c_str() ); |
| 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(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be an int.\n", keyword.c_str() ); |
| 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 |
< |
|
| 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); |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
if (keyword == "nComponents" && getNComponents() > 0) { |
| 339 |
|
} |
| 340 |
|
} |
| 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() ); |