LDAFunctional.C 5.31 KB
Newer Older
Francois Gygi committed
1 2 3 4 5 6 7 8
////////////////////////////////////////////////////////////////////////////////
//
// LDAFunctional.C
//
// LDA Exchange-correlation energy and potential
// Ceperley & Alder, parametrized by Perdew and Zunger
//
////////////////////////////////////////////////////////////////////////////////
9
// $Id: LDAFunctional.C,v 1.5 2007-10-19 16:24:04 fgygi Exp $
Francois Gygi committed
10 11 12 13 14 15

#include <cmath>
#include <cassert>
#include <vector>
#include "LDAFunctional.h"

16
void LDAFunctional::setxc(void)
Francois Gygi committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
{
  if ( _np == 0 ) return;
  if ( _nspin == 1 )
  {
    assert(rho != 0);
    assert(exc != 0);
    assert(vxc1 != 0);
    for ( int ir = 0; ir < _np; ir++ )
    {
      xc_unpolarized(rho[ir],exc[ir],vxc1[ir]);
    }
  }
  else
  {
    // spin polarized
    assert(rho_up != 0);
    assert(rho_dn != 0);
    assert(exc != 0);
    assert(vxc1_up != 0);
    assert(vxc1_dn != 0);
    const double fz_prefac = 1.0 / ( cbrt(2.0)*2.0 - 2.0 );
    const double dfz_prefac = (4.0/3.0) * fz_prefac;
    for ( int ir = 0; ir < _np; ir++ )
    {
      double excir = 0.0;
      double v_up = 0.0;
      double v_dn = 0.0;

      double roe_up = rho_up[ir];
      double roe_dn = rho_dn[ir];
      double roe = roe_up + roe_dn;

      if ( roe > 0.0 )
      {
        double zeta = ( roe_up - roe_dn ) / roe;

        double zp1 = 1.0 + zeta;
        double zm1 = 1.0 - zeta;
        double zp1_13 = cbrt(zp1);
        double zm1_13 = cbrt(zm1);
        double fz = fz_prefac * ( zp1_13 * zp1 + zm1_13 * zm1 - 2.0 );
        double dfz = dfz_prefac * ( zp1_13 - zm1_13 );

        double xc_u, xc_p, v_u, v_p;
        xc_unpolarized(roe,xc_u,v_u);
        xc_polarized(roe,xc_p,v_p);

        double xc_pu = xc_p - xc_u;
        excir = xc_u + fz * xc_pu;

        double v = v_u + fz * ( v_p - v_u );
        v_up = v + xc_pu * (  1.0 - zeta ) * dfz;
        v_dn = v + xc_pu * ( -1.0 - zeta ) * dfz;
      }

      vxc1_up[ir] = v_up;
      vxc1_dn[ir] = v_dn;
      exc[ir] = excir;
    }
  }
}

