MADNESS 0.10.1
wst_functional.h
Go to the documentation of this file.
1#include <madness/mra/mra.h>
3
5{
6 public:
7
8 real_function_3d make_dft_potential(World& world, const XCfunctional& xc, const vector_real_function_3d& vf, int ispin, int what)
9 {
10 return multiop_values<double, xc_potential, 3>(xc_potential(xc, ispin, what), vf);
11 }
12
13 double make_dft_energy(World& world, const XCfunctional& xc, const vector_real_function_3d& vf, int ispin)
14 {
15 real_function_3d vlda = multiop_values<double, xc_functional, 3>(xc_functional(xc, ispin), vf);
16 return vlda.trace();
17 }
18
19 std::pair<real_function_3d, double> apply_xc(World& world, const XCfunctional& xc, real_function_3d& rho)
20 {
21 vector_real_function_3d delrho;
22 vector_real_function_3d vf;
23
24 rho.reconstruct();
25 vf.push_back(rho);
26 if (xc.is_gga())
27 {
28 for(int axis = 0; axis < 3; ++axis)
29 {
30 Derivative<double,3> D = free_space_derivative<double,3>(world, axis);
31 delrho.push_back(D(rho));
32 }
33 real_function_3d saa = delrho[0]*delrho[0]+delrho[1]*delrho[1]+delrho[2]*delrho[2];
34 vf.push_back(saa); // sigma_aa
35 if (vf.size())
36 {
37 reconstruct(world, vf);
38// rho.refine_to_common_level(vf); // Ugly but temporary (I hope!)
39 refine_to_common_level(world,vf); // Ugly but temporary (I hope!)
40 }
41 }
42 double exc = make_dft_energy(world, xc, vf, 0);
43 real_function_3d vxc = make_dft_potential(world, xc, vf, 0, 0);
44
45 if (xc.is_gga())
46 {
47 real_function_3d vsigaa = make_dft_potential(world, xc, vf, 0, 1).truncate();
48 for (int axis=0; axis<1; axis++)
49 {
50 Derivative<double,3> D = free_space_derivative<double,3>(world, axis);
51 real_function_3d gradn = D(rho);
52 real_function_3d ddel = vsigaa*gradn;
53 ddel.scale(2.0);
54
55 real_function_3d vxc2=D(ddel).truncate();
56 vxc = vxc - vxc2;
57 }
58 }
59 return std::pair<real_function_3d, double>(vxc, exc);
60 }
61};
62
Definition wst_functional.h:5
std::pair< real_function_3d, double > apply_xc(World &world, const XCfunctional &xc, real_function_3d &rho)
Definition wst_functional.h:19
double make_dft_energy(World &world, const XCfunctional &xc, const vector_real_function_3d &vf, int ispin)
Definition wst_functional.h:13
real_function_3d make_dft_potential(World &world, const XCfunctional &xc, const vector_real_function_3d &vf, int ispin, int what)
Definition wst_functional.h:8
Function< T, NDIM > & scale(const Q q, bool fence=true)
Inplace, scale the function by a constant. No communication except for optional fence.
Definition mra.h:953
Function< T, NDIM > & truncate(double tol=0.0, bool fence=true)
Truncate the function with optional fence. Compresses with fence if not compressed.
Definition mra.h:602
Main include file for MADNESS and defines Function interface.
XCfunctional xc
Definition newsolver_lda.cc:53
Definition test_ar.cc:204
std::size_t axis
Definition testpdiff.cc:59