--- trunk/src/brains/SimInfo.cpp 2005/10/18 15:01:42 682 +++ trunk/src/brains/SimInfo.cpp 2005/11/11 15:22:11 726 @@ -54,9 +54,12 @@ #include "primitives/Molecule.hpp" #include "UseTheForce/fCutoffPolicy.h" #include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" +#include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h" +#include "UseTheForce/DarkSide/fSwitchingFunctionType.h" #include "UseTheForce/doForces_interface.h" #include "UseTheForce/DarkSide/electrostatic_interface.h" #include "UseTheForce/notifyCutoffs_interface.h" +#include "UseTheForce/DarkSide/switcheroo_interface.h" #include "utils/MemoryUtils.hpp" #include "utils/simError.h" #include "selection/SelectionManager.hpp" @@ -471,6 +474,7 @@ namespace oopse { int isError = 0; setupElectrostaticSummationMethod( isError ); + setupSwitchingFunction(); if(isError){ sprintf( painCave.errMsg, @@ -528,14 +532,24 @@ namespace oopse { //usePBC and useRF are from simParams int usePBC = simParams_->getUsePeriodicBoundaryConditions(); int useRF; + int useSF; std::string myMethod; // set the useRF logical useRF = 0; + useSF = 0; + + if (simParams_->haveElectrostaticSummationMethod()) { - myMethod = simParams_->getElectrostaticSummationMethod(); - if (myMethod == "REACTION_FIELD") - useRF = 1; + std::string myMethod = simParams_->getElectrostaticSummationMethod(); + toUpper(myMethod); + if (myMethod == "REACTION_FIELD") { + useRF=1; + } else { + if (myMethod == "SHIFTED_FORCE") { + useSF = 1; + } + } } //loop over all of the atom types @@ -602,6 +616,9 @@ namespace oopse { temp = useRF; MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); + temp = useSF; + MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); + #endif fInfo_.SIM_uses_PBC = usePBC; @@ -617,9 +634,10 @@ namespace oopse { fInfo_.SIM_uses_Shapes = useShape; fInfo_.SIM_uses_FLARB = useFLARB; fInfo_.SIM_uses_RF = useRF; - - if( fInfo_.SIM_uses_Dipoles && myMethod == "REACTION_FIELD") { + fInfo_.SIM_uses_SF = useSF; + if( myMethod == "REACTION_FIELD") { + if (simParams_->haveDielectric()) { fInfo_.dielect = simParams_->getDielectric(); } else { @@ -629,10 +647,7 @@ namespace oopse { "\tsetting a dielectric constant!\n"); painCave.isFatal = 1; simError(); - } - - } else { - fInfo_.dielect = 0.0; + } } } @@ -824,10 +839,10 @@ namespace oopse { sprintf(painCave.errMsg, "SimCreator Warning: No value was set for switchingRadius.\n" "\tOOPSE will use a default value of\n" - "\t0.95 * cutoffRadius for the switchingRadius\n"); + "\t0.85 * cutoffRadius for the switchingRadius\n"); painCave.isFatal = 0; simError(); - rsw = 0.95 * rcut; + rsw = 0.85 * rcut; } else{ rsw = simParams_->getSwitchingRadius(); } @@ -895,6 +910,7 @@ namespace oopse { int errorOut; int esm = NONE; + int sm = UNDAMPED; double alphaVal; double dielectric; @@ -908,37 +924,87 @@ namespace oopse { if (myMethod == "NONE") { esm = NONE; } else { - if (myMethod == "UNDAMPED_WOLF") { - esm = UNDAMPED_WOLF; + if (myMethod == "SWITCHING_FUNCTION") { + esm = SWITCHING_FUNCTION; } else { - if (myMethod == "DAMPED_WOLF") { - esm = DAMPED_WOLF; - if (!simParams_->haveDampingAlpha()) { - //throw error - sprintf( painCave.errMsg, - "SimInfo warning: dampingAlpha was not specified in the input file. A default value of %f (1/ang) will be used for the Damped Wolf Method.", alphaVal); - painCave.isFatal = 0; - simError(); - } - } else { - if (myMethod == "REACTION_FIELD") { - esm = REACTION_FIELD; + if (myMethod == "SHIFTED_POTENTIAL") { + esm = SHIFTED_POTENTIAL; + } else { + if (myMethod == "SHIFTED_FORCE") { + esm = SHIFTED_FORCE; } else { - // throw error - sprintf( painCave.errMsg, - "SimInfo error: Unknown electrostaticSummationMethod. (Input file specified %s .)\n\telectrostaticSummationMethod must be one of: \"none\", \"undamped_wolf\", \"damped_wolf\", or \"reaction_field\".", myMethod.c_str() ); - painCave.isFatal = 1; - simError(); - } - } + if (myMethod == "REACTION_FIELD") { + esm = REACTION_FIELD; + } else { + // throw error + sprintf( painCave.errMsg, + "SimInfo error: Unknown electrostaticSummationMethod. (Input file specified %s .)\n\telectrostaticSummationMethod must be one of: \"none\", \"shifted_potential\", \"shifted_force\", or \"reaction_field\".", myMethod.c_str() ); + painCave.isFatal = 1; + simError(); + } + } + } } } } + + if (simParams_->haveElectrostaticScreeningMethod()) { + std::string myScreen = simParams_->getElectrostaticScreeningMethod(); + toUpper(myScreen); + if (myScreen == "UNDAMPED") { + sm = UNDAMPED; + } else { + if (myScreen == "DAMPED") { + sm = DAMPED; + if (!simParams_->haveDampingAlpha()) { + //throw error + sprintf( painCave.errMsg, + "SimInfo warning: dampingAlpha was not specified in the input file. A default value of %f (1/ang) will be used.", alphaVal); + painCave.isFatal = 0; + simError(); + } + } else { + // throw error + sprintf( painCave.errMsg, + "SimInfo error: Unknown electrostaticScreeningMethod. (Input file specified %s .)\n\telectrostaticScreeningMethod must be one of: \"undamped\" or \"damped\".", myScreen.c_str() ); + painCave.isFatal = 1; + simError(); + } + } + } + // let's pass some summation method variables to fortran setElectrostaticSummationMethod( &esm ); - setDampedWolfAlpha( &alphaVal ); + setScreeningMethod( &sm ); + setDampingAlpha( &alphaVal ); setReactionFieldDielectric( &dielectric ); initFortranFF( &esm, &errorOut ); + } + + void SimInfo::setupSwitchingFunction() { + int ft = CUBIC; + + if (simParams_->haveSwitchingFunctionType()) { + std::string funcType = simParams_->getSwitchingFunctionType(); + toUpper(funcType); + if (funcType == "CUBIC") { + ft = CUBIC; + } else { + if (funcType == "FIFTH_ORDER_POLYNOMIAL") { + ft = FIFTH_ORDER_POLY; + } else { + // throw error + sprintf( painCave.errMsg, + "SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() ); + painCave.isFatal = 1; + simError(); + } + } + } + + // send switching function notification to switcheroo + setFunctionType(&ft); + } void SimInfo::addProperty(GenericData* genData) {