54 |
|
#include "primitives/Molecule.hpp" |
55 |
|
#include "UseTheForce/fCutoffPolicy.h" |
56 |
|
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
57 |
+ |
#include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h" |
58 |
+ |
#include "UseTheForce/DarkSide/fSwitchingFunctionType.h" |
59 |
|
#include "UseTheForce/doForces_interface.h" |
60 |
|
#include "UseTheForce/DarkSide/electrostatic_interface.h" |
61 |
|
#include "UseTheForce/notifyCutoffs_interface.h" |
62 |
+ |
#include "UseTheForce/DarkSide/switcheroo_interface.h" |
63 |
|
#include "utils/MemoryUtils.hpp" |
64 |
|
#include "utils/simError.h" |
65 |
|
#include "selection/SelectionManager.hpp" |
474 |
|
int isError = 0; |
475 |
|
|
476 |
|
setupElectrostaticSummationMethod( isError ); |
477 |
+ |
setupSwitchingFunction(); |
478 |
|
|
479 |
|
if(isError){ |
480 |
|
sprintf( painCave.errMsg, |
530 |
|
int useDirectionalAtom = 0; |
531 |
|
int useElectrostatics = 0; |
532 |
|
//usePBC and useRF are from simParams |
533 |
< |
int usePBC = simParams_->getPBC(); |
533 |
> |
int usePBC = simParams_->getUsePeriodicBoundaryConditions(); |
534 |
|
int useRF; |
535 |
+ |
int useSF; |
536 |
+ |
std::string myMethod; |
537 |
|
|
538 |
|
// set the useRF logical |
539 |
< |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
540 |
< |
if (myMethod == "REACTION_FIELD") |
535 |
< |
useRF = 1; |
536 |
< |
else |
537 |
< |
useRF = 0; |
539 |
> |
useRF = 0; |
540 |
> |
useSF = 0; |
541 |
|
|
542 |
+ |
|
543 |
+ |
if (simParams_->haveElectrostaticSummationMethod()) { |
544 |
+ |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
545 |
+ |
toUpper(myMethod); |
546 |
+ |
if (myMethod == "REACTION_FIELD") { |
547 |
+ |
useRF=1; |
548 |
+ |
} else { |
549 |
+ |
if (myMethod == "SHIFTED_FORCE") { |
550 |
+ |
useSF = 1; |
551 |
+ |
} |
552 |
+ |
} |
553 |
+ |
} |
554 |
+ |
|
555 |
|
//loop over all of the atom types |
556 |
|
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
557 |
|
useLennardJones |= (*i)->isLennardJones(); |
615 |
|
|
616 |
|
temp = useRF; |
617 |
|
MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
618 |
+ |
|
619 |
+ |
temp = useSF; |
620 |
+ |
MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
621 |
|
|
622 |
|
#endif |
623 |
|
|
634 |
|
fInfo_.SIM_uses_Shapes = useShape; |
635 |
|
fInfo_.SIM_uses_FLARB = useFLARB; |
636 |
|
fInfo_.SIM_uses_RF = useRF; |
637 |
+ |
fInfo_.SIM_uses_SF = useSF; |
638 |
|
|
639 |
< |
if( fInfo_.SIM_uses_Dipoles && myMethod == "REACTION_FIELD") { |
640 |
< |
|
639 |
> |
if( myMethod == "REACTION_FIELD") { |
640 |
> |
|
641 |
|
if (simParams_->haveDielectric()) { |
642 |
|
fInfo_.dielect = simParams_->getDielectric(); |
643 |
|
} else { |
647 |
|
"\tsetting a dielectric constant!\n"); |
648 |
|
painCave.isFatal = 1; |
649 |
|
simError(); |
650 |
< |
} |
631 |
< |
|
632 |
< |
} else { |
633 |
< |
fInfo_.dielect = 0.0; |
650 |
> |
} |
651 |
|
} |
652 |
|
|
653 |
|
} |
823 |
|
|
824 |
|
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
825 |
|
|
826 |
< |
if (!simParams_->haveRcut()){ |
826 |
> |
if (!simParams_->haveCutoffRadius()){ |
827 |
|
sprintf(painCave.errMsg, |
828 |
|
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
829 |
|
"\tOOPSE will use a default value of 15.0 angstroms" |
832 |
|
simError(); |
833 |
|
rcut = 15.0; |
834 |
|
} else{ |
835 |
< |
rcut = simParams_->getRcut(); |
835 |
> |
rcut = simParams_->getCutoffRadius(); |
836 |
|
} |
837 |
|
|
838 |
< |
if (!simParams_->haveRsw()){ |
838 |
> |
if (!simParams_->haveSwitchingRadius()){ |
839 |
|
sprintf(painCave.errMsg, |
840 |
|
"SimCreator Warning: No value was set for switchingRadius.\n" |
841 |
|
"\tOOPSE will use a default value of\n" |
842 |
< |
"\t0.95 * cutoffRadius for the switchingRadius\n"); |
842 |
> |
"\t0.85 * cutoffRadius for the switchingRadius\n"); |
843 |
|
painCave.isFatal = 0; |
844 |
|
simError(); |
845 |
< |
rsw = 0.95 * rcut; |
845 |
> |
rsw = 0.85 * rcut; |
846 |
|
} else{ |
847 |
< |
rsw = simParams_->getRsw(); |
847 |
> |
rsw = simParams_->getSwitchingRadius(); |
848 |
|
} |
849 |
|
|
850 |
|
} else { |
851 |
|
// if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
852 |
|
//meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
853 |
|
|
854 |
< |
if (simParams_->haveRcut()) { |
855 |
< |
rcut = simParams_->getRcut(); |
854 |
> |
if (simParams_->haveCutoffRadius()) { |
855 |
> |
rcut = simParams_->getCutoffRadius(); |
856 |
|
} else { |
857 |
|
//set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
858 |
|
rcut = calcMaxCutoffRadius(); |
859 |
|
} |
860 |
|
|
861 |
< |
if (simParams_->haveRsw()) { |
862 |
< |
rsw = simParams_->getRsw(); |
861 |
> |
if (simParams_->haveSwitchingRadius()) { |
862 |
> |
rsw = simParams_->getSwitchingRadius(); |
863 |
|
} else { |
864 |
|
rsw = rcut; |
865 |
|
} |
876 |
|
int cp = TRADITIONAL_CUTOFF_POLICY; |
877 |
|
if (simParams_->haveCutoffPolicy()) { |
878 |
|
std::string myPolicy = simParams_->getCutoffPolicy(); |
879 |
+ |
toUpper(myPolicy); |
880 |
|
if (myPolicy == "MIX") { |
881 |
|
cp = MIX_CUTOFF_POLICY; |
882 |
|
} else { |
903 |
|
|
904 |
|
notifyFortranCutoffs(&rcut_, &rsw_, &rnblist, &cp); |
905 |
|
// also send cutoff notification to electrostatics |
906 |
< |
setElectrostaticCutoffRadius(&rcut_); |
906 |
> |
setElectrostaticCutoffRadius(&rcut_, &rsw_); |
907 |
|
} |
908 |
|
|
909 |
|
void SimInfo::setupElectrostaticSummationMethod( int isError ) { |
910 |
|
|
911 |
|
int errorOut; |
912 |
|
int esm = NONE; |
913 |
+ |
int sm = UNDAMPED; |
914 |
|
double alphaVal; |
915 |
|
double dielectric; |
916 |
|
|
920 |
|
|
921 |
|
if (simParams_->haveElectrostaticSummationMethod()) { |
922 |
|
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
923 |
+ |
toUpper(myMethod); |
924 |
|
if (myMethod == "NONE") { |
925 |
|
esm = NONE; |
926 |
|
} else { |
927 |
< |
if (myMethod == "UNDAMPED_WOLF") { |
928 |
< |
esm = UNDAMPED_WOLF; |
929 |
< |
} else { |
930 |
< |
if (myMethod == "DAMPED_WOLF") { |
931 |
< |
esm = DAMPED_WOLF; |
932 |
< |
if (!simParams_->haveDampingAlpha()) { |
933 |
< |
//throw error |
934 |
< |
sprintf( painCave.errMsg, |
915 |
< |
"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); |
916 |
< |
painCave.isFatal = 0; |
917 |
< |
simError(); |
918 |
< |
} |
919 |
< |
} else { |
920 |
< |
if (myMethod == "REACTION_FIELD") { |
921 |
< |
esm = REACTION_FIELD; |
927 |
> |
if (myMethod == "SWITCHING_FUNCTION") { |
928 |
> |
esm = SWITCHING_FUNCTION; |
929 |
> |
} else { |
930 |
> |
if (myMethod == "SHIFTED_POTENTIAL") { |
931 |
> |
esm = SHIFTED_POTENTIAL; |
932 |
> |
} else { |
933 |
> |
if (myMethod == "SHIFTED_FORCE") { |
934 |
> |
esm = SHIFTED_FORCE; |
935 |
|
} else { |
936 |
< |
// throw error |
937 |
< |
sprintf( painCave.errMsg, |
938 |
< |
"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() ); |
939 |
< |
painCave.isFatal = 1; |
940 |
< |
simError(); |
941 |
< |
} |
942 |
< |
} |
936 |
> |
if (myMethod == "REACTION_FIELD") { |
937 |
> |
esm = REACTION_FIELD; |
938 |
> |
} else { |
939 |
> |
// throw error |
940 |
> |
sprintf( painCave.errMsg, |
941 |
> |
"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() ); |
942 |
> |
painCave.isFatal = 1; |
943 |
> |
simError(); |
944 |
> |
} |
945 |
> |
} |
946 |
> |
} |
947 |
> |
} |
948 |
> |
} |
949 |
> |
} |
950 |
> |
|
951 |
> |
if (simParams_->haveElectrostaticScreeningMethod()) { |
952 |
> |
std::string myScreen = simParams_->getElectrostaticScreeningMethod(); |
953 |
> |
toUpper(myScreen); |
954 |
> |
if (myScreen == "UNDAMPED") { |
955 |
> |
sm = UNDAMPED; |
956 |
> |
} else { |
957 |
> |
if (myScreen == "DAMPED") { |
958 |
> |
sm = DAMPED; |
959 |
> |
if (!simParams_->haveDampingAlpha()) { |
960 |
> |
//throw error |
961 |
> |
sprintf( painCave.errMsg, |
962 |
> |
"SimInfo warning: dampingAlpha was not specified in the input file. A default value of %f (1/ang) will be used.", alphaVal); |
963 |
> |
painCave.isFatal = 0; |
964 |
> |
simError(); |
965 |
> |
} |
966 |
> |
} else { |
967 |
> |
// throw error |
968 |
> |
sprintf( painCave.errMsg, |
969 |
> |
"SimInfo error: Unknown electrostaticScreeningMethod. (Input file specified %s .)\n\telectrostaticScreeningMethod must be one of: \"undamped\" or \"damped\".", myScreen.c_str() ); |
970 |
> |
painCave.isFatal = 1; |
971 |
> |
simError(); |
972 |
|
} |
973 |
|
} |
974 |
|
} |
975 |
+ |
|
976 |
|
// let's pass some summation method variables to fortran |
977 |
|
setElectrostaticSummationMethod( &esm ); |
978 |
< |
setDampedWolfAlpha( &alphaVal ); |
978 |
> |
setScreeningMethod( &sm ); |
979 |
> |
setDampingAlpha( &alphaVal ); |
980 |
|
setReactionFieldDielectric( &dielectric ); |
981 |
|
initFortranFF( &esm, &errorOut ); |
982 |
|
} |
983 |
|
|
984 |
+ |
void SimInfo::setupSwitchingFunction() { |
985 |
+ |
int ft = CUBIC; |
986 |
+ |
|
987 |
+ |
if (simParams_->haveSwitchingFunctionType()) { |
988 |
+ |
std::string funcType = simParams_->getSwitchingFunctionType(); |
989 |
+ |
toUpper(funcType); |
990 |
+ |
if (funcType == "CUBIC") { |
991 |
+ |
ft = CUBIC; |
992 |
+ |
} else { |
993 |
+ |
if (funcType == "FIFTH_ORDER_POLYNOMIAL") { |
994 |
+ |
ft = FIFTH_ORDER_POLY; |
995 |
+ |
} else { |
996 |
+ |
// throw error |
997 |
+ |
sprintf( painCave.errMsg, |
998 |
+ |
"SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() ); |
999 |
+ |
painCave.isFatal = 1; |
1000 |
+ |
simError(); |
1001 |
+ |
} |
1002 |
+ |
} |
1003 |
+ |
} |
1004 |
+ |
|
1005 |
+ |
// send switching function notification to switcheroo |
1006 |
+ |
setFunctionType(&ft); |
1007 |
+ |
|
1008 |
+ |
} |
1009 |
+ |
|
1010 |
|
void SimInfo::addProperty(GenericData* genData) { |
1011 |
|
properties_.addProperty(genData); |
1012 |
|
} |