#include <init.hpp>
Inheritance diagram for q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator:Additional Inherited Members | |
Public Attributes inherited from q3::KohnShamSCFIterator | |
| KohnShamSCFIteratorConfig | config_ |
| std::string | exchange_correlation_functional_ |
| int | methfessel_paxton_order_ |
| Real | mixing_beta_ |
| int | mixing_history_size_ |
| std::string | mixing_mode_ |
| std::string | mixing_preconditioning_ |
| Real | mixing_q0_ |
| std::string | smearing_ |
| Real | smearing_width_ |
|
inlineexplicit |
|
overridedefault |
|
inlineprotectedvirtual |
Accumulate the per-atom projector overlap coefficients from the bands.
Uses BLAS zgemm to compute all <beta|psi> overlaps in a single call instead of per-projector-per-band zdotc calls. Virtual so PAW can damp the result before it is used.
The coefficients feed two things — the augmentation charge on the grid and, for PAW, the on-site D matrix — and the second closes a loop that the density mixer cannot reach: ρ_ij is recomputed from fresh ψ every step, so its feedback gain is 1 no matter how small the mixing beta. That is harmless while the on-site terms are small, and not harmless for a dataset with a stiff channel, which is why PAW overrides this.
G=0 correction. The 2 Re sum above counts the origin twice, so the rank whose plane-wave list begins with G = 0 removes one copy. The density list cannot answer that: it is complete on every rank, so asking it whether G = 0 comes first says yes on every rank of a shared pool, and each rank without the origin subtracted its first stored plane wave instead.
Band-parallel ranks own disjoint G-vector slabs, so BLAS has produced only each rank's partial <beta|psi>. Complete those amplitudes before forming rho_ij = <psi|beta_i><beta_j|psi>. Reducing rho_ij afterward is not equivalent because it omits cross-rank products. The later reduce_vector remains the separate across-pool sum over distinct k-points.
projector_overlaps is column-major (total_projectors × occupied_bands)
Reimplemented in q3::PawPlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 258 of file init.hpp.
References q3::PlanewavePseudopotentialKohnShamSCFIterator::cached_kleinman_bylander_projectors_, q3::KohnShamSCFIterator::crystal_structure(), q3::blas::dgemm_(), q3::PlanewaveKohnShamSCFIterator::execution_policy_, q3::PlanewaveBasis::gamma_origin_is_local(), q3::PlanewaveBasis::is_gamma_only(), q3::PlanewaveKohnShamSCFIterator::kpoint_grid(), q3::Crystal::number_of_atoms(), q3::PlanewaveKohnShamSCFIterator::number_of_bands_, q3::PlanewaveKohnShamSCFIterator::number_of_kpoint_states(), q3::KPointsGrid::number_of_kpoints(), q3::PlanewaveKohnShamSCFIterator::number_of_plane_waves(), q3::SCFIterator::number_of_spin_components(), q3::PlanewaveKohnShamSCFIterator::occupation(), q3::PlanewaveKohnShamQuantumSystem::occupation_by_kpoint_state_index_and_band_index(), q3::math::tolerances::occupation_threshold, q3::PlanewaveKohnShamSCFIterator::planewave_basis_, projector_overlap_coefficients_, projector_overlap_coefficients_by_spin_, q3::PlanewaveKohnShamSCFIterator::quantum_system_, q3::PlanewavePseudopotentialKohnShamSCFIterator::quantum_system_snapshot_, q3::Matrix< T >::raw(), q3::execution::PlanewaveExecutionPolicy::reduce_vector(), q3::execution::ExecutionPolicy::reduce_within_group(), reset_projector_overlap_coefficients(), q3::Crystal::species_type_index(), q3::PlanewaveKohnShamQuantumSystem::wavefunction_band_data(), and q3::blas::zgemm_().
Referenced by q3::PawPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), and construct_density_from_states().
|
inlineprotected |
Add the compensation charge n̂ to the smooth density, per spin channel.
The augmentation charge is built from ρ_ij, and ρ_ij is spin-resolved, so each channel gets its own n̂ from its own occupancies. That matters far more than it sounds: in a 3d metal almost the entire moment lives inside the augmentation spheres, so how n̂ is divided between the channels is the magnetization.
This used to add one total n̂ and split it by the ratio of the smooth densities, which forces the on-site polarization to match the interstitial polarization — small, and nearly unpolarized. Nickel came out at 1e-4 Bohr magnetons against a PBE moment near 0.6.
projector_overlap_coefficients_by_spin_ is empty only on paths that never accumulated it; falling back to the spin-summed array then reproduces the old single-channel behaviour rather than adding nothing.
Definition at line 474 of file init.hpp.
References cached_augmented_density_g_, q3::UltrasoftPlanewaveEffectivePotential::cached_structure_factors(), q3::KohnShamSCFIterator::charge_density_real_, q3::KohnShamSCFIterator::crystal_structure(), nonlocal_effective_potential_, q3::SCFIterator::number_of_spin_components(), q3::PlanewaveKohnShamSCFIterator::planewave_basis_, projector_overlap_coefficients_, projector_overlap_coefficients_by_spin_, q3::PlanewaveBasis::rho_g_to_r(), q3::PlanewaveBasis::rho_r_to_g(), and ultrasoft_quantum_system().
Referenced by construct_density_from_states().
|
inlineoverrideprotectedvirtual |
Reimplemented from q3::PlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 140 of file init.hpp.
References accumulate_projector_overlaps(), add_augmentation_to_charge_density(), q3::PlanewavePseudopotentialKohnShamSCFIterator::construct_density_from_states(), q3::log::debug(), snapshot_smooth_density(), and q3::PlanewaveKohnShamSCFIterator::warn_if_total_charge_deviates().
Referenced by q3::PawPlanewavePseudopotentialKohnShamSCFIterator::construct_density_from_states().
|
inlineoverrideprotectedvirtual |
Reimplemented from q3::PlanewaveKohnShamSCFIterator.
Definition at line 186 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_.
|
inlineprotected |
Definition at line 93 of file init.hpp.
Referenced by prepare_hamiltonian().
|
inlineprotected |
The nonlocal D matrix is built per spin channel.
D_ij = D_ion + ∫v_eff·Q_ij, and for a spin-polarized system v_eff differs between channels, so D does too. It used to be built once from the spin average and shared: exact for a non-magnetic cell, and for a magnetic one it collapsed the moment — nickel with a PAW dataset converged to 1e-4 Bohr magnetons against a PBE moment near 0.64, which the norm-conserving path reproduces at 0.605. Norm-conserving was never affected because its D_ion is a constant with no v_eff dependence, which is why Q3's LSDA validation — all of it norm-conserving — passed and said nothing about this.
nonlocal_potentials_by_spin() returns one entry per channel, or a single averaged entry when the per-spin copies are unavailable, so the unpolarized path is bit-for-bit what it was. The potential each spin channel's D should be built from.
Falls back to a single entry holding the spin average whenever the per-spin copies are absent, which keeps every non-spin-polarized path and every path that predates them behaving exactly as before.
Definition at line 122 of file init.hpp.
References q3::KohnShamSCFIterator::total_potential_g_, and q3::KohnShamSCFIterator::total_potential_g_by_spin_.
Referenced by prepare_hamiltonian().
|
inlineoverrideprotectedvirtual |
Hook invoked once the initial atomic-superposition charge density is ready.
Default no-op. The ultrasoft subclass overrides it to initialise the smooth density and projector overlap storage.
Reimplemented from q3::PlanewaveKohnShamSCFIterator.
Definition at line 196 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_, charge_density_real_smooth_, q3::SCFIterator::number_of_spin_components(), and reset_projector_overlap_coefficients().
Referenced by q3::PawPlanewavePseudopotentialKohnShamSCFIterator::on_charge_density_initialized().
|
inlineoverrideprotectedvirtual |
Reimplemented from q3::KohnShamSCFIterator.
Definition at line 128 of file init.hpp.
References q3::UltrasoftPlanewaveEffectivePotential::compute_by_spin(), q3::KohnShamSCFIterator::crystal_structure(), mutable_ultrasoft_quantum_system(), nonlocal_effective_potential_, nonlocal_potentials_by_spin(), q3::PlanewaveKohnShamSCFIterator::planewave_basis_, q3::UltrasoftPlanewaveKohnShamQuantumSystem::set_nonlocal_effective_potential(), and ultrasoft_quantum_system().
Referenced by q3::PawPlanewavePseudopotentialKohnShamSCFIterator::prepare_hamiltonian().
|
inlineoverridevirtual |
Overlap coefficients ⟨β_i|ψ_nk⟩ at convergence.
Returns an empty matrix for norm-conserving calculations. The ultrasoft iterator overrides this to return the accumulated coefficients.
Reimplemented from q3::PlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 34 of file init.hpp.
References projector_overlap_coefficients_.
|
inlineprotected |
Allocate and zero the per-atom projector overlap matrix when augmentation is required.
Definition at line 216 of file init.hpp.
References q3::Matrix< T >::assign(), q3::KohnShamSCFIterator::crystal_structure(), q3::Crystal::number_of_atoms(), q3::Crystal::number_of_species(), q3::SCFIterator::number_of_spin_components(), projector_overlap_coefficients_, projector_overlap_coefficients_by_spin_, and q3::PlanewavePseudopotentialKohnShamSCFIterator::quantum_system_snapshot_.
Referenced by accumulate_projector_overlaps(), and on_charge_density_initialized().
|
inlineoverrideprotectedvirtual |
Reimplemented from q3::PlanewaveKohnShamSCFIterator.
Definition at line 209 of file init.hpp.
References charge_density_real_smooth_, convergence_output_density_smooth_, and q3::KohnShamSCFIterator::restore_density_at_convergence().
|
inlineoverridevirtual |
Assemble and return a snapshot of the converged SCF state.
The ultrasoft subclass overrides this to inject the effective D-matrix into the snapshot.
Copy the converged effective D-matrix into the snapshot's owned storage. Without this, d_matrix_element() falls back to bare_d_matrix_element() which uses channel indices (0..number_of_channels-1) on the radial d_ion_matrix (size nbeta × nbeta), causing an out-of-bounds access → SIGSEGV for USPP.
Share the existing quantum system snapshot instead of creating a new one. The PP basis (beta tables, local potential, core charge) is expensive to initialize, and we only need a read-only view for forces/stress/IO.
Reimplemented from q3::PlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 38 of file init.hpp.
References nonlocal_effective_potential_, q3::NormConservingPlanewaveKohnShamSCFState::projector_overlap_coefficients, projector_overlap_coefficients_, q3::NormConservingPlanewaveKohnShamSCFState::projector_overlap_coefficients_by_spin, projector_overlap_coefficients_by_spin_, q3::NormConservingPlanewaveKohnShamSCFState::quantum_system_snapshot_, q3::PlanewavePseudopotentialKohnShamSCFIterator::result(), and q3::UltrasoftPlanewaveKohnShamQuantumSystem::set_nonlocal_effective_potential().
|
inlineoverrideprotectedvirtual |
Reimplemented from q3::PlanewaveKohnShamSCFIterator.
Definition at line 204 of file init.hpp.
References charge_density_real_smooth_, convergence_output_density_smooth_, and q3::KohnShamSCFIterator::snapshot_output_density().
|
inlineprotected |
Definition at line 235 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_, charge_density_real_smooth_, and q3::SCFIterator::number_of_spin_components().
Referenced by construct_density_from_states().
|
inlineoverrideprotectedvirtual |
If augmentation cached the G-space density, use the G-space symmetrizer to avoid a redundant R→G FFT. This saves ~100ms per iteration.
Reimplemented from q3::PlanewaveKohnShamSCFIterator.
Definition at line 169 of file init.hpp.
References cached_augmented_density_g_, q3::KohnShamSCFIterator::charge_density_real_, q3::PlanewaveKohnShamSCFIterator::density_symmetrizer_, q3::SCFIterator::number_of_spin_components(), q3::PlanewaveKohnShamSCFIterator::planewave_basis_, q3::KohnShamSCFIterator::symmetrize_density(), and q3::PlanewaveChargeDensitySymmetrizer::symmetrize_from_g_space().
|
inlineoverrideprotectedvirtual |
Hook for representations that keep an auxiliary density (e.g. the smooth pre-augmentation density of ultrasoft pseudopotential_set). No-op by default.
Reimplemented from q3::KohnShamSCFIterator.
Definition at line 190 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_, charge_density_real_smooth_, and q3::SCFIterator::number_of_spin_components().
|
inlineprotected |
Access the ultrasoft quantum system (downcast).
Definition at line 88 of file init.hpp.
References q3::PlanewavePseudopotentialKohnShamSCFIterator::quantum_system_snapshot_.
Referenced by add_augmentation_to_charge_density(), and prepare_hamiltonian().
|
protected |
Cached G-space augmented density from construct_density_from_states. Used by symmetrize_density to avoid a redundant R→G FFT.
Definition at line 83 of file init.hpp.
Referenced by add_augmentation_to_charge_density(), and symmetrize_density().
|
protected |
Smooth (pre-augmentation) charge density used by ultrasoft pseudopotential_set, plus its converged snapshot restored at self-consistency.
Definition at line 76 of file init.hpp.
Referenced by on_charge_density_initialized(), restore_density_at_convergence(), snapshot_output_density(), snapshot_smooth_density(), and synchronize_smooth_density_from_mixed().
|
protected |
Definition at line 77 of file init.hpp.
Referenced by restore_density_at_convergence(), and snapshot_output_density().
|
protected |
Definition at line 70 of file init.hpp.
Referenced by add_augmentation_to_charge_density(), prepare_hamiltonian(), and result().
|
protected |
The same coefficients per spin channel, un-summed.
projector_overlap_coefficients_ above is accumulated over kpoint_index_state, which folds spin in, so by the time it is read the two channels are indistinguishable. That is what the augmentation charge on the grid wants — it is a total density — but the PAW one-center terms need ρ↑ and ρ↓ apart, because exchange-correlation is nonlinear in the spin density. Kept as a parallel array rather than reshaping the primary one so every existing ultrasoft consumer is untouched.
Definition at line 69 of file init.hpp.
Referenced by accumulate_projector_overlaps(), q3::PawPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), add_augmentation_to_charge_density(), q3::PawPlanewavePseudopotentialKohnShamSCFIterator::one_center_occupations(), reset_projector_overlap_coefficients(), and result().