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 // LDAFunctional.h
16 //
17 ////////////////////////////////////////////////////////////////////////////////
18 
19 #ifndef LDAFUNCTIONAL_H
20 #define LDAFUNCTIONAL_H
21 
22 #include <vector>
23 #include <cassert>
24 #include "XCFunctional.h"
25 
26 class LDAFunctional : public XCFunctional
27 {
28   void xc_unpolarized(const double rh, double &ee, double &vv);
29   void xc_polarized(const double rh, double &ee, double &vv);
30   std::vector<double> _exc;
31   std::vector<std::vector<double> > _vxc;
32 
33   LDAFunctional();
34 
35   public:
36 
LDAFunctional(const std::vector<std::vector<double>> & rhoe)37   LDAFunctional(const std::vector<std::vector<double> > &rhoe)
38   {
39     _nspin = rhoe.size();
40     if ( _nspin > 1 ) assert(rhoe[0].size() == rhoe[1].size());
41     _np = rhoe[0].size();
42     _exc.resize(_np);
43     _vxc.resize(_nspin);
44     for ( int i = 0; i < _nspin; i++ )
45     {
46       _vxc[i].resize(_np);
47     }
48 
49     if ( _nspin == 1 )
50     {
51       rho = &rhoe[0][0];
52       exc = &_exc[0];
53       vxc1 = &_vxc[0][0];
54     }
55     else
56     {
57       rho_up = &rhoe[0][0];
58       rho_dn = &rhoe[1][0];
59       exc = &_exc[0];
60       vxc1_up = &_vxc[0][0];
61       vxc1_dn = &_vxc[1][0];
62     }
63   };
64 
name()65   std::string name() const { return "LDA"; };
66   void setxc(void);
67 };
68 #endif
69