1 /*-------------------------------------------------------------------
2 Copyright 2013 Ravishankar Sundararaman, Kendra Letchworth Weaver, Deniz Gunceler
3 
4 This file is part of JDFTx.
5 
6 JDFTx is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 JDFTx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with JDFTx.  If not, see <http://www.gnu.org/licenses/>.
18 -------------------------------------------------------------------*/
19 
20 #ifndef JDFTX_ELECTRONIC_FLUIDSOLVERPARAMS_H
21 #define JDFTX_ELECTRONIC_FLUIDSOLVERPARAMS_H
22 
23 //! @addtogroup Fluid
24 //! @{
25 //! @file FluidSolverParams.h
26 //! Parameters describing the fluids in the electronic code
27 
28 #include <electronic/ExCorr.h>
29 #include <fluid/FluidComponent.h>
30 #include <core/PulayParams.h>
31 
32 enum FluidType
33 {
34 	FluidNone, //!< No fluid
35 	FluidLinearPCM, //!< Linear local-dielectric fluid, optionally including non-electrostatic terms \cite PCM-Kendra
36 	FluidNonlinearPCM, //!< Nonlinear local-dielectric fluid including non-electrostatic terms \cite NonlinearPCM
37 	FluidSaLSA, //!< Spherically-averaged liquid susceptibility ansatz \cite SaLSA
38 	FluidClassicalDFT //!< Classical density functional description of fluid \cite PolarizableCDFT \cite RigidCDFT
39 };
40 
41 enum FluidSolveFrequency
42 {
43 	FluidFreqInner, //!< Solve fluid every electronic step
44 	FluidFreqGummel, //!< Use a Gummel iteration
45 	FluidFreqDefault //!< Decide based on fluid type (Inner for linear fluids, Gummel for rest)
46 };
47 
48 //!Mixing functional choices
49 enum FMixFunctional
50 {
51 	FMixNone, //!< No Interaction
52 	LJPotential, //!<Interaction with attractive part of Lennard Jones with sigma/eps potential only
53 	GaussianKernel, //!< Interaction with gaussian kernel with Rsolv/Esolv
54 };
55 
56 //! Parameters needed to mix fluids
57 struct FmixParams
58 {
59 	std::shared_ptr<FluidComponent> fluid1,fluid2;
60 	FMixFunctional FmixType; //!<Type of Fmix to be used (GaussianKernel or LJPotential)
61 	double energyScale,lengthScale; //!<Energy scale (eps for LJ potential) and range parameter (sigma for LJ potential)
62 };
63 
64 enum PCMVariant
65 {	PCM_SaLSA, //!< Use only with fluid type FluidSaLSA \cite SaLSA
66 	PCM_CANDLE, //!< Charge-asymmetric nonlocally-determined local-electric (CANDLE) solvation model \cite CANDLE
67 	PCM_SGA13, //!< Local-response dielectric fluid or electrolyte with weighted-density cavitation and dispersion \cite CavityWDA
68 	PCM_GLSSA13, //!< Local-response dielectric fluid or electrolyte with empirical cavity tension \cite NonlinearPCM
69 	PCM_LA12, //!< Linear local-response electrolyte \cite PCM-Kendra
70 	PCM_SoftSphere, //!< Soft-sphere continuum solvation model \cite PCM-SoftSphere
71 	PCM_FixedCavity, //!< Fixed-cavity electrostatic-only continuum solvation model
72 	PCM_SCCS_g09,      //!< g09 parametrization of SCCS local linear model for water \cite PCM-SCCS
73 	PCM_SCCS_g03,      //!< g03 parametrization of SCCS local linear model for water \cite PCM-SCCS
74 	PCM_SCCS_g03p,     //!< g03' parametrization of SCCS local linear model for water  \cite PCM-SCCS
75 	PCM_SCCS_g09beta,  //!< g09+beta parametrization of SCCS local linear model for water \cite PCM-SCCS
76 	PCM_SCCS_g03beta,  //!< g03+beta parametrization of SCCS local linear model for water \cite PCM-SCCS
77 	PCM_SCCS_g03pbeta, //!< g03'+beta parametrization of SCCS local linear model for water \cite PCM-SCCS
78 	PCM_SCCS_cation,   //!< cations-only parametrization of SCCS local linear model for water \cite PCM-SCCS-charged
79 	PCM_SCCS_anion     //!< anions-only parametrization of SCCS local linear model for water \cite PCM-SCCS-charged
80 };
81 
82 //! Check for any of the SCCS cases:
83 #define case_PCM_SCCS_any \
84 	case PCM_SCCS_g09: \
85 	case PCM_SCCS_g03: \
86 	case PCM_SCCS_g03p: \
87 	case PCM_SCCS_g09beta: \
88 	case PCM_SCCS_g03beta: \
89 	case PCM_SCCS_g03pbeta: \
90 	case PCM_SCCS_cation: \
91 	case PCM_SCCS_anion
isPCM_SCCS(PCMVariant pcmVariant)92 inline bool isPCM_SCCS(PCMVariant pcmVariant) { switch(pcmVariant) { case_PCM_SCCS_any: return true; default: return false; } }
93 
94 
95 //! Extra parameters for fluids:
96 struct FluidSolverParams
97 {
98 	FluidType fluidType;
99 	PCMVariant pcmVariant;
100 
101 	double T; //!< temperature
102 	double P; //!< pressure
103 	double epsBulkOverride, epsInfOverride; //!< Override default dielectric constants if non-zero
104 	vector3<> epsBulkTensor; //!< Override default dielectric constants with a tensor if non-zero (assuming Cartesian coords are principal axes, LinearPCM only)
105 	bool verboseLog; //!< whether iteration progress is printed for Linear PCM's, and whether sub-iteration progress is printed for others
106 	FluidSolveFrequency solveFrequency;
107 
108 	const std::vector< std::shared_ptr<FluidComponent> >& components; //!< list of all fluid components
109 	const std::vector< std::shared_ptr<FluidComponent> >& solvents; //!< list of solvent components
110 	const std::vector< std::shared_ptr<FluidComponent> >& cations; //!< list of cationic components
111 	const std::vector< std::shared_ptr<FluidComponent> >& anions; //!< list of anionic components
112 
113 	void addComponent(const std::shared_ptr<FluidComponent>& component); //!< Add component to the component list as well as one of solvents, anions or cations as appropriate
114 
115 	//Fit parameters:
116 	double nc; //!< critical density for the PCM cavity shape function
117 	double sigma; //!< smoothing factor for the PCM cavity shape function (dimensionless for most, but in bohrs for SoftSphere)
118 	double cavityTension; //!< effective surface tension (including dispersion etc.) of the cavity (hartree per bohr^2)
119 	double vdwScale; //!< overall scale factor for Grimme pair potentials (or damping range scale factor for vdw-TS when implemented)
120 
121 	//For CANDLE alone:
122 	double Ztot; //!< number of valence electrons
123 	double eta_wDiel; //!< electrostatic cavity expansion widthin bohrs (fit parameter)
124 	double sqrtC6eff; //!< (effective C6 parameter in J-nm^6/mol)^(1/2) for the entire molecule (fit parameter) (vdwScale unnecessary and not used due to this)
125 	double pCavity; //!< sensitivity of cavity to surface electric field to emulate charge asymmetry [e-a0/Eh]  (fit parameter)
126 
127 	//For SCCS alone:
128 	double rhoMin, rhoMax; //!< start and end of transition
129 	double rhoDelta; //!< Delta used for "quantum surface"
130 	double cavityPressure; //!< volume term (used in some parametrizations)
131 
132 	//For SaLSA alone:
133 	int lMax;
134 
135 	//For soft sphere model alone:
136 	double getAtomicRadius(const class SpeciesInfo& sp) const; //!< get the solute atom radius for the soft-sphere solvation model given species
137 	double cavityScale; //!< radius scale factor
138 	double ionSpacing; //!< extra spacing from dielectric to ionic cavity (in bohrs)
139 
140 	//For fixed-cavity model alone:
141 	string cavityFile; //!< filename of cavity to read in
142 
143 	//Cavity masking parameters (erf slab centered at zMask0 with half-width zMaskH where fluid is excluded):
144 	double zMask0; //z center in lattice coordinates for cavity mask
145 	double zMaskH; //half-width in z lattice coordinates for cavity mask
146 	double zMaskIonH; //half-width in z lattice coordinates for ionic cavity mask
147 	double zMaskSigma; //smoothness of z-mask in bohrs
148 
149 	//Debug parameters for Nonlinear PCM's:
150 	bool linearDielectric; //!< If true, work in the linear dielectric response limit
151 	bool linearScreening; //!< If true, work in the linearized Poisson-Boltzman limit for the ions
152 	bool nonlinearSCF; //!< whether to use an SCF method for nonlinear PCMs
153 	double screenOverride; //! overrides screening factor with this value
154 	PulayParams scfParams; //!< parameters controlling Pulay mixing for SCF version of nonlinear PCM
155 
156 	//For Explicit Fluid JDFT alone:
157 	ExCorr exCorr; //!< Fluid exchange-correlation and kinetic energy functional
158         std::vector<FmixParams> FmixList; //!< Tabulates which components interact through an additional Fmix
159 
160 	string initWarnings; //!< warnings emitted during parameter initialization, if any
161 
162 	FluidSolverParams();
163 	void setPCMparams(); //!< Set predefined parameters for solventName (for a specific model)
164 	void setCDFTparams(); //!< Set predefined parameters for solventName (for a classical DFT model)
165 	bool needsVDW() const; //!< whether pair-potential vdW corrections are required
166 	bool ionicScreening() const; //!< whether list of fluid components includes ionic species for Debye screening
167 private:
168 	std::vector< std::shared_ptr<FluidComponent> > components_, solvents_, cations_, anions_; //internal mutable versions of the public component lists
169 };
170 
171 //! @}
172 #endif // JDFTX_ELECTRONIC_FLUIDSOLVERPARAMS_H
173