void LDAFunctional::xc_unpolarized(const double rh, double &ee, double &vv)
{
81
  // compute LDA xc energy and potential, unpolarized
Francois Gygi committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95
  // const double third=1.0/3.0;
  // c1 is (3.D0/(4.D0*pi))**third
  const double c1 = 0.6203504908994001;
  // alpha = (4/(9*pi))**third = 0.521061761198
  // const double alpha = 0.521061761198;
  // c2 = -(3/(4*pi)) / alpha = -0.458165293283
  // const double c2 = -0.458165293283;
  // c3 = (4/3) * c2 = -0.610887057711
  const double c3 = -0.610887057711;

  const double A  =  0.0311;
  const double B  = -0.048;
  const double b1 =  1.0529;
  const double b2 =  0.3334;
96
  const double G  = -0.1423;
97

98 99 100 101 102
  // C from the PZ paper: const double C  =  0.0020;
  // D from the PZ paper: const double D  = -0.0116;
  // C and D by matching Ec and Vc at rs=1
  const double D = G / ( 1.0 + b1 + b2 ) - B;
  const double C = -A - D - G * ( (b1/2.0 + b2) / ((1.0+b1+b2)*(1.0+b1+b2)));
103

Francois Gygi committed
104 105 106 107 108 109 110 111 112 113 114 115 116
  ee = 0.0;
  vv = 0.0;

  if ( rh > 0.0 )
  {
    double ro13 = cbrt(rh);
    double rs = c1 / ro13;

    double ex=0.0,vx=0.0,ec=0.0,vc=0.0;

    // Next line : exchange part in Hartree units
    vx = c3 / rs;
    ex = 0.75 * vx;
117

Francois Gygi committed
118 119 120 121 122 123 124 125 126 127 128 129 130
    // Next lines : Ceperley & Alder correlation (Zunger & Perdew)
    if ( rs < 1.0 )
    {
      double logrs = log(rs);
      ec = A * logrs + B + C * rs * logrs + D * rs;
      vc = A * logrs + ( B - A / 3.0 ) +
           (2.0/3.0) * C * rs * logrs +
           ( ( 2.0 * D - C ) / 3.0 ) * rs;
    }
    else
    {
      double sqrtrs = sqrt(rs);
      double den = 1.0 + b1 * sqrtrs + b2 * rs;
131
      ec = G / den;
Francois Gygi committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
      vc = ec * ( 1.0 + (7.0/6.0) * b1 * sqrtrs +
                  (4.0/3.0) * b2 * rs ) / den;
    }
    ee = ex + ec;
    vv = vx + vc;
  }
}

void LDAFunctional::xc_polarized(const double rh, double &ee, double &vv)
{
  // compute LDA polarized XC energy and potential

  // const double third=1.0/3.0;
  // c1 is (3.D0/(4.D0*pi))**third
  const double c1 = 0.6203504908994001;
  // alpha = (4/(9*pi))**third = 0.521061761198
  // const double alpha = 0.521061761198;
  // c2 = -(3/(4*pi)) / alpha = -0.458165293283
  // const double c2 = -0.458165293283;
  // c3 = (4/3) * c2 = -0.610887057711
  // const double c3 = -0.610887057711;
153
  // c4 = 2**third * c3
Francois Gygi committed
154 155 156 157 158 159
  const double c4 = -0.769669463118;

  const double A =  0.01555;
  const double B = -0.0269;
  const double b1  =  1.3981;
  const double b2  =  0.2611;
160 161 162 163 164 165
  const double G   = -0.0843;
  // C from PZ paper: const double C   =  0.0007;
  // D from PZ paper: const double D   = -0.0048;
  // C and D by matching Ec and Vc at rs=1
  const double D = G / ( 1.0 + b1 + b2 ) - B;
  const double C = -A - D - G * ( (b1/2.0 + b2) / ((1.0+b1+b2)*(1.0+b1+b2)));
Francois Gygi committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179

  ee = 0.0;
  vv = 0.0;

  if ( rh > 0.0 )
  {
    double ro13 = cbrt(rh);
    double rs = c1 / ro13;

    double ex=0.0,vx=0.0,ec=0.0,vc=0.0;

    // Next line : exchange part in Hartree units
    vx = c4 / rs;
    ex = 0.75 * vx;
180

Francois Gygi committed
181 182 183 184 185 186 187 188 189 190 191 192 193
    // Next lines : Ceperley & Alder correlation (Zunger & Perdew)
    if ( rs < 1.0 )
    {
      double logrs = log(rs);
      ec = A * logrs + B + C * rs * logrs + D * rs;
      vc = A * logrs + ( B - A / 3.0 ) +
           (2.0/3.0) * C * rs * logrs +
           ( ( 2.0 * D - C ) / 3.0 ) * rs;
    }
    else
    {
      double sqrtrs = sqrt(rs);
      double den = 1.0 + b1 * sqrtrs + b2 * rs;
194
      ec = G / den;
Francois Gygi committed
195 196 197 198 199 200 201
      vc = ec * ( 1.0 + (7.0/6.0) * b1 * sqrtrs +
                  (4.0/3.0) * b2 * rs ) / den;
    }
    ee = ex + ec;
    vv = vx + vc;
  }
}