# | Line 52 | Line 52 | |
---|---|---|
52 | #include "brains/SimInfo.hpp" | |
53 | #include "math/Vector3.hpp" | |
54 | #include "primitives/Molecule.hpp" | |
55 | + | #include "UseTheForce/fCutoffPolicy.h" |
56 | + | #include "UseTheForce/fCoulombicCorrection.h" |
57 | #include "UseTheForce/doForces_interface.h" | |
58 | #include "UseTheForce/notifyCutoffs_interface.h" | |
59 | #include "utils/MemoryUtils.hpp" | |
# | Line 462 | Line 464 | namespace oopse { | |
464 | //setup fortran force field | |
465 | /** @deprecate */ | |
466 | int isError = 0; | |
467 | < | initFortranFF( &fInfo_.SIM_uses_RF , &isError ); |
467 | > | |
468 | > | setupCoulombicCorrection( isError ); |
469 | > | |
470 | if(isError){ | |
471 | sprintf( painCave.errMsg, | |
472 | "ForceField error: There was an error initializing the forceField in fortran.\n" ); | |
# | Line 583 | Line 587 | namespace oopse { | |
587 | ||
588 | temp = useRF; | |
589 | MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | |
590 | + | |
591 | + | temp = useUW; |
592 | + | MPI_Allreduce(&temp, &useUW, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
593 | + | |
594 | + | temp = useDW; |
595 | + | MPI_Allreduce(&temp, &useDW, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
596 | ||
597 | #endif | |
598 | ||
# | Line 830 | Line 840 | namespace oopse { | |
840 | } | |
841 | } | |
842 | ||
843 | < | void SimInfo::setupCutoff() { |
843 | > | void SimInfo::setupCutoff() { |
844 | getCutoff(rcut_, rsw_); | |
845 | double rnblist = rcut_ + 1; // skin of neighbor list | |
846 | ||
847 | //Pass these cutoff radius etc. to fortran. This function should be called once and only once | |
848 | < | notifyFortranCutoffs(&rcut_, &rsw_, &rnblist); |
848 | > | |
849 | > | int cp = TRADITIONAL_CUTOFF_POLICY; |
850 | > | if (simParams_->haveCutoffPolicy()) { |
851 | > | std::string myPolicy = simParams_->getCutoffPolicy(); |
852 | > | if (myPolicy == "MIX") { |
853 | > | cp = MIX_CUTOFF_POLICY; |
854 | > | } else { |
855 | > | if (myPolicy == "MAX") { |
856 | > | cp = MAX_CUTOFF_POLICY; |
857 | > | } else { |
858 | > | if (myPolicy == "TRADITIONAL") { |
859 | > | cp = TRADITIONAL_CUTOFF_POLICY; |
860 | > | } else { |
861 | > | // throw error |
862 | > | sprintf( painCave.errMsg, |
863 | > | "SimInfo error: Unknown cutoffPolicy. (Input file specified %s .)\n\tcutoffPolicy must be one of: \"Mix\", \"Max\", or \"Traditional\".", myPolicy.c_str() ); |
864 | > | painCave.isFatal = 1; |
865 | > | simError(); |
866 | > | } |
867 | > | } |
868 | > | } |
869 | > | } |
870 | > | notifyFortranCutoffs(&rcut_, &rsw_, &rnblist, &cp); |
871 | } | |
872 | ||
873 | + | void SimInfo::setupCoulombicCorrection( int isError ) { |
874 | + | |
875 | + | int errorOut; |
876 | + | int cc = NONE; |
877 | + | double alphaVal; |
878 | + | |
879 | + | errorOut = isError; |
880 | + | |
881 | + | if (simParams_->haveCoulombicCorrection()) { |
882 | + | std::string myCorrection = simParams_->getCoulombicCorrection(); |
883 | + | if (myCorrection == "NONE") { |
884 | + | cc = NONE; |
885 | + | } else { |
886 | + | if (myCorrection == "UNDAMPED_WOLF") { |
887 | + | cc = UNDAMPED_WOLF; |
888 | + | } else { |
889 | + | if (myCorrection == "WOLF") { |
890 | + | cc = WOLF; |
891 | + | if (!simParams_->haveDampingAlpha()) { |
892 | + | //throw error |
893 | + | sprintf( painCave.errMsg, |
894 | + | "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()); |
895 | + | painCave.isFatal = 0; |
896 | + | simError(); |
897 | + | } |
898 | + | alphaVal = simParams_->getDampingAlpha(); |
899 | + | } else { |
900 | + | if (myCorrection == "REACTION_FIELD") { |
901 | + | cc = REACTION_FIELD; |
902 | + | } else { |
903 | + | // throw error |
904 | + | sprintf( painCave.errMsg, |
905 | + | "SimInfo error: Unknown coulombicCorrection. (Input file specified %s .)\n\tcoulombicCorrection must be one of: \"none\", \"undamped_wolf\", \"wolf\", or \"reaction_field\".", myCorrection.c_str() ); |
906 | + | painCave.isFatal = 1; |
907 | + | simError(); |
908 | + | } |
909 | + | } |
910 | + | } |
911 | + | } |
912 | + | } |
913 | + | initFortranFF( &fInfo_.SIM_uses_RF, &cc, &alphaVal, &errorOut ); |
914 | + | } |
915 | + | |
916 | void SimInfo::addProperty(GenericData* genData) { | |
917 | properties_.addProperty(genData); | |
918 | } | |
# | Line 981 | Line 1056 | namespace oopse { | |
1056 | ||
1057 | /* | |
1058 | Return intertia tensor for entire system and angular momentum Vector. | |
1059 | + | |
1060 | + | |
1061 | + | [ Ixx -Ixy -Ixz ] |
1062 | + | J =| -Iyx Iyy -Iyz | |
1063 | + | [ -Izx -Iyz Izz ] |
1064 | */ | |
1065 | ||
1066 | void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){ | |
# | Line 1032 | Line 1112 | namespace oopse { | |
1112 | inertiaTensor(0,1) = -xy; | |
1113 | inertiaTensor(0,2) = -xz; | |
1114 | inertiaTensor(1,0) = -xy; | |
1115 | < | inertiaTensor(2,0) = xx + zz; |
1115 | > | inertiaTensor(1,1) = xx + zz; |
1116 | inertiaTensor(1,2) = -yz; | |
1117 | inertiaTensor(2,0) = -xz; | |
1118 | inertiaTensor(2,1) = -yz; | |
# | Line 1060 | Line 1140 | namespace oopse { | |
1140 | SimInfo::MoleculeIterator i; | |
1141 | Molecule* mol; | |
1142 | ||
1143 | < | Vector3d thisq(0.0); |
1144 | < | Vector3d thisv(0.0); |
1143 | > | Vector3d thisr(0.0); |
1144 | > | Vector3d thisp(0.0); |
1145 | ||
1146 | < | double thisMass = 0.0; |
1146 | > | double thisMass; |
1147 | ||
1148 | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | |
1149 | < | thisq = mol->getCom()-com; |
1150 | < | thisv = mol->getComVel()-comVel; |
1151 | < | thisMass = mol->getMass(); |
1072 | < | angularMomentum += cross( thisq, thisv ) * thisMass; |
1149 | > | thisMass = mol->getMass(); |
1150 | > | thisr = mol->getCom()-com; |
1151 | > | thisp = (mol->getComVel()-comVel)*thisMass; |
1152 | ||
1153 | + | angularMomentum += cross( thisr, thisp ); |
1154 | + | |
1155 | } | |
1156 | ||
1157 | #ifdef IS_MPI |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |