30void check_xc_potential(Density
const& rho__)
32 Potential p0(
const_cast<Simulation_context&
>(rho__.ctx()));
33 p0.generate(rho__, rho__.ctx().use_symmetry(),
true);
35 double evxc{0}, ebxc{0};
36 if (rho__.ctx().full_potential()) {
38 evxc = p0.energy_vxc(rho__) + p0.energy_vxc_core(rho__);
41 std::printf(
"<vxc|rho> : %18.12f\n", evxc);
42 std::printf(
"<bxc|mag> : %18.12f\n", ebxc);
45 double best_result{1e10};
47 for (
int i = 0; i < 10; i++) {
48 Potential p1(
const_cast<Simulation_context&
>(rho__.ctx()));
50 p1.add_delta_rho_xc(eps);
51 p1.generate(rho__, rho__.ctx().use_symmetry(),
true);
55 if (rho__.ctx().num_mag_dims() > 0) {
56 Potential p2(
const_cast<Simulation_context&
>(rho__.ctx()));
58 p2.add_delta_mag_xc(eps);
59 p2.generate(rho__, rho__.ctx().use_symmetry(),
true);
61 deriv_mag = (p2.energy_exc(rho__) - p0.energy_exc(rho__)) / eps;
64 double deriv_rho = (p1.energy_exc(rho__) - p0.energy_exc(rho__)) / eps;
66 std::printf(
"eps: %18.12f, drho: %18.12f, dmag: %18.12f\n", eps, std::abs(evxc - deriv_rho),
67 std::abs(ebxc - deriv_mag));
69 if (std::abs(evxc - deriv_rho) + std::abs(ebxc - deriv_mag) < best_result) {
70 best_result = std::abs(evxc - deriv_rho) + std::abs(ebxc - deriv_mag);
76 std::printf(
"best total result : %18.12f for epsilon %18.12f\n", best_result, best_eps);
Namespace of the SIRIUS library.
double energy_bxc(const Density &density, const Potential &potential)
TODO doc.
Contains declaration and partial implementation of sirius::Potential class.