1 //////////////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (c) 2008 The Regents of the University of California 4 // 5 // This file is part of Qbox 6 // 7 // Qbox is distributed under the terms of the GNU General Public License 8 // as published by the Free Software Foundation, either version 2 of 9 // the License, or (at your option) any later version. 10 // See the file COPYING in the root directory of this distribution 11 // or <http://www.gnu.org/licenses/>. 12 // 13 //////////////////////////////////////////////////////////////////////////////// 14 // 15 // XCFunctional.h 16 // 17 //////////////////////////////////////////////////////////////////////////////// 18 19 // 20 // Abstract base class for density functionals 21 // Input variables are: rho, rho_up, rho_dn, grad_rho, grad_rho_up, grad_rho_dn 22 // 23 // Output quantities: 24 // The exchange-correlation energy is expressed as 25 // 26 // Exc = int{ rho[i] * exc[i] + rho_up[i] * exc_up[i] + rho_dn[i] * exc_dn[i] } 27 // 28 // It is assumed that exchange correlation potentials can be 29 // written as: 30 // 31 // vxc_up = vxc1 + vxc1_up + 32 // div ( vxc2_upup grad_rho_up ) + div ( vxc2_updn grad_rho_dn ) 33 // 34 // vxc_dn = vxc1 + vxc1_dn + 35 // div ( vxc2_dndn grad_rho_dn ) + div ( vxc2_dnup grad_rho_up ) 36 // 37 // Not all input quantities are needed, and not all output quantities are 38 // computed by certain functionals. Example: 39 // 40 // LDAFunctional: 41 // without spin: Input: rho 42 // Output: exc, vxc1 43 // with spin: Input: rho_up, rho_dn 44 // Output: vxc1_up, vxc1_dn 45 // 46 // PBEFunctional: 47 // without spin: Input: rho, grad_rho 48 // Output: exc, vxc1, vxc2 49 // with spin: Input: rho_up, rho_dn, grad_rho_up, grad_rho_dn, 50 // Output: exc_up, exc_dn, vxc1_up, vxc1_dn, 51 // vxc2_upup, vxc2_dndn, vxc2_updn, vxc2_dnup 52 53 #ifndef XCFUNCTIONAL_H 54 #define XCFUNCTIONAL_H 55 56 #include <string> 57 58 class XCFunctional 59 { 60 protected: 61 62 int _np, _nspin; 63 64 public: 65 66 const double *rho, *rho_up, *rho_dn; 67 double *grad_rho[3], *grad_rho_up[3], *grad_rho_dn[3]; 68 double *tau, *tau_up, *tau_dn; 69 double *exc, *exc_up, *exc_dn; 70 double *vxc1, *vxc1_up, *vxc1_dn; 71 double *vxc2, *vxc2_upup, *vxc2_dndn, *vxc2_updn, *vxc2_dnup; 72 double *vxc3,*vxc3_up,*vxc3_dn; 73 74 // default functional is not GGA, not Meta 75 // GGA functionals must override isGGA() 76 // meta functionals must override isMeta() isGGA(void)77 virtual bool isGGA(void) const { return false; } isMeta(void)78 virtual bool isMeta(void) const { return false; } 79 virtual std::string name(void) const = 0; np(void)80 int np(void) const { return _np; } nspin(void)81 int nspin(void) const { return _nspin; } 82 XCFunctional()83 XCFunctional() 84 { 85 rho = rho_up = rho_dn = 0; 86 grad_rho[0] = grad_rho[1] = grad_rho[2] = 0; 87 grad_rho_up[0] = grad_rho_up[1] = grad_rho_up[2] = 0; 88 grad_rho_dn[0] = grad_rho_dn[1] = grad_rho_dn[2] = 0; 89 tau = tau_up = tau_dn = 0; 90 exc = exc_up = exc_dn = 0; 91 vxc1 = vxc1_up = vxc1_dn = 0; 92 vxc2 = vxc2_upup = vxc2_dndn = vxc2_updn = vxc2_dnup = 0; 93 vxc3 = 0; 94 } 95 96 // virtual destructor needed to ensure proper deallocation ~XCFunctional()97 virtual ~XCFunctional() {} 98 99 virtual void setxc(void) = 0; 100 }; 101 #endif 102