MADNESS  version 0.9
wst_functional.h
Go to the documentation of this file.
1 //#define WORLD_INSTANTIATE_STATIC_TEMPLATES
2 
3 #include <madness/mra/mra.h>
4 #include <chem/xcfunctional.h>
5 
6 using namespace madness;
7 
9 {
10  public:
11 
12  real_function_3d make_dft_potential(World& world, const XCfunctional& xc, const vector_real_function_3d& vf, int ispin, int what)
13  {
14  return multiop_values<double, xc_potential, 3>(xc_potential(xc, ispin, what), vf);
15  }
16 
17  double make_dft_energy(World& world, const XCfunctional& xc, const vector_real_function_3d& vf, int ispin)
18  {
19  real_function_3d vlda = multiop_values<double, xc_functional, 3>(xc_functional(xc, ispin), vf);
20  return vlda.trace();
21  }
22 
23  std::pair<real_function_3d, double> apply_xc(World& world, const XCfunctional& xc, real_function_3d& rho)
24  {
27 
28  rho.reconstruct();
29  vf.push_back(rho);
30  if (xc.is_gga())
31  {
32  for(int axis = 0; axis < 3; ++axis)
33  {
34  Derivative<double,3> D = free_space_derivative<double,3>(world, axis);
35  delrho.push_back(D(rho));
36  }
37  real_function_3d saa = delrho[0]*delrho[0]+delrho[1]*delrho[1]+delrho[2]*delrho[2];
38  vf.push_back(saa); // sigma_aa
39  if (vf.size())
40  {
41  reconstruct(world, vf);
42  rho.refine_to_common_level(vf); // Ugly but temporary (I hope!)
43  }
44  }
45  double exc = make_dft_energy(world, xc, vf, 0);
46  real_function_3d vxc = make_dft_potential(world, xc, vf, 0, 0);
47 
48  if (xc.is_gga())
49  {
50  real_function_3d vsigaa = make_dft_potential(world, xc, vf, 0, 1).truncate();
51  for (int axis=0; axis<1; axis++)
52  {
53  Derivative<double,3> D = free_space_derivative<double,3>(world, axis);
54  real_function_3d gradn = D(rho);
55  real_function_3d ddel = vsigaa*gradn;
56  ddel.scale(2.0);
57 
58  real_function_3d vxc2=D(ddel).truncate();
59  vxc = vxc - vxc2;
60  }
61  }
62  return std::pair<real_function_3d, double>(vxc, exc);
63  }
64 };
65 
void reconstruct(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Reconstruct a vector of functions.
Definition: vmra.h:149
Main include file for MADNESS and defines Function interface.
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:577
Implements derivatives operators with variety of boundary conditions on simulation domain...
Definition: derivative.h:272
void refine_to_common_level(std::vector< Function< T, NDIM > > &vf, bool fence=true)
Refine vector of functions down to common finest level (reconstructs as necessary, optional fence)
Definition: mra.h:1386
XCfunctional xc
Definition: hedft.cc:54
Definition: wst_functional.h:8
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:12
std::vector< real_function_3d > vector_real_function_3d
Definition: functypedefs.h:79
functionT make_dft_potential(World &world, XCfunctional &xc, const vecfuncT &vf, int ispin, int what)
Definition: h2dft.cc:54
Class to compute terms of the potential.
Definition: chem/xcfunctional.h:282
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:896
double make_dft_energy(World &world, XCfunctional &xc, const vecfuncT &vf, int ispin)
Definition: h2dft.cc:59
double make_dft_energy(World &world, const XCfunctional &xc, const vector_real_function_3d &vf, int ispin)
Definition: wst_functional.h:17
void reconstruct(bool fence=true) const
Reconstructs the function, transforming into scaling function basis. Possible non-blocking comm...
Definition: mra.h:737
T trace() const
Returns global value of int(f(x),x) ... global comm required.
Definition: mra.h:1034
A parallel world with full functionality wrapping an MPI communicator.
Definition: worldfwd.h:416
Class to compute the energy functional.
Definition: chem/xcfunctional.h:266
bool is_gga() const
Returns true if the potential is gga (needs first derivatives)
Definition: chem/xcfunctional_ldaonly.cc:61
Simplified interface to XC functionals.
Definition: chem/xcfunctional.h:41
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
std::pair< real_function_3d, double > apply_xc(World &world, const XCfunctional &xc, real_function_3d &rho)
Definition: wst_functional.h:23