XCFunctional.h 2.8 KB
Newer Older
Francois Gygi committed
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
Francois Gygi committed
7 8
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
Francois Gygi committed
9 10 11 12 13 14
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
15 16 17 18 19 20 21 22 23 24 25 26 27
// XCFunctional.h
//
////////////////////////////////////////////////////////////////////////////////

//
// Abstract base class for density functionals
// Input variables are: rho, rho_up, rho_dn, grad_rho, grad_rho_up, grad_rho_dn
//
// Output quantities:
// The exchange-correlation energy is expressed as
//
// Exc = int{ rho[i] * exc[i] + rho_up[i] * exc_up[i] + rho_dn[i] * exc_dn[i] }
//
28
// It is assumed that exchange correlation potentials can be
Francois Gygi committed
29
// written as:
30
//
Francois Gygi committed
31 32
// vxc_up = vxc1 + vxc1_up +
//          div ( vxc2_upup grad_rho_up ) + div ( vxc2_updn grad_rho_dn )
33 34
//
// vxc_dn = vxc1 + vxc1_dn +
Francois Gygi committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
//          div ( vxc2_dndn grad_rho_dn ) + div ( vxc2_dnup grad_rho_up )
//
// Not all input quantities are needed, and not all output quantities are
// computed by certain functionals. Example:
//
// LDAFunctional:
//   without spin: Input: rho
//                 Output: exc, vxc1
//   with spin:    Input: rho_up, rho_dn
//                 Output: vxc1_up, vxc1_dn
//
// PBEFunctional:
//   without spin: Input:  rho, grad_rho
//                 Output: exc, vxc1, vxc2
//   with spin:    Input:  rho_up, rho_dn, grad_rho_up, grad_rho_dn,
//                 Output: exc_up, exc_dn, vxc1_up, vxc1_dn,
//                         vxc2_upup, vxc2_dndn, vxc2_updn, vxc2_dnup

#ifndef XCFUNCTIONAL_H
#define XCFUNCTIONAL_H

#include <string>

class XCFunctional
{
  protected:

  int _np, _nspin;
63

Francois Gygi committed
64
  public:
65

Francois Gygi committed
66
  const double *rho, *rho_up, *rho_dn;
Francois Gygi committed
67 68 69 70 71
  double *grad_rho[3], *grad_rho_up[3], *grad_rho_dn[3];
  double *exc, *exc_up, *exc_dn;
  double *vxc1, *vxc1_up, *vxc1_dn;
  double *vxc2, *vxc2_upup, *vxc2_dndn, *vxc2_updn, *vxc2_dnup;

72 73 74 75
  virtual bool isGGA(void) const = 0;
  virtual std::string name(void) const = 0;
  int np(void) const { return _np; };
  int nspin(void) const { return _nspin; };
76

Francois Gygi committed
77 78 79 80 81 82 83 84 85 86 87 88 89
  XCFunctional()
  {
    rho = rho_up = rho_dn = 0;
    grad_rho[0] = grad_rho[1] = grad_rho[2] = 0;
    grad_rho_up[0] = grad_rho_up[1] = grad_rho_up[2] = 0;
    grad_rho_dn[0] = grad_rho_dn[1] = grad_rho_dn[2] = 0;
    exc = exc_up = exc_dn = 0;
    vxc1 = vxc1_up = vxc1_dn = 0;
    vxc2 = vxc2_upup = vxc2_dndn = vxc2_updn = vxc2_dnup = 0;
  }

  // virtual destructor needed to ensure proper deallocation
  virtual ~XCFunctional() {}
90 91

  virtual void setxc(void) = 0;
Francois Gygi committed
92 93
};
#endif