40 : scf_state_(scf_state) {}
43 int band_index)
const override {
58[[nodiscard]]
inline MeanFieldRecord
61 throw std::runtime_error(
62 "build_mean_field_record: the SCF state is missing planewave_basis, kpoint_grid or "
63 "crystal_structure, so no mean-field record can be built from it.");
83 for (
int atom_index = 0; atom_index < number_of_atoms; atom_index++) {
91 const auto& fft_rho = planewave_basis.
fft_rho();
93 fft_rho.grid_dimension_1(), fft_rho.grid_dimension_2(), fft_rho.grid_dimension_3()};
94 const auto& g_vectors = planewave_basis.
g_vectors();
96 for (
const auto& g_vector : g_vectors) {
108 for (
int kpoint_index = 0; kpoint_index < number_of_kpoints; kpoint_index++) {
110 record.
kpoint_weights.push_back(kpoint_grid[kpoint_index].weight);
114 plane_waves_per_kpoint.end());
122 record.
occupations.resize(number_of_kpoint_states);
123 for (
int state_index = 0; state_index < number_of_kpoint_states; state_index++) {
126 for (
int band_index = 0; band_index < record.
number_of_bands; band_index++) {
128 quantum_system.eigenvalue(state_index, band_index);
130 quantum_system.occupation_by_kpoint_state_index_and_band_index(state_index,
135 record.
band_source = std::make_shared<ScfStateMeanFieldBandSource>(scf_state);
144 for (
size_t spin_index = 0; spin_index < scf_state.
charge_density_real.size(); spin_index++) {
179 quantum_system.require_identity_overlap(
180 "mean_field_export_kleinman_bylander_projectors (BerkeleyGW VKB)");
182 throw std::runtime_error(
183 "mean_field_export_kleinman_bylander_projectors is not available with DFT+U: the "
184 "Hubbard term is a nonlocal potential of its own, which a BerkeleyGW VKB file "
190 int number_of_species =
static_cast<int>(pseudopotential_basis.pseudopotential_set().size());
193 for (
int species_index = 0; species_index < number_of_species; species_index++) {
195 pseudopotential_basis.number_of_projector_channels(species_index);
198 for (
int atom_index = 0; atom_index < number_of_atoms; atom_index++) {
203 for (
int spin_index = 0; spin_index < record.number_of_spin_components; spin_index++) {
204 auto& coefficients_by_atom = record.nonlocal_coefficients[spin_index];
205 coefficients_by_atom.resize(number_of_atoms);
206 for (
int atom_index = 0; atom_index < number_of_atoms; atom_index++) {
207 int species_index = record.atom_species_indices[atom_index];
208 int number_of_channels = record.projectors_per_species[species_index];
209 auto& block = coefficients_by_atom[atom_index];
210 block.resize(
static_cast<size_t>(number_of_channels) * number_of_channels);
211 for (
int channel_j = 0; channel_j < number_of_channels; channel_j++) {
212 for (
int channel_i = 0; channel_i < number_of_channels; channel_i++) {
213 block[
static_cast<size_t>(channel_i) +
214 static_cast<size_t>(channel_j) * number_of_channels] =
215 quantum_system.d_matrix_element(
216 atom_index, species_index, channel_i, channel_j, spin_index);
222 record.projector_source = std::make_shared<ScfStateMeanFieldProjectorSource>(scf_state);
Vector3D convert_from_crystal_to_cartesian(int atom_index) const
int bravais_lattice_index() const
Real two_pi_over_lattice_parameter() const
const Matrix3x3 & reciprocal_lattice_vectors() const
const Matrix3x3 & lattice_vectors() const
int species_type_index(int atom_index) const
int atomic_number(int atom_index) const
int number_of_atoms() const
Real lattice_parameter() const
int number_of_kpoints() const
const std::array< int, 3 > & grid_dimensions() const
const std::array< int, 3 > & grid_shifts() const
const NormConservingPlanewaveBasis & pseudopotential_basis() const
const std::vector< GVector > & g_vectors() const
Real wavefunction_energy_cutoff() const
void rho_r_to_g(const std::vector< Real > &charge_density_real_space, std::vector< Complex > &charge_density_g_space) const
const std::vector< std::vector< int > > & kpoint_g_vector_indices() const
Real charge_density_energy_cutoff() const
const std::vector< int > & kpoint_number_of_plane_waves() const
bool is_gamma_only() const
Complex * wavefunction_band_data(int kpoint_state_index, int band_index)
const Complex * coefficients(int kpoint_state_index, int band_index) const override
ScfStateMeanFieldBandSource(const NormConservingPlanewaveKohnShamSCFState &scf_state)
static std::vector< SymmetryOperation > get_symmetry_operations(const Crystal &crystal, Real symmetry_precision=math::tolerances::default_symmetry_precision)
void add_kleinman_bylander_projectors_to_mean_field_record(MeanFieldRecord &record, const NormConservingPlanewaveKohnShamSCFState &scf_state)
MeanFieldRecord build_mean_field_record(const NormConservingPlanewaveKohnShamSCFState &scf_state)
std::complex< double > Complex
std::vector< Vector3D > kpoint_coordinates
Crystal (fractional) coordinates, one per physical k-point.
std::vector< std::vector< Real > > occupations
Indexed [kpoint_state_index][band_index]; max 1 per (k, spin) state.
std::vector< std::vector< int > > kpoint_g_vector_indices
Per physical k-point, indices into charge_density_miller_indices.
Real wavefunction_energy_cutoff
int number_of_spin_components
std::array< int, 3 > kpoint_grid_shifts
std::vector< SymmetryOperation > symmetry_operations
Matrix3x3 reciprocal_lattice_vectors
std::vector< std::vector< Complex > > charge_density_g
std::vector< std::vector< std::vector< Real > > > nonlocal_coefficients
std::vector< std::vector< Real > > eigenvalues_rydberg
Indexed [kpoint_state_index][band_index]; Rydberg.
std::vector< int > projectors_per_species
Projector channels – one per (β, m) – of each species.
std::vector< Complex > exchange_correlation_potential_g
int bravais_lattice_index
QE ibrav convention; 0 means explicit/free lattice vectors.
Matrix3x3 lattice_vectors
std::vector< std::vector< Complex > > self_consistent_potential_g
std::vector< int > plane_waves_per_kpoint
std::vector< int > atomic_numbers
std::array< int, 3 > fft_grid_dimensions
Charge-density ("dense") FFT grid dimensions.
std::array< int, 3 > kpoint_grid_dimensions
Real charge_density_energy_cutoff
Plane-wave kinetic-energy cutoffs, Rydberg (BGW's ecutrho/ecutwfc).
int number_of_kpoint_states() const
(k-point, spin) state count – the row count of eigenvalues/occupations.
std::shared_ptr< const MeanFieldBandSource > band_source
std::vector< IntegerVector3D > charge_density_miller_indices
std::vector< int > atom_species_indices
0-based species index of each atom, parallel to atomic_numbers.
std::vector< Vector3D > atom_positions_cartesian
Cartesian positions in alat units, parallel to atomic_numbers.
Real two_pi_over_lattice_parameter
std::vector< Real > kpoint_weights
Engine-convention weights; formats renormalize as they require.
const NormConservingPlanewaveKohnShamQuantumSystem & quantum_system() const override
std::vector< HubbardManifold > hubbard_manifolds
DFT+U (Hubbard) resolved manifolds at convergence; empty means no correction is active.
std::vector< std::vector< Real > > charge_density_real
std::vector< Complex > total_potential_g
const KPointsGrid * kpoint_grid
std::vector< Complex > exchange_correlation_potential_g
const Crystal * crystal_structure
int number_of_spin_components() const
const PlanewaveBasis * planewave_basis
std::vector< std::vector< Complex > > total_potential_g_by_spin