VWNFunctional.h 2.21 KB
Newer Older
Francois Gygi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2015 The Regents of the University of California
//
// This file is part of Qbox
//
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
// 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/>.
//
////////////////////////////////////////////////////////////////////////////////
//
// VWNFunctional.h
//
////////////////////////////////////////////////////////////////////////////////

#ifndef VWNFUNCTIONAL_H
#define VWNFUNCTIONAL_H

#include <vector>
#include <cassert>
#include "XCFunctional.h"

class VWNFunctional : public XCFunctional
{
28 29 30 31 32 33
  static void alpha_c(const double rh, double &a, double &da);
  static void x_unpolarized(const double rh, double &ex, double &vx);
  static void c_unpolarized(const double rh, double &ec, double &vc);
  static void x_polarized(const double rh, double &ex, double &vx);
  static void c_polarized(const double rh, double &ec, double &vc);

Francois Gygi committed
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
  std::vector<double> _exc;
  std::vector<std::vector<double> > _vxc;

  VWNFunctional();

  public:

  VWNFunctional(const std::vector<std::vector<double> > &rhoe)
  {
    _nspin = rhoe.size();
    if ( _nspin > 1 ) assert(rhoe[0].size() == rhoe[1].size());
    _np = rhoe[0].size();
    _exc.resize(_np);
    _vxc.resize(_nspin);
    for ( int i = 0; i < _nspin; i++ )
    {
      _vxc[i].resize(_np);
    }

    if ( _nspin == 1 )
    {
      rho = &rhoe[0][0];
      exc = &_exc[0];
      vxc1 = &_vxc[0][0];
    }
    else
    {
      rho_up = &rhoe[0][0];
      rho_dn = &rhoe[1][0];
      exc = &_exc[0];
      vxc1_up = &_vxc[0][0];
      vxc1_dn = &_vxc[1][0];
    }
  };

69 70 71
  static void exvwn(const double rh, double &ex, double &vx);
  static void ecvwn(const double rh, double &ec, double &vc);

72
  static void exvwn_sp(double roe_up, double roe_dn,
73
    double &ex, double &vx_up, double &vx_dn);
74
  static void ecvwn_sp(double roe_up, double roe_dn,
75 76
    double &ec, double &vc_up, double &vc_dn);

Francois Gygi committed
77 78 79 80
  std::string name() const { return "VWN"; };
  void setxc(void);
};
#endif