JDFTx  1.2.0
ExCorr.h
1 /*-------------------------------------------------------------------
2 Copyright 2011 Ravishankar Sundararaman
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_EXCORR_H
21 #define JDFTX_ELECTRONIC_EXCORR_H
22 
23 #include <electronic/common.h>
24 #include <core/ScalarFieldArray.h>
25 
27 enum ExCorrType
28 {
29  ExCorrLDA_PZ,
30  ExCorrLDA_PW,
31  ExCorrLDA_PW_prec,
32  ExCorrLDA_VWN,
33  ExCorrLDA_Teter,
34  ExCorrGGA_PBE,
35  ExCorrGGA_PBEsol,
36  ExCorrGGA_PW91,
37  ExCorrMGGA_TPSS,
38  ExCorrMGGA_revTPSS,
39 #ifdef LIBXC_ENABLED
40  ExCorrLibXC,
41 #endif
42  ExCorrORB_GLLBsc,
43  ExCorrPOT_LB94,
44  ExCorrHYB_PBE0,
45  ExCorrHYB_HSE06,
46  ExCorrHYB_HSE12,
47  ExCorrHYB_HSE12s,
48  ExCorrHF
49 };
50 
52 enum KineticType
53 {
54 #ifdef LIBXC_ENABLED
55  KineticLibXC,
56 #endif
57  KineticNone,
58  KineticTF,
59  KineticVW,
60  KineticPW91
61 };
62 
64 struct IncludeTXC
65 { bool T;
66  bool X;
67  bool C;
68 
69  IncludeTXC(bool T=false, bool X=true, bool C=true) : T(T), X(X), C(C) {}
70 };
71 
72 class ExCorr
73 {
74 public:
75  ExCorr(ExCorrType exCorrType=ExCorrGGA_PBE, KineticType kineticType=KineticNone);
76  void setup(const Everything&);
77  string getName() const;
78 
84  double operator()(const ScalarFieldArray& n, ScalarFieldArray* Vxc=0, IncludeTXC includeTXC=IncludeTXC(),
85  const ScalarFieldArray* tau=0, ScalarFieldArray* Vtau=0) const;
86 
92  double operator()(const ScalarField& n, ScalarField* Vxc=0, IncludeTXC includeTXC=IncludeTXC(),
93  const ScalarField* tau=0, ScalarField* Vtau=0) const;
94 
95  double exxFactor() const;
96  double exxRange() const;
97  bool needsKEdensity() const;
98  bool hasEnergy() const;
99 
104  void getSecondDerivatives(const ScalarField& n, ScalarField& e_nn, ScalarField& e_sigma, ScalarField& e_nsigma, ScalarField& e_sigmasigma, double nCut=1e-4) const;
105 
107  struct OrbitalDep
108  { OrbitalDep(const Everything& e) : e(e) {}
109  virtual ~OrbitalDep() {}
110  virtual bool ignore_nCore() const=0;
111  virtual ScalarFieldArray getPotential() const=0;
112  virtual void dump() const=0;
113  protected:
114  const Everything& e;
115  };
116  std::shared_ptr<OrbitalDep> orbitalDep; //optional orbital-dependent potential functional
117 
118 private:
119  const Everything* e;
120  ExCorrType exCorrType;
121  KineticType kineticType;
122  string xcName; // short name of the functional (set by command elec-ex-corr)
123  friend struct CommandElecExCorr;
124  friend struct CommandFluidExCorr;
125 
126  double exxScale; //scale factor for exact exchange
127  double exxOmega; //Range parameter for exact exchange
128  std::shared_ptr<struct FunctionalList> functionals; //List of component functionals
129 #ifdef LIBXC_ENABLED
130  int xcExchange, xcCorr, xcExcorr, xcKinetic; //LibXC codes for various functional components (0 if unused)
131 #endif
132 };
133 
134 #endif // JDFTX_ELECTRONIC_EXCORR_H
std::vector< ScalarField > ScalarFieldArray
dynamic size collection of real space scalar fields
Definition: ScalarFieldArray.h:32
bool C
correlation
Definition: ExCorr.h:67
IncludeTXC(bool T=false, bool X=true, bool C=true)
defaults to exchange-correlation without kinetic
Definition: ExCorr.h:69
Which components to include in the results of ExCorr::operator()
Definition: ExCorr.h:64
bool T
kinetic
Definition: ExCorr.h:65
bool X
exchange
Definition: ExCorr.h:66
Definition: ExCorr.h:72
Definition: Everything.h:41
classes ScalarFieldArray, ScalarFieldTildeArray and just enough operators to enable CG w...
std::shared_ptr< ScalarFieldData > ScalarField
A smart reference-counting pointer to ScalarFieldData.
Definition: ScalarField.h:41
Abstract base class (interface specification) for orbital-dependent potential functionals.
Definition: ExCorr.h:107