Loading...
Searching...
No Matches
init.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
12
13namespace q3 {
14
15class PlanewaveBasis;
16class XCFunctional;
17
18/**
19 * Converged SCF state for a plane-wave Kohn-Sham calculation.
20 *
21 * Extends SCFState with the fields that are specific to a plane-wave
22 * representation: charge density, effective potential, and non-owning
23 * pointers to the basis and XC functional (which are owned by the iterator).
24 *
25 * The quantum system snapshot is declared as a pure virtual accessor here
26 * (covariant return), so that concrete subtypes can own the correctly typed
27 * quantum system by value.
28 */
35
36 std::vector<Complex> charge_density_g; // total density in G-space
37 std::vector<std::vector<Real>> charge_density_real; // [ispin][ir] in real space
38 std::vector<Complex> total_potential_g; // total potential in G-space
39 /**
40 * The same potential per spin channel, un-averaged. Empty for an
41 * unpolarized run, where `total_potential_g` already is the whole story.
42 *
43 * Layer 5 needs both: the augmentation force and stress contract the
44 * potential against the projector occupancies, and doing that with the
45 * spin *average* against the spin *sum* drops
46 * ∫(V↑−V↓)(ρ↑−ρ↓) dQ/dR / 2 — identically zero without a moment, and not
47 * zero with one.
48 */
49 std::vector<std::vector<Complex>> total_potential_g_by_spin;
50 std::vector<Complex> exchange_correlation_potential_g; // XC potential in G-space
51 std::vector<std::vector<Real>> real_space_potential; // [ispin][ir] effective potential
52
55 const Crystal* crystal_structure{nullptr};
56 const KPointsGrid* kpoint_grid{nullptr};
57 /**
58 * Non-owning pointer to the execution policy, set by the iterator.
59 *
60 * Forces and stress calculators use this to perform pool-level reductions
61 * (MPI_Allreduce across k-point pools) after accumulating k-point-local
62 * contributions. Null in serial mode; non-null in MPI mode.
63 */
65
66 /**
67 * Return the correctly typed quantum system snapshot.
68 * Overridden with covariant return in each concrete subtype.
69 */
70 [[nodiscard]] virtual const PlanewaveKohnShamQuantumSystem& quantum_system() const = 0;
71
72 /// Narrow the energies return type to the planewave level.
73 const PlanewaveKohnShamEnergies& energies() const override = 0;
74
75 // ----- Convenience accessors (delegate to quantum_system() and planewave_basis) -----
76
77 [[nodiscard]] int number_of_plane_waves(int kpoint_index) const {
79 }
80 [[nodiscard]] const std::vector<int>& g_vector_indices_at_kpoint(int kpoint_index) const {
82 }
83 [[nodiscard]] Complex
84 wavefunction_coefficient(int kpoint_index, int band_index, int g_vector_index) const {
85 return quantum_system().wavefunction(kpoint_index, band_index, g_vector_index);
86 }
87 [[nodiscard]] Real eigenvalue(int kpoint_index, int band_index) const {
88 return quantum_system().eigenvalue(kpoint_index, band_index);
89 }
90 [[nodiscard]] Real occupation(int kpoint_index, int band_index) const {
92 band_index);
93 }
94 [[nodiscard]] const std::vector<Real>& charge_density_for_spin(int spin_index) const {
95 return charge_density_real[spin_index];
96 }
100 [[nodiscard]] Real spin_degeneracy() const {
102 }
103 [[nodiscard]] int number_of_bands() const {
105 }
106 [[nodiscard]] int number_of_spin_components() const {
108 }
109};
110
111} // namespace q3
const std::vector< int > & g_vector_indices_by_kpoint_index(int kpoint_index) const
Definition init.hpp:259
int number_of_plane_waves_by_kpoint_index(int kpoint_index) const
Definition init.hpp:263
Complex wavefunction(int kpoint_index, int band_index, int g_vector_index) const
Definition init.hpp:99
Real occupation_by_kpoint_state_index_and_band_index(int kpoint_state_index, int band_index) const
Definition init.hpp:127
int number_of_occupied_bands_per_spin() const
Definition init.hpp:156
Real eigenvalue(int kpoint_state_index, int band_index) const
Definition init.hpp:118
Abstract base class for XC functionals.
Definition init.hpp:23
double Real
std::complex< double > Complex
int number_of_occupied_bands_per_spin() const
Definition init.hpp:97
const std::vector< int > & g_vector_indices_at_kpoint(int kpoint_index) const
Definition init.hpp:80
int number_of_plane_waves(int kpoint_index) const
Definition init.hpp:77
Real occupation(int kpoint_index, int band_index) const
Definition init.hpp:90
std::vector< std::vector< Real > > charge_density_real
Definition init.hpp:37
std::vector< Complex > total_potential_g
Definition init.hpp:38
const KPointsGrid * kpoint_grid
Definition init.hpp:56
const XCFunctional * exchange_correlation
Definition init.hpp:54
PlanewaveKohnShamSCFState & operator=(const PlanewaveKohnShamSCFState &)=delete
const PlanewaveKohnShamEnergies & energies() const override=0
Narrow the energies return type to the planewave level.
std::vector< Complex > exchange_correlation_potential_g
Definition init.hpp:50
const Crystal * crystal_structure
Definition init.hpp:55
PlanewaveKohnShamSCFState & operator=(PlanewaveKohnShamSCFState &&)=default
std::vector< std::vector< Real > > real_space_potential
Definition init.hpp:51
virtual const PlanewaveKohnShamQuantumSystem & quantum_system() const =0
const execution::PlanewaveExecutionPolicy * execution_policy
Definition init.hpp:64
int number_of_spin_components() const
Definition init.hpp:106
const PlanewaveBasis * planewave_basis
Definition init.hpp:53
PlanewaveKohnShamSCFState(PlanewaveKohnShamSCFState &&)=default
const std::vector< Real > & charge_density_for_spin(int spin_index) const
Definition init.hpp:94
PlanewaveKohnShamSCFState(const PlanewaveKohnShamSCFState &)=delete
std::vector< std::vector< Complex > > total_potential_g_by_spin
Definition init.hpp:49
Real spin_degeneracy() const
Definition init.hpp:100
Real eigenvalue(int kpoint_index, int band_index) const
Definition init.hpp:87
Complex wavefunction_coefficient(int kpoint_index, int band_index, int g_vector_index) const
Definition init.hpp:84
std::vector< Complex > charge_density_g
Definition init.hpp:36