Loading...
Searching...
No Matches
init.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * How a PAW dataset's one-center terms are referenced.
5 *
6 * PAW is exact, but the split between what a dataset's `D_ion` already carries
7 * and what the SCF adds on top is a *convention*, and the two codes Q3 is
8 * validated against made different choices. Reading a dataset produced for one
9 * convention and computing with the other is wrong by a per-element constant —
10 * large enough to dominate any energy difference of interest — while every
11 * observable that does not depend on the reference (eigenvalues, Ewald,
12 * forces) agrees perfectly, which is exactly what makes the error hard to see.
13 *
14 * This class is the seam. The base is QE's convention, which is also the
15 * absolute one: the one-center energy is E¹ − Ẽ¹ computed outright, `PP_DIJ`
16 * already contains the kinetic and core-reference pieces, and no correction is
17 * applied. Everything it does is nothing, deliberately — a UPF-PAW dataset
18 * needs no adjustment, and that path is validated against QE to under
19 * 10 meV/atom on Si, Cu and C.
20 *
21 * A convention for datasets generated differently overrides it and is
22 * registered under its own name (registry.hpp). The factory picks the one the
23 * dataset's own declared `one_center_convention` names, never from the file
24 * format, so a dataset that arrives by some other route still gets the
25 * treatment its numbers were generated for.
26 */
27
28#include <string>
29#include <vector>
30
37
38namespace q3 {
39namespace paw_one_center {
40
41/// Everything the engine needs to rebuild a dataset's own reference state.
44 const ChannelExpansion* expansion{nullptr};
46 const std::vector<AngularPoint>* angular_grid{nullptr};
47 const std::vector<std::vector<Real>>* harmonics{nullptr};
48 const std::vector<std::vector<std::array<Real, 3>>>* harmonic_gradients{nullptr};
49 const XCFunctional* functional{nullptr};
50};
51
52/**
53 * The absolute (QE / UPF-PAW) convention: compute E¹ − Ẽ¹ and add it.
54 *
55 * Every method is a no-op. Kept as a real class rather than a null pointer so
56 * that the SCF driver has one code path, and so every other convention is
57 * expressed as a difference from a stated baseline rather than as a branch.
58 */
60 public:
61 virtual ~PawOneCenterConvention() = default;
62
63 [[nodiscard]] virtual std::string name() const {
64 return "absolute";
65 }
66
67 /// Extra terms this convention wants in the one-center energy. None here.
68 [[nodiscard]] virtual OneCenterOptions options() const {
69 return {};
70 }
71
72 /// Build any per-species reference state. Called once, at setup.
73 virtual void prepare(const ReferenceStateInputs&) {}
74
75 /**
76 * Correction added to the one-center energy for the current occupancies.
77 *
78 * Zero here. A referencing convention returns −Σ_ij ρ_ij D^ref_ij, which
79 * is what makes D remain the exact derivative of the energy after the D
80 * correction below is applied.
81 */
82 [[nodiscard]] virtual Real energy_correction(const OnSiteOccupancies&) const {
83 return 0.0;
84 }
85
86 /// Correction applied to D_ij in place. None here.
87 virtual void correct_d_matrix(std::vector<Real>&) const {}
88
89 /**
90 * Absolute one-center Hxc energy at the dataset's atomic reference state.
91 *
92 * This is a radial setup diagnostic, not an atomic total energy a dataset
93 * may state for output.
94 */
95 [[nodiscard]] virtual Real reference_one_center_energy() const {
96 return 0.0;
97 }
98
99 /**
100 * One-center double counting at the atomic reference state.
101 *
102 * For an atomic-referenced convention this is
103 * `E_Hxc[rho_ref] - rho_ref D_Hxc[rho_ref]`, including the AE-minus-PS and
104 * core-only conventions.
105 */
106 [[nodiscard]] virtual Real reference_double_counting_energy() const {
107 return 0.0;
108 }
109};
110
111} // namespace paw_one_center
112} // namespace q3
PAW pseudopotential — extends ultrasoft with one-center (on-site) data.
Definition init.hpp:33
Abstract base class for XC functionals.
Definition init.hpp:23
virtual Real energy_correction(const OnSiteOccupancies &) const
Definition init.hpp:82
virtual Real reference_double_counting_energy() const
Definition init.hpp:106
virtual void correct_d_matrix(std::vector< Real > &) const
Correction applied to D_ij in place. None here.
Definition init.hpp:87
virtual OneCenterOptions options() const
Extra terms this convention wants in the one-center energy. None here.
Definition init.hpp:68
virtual void prepare(const ReferenceStateInputs &)
Build any per-species reference state. Called once, at setup.
Definition init.hpp:73
virtual Real reference_one_center_energy() const
Definition init.hpp:95
virtual std::string name() const
Definition init.hpp:63
double Real
Everything the engine needs to rebuild a dataset's own reference state.
Definition init.hpp:42
const PawPseudopotential * pseudopotential
Definition init.hpp:43
const std::vector< std::vector< std::array< Real, 3 > > > * harmonic_gradients
Definition init.hpp:48
const XCFunctional * functional
Definition init.hpp:49
const std::vector< std::vector< Real > > * harmonics
Definition init.hpp:47
const GauntCoefficientTable * gaunt
Definition init.hpp:45
const std::vector< AngularPoint > * angular_grid
Definition init.hpp:46
const ChannelExpansion * expansion
Definition init.hpp:44