--- trunk/src/brains/SimInfo.cpp 2005/05/30 14:01:52 555 +++ trunk/src/brains/SimInfo.cpp 2005/09/15 00:14:35 598 @@ -52,6 +52,8 @@ #include "brains/SimInfo.hpp" #include "math/Vector3.hpp" #include "primitives/Molecule.hpp" +#include "UseTheForce/fCutoffPolicy.h" +#include "UseTheForce/fCoulombicCorrection.h" #include "UseTheForce/doForces_interface.h" #include "UseTheForce/notifyCutoffs_interface.h" #include "utils/MemoryUtils.hpp" @@ -462,7 +464,9 @@ namespace oopse { //setup fortran force field /** @deprecate */ int isError = 0; - initFortranFF( &fInfo_.SIM_uses_RF , &isError ); + + setupCoulombicCorrection( isError ); + if(isError){ sprintf( painCave.errMsg, "ForceField error: There was an error initializing the forceField in fortran.\n" ); @@ -583,6 +587,12 @@ namespace oopse { temp = useRF; MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); + + temp = useUW; + MPI_Allreduce(&temp, &useUW, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); + + temp = useDW; + MPI_Allreduce(&temp, &useDW, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); #endif @@ -830,14 +840,79 @@ namespace oopse { } } - void SimInfo::setupCutoff() { + void SimInfo::setupCutoff() { getCutoff(rcut_, rsw_); double rnblist = rcut_ + 1; // skin of neighbor list //Pass these cutoff radius etc. to fortran. This function should be called once and only once - notifyFortranCutoffs(&rcut_, &rsw_, &rnblist); + + int cp = TRADITIONAL_CUTOFF_POLICY; + if (simParams_->haveCutoffPolicy()) { + std::string myPolicy = simParams_->getCutoffPolicy(); + if (myPolicy == "MIX") { + cp = MIX_CUTOFF_POLICY; + } else { + if (myPolicy == "MAX") { + cp = MAX_CUTOFF_POLICY; + } else { + if (myPolicy == "TRADITIONAL") { + cp = TRADITIONAL_CUTOFF_POLICY; + } else { + // throw error + sprintf( painCave.errMsg, + "SimInfo error: Unknown cutoffPolicy. (Input file specified %s .)\n\tcutoffPolicy must be one of: \"Mix\", \"Max\", or \"Traditional\".", myPolicy.c_str() ); + painCave.isFatal = 1; + simError(); + } + } + } + } + notifyFortranCutoffs(&rcut_, &rsw_, &rnblist, &cp); } + void SimInfo::setupCoulombicCorrection( int isError ) { + + int errorOut; + int cc = NONE; + double alphaVal; + + errorOut = isError; + + if (simParams_->haveCoulombicCorrection()) { + std::string myCorrection = simParams_->getCoulombicCorrection(); + if (myCorrection == "NONE") { + cc = NONE; + } else { + if (myCorrection == "UNDAMPED_WOLF") { + cc = UNDAMPED_WOLF; + } else { + if (myCorrection == "WOLF") { + cc = 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 Wolf Coulombic Correction.", simParams_->getDampingAlpha()); + painCave.isFatal = 0; + simError(); + } + alphaVal = simParams_->getDampingAlpha(); + } else { + if (myCorrection == "REACTION_FIELD") { + cc = REACTION_FIELD; + } else { + // throw error + sprintf( painCave.errMsg, + "SimInfo error: Unknown coulombicCorrection. (Input file specified %s .)\n\tcoulombicCorrection must be one of: \"none\", \"undamped_wolf\", \"wolf\", or \"reaction_field\".", myCorrection.c_str() ); + painCave.isFatal = 1; + simError(); + } + } + } + } + } + initFortranFF( &fInfo_.SIM_uses_RF, &cc, &alphaVal, &errorOut ); + } + void SimInfo::addProperty(GenericData* genData) { properties_.addProperty(genData); } @@ -981,6 +1056,11 @@ namespace oopse { /* Return intertia tensor for entire system and angular momentum Vector. + + + [ Ixx -Ixy -Ixz ] + J =| -Iyx Iyy -Iyz | + [ -Izx -Iyz Izz ] */ void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){ @@ -1032,7 +1112,7 @@ namespace oopse { inertiaTensor(0,1) = -xy; inertiaTensor(0,2) = -xz; inertiaTensor(1,0) = -xy; - inertiaTensor(2,0) = xx + zz; + inertiaTensor(1,1) = xx + zz; inertiaTensor(1,2) = -yz; inertiaTensor(2,0) = -xz; inertiaTensor(2,1) = -yz; @@ -1060,17 +1140,18 @@ namespace oopse { SimInfo::MoleculeIterator i; Molecule* mol; - Vector3d thisq(0.0); - Vector3d thisv(0.0); + Vector3d thisr(0.0); + Vector3d thisp(0.0); - double thisMass = 0.0; + double thisMass; for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { - thisq = mol->getCom()-com; - thisv = mol->getComVel()-comVel; - thisMass = mol->getMass(); - angularMomentum += cross( thisq, thisv ) * thisMass; + thisMass = mol->getMass(); + thisr = mol->getCom()-com; + thisp = (mol->getComVel()-comVel)*thisMass; + angularMomentum += cross( thisr, thisp ); + } #ifdef IS_MPI