--- trunk/src/brains/SimInfo.cpp 2006/08/30 18:42:29 1024 +++ trunk/src/brains/SimInfo.cpp 2007/04/06 21:53:43 1126 @@ -59,6 +59,7 @@ #include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h" #include "UseTheForce/DarkSide/fSwitchingFunctionType.h" #include "UseTheForce/doForces_interface.h" +#include "UseTheForce/DarkSide/neighborLists_interface.h" #include "UseTheForce/DarkSide/electrostatic_interface.h" #include "UseTheForce/DarkSide/switcheroo_interface.h" #include "utils/MemoryUtils.hpp" @@ -67,6 +68,7 @@ #include "io/ForceFieldOptions.hpp" #include "UseTheForce/ForceField.hpp" + #ifdef IS_MPI #include "UseTheForce/mpiComponentPlan.h" #include "UseTheForce/DarkSide/simParallel_interface.h" @@ -90,7 +92,8 @@ namespace oopse { nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nRigidBodies_(0), nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), - sman_(NULL), fortranInitialized_(false), calcBoxDipole_(false) { + sman_(NULL), fortranInitialized_(false), calcBoxDipole_(false), + useAtomicVirial_(true) { MoleculeStamp* molStamp; int nMolWithSameStamp; @@ -600,6 +603,8 @@ namespace oopse { //setup fortran force field /** @deprecate */ int isError = 0; + + setupCutoff(); setupElectrostaticSummationMethod( isError ); setupSwitchingFunction(); @@ -611,9 +616,6 @@ namespace oopse { painCave.isFatal = 1; simError(); } - - - setupCutoff(); calcNdf(); calcNdfRaw(); @@ -665,18 +667,20 @@ namespace oopse { int useSF; int useSP; int useBoxDipole; + std::string myMethod; // set the useRF logical useRF = 0; useSF = 0; + useSP = 0; if (simParams_->haveElectrostaticSummationMethod()) { std::string myMethod = simParams_->getElectrostaticSummationMethod(); toUpper(myMethod); if (myMethod == "REACTION_FIELD"){ - useRF=1; + useRF = 1; } else if (myMethod == "SHIFTED_FORCE"){ useSF = 1; } else if (myMethod == "SHIFTED_POTENTIAL"){ @@ -688,6 +692,8 @@ namespace oopse { if (simParams_->getAccumulateBoxDipole()) useBoxDipole = 1; + useAtomicVirial_ = simParams_->getUseAtomicVirial(); + //loop over all of the atom types for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { useLennardJones |= (*i)->isLennardJones(); @@ -765,6 +771,9 @@ namespace oopse { temp = useBoxDipole; MPI_Allreduce(&temp, &useBoxDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); + temp = useAtomicVirial_; + MPI_Allreduce(&temp, &useAtomicVirial_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); + #endif fInfo_.SIM_uses_PBC = usePBC; @@ -784,21 +793,7 @@ namespace oopse { fInfo_.SIM_uses_SF = useSF; fInfo_.SIM_uses_SP = useSP; fInfo_.SIM_uses_BoxDipole = useBoxDipole; - - if( myMethod == "REACTION_FIELD") { - - if (simParams_->haveDielectric()) { - fInfo_.dielect = simParams_->getDielectric(); - } else { - sprintf(painCave.errMsg, - "SimSetup Error: No Dielectric constant was set.\n" - "\tYou are trying to use Reaction Field without" - "\tsetting a dielectric constant!\n"); - painCave.isFatal = 1; - simError(); - } - } - + fInfo_.SIM_uses_AtomicVirial = useAtomicVirial_; } void SimInfo::setupFortranSim() { @@ -883,6 +878,14 @@ namespace oopse { "succesfully sent the simulation information to fortran.\n"); MPIcheckPoint(); #endif // is_mpi + + // Setup number of neighbors in neighbor list if present + if (simParams_->haveNeighborListNeighbors()) { + int nlistNeighbors = simParams_->getNeighborListNeighbors(); + setNeighbors(&nlistNeighbors); + } + + } @@ -1074,10 +1077,8 @@ namespace oopse { int sm = UNDAMPED; RealType alphaVal; RealType dielectric; - + errorOut = isError; - alphaVal = simParams_->getDampingAlpha(); - dielectric = simParams_->getDielectric(); if (simParams_->haveElectrostaticSummationMethod()) { std::string myMethod = simParams_->getElectrostaticSummationMethod(); @@ -1094,8 +1095,17 @@ namespace oopse { if (myMethod == "SHIFTED_FORCE") { esm = SHIFTED_FORCE; } else { - if (myMethod == "REACTION_FIELD") { + if (myMethod == "REACTION_FIELD") { esm = REACTION_FIELD; + dielectric = simParams_->getDielectric(); + if (!simParams_->haveDielectric()) { + // throw warning + sprintf( painCave.errMsg, + "SimInfo warning: dielectric was not specified in the input file\n\tfor the reaction field correction method.\n" + "\tA default value of %f will be used for the dielectric.\n", dielectric); + painCave.isFatal = 0; + simError(); + } } else { // throw error sprintf( painCave.errMsg, @@ -1122,13 +1132,22 @@ namespace oopse { if (myScreen == "DAMPED") { sm = DAMPED; if (!simParams_->haveDampingAlpha()) { - //throw error + // first set a cutoff dependent alpha value + // we assume alpha depends linearly with rcut from 0 to 20.5 ang + alphaVal = 0.5125 - rcut_* 0.025; + // for values rcut > 20.5, alpha is zero + if (alphaVal < 0) alphaVal = 0; + + // throw warning sprintf( painCave.errMsg, "SimInfo warning: dampingAlpha was not specified in the input file.\n" - "\tA default value of %f (1/ang) will be used.\n", alphaVal); + "\tA default value of %f (1/ang) will be used for the cutoff of\n\t%f (ang).\n", alphaVal, rcut_); painCave.isFatal = 0; simError(); + } else { + alphaVal = simParams_->getDampingAlpha(); } + } else { // throw error sprintf( painCave.errMsg, @@ -1445,6 +1464,43 @@ namespace oopse { IOIndexToIntegrableObject= v; } + /* Returns the Volume of the simulation based on a ellipsoid with semi-axes + based on the radius of gyration V=4/3*Pi*R_1*R_2*R_3 + where R_i are related to the principle inertia moments R_i = sqrt(C*I_i/N), this reduces to + V = 4/3*Pi*(C/N)^3/2*sqrt(det(I)). See S.E. Baltazar et. al. Comp. Mat. Sci. 37 (2006) 526-536. + */ + void SimInfo::getGyrationalVolume(RealType &volume){ + Mat3x3d intTensor; + RealType det; + Vector3d dummyAngMom; + RealType sysconstants; + RealType geomCnst; + + geomCnst = 3.0/2.0; + /* Get the inertial tensor and angular momentum for free*/ + getInertiaTensor(intTensor,dummyAngMom); + + det = intTensor.determinant(); + sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_; + volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(det); + return; + } + + void SimInfo::getGyrationalVolume(RealType &volume, RealType &detI){ + Mat3x3d intTensor; + Vector3d dummyAngMom; + RealType sysconstants; + RealType geomCnst; + + geomCnst = 3.0/2.0; + /* Get the inertial tensor and angular momentum for free*/ + getInertiaTensor(intTensor,dummyAngMom); + + detI = intTensor.determinant(); + sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_; + volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(detI); + return; + } /* void SimInfo::setStuntDoubleFromGlobalIndex(std::vector v) { assert( v.size() == nAtoms_ + nRigidBodies_);