#include <init.hpp>
Inheritance diagram for q3::PlanewaveKohnShamSCFIterator:Public Member Functions | |
| PlanewaveKohnShamSCFIterator (KohnShamSCFIteratorConfig config) | |
| ~PlanewaveKohnShamSCFIterator () override=default | |
| Real | eigenvalue (int kpoint_index, int band_index) const |
| Matrix< Real > | eigenvalues () const |
| const execution::PlanewaveExecutionPolicy & | execution_policy () const |
| const std::vector< std::vector< int > > & | g_vector_indices () const |
| const std::vector< int > & | g_vector_indices (int kpoint_index) const |
| Matrix< Real > | global_eigenvalues () const |
| const std::vector< std::vector< Real > > & | kinetic_energy_squared () const |
| const KPointsGrid & | kpoint_grid () const |
| void | load_quantum_system (const PlanewaveKohnShamQuantumSystem &system) |
| bool | loaded_charge_density_fits_grid () const |
| const std::optional< Magnetization > & | magnetization () const |
| int | number_of_bands () const override |
| Real | number_of_electrons () const override |
| int | number_of_kpoint_states () const override |
| int | number_of_occupied_bands_per_spin () const |
| const std::vector< int > & | number_of_plane_waves () const |
| int | number_of_plane_waves (int kpoint_index) const |
| Real | occupation (int kpoint_index, int band_index) const |
| const PlanewaveBasis & | planewave_basis () const |
| void | preload_charge_density () |
| void | preload_single_particle_states () |
| const PlanewaveKohnShamQuantumSystem & | quantum_system () const |
| virtual void | release_scf_workspace () |
| virtual NormConservingPlanewaveKohnShamSCFState | result () const =0 |
| void | scale_loaded_charge_density_to_electron_count () |
| Rescale the loaded density so it integrates to this system's electron count. | |
| void | set_diagonalizer (std::unique_ptr< PlanewaveDiagonalizer > diagonalizer) |
| void | set_owned_execution_policy (std::unique_ptr< execution::PlanewaveExecutionPolicy > policy) |
| void | set_owned_kpoint_grid (KPointsGrid kpoint_grid) |
| Transfer ownership of a KPointsGrid into this iterator. | |
| Real | spin_degeneracy () const |
| Complex | wavefunction (int kpoint_index, int band_index, int g_vector_index) const |
Public Member Functions inherited from q3::KohnShamSCFIterator | |
| KohnShamSCFIterator (KohnShamSCFIteratorConfig config) | |
| ~KohnShamSCFIterator () override=default | |
| const std::vector< Real > & | charge_density_for_spin (int spin_index) const |
| const std::vector< Complex > & | charge_density_g () const |
| const std::vector< Real > & | charge_density_real () const |
| Crystal & | crystal_structure () const |
| virtual const KohnShamEnergies & | energies () const =0 |
| virtual KohnShamEnergies & | energies_mutable ()=0 |
| const XCFunctional & | exchange_correlation () const |
| const std::vector< Complex > & | exchange_correlation_potential_g () const |
| void | load_charge_density (std::vector< std::vector< Real > > charge_density) |
| void | load_effective_potential (std::vector< std::vector< Real > > effective_potential) |
| void | offer_starting_charge_density (std::vector< std::vector< Real > > charge_density) |
| const std::vector< Real > & | potential_for_spin (int spin_index) const |
| const std::vector< Real > & | real_space_potential () const |
| const std::vector< ScfIterationRecord > & | scf_history () const |
| Real | total_energy () const override |
| const std::vector< Complex > & | total_potential_g () const |
Public Member Functions inherited from q3::SCFIterator | |
| SCFIterator (SCFIteratorConfig config) | |
| virtual | ~SCFIterator ()=default |
| bool | is_converged () const |
| int | iteration () const |
| int | number_of_spin_components () const |
| void | run () |
| void | set_convergence_threshold (Real threshold) |
| Set the SCF convergence threshold (in Ry). | |
| void | set_maximum_iterations (int maximum_iterations) |
| Set the maximum number of SCF iterations. | |
| void | set_owned_crystal (Crystal crystal) |
| Transfer ownership of a Crystal into this iterator. | |
| const std::vector< Real > & | total_energy_history_in_ry () const |
| virtual void | write_checkpoints (const std::string &output_directory, const std::string &prefix) const |
Protected Member Functions | |
| void | allocate_electronic_states () |
| void | build_kpoint_plane_wave_data () |
| Real | compute_delta_escf_correction () const override |
| Real | compute_density_residual (const std::vector< std::vector< Real > > &input_density_for_mixing) const override |
| Real | compute_double_counting_correction () const override |
| virtual void | compute_effective_potential_from_density ()=0 |
| void | compute_energy_components () override |
| Real | compute_local_residual_between (const std::vector< std::vector< Real > > &density_in, const std::vector< std::vector< Real > > &density_out) const |
| Real | compute_number_of_electrons () const |
| Real | compute_residual_between (const std::vector< std::vector< Real > > &density_in, const std::vector< std::vector< Real > > &density_out) const |
| void | construct_density_from_states () override |
| virtual const std::vector< Complex > & | core_charge_density_g () const =0 |
| Real | effective_charge_density_energy_cutoff () const |
| Real | hartree_metric_prefactor () const |
| void | initialize_representation () override |
| void | initiate_mixer () override |
| std::vector< std::vector< Real > > | input_density_for_mixing () const override |
| virtual const std::vector< Complex > & | local_ionic_potential_g () const =0 |
| void | log_representation_summary () const |
| Real | magnetization_metric_weight () const |
| void | mix_density (const std::vector< std::vector< Real > > &input_density_for_mixing) override |
| virtual void | on_charge_density_initialized () |
| const PlanewaveKohnShamEnergies & | planewave_energies () const |
| PlanewaveKohnShamEnergies & | planewave_energies_mutable () |
| void | report_convergence_details () override |
| void | report_first_iteration_details () override |
| int | resolve_number_of_bands () const |
| void | restore_density_at_convergence () override |
| void | set_diagonalization_tolerance (int iteration) override |
| void | set_diagonalizer_tolerance (Real tolerance) override |
| void | snapshot_output_density () override |
| void | symmetrize_density () override |
| void | update_effective_potential () override |
| void | update_occupations () override |
| void | warn_if_total_charge_deviates () const |
Protected Member Functions inherited from q3::KohnShamSCFIterator | |
| const KohnShamSCFIteratorConfig & | config () const |
| Real | diagonalization_threshold () const |
| void | finalize () override |
| void | initialize () override |
| Base implementation prints the SCF banner. Children call SCFIterator::initialize() last. | |
| virtual void | initialize_charge_density ()=0 |
| virtual void | initialize_single_particle_states ()=0 |
| bool | is_iteration_converged () const override |
| void | log_iteration_energy (Real delta_energy) |
| Single source of truth for the per-iteration energy/convergence log line. | |
| void | perform_iteration () override |
| virtual void | prepare_hamiltonian () |
| void | report_convergence () override |
| void | report_iteration () override |
| void | report_non_convergence () override |
| virtual void | solve_single_particle_states ()=0 |
| virtual void | synchronize_smooth_density_from_mixed () |
Protected Member Functions inherited from q3::SCFIterator | |
| virtual void | iterate () |
| Main iteration loop. | |
| virtual void | report () |
| Report convergence or non-convergence after iterate() finishes. | |
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 |
Definition at line 54 of file init.hpp.
References q3::KohnShamSCFIterator::config_, q3::KohnShamSCFIteratorConfig::execution_policy, and execution_policy_.
|
overridedefault |
|
inlineprotected |
Definition at line 1281 of file init.hpp.
References q3::PlanewaveKohnShamQuantumSystem::allocate_electronic_states(), q3::PlanewaveBasis::kpoint_number_of_plane_waves(), planewave_basis_, and quantum_system_.
Referenced by initialize_representation().
|
inlineprotected |
Safety: if band parallelism gave any rank 0 plane waves at any k-point, fall back to replicated mode for ALL ranks in the pool. This prevents zero-dimension BLAS crashes and asymmetric MPI reductions.
The FFT grids were built during generate(), while the group was still distributed, so they are MPI grids whose transforms are collective across the band group. Disabling band distribution turns every group reduction into a no-op and leaves each rank holding a replicated copy of the coefficients – at which point ranks legitimately take different paths through Davidson while those collective transforms still expect every one of them. The first divergence blocks inside FFTW-MPI's transpose.
Rebuild the basis now that group_size() is 1, so the factory hands back serial grids each rank drives alone. This repeats the FFT planning generate() already did, which is the price of discovering the empty slab only after the grids exist.
Definition at line 1231 of file init.hpp.
References q3::execution::QuantumSystemExecutionPolicy::band_size(), q3::KohnShamSCFIterator::config_, q3::KohnShamSCFIterator::crystal_structure(), q3::execution::PlanewaveExecutionPolicy::disable_band_distribution(), effective_charge_density_energy_cutoff(), execution_policy_, q3::PlanewaveBasis::generate(), q3::PlanewaveBasis::initialize_kpoint_data(), q3::PlanewaveBasis::is_gamma_only(), kpoint_grid(), q3::PlanewaveBasis::kpoint_number_of_plane_waves(), planewave_basis_, q3::execution::PlanewaveExecutionPolicy::reduce_band_group_scalar_min(), replicated_plane_wave_fallback_active_, q3::KohnShamSCFIteratorConfig::use_deterministic_fft_planning, q3::KohnShamSCFIteratorConfig::use_exact_wavefunction_grid, q3::log::warn(), and wavefunction_energy_cutoff_.
Referenced by initialize_representation().
|
inlineoverrideprotectedvirtual |
Compute the first-order energy correction for evaluating E_Hartree and E_XC at the mixed density instead of the output density.
delta_escf = -Σ_r (ρ_mixed(r) - ρ_out(r)) · V_Hxc^mixed(r) · (Ω/N)
Matches QE's SCF-correction term of the same name. Must be called AFTER update_effective_potential() has been applied to the mixed density and AFTER snapshot_output_density() has saved the output density.
Same slab decomposition as compute_double_counting_correction: partial real-space integral over local_grid_points, requires band-communicator reduction when multiple ranks share the pool.
After mixing, charge_density_real_ = rho_mixed convergence_output_density_ = rho_out (saved by snapshot_output_density()) real_space_potential_ = V_Hxc from rho_mixed (set by update_effective_potential())
Implements q3::KohnShamSCFIterator.
Definition at line 950 of file init.hpp.
References cached_local_ionic_potential_real_, q3::Crystal::cell_volume(), q3::KohnShamSCFIterator::charge_density_real_, convergence_output_density_, q3::KohnShamSCFIterator::crystal_structure(), execution_policy_, q3::PlanewaveBasis::fft_rho(), q3::FFTGrid::local_grid_points(), q3::SCFIterator::number_of_spin_components(), planewave_basis_, q3::KohnShamSCFIterator::real_space_potential_, q3::execution::PlanewaveExecutionPolicy::reduce_within_pool_scalar(), and q3::FFTGrid::total_grid_points().
|
inlineoverrideprotectedvirtual |
Implements q3::KohnShamSCFIterator.
Definition at line 783 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_, compute_residual_between(), and input_density_for_mixing().
|
inlineoverrideprotectedvirtual |
Each rank integrates only its local real-space slabs (FFTW-MPI slab decomposition). With 1-rank-per-pool the integral is complete; with multiple ranks per pool it must be summed across the band communicator.
Implements q3::KohnShamSCFIterator.
Reimplemented in q3::PlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 925 of file init.hpp.
References cached_local_ionic_potential_real_, q3::Crystal::cell_volume(), q3::KohnShamSCFIterator::charge_density_real_, q3::KohnShamSCFIterator::crystal_structure(), execution_policy_, q3::PlanewaveBasis::fft_rho(), q3::FFTGrid::local_grid_points(), q3::SCFIterator::number_of_spin_components(), planewave_basis_, q3::KohnShamSCFIterator::real_space_potential_, q3::execution::PlanewaveExecutionPolicy::reduce_within_pool_scalar(), and q3::FFTGrid::total_grid_points().
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::compute_double_counting_correction().
|
protectedpure virtual |
Compute the effective potential from the current charge density. Must set charge_density_g_, real_space_potential_, total_potential_g_, exchange_correlation_potential_g_, and energy components (hartree, xc).
Implemented in q3::PlanewavePseudopotentialKohnShamSCFIterator.
Referenced by update_effective_potential().
|
inlineoverrideprotectedvirtual |
Compute sub-components (e.g. band energy, entropy) needed for total(). Default no-op; override in representations that compute eagerly.
Reimplemented from q3::KohnShamSCFIterator.
Definition at line 981 of file init.hpp.
References q3::KohnShamEnergies::band_energy, q3::KohnShamSCFIterator::energies_mutable(), energy_calculator_, execution_policy_, number_of_bands_, q3::SCFIterator::number_of_spin_components(), planewave_energies_mutable(), q3::execution::PlanewaveExecutionPolicy::reduce_scalar(), and q3::PlanewaveKohnShamEnergies::smearing_entropy_contribution.
|
inlineprotected |
This rank's own (unsynchronized) Hartree-metric residual between two charge densities.
Uses only smooth G-vectors (up to number_of_smooth_g_vectors_), matching QE, which measures dr2 as the metric dot product of (ρ_out − ρ_in) over the smooth G-vector count only. Subclasses (e.g. ultrasoft) may call this with smooth-only densities to avoid augmentation contamination. Never branch on this value directly under k-point-pool MPI – go through compute_residual_between so all pools agree (see its docstring).
LSDA: measure the total density Δ(ρ↑+ρ↓) with the Hartree metric and the magnetization Δ(ρ↑−ρ↓) with a constant metric that INCLUDES G=0 (QE's density-dot-product convention). A per-channel Hartree metric would miss a uniform electron transfer between the spin channels — it lives purely in the magnetization's G=0 component — and report convergence while the moment is still relaxing.
Definition at line 856 of file init.hpp.
References q3::PlanewaveBasis::first_nonzero_g_index(), q3::PlanewaveBasis::g_vectors(), hartree_metric_prefactor(), q3::PlanewaveBasis::is_gamma_only(), magnetization_metric_weight(), q3::PlanewaveBasis::number_of_g_vectors(), number_of_smooth_g_vectors_, q3::SCFIterator::number_of_spin_components(), planewave_basis_, and q3::PlanewaveBasis::rho_r_to_g().
Referenced by compute_residual_between().
|
inlineprotected |
total_charge follows QE's tot_charge convention: positive = electrons removed (cationic). The Ewald ion-ion sum and the Hartree G=0 skip are both keyed only to the ionic charge (see ewald_summation.hpp), so no separate compensating-background term is needed here – only the electron count itself changes.
Definition at line 1167 of file init.hpp.
References q3::KohnShamSCFIterator::config(), q3::KohnShamSCFIterator::crystal_structure(), q3::Crystal::number_of_atoms(), q3::KohnShamSCFIteratorConfig::total_charge, and q3::Crystal::valence_charge().
Referenced by initialize_representation().
|
inlineprotected |
Compute the Hartree-metric density residual between two charge densities, synchronized across k-point pools.
The raw residual (see compute_local_residual_between below) is computed independently on every rank from that rank's own rho_r_to_g transforms. FFTW plans are timing-selected per rank (FFTW_MEASURE), so bit-identical input densities yield bit-DIFFERENT residuals on different pool ranks – measured on a 4-pool Ni LSDA+smearing run: last-bit (~1e-15 relative) divergence already at iteration 1, amplified through the nonlinear mixing-history feedback to factors of 2-30x near convergence (the residual tends to zero while the per-rank noise it is measured against does not). This residual gates three branches that change the inter-pool collective call sequence: the SCF loop exit (is_iteration_converged), the skip-mixing early return, and the first-iteration re-diagonalization. If ranks decide those branches differently, their Fermi-bisection / charge-density-Allreduce / force-stress collectives pair up out of order across pools: MPI_ERR_TRUNCATE when the mismatched calls have different message sizes, silently corrupted totals when they happen to match. Reducing with MPI_MAX makes every rank branch on the same value and is conservative – the SCF stops only when the slowest pool's estimate has converged. (Within a pool no synchronization is needed: band ranks compute the residual from pool-collectively-transformed, replicated G-space data, so they already agree bitwise.)
Definition at line 836 of file init.hpp.
References compute_local_residual_between(), execution_policy_, q3::execution::PlanewaveExecutionPolicy::number_of_pools(), and q3::execution::PlanewaveExecutionPolicy::reduce_scalar_max().
Referenced by compute_density_residual().
|
inlineoverrideprotectedvirtual |
Implements q3::KohnShamSCFIterator.
Reimplemented in q3::PlanewavePseudopotentialKohnShamSCFIterator, and q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 768 of file init.hpp.
References charge_density_accumulator_, q3::KohnShamSCFIterator::charge_density_real_, q3::KohnShamSCFIterator::crystal_structure(), execution_policy_, number_of_bands_, q3::SCFIterator::number_of_spin_components(), and q3::execution::PlanewaveExecutionPolicy::reduce_charge_density().
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::construct_density_from_states().
|
protectedpure virtual |
Return the core charge density in reciprocal space.
Implemented in q3::PlanewavePseudopotentialKohnShamSCFIterator.
|
inlineprotected |
Definition at line 1162 of file init.hpp.
References charge_density_energy_cutoff_, and wavefunction_energy_cutoff_.
Referenced by build_kpoint_plane_wave_data(), initialize_representation(), initiate_mixer(), and log_representation_summary().
|
inline |
Access a single eigenvalue ε_{k,n} (Ry).
Definition at line 265 of file init.hpp.
References q3::PlanewaveKohnShamQuantumSystem::eigenvalue(), and quantum_system_.
Access eigenvalues as a Matrix (for compatibility).
Definition at line 237 of file init.hpp.
References q3::PlanewaveKohnShamQuantumSystem::eigenvalues_matrix(), and quantum_system_.
Referenced by q3::assemble_global_eigenvalues_at_kpoints(), and global_eigenvalues().
|
inline |
Definition at line 119 of file init.hpp.
References execution_policy_.
Referenced by q3::assemble_global_eigenvalues_at_kpoints(), q3::assemble_global_kpoint_state_blocks(), q3::internal::build_wannier_interface_record(), q3::capture_interpolation_record(), q3::SelfConsistentFieldFlavor::run_calculation(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::valence_exchange_correlation_potential_g_of().
|
inline |
G-vector index mapping for all k-points: g_vector_indices[k][i] → global G-vector index.
Definition at line 280 of file init.hpp.
References q3::PlanewaveBasis::kpoint_g_vector_indices(), and planewave_basis_.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::accumulate_hubbard_occupation_and_potential(), q3::internal::build_wannier_interface_record(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), q3::PlanewavePseudopotentialKohnShamSCFIterator::setup_hubbard(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::solve_single_particle_states().
|
inline |
G-vector indices for a specific k-point.
Definition at line 308 of file init.hpp.
References q3::PlanewaveBasis::g_vector_indices_by_kpoint_index(), and planewave_basis_.
The eigenvalues of every k-point state in the run, in global order (Ry).
eigenvalues() holds only this pool's k-point states. The rows here are spin-major over the global grid, as a serial run's are. Collective under MPI: every rank must call it.
Definition at line 248 of file init.hpp.
References q3::execution::PlanewaveExecutionPolicy::assemble_global_kpoint_state_data(), q3::Matrix< T >::cols(), eigenvalues(), execution_policy_, kpoint_grid(), number_of_bands(), q3::KPointsGrid::number_of_kpoints(), q3::SCFIterator::number_of_spin_components(), and q3::Matrix< T >::raw().
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::write_checkpoints().
|
inlineprotected |
Hartree-metric prefactor e² · 4π / tpiba² · V/2. The per-G charge-channel metric weight is this divided by the dimensionless (miller-basis) |G|². Single source for both the mixer environment and the SCF dr2.
Definition at line 794 of file init.hpp.
References q3::Crystal::cell_volume(), q3::KohnShamSCFIterator::crystal_structure(), q3::constants::electron_charge_squared_rydberg, q3::constants::four_pi, and q3::Crystal::two_pi_over_lattice_parameter_squared().
Referenced by compute_local_residual_between(), and initiate_mixer().
|
inlineoverrideprotectedvirtual |
Detect gamma-only: single k-point at Γ = (0,0,0) with no shift. This enables half-sphere G-vector storage for ~2× speedup.
Under a shared pool the half sphere is rebuilt inside every transform from each G and its negative, so the FFT layout has to keep the two on one rank. The stick grid does; the slab grid it replaced did not, which is what used to force this off under MPI. The grid is asked once it exists, below, rather than assumed here.
K-points are already distributed by the factory (set_owned_kpoint_grid) and protected by the owned_kpoint_grid_.has_value() guard above.
Implements q3::KohnShamSCFIterator.
Reimplemented in q3::PlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 452 of file init.hpp.
References allocate_electronic_states(), build_kpoint_plane_wave_data(), q3::PlanewaveChargeDensitySymmetrizer::build_shells(), charge_density_accumulator_, q3::KohnShamSCFIteratorConfig::charge_density_energy_cutoff, charge_density_energy_cutoff_, q3::FFTGrid::co_locates_mirrors(), q3::Crystal::compute_derived_quantities(), q3::compute_ewald(), compute_number_of_electrons(), q3::KohnShamSCFIterator::config(), q3::KohnShamSCFIterator::config_, q3::create_planewave_diagonalizer(), q3::KohnShamSCFIterator::crystal_structure(), density_symmetrizer_, q3::KohnShamSCFIteratorConfig::diagonalization_method, diagonalization_method_, diagonalizer_, q3::KohnShamSCFIteratorConfig::disable_symmetry, effective_charge_density_energy_cutoff(), energy_calculator_, q3::PlanewaveKohnShamEnergies::ewald_energy, execution_policy_, fermi_energy_calculator_, q3::PlanewaveBasis::fft_wave(), q3::PlanewaveBasis::generate(), q3::KPointsGrid::grid_dimensions(), q3::KPointsGrid::grid_shifts(), q3::log::info(), q3::ProfilingCounters::instance(), q3::KohnShamSCFIteratorConfig::kpoint_grid, kpoint_grid(), kpoint_grid_, q3::QuantumSystem< QuantumStateType >::load_quantum_system(), log_representation_summary(), q3::ProfilingCounters::log_resident_checkpoint(), q3::KohnShamSCFIteratorConfig::number_of_bands, number_of_bands_, number_of_electrons_, q3::SCFIterator::number_of_spin_components(), owned_execution_policy_, planewave_basis_, planewave_energies_mutable(), q3::QuantumSystem< QuantumStateType >::preloaded_quantum_system_, quantum_system_, resolve_number_of_bands(), q3::KohnShamSCFIterator::smearing_scheme_, q3::KohnShamSCFIteratorConfig::use_deterministic_fft_planning, q3::KohnShamSCFIteratorConfig::use_exact_wavefunction_grid, q3::KohnShamSCFIteratorConfig::wavefunction_energy_cutoff, and wavefunction_energy_cutoff_.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_representation().
|
inlineoverrideprotectedvirtual |
Same metric definitions as the SCF dr2 (see hartree_metric_prefactor / magnetization_metric_weight) so mixer-internal norms and the SCF convergence check agree.
The residual preconditioner. |G|² is carried in bohr⁻² – the stored magnitude is in units of (2π/a)² – because every preconditioner compares it against a screening wavevector in those units.
Compute the number of smooth G-vectors for dual-grid mixing (QE convention). The smooth cutoff is 4*ecutwfc (the norm-conserving default density cutoff). G-vectors above this cutoff get simple linear mixing instead of Broyden, keeping noisy high-frequency augmentation artifacts out of the Broyden subspace.
Count G-vectors within the smooth cutoff G-vectors are sorted by magnitude, so we can stop when we exceed the cutoff
Zero metric weights for hard G-vectors so the Gram matrix and projections naturally use only smooth G-vectors, matching QE's density dot product, which is truncated at the smooth G-vector count.
Implements q3::KohnShamSCFIterator.
Definition at line 558 of file init.hpp.
References q3::MixerEnvironment::charge_metric_weights, q3::PreconditionerFactory::create(), q3::KohnShamSCFIterator::crystal_structure(), effective_charge_density_energy_cutoff(), execution_policy_, q3::PlanewaveBasis::first_nonzero_g_index(), q3::MixerEnvironment::first_nonzero_g_index, q3::PreconditionerEnvironment::first_nonzero_g_index, q3::PreconditionerEnvironment::g_squared, q3::PlanewaveBasis::g_vectors(), q3::MixerEnvironment::global_reduce, q3::PreconditionerEnvironment::global_reduce, hartree_metric_prefactor(), q3::log::info(), q3::PlanewaveBasis::is_gamma_only(), q3::MixerEnvironment::is_gamma_only, q3::MixerEnvironment::magnetization_metric_weight, magnetization_metric_weight(), q3::KohnShamSCFIterator::mixer_, q3::KohnShamSCFIterator::mixing_preconditioning_, q3::KohnShamSCFIterator::mixing_q0_, q3::PlanewaveBasis::number_of_g_vectors(), q3::MixerEnvironment::number_of_smooth_g_vectors, number_of_smooth_g_vectors_, planewave_basis_, q3::MixerEnvironment::preconditioner, q3::PreconditionerEnvironment::q0_squared, q3::execution::PlanewaveExecutionPolicy::reduce_within_pool_vector(), q3::PlanewaveBasis::rho_g_to_r(), q3::PlanewaveBasis::rho_r_to_g(), q3::MixerEnvironment::to_real_space, q3::PreconditionerEnvironment::to_real_space, q3::MixerEnvironment::to_reciprocal_space, q3::PreconditionerEnvironment::to_reciprocal_space, q3::Crystal::two_pi_over_lattice_parameter_squared(), and wavefunction_energy_cutoff_.
|
inlineoverrideprotectedvirtual |
Implements q3::KohnShamSCFIterator.
Reimplemented in q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 662 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_.
Referenced by compute_density_residual(), and mix_density().
|
inline |
Kinetic energies |k+G|² for all k-points.
Definition at line 287 of file init.hpp.
References q3::PlanewaveBasis::kpoint_kinetic_energy_squared(), and planewave_basis_.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::solve_single_particle_states().
|
inline |
Access the k-point grid.
Definition at line 209 of file init.hpp.
References kpoint_grid_.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::accumulate_hubbard_occupation_and_potential(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), q3::assemble_global_eigenvalues_at_kpoints(), q3::assemble_global_kpoint_state_blocks(), build_kpoint_plane_wave_data(), q3::internal::build_wannier_interface_record(), global_eigenvalues(), initialize_representation(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), log_representation_summary(), number_of_kpoint_states(), report_convergence_details(), q3::PlanewavePseudopotentialKohnShamSCFIterator::result(), set_owned_kpoint_grid(), q3::PlanewavePseudopotentialKohnShamSCFIterator::setup_hubbard(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::solve_single_particle_states().
|
inline |
Set the preloaded quantum system snapshot.
Definition at line 129 of file init.hpp.
References q3::QuantumSystem< QuantumStateType >::load_quantum_system(), and quantum_system_.
|
inline |
Whether the loaded density has this run's spin components and this rank's share of its charge-density grid. Every rank of a run reads the same saved file, so the answer is the same on every rank: a whole grid fits ranks that each hold one, and no rank of a pool split into slabs.
Definition at line 153 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_, q3::PlanewaveBasis::fft_rho(), q3::FFTGrid::local_grid_points(), q3::SCFIterator::number_of_spin_components(), and planewave_basis_.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_charge_density().
|
protectedpure virtual |
Return the local ionic potential in reciprocal space.
Implemented in q3::PlanewavePseudopotentialKohnShamSCFIterator.
Referenced by update_effective_potential().
|
inlineprotected |
The irreducible count, not this pool's share. kpoint_grid() is the distributed grid, so with 8 pools a 60-k-point calculation reported 8 here – next to an "IBZ reduction ... -> 60 k-points" line two rows above, which made one of the two look wrong.
Derived from the same assembly the convergence report uses, with a one-value-per-state payload: its return size is the global state count, so this costs an Allreduce of a few dozen doubles once per run. The serial policy returns the input unchanged, which gives the local count – and in serial the local count IS the global one.
Each pool holds only its local k-points, so the local max may be less than the global max. Reduce across pools to get the true maximum.
Ranks per pool, not band_size(). The two agree for the reciprocal-space split, but band_size() is deliberately 1 once bands are distributed – reporting it there would claim one rank per pool on a run using four.
Definition at line 1285 of file init.hpp.
References q3::execution::PlanewaveExecutionPolicy::assemble_global_kpoint_state_data(), q3::execution::ExecutionPolicy::band_distribution_size(), q3::PlanewaveKohnShamSCFSetupSummary::band_group_size, q3::PlanewaveKohnShamSCFSetupSummary::bands_are_distributed, q3::Crystal::cell_volume(), q3::PlanewaveKohnShamSCFSetupSummary::cell_volume, q3::PlanewaveKohnShamSCFSetupSummary::charge_density_energy_cutoff, q3::KohnShamSCFIterator::config(), q3::KohnShamSCFIterator::crystal_structure(), q3::KohnShamSCFIteratorConfig::davidson_basis_expansion_factor, q3::PlanewaveKohnShamSCFSetupSummary::davidson_basis_expansion_factor, q3::PlanewaveKohnShamSCFSetupSummary::density_symmetrization_active, density_symmetrizer_, diagonalization_method_, diagonalizer_, q3::PlanewaveKohnShamSCFSetupSummary::diagonalizer_name, effective_charge_density_energy_cutoff(), q3::PlanewaveKohnShamSCFSetupSummary::ewald_energy, q3::PlanewaveKohnShamEnergies::ewald_energy, q3::KohnShamSCFIterator::exchange_correlation_, execution_policy_, q3::PlanewaveBasis::fft_rho(), q3::PlanewaveKohnShamSCFSetupSummary::fft_rho_grid_dimension_1, q3::PlanewaveKohnShamSCFSetupSummary::fft_rho_grid_dimension_2, q3::PlanewaveKohnShamSCFSetupSummary::fft_rho_grid_dimension_3, q3::PlanewaveBasis::fft_wave(), q3::PlanewaveKohnShamSCFSetupSummary::fft_wave_grid_dimension_1, q3::PlanewaveKohnShamSCFSetupSummary::fft_wave_grid_dimension_2, q3::PlanewaveKohnShamSCFSetupSummary::fft_wave_grid_dimension_3, q3::FFTGrid::grid_dimension_1(), q3::FFTGrid::grid_dimension_2(), q3::FFTGrid::grid_dimension_3(), q3::PlanewaveChargeDensitySymmetrizer::is_initialized(), kpoint_grid(), q3::PlanewaveBasis::kpoint_number_of_plane_waves(), q3::Crystal::lattice_parameter(), q3::PlanewaveKohnShamSCFSetupSummary::lattice_parameter, q3::PlanewaveKohnShamSCFSetupSummary::max_plane_waves_per_kpoint, q3::KohnShamSCFIterator::mixer_, q3::PlanewaveKohnShamSCFSetupSummary::mixer_name, q3::PlanewaveKohnShamSCFSetupSummary::mixing_beta, q3::KohnShamSCFIterator::mixing_beta_, q3::Crystal::number_of_atoms(), q3::PlanewaveKohnShamSCFSetupSummary::number_of_atoms, q3::PlanewaveKohnShamSCFSetupSummary::number_of_bands, number_of_bands_, q3::PlanewaveKohnShamSCFSetupSummary::number_of_electrons, number_of_electrons_, q3::PlanewaveBasis::number_of_g_vectors(), q3::PlanewaveKohnShamSCFSetupSummary::number_of_g_vectors, q3::PlanewaveKohnShamSCFSetupSummary::number_of_kpoint_pools, q3::KPointsGrid::number_of_kpoints(), q3::PlanewaveKohnShamSCFSetupSummary::number_of_kpoints, q3::execution::PlanewaveExecutionPolicy::number_of_pools(), q3::execution::ExecutionPolicy::number_of_processes(), q3::PlanewaveKohnShamSCFSetupSummary::number_of_processes, q3::PlanewaveChargeDensitySymmetrizer::number_of_shells(), q3::PlanewaveKohnShamSCFSetupSummary::number_of_shells, q3::SCFIterator::number_of_spin_components(), q3::PlanewaveKohnShamSCFSetupSummary::number_of_spin_components, q3::PlanewaveChargeDensitySymmetrizer::number_of_symmetry_operations(), q3::PlanewaveKohnShamSCFSetupSummary::number_of_symmetry_operations, planewave_basis_, planewave_energies(), q3::execution::PlanewaveExecutionPolicy::reduce_scalar_max(), q3::PlanewaveKohnShamSCFSetupSummary::replicated_plane_wave_fallback_active, replicated_plane_wave_fallback_active_, q3::PlanewaveKohnShamSCFReporter::report_setup_summary(), q3::PlanewaveKohnShamSCFSetupSummary::wavefunction_energy_cutoff, wavefunction_energy_cutoff_, and q3::PlanewaveKohnShamSCFSetupSummary::xc_functional_name.
Referenced by initialize_representation().
|
inline |
∫(ρ↑−ρ↓) and ∫|ρ↑−ρ↓| for this run, in Bohr magnetons.
Present only for a spin-polarized run that reached its convergence report, which is where they are integrated; empty elsewhere, so a consumer can tell "not a magnetic calculation" from "a moment that came out at zero" without asking which kind of run this was.
Definition at line 355 of file init.hpp.
References magnetization_.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_representation().
|
inlineprotected |
Flat metric weight for the magnetization channel: e² · 4π / (2π)² · V/2 (the constant prefactor of the spin-polarized term in QE's density dot product). Single source for both the mixer environment and the SCF dr2.
Definition at line 805 of file init.hpp.
References q3::Crystal::cell_volume(), q3::KohnShamSCFIterator::crystal_structure(), q3::constants::electron_charge_squared_rydberg, q3::constants::four_pi, and q3::constants::two_pi.
Referenced by compute_local_residual_between(), and initiate_mixer().
|
inlineoverrideprotectedvirtual |
Implements q3::KohnShamSCFIterator.
Definition at line 913 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_, input_density_for_mixing(), q3::KohnShamSCFIterator::mixer_, and q3::SCFIterator::number_of_spin_components().
|
inlineoverridevirtual |
Total number of bands (user-specified or auto-determined).
Implements q3::KohnShamSCFIterator.
Definition at line 315 of file init.hpp.
References number_of_bands_.
Referenced by global_eigenvalues().
|
inlineoverridevirtual |
Total number of valence electrons from all atoms.
Implements q3::KohnShamSCFIterator.
Definition at line 322 of file init.hpp.
References number_of_electrons_.
Referenced by scale_loaded_charge_density_to_electron_count().
|
inlineoverridevirtual |
Total number of k-point states (k-points × spin components).
Implements q3::KohnShamSCFIterator.
Definition at line 329 of file init.hpp.
References kpoint_grid(), q3::KPointsGrid::number_of_kpoints(), and q3::SCFIterator::number_of_spin_components().
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::accumulate_hubbard_occupation_and_potential(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::solve_single_particle_states().
|
inline |
Number of fully occupied bands per spin channel.
Definition at line 336 of file init.hpp.
References q3::PlanewaveKohnShamQuantumSystem::number_of_occupied_bands_per_spin(), and quantum_system_.
|
inline |
Number of plane waves per k-point (full array).
Definition at line 294 of file init.hpp.
References q3::PlanewaveBasis::kpoint_number_of_plane_waves(), and planewave_basis_.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::accumulate_hubbard_occupation_and_potential(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), q3::PlanewavePseudopotentialKohnShamSCFIterator::setup_hubbard(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::solve_single_particle_states().
|
inline |
Number of plane waves for a specific k-point.
Definition at line 301 of file init.hpp.
References q3::PlanewaveBasis::number_of_plane_waves_by_kpoint_index(), and planewave_basis_.
|
inline |
Access the occupation number f_{k,n} for a given k-point state and band.
Definition at line 272 of file init.hpp.
References q3::PlanewaveKohnShamQuantumSystem::occupation_by_kpoint_state_index_and_band_index(), and quantum_system_.
Referenced by q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), and q3::assemble_global_eigenvalues_at_kpoints().
|
inlineprotectedvirtual |
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 in q3::PawPlanewavePseudopotentialKohnShamSCFIterator, and q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 1159 of file init.hpp.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_charge_density().
|
inline |
Access the plane-wave basis set.
Definition at line 216 of file init.hpp.
References planewave_basis_.
Referenced by q3::internal::build_wannier_interface_record().
|
inlineprotected |
Definition at line 443 of file init.hpp.
References q3::KohnShamSCFIterator::energies().
Referenced by log_representation_summary(), report_convergence_details(), and report_first_iteration_details().
|
inlineprotected |
Definition at line 446 of file init.hpp.
References q3::KohnShamSCFIterator::energies_mutable().
Referenced by compute_energy_components(), and initialize_representation().
|
inline |
Preload charge density from the cached charge_density_real_.
Definition at line 191 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_g_, q3::KohnShamSCFIterator::charge_density_real_, q3::log::debug(), q3::PlanewaveBasis::fft_rho(), q3::SCFIterator::number_of_spin_components(), planewave_basis_, q3::PlanewaveBasis::rho_r_to_g(), and q3::FFTGrid::total_grid_points().
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_charge_density().
|
inline |
Preload single-particle states from the cached quantum system snapshot.
Definition at line 136 of file init.hpp.
References q3::PlanewaveKohnShamQuantumSystem::copy_quantum_states_from(), q3::log::debug(), q3::QuantumSystem< QuantumStateType >::preloaded_quantum_system_, q3::KohnShamSCFIterator::prepare_hamiltonian(), quantum_system_, and update_effective_potential().
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states().
|
inline |
Access the generic Kohn-Sham quantum system.
Definition at line 223 of file init.hpp.
References quantum_system_.
Referenced by q3::assemble_global_eigenvalues_at_kpoints(), q3::assemble_global_kpoint_state_blocks(), and q3::internal::build_wannier_interface_record().
|
inlinevirtual |
Release what only the SCF needed, once it has converged: the solver's working basis and the mixing history. The forces and stress that follow work from the wavefunctions and density in the quantum system, and they allocate arrays of their own – on the 54-atom silicon cell at two ranks the forces stage set the run's peak 0.3 GiB above the SCF's, because the SCF's working set was still alive under it. A subclass adds the caches it owns. A later run() rebuilds everything on demand.
Reimplemented in q3::PlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 109 of file init.hpp.
References diagonalizer_, q3::ProfilingCounters::instance(), q3::KohnShamSCFIterator::mixer_, and q3::ProfilingCounters::release_unused_heap().
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::release_scf_workspace().
|
inlineoverrideprotectedvirtual |
Representation-specific tail of the convergence report (eigenvalues, magnetization, final energy breakdown). Generic banner lives in report_convergence().
Kept here, where they are integrated for the report, rather than re-integrated for the results file: the density this reads is released with the rest of the SCF workspace before the flavor assembles its result, and a second integration somewhere else would be a second chance for the two to disagree – the same reason the SCF history is recorded at the line that prints it.
Report every irreducible k-point, not just this rank's pool share.
kpoint_grid() is the DISTRIBUTED grid, so with pools it holds only this pool's k-points – a 60-k-point calculation on 8 pools used to report 8, restart its labels at k_0 in each pool, and give no way to tell which of the 60 they were. The same fixed-width pack-and-gather the SCF flavor already uses to build results.json (see flavors/self_consistent_field.hpp) puts them back in global order, and it costs one Allreduce at the end of a converged run.
Layout per k-point state: number_of_bands_ eigenvalues followed by the three k-point coordinates. Weights are not needed for the report. assemble_global_kpoint_state_data() is spin-major over the global grid and returns the whole array on every rank; the serial policy hands the input straight back, so this path is not MPI-only.
The counters as the SCF leaves them, which is not what the entry point prints at exit: forces and stress add transforms of their own afterwards, so the two figures differ, and that difference is the reason to have this one at all.
The Davidson timing table is deliberately not dumped here. Nothing between this line and the entry point's closing dump touches the accumulator, so the two were byte-identical – the same table twice in one run.
Implements q3::KohnShamSCFIterator.
Definition at line 999 of file init.hpp.
References q3::PlanewaveKohnShamSCFConvergenceSummary::absolute_magnetization, q3::execution::PlanewaveExecutionPolicy::assemble_global_kpoint_state_data(), q3::Crystal::cell_volume(), q3::KohnShamSCFIterator::charge_density_real_, q3::KohnShamSCFIterator::crystal_structure(), q3::log::debug(), q3::PlanewaveKohnShamQuantumSystem::eigenvalue(), q3::PlanewaveKohnShamSCFConvergenceSummary::eigenvalues, q3::PlanewaveKohnShamSCFConvergenceSummary::energies, execution_policy_, q3::PlanewaveBasis::fft_rho(), q3::ProfilingCounters::instance(), kpoint_grid(), q3::PlanewaveKohnShamSCFConvergenceSummary::kpoints, magnetization_, q3::PlanewaveKohnShamSCFConvergenceSummary::number_of_bands, number_of_bands_, q3::PlanewaveKohnShamSCFConvergenceSummary::number_of_kpoint_pools, q3::KPointsGrid::number_of_kpoints(), q3::PlanewaveKohnShamSCFConvergenceSummary::number_of_kpoints, q3::execution::PlanewaveExecutionPolicy::number_of_pools(), q3::SCFIterator::number_of_spin_components(), q3::PlanewaveKohnShamSCFConvergenceSummary::number_of_spin_components, planewave_basis_, planewave_energies(), quantum_system_, q3::execution::PlanewaveExecutionPolicy::reduce_within_pool_scalar(), q3::PlanewaveKohnShamSCFReporter::report_convergence_summary(), q3::FFTGrid::total_grid_points(), and q3::PlanewaveKohnShamSCFConvergenceSummary::total_magnetization.
|
inlineoverrideprotectedvirtual |
Implements q3::KohnShamSCFIterator.
Definition at line 994 of file init.hpp.
References q3::KohnShamSCFIterator::energies(), planewave_energies(), and q3::PlanewaveKohnShamSCFReporter::report_first_iteration().
|
inlineprotected |
Bands to solve for, when the input did not say.
Insulator: the occupied count plus four empty bands, which cost little and give the eigensolver room to converge the top of the valence manifold. Metal: 20% more than the occupied count, but never fewer than four extra — a partly filled band must be resolved well above the Fermi level or the smeared occupations are truncated and the total energy is wrong.
The 20% and the four-band floor are heuristics, and they are the same pair Quantum ESPRESSO uses, deliberately: for a metal the band count changes the total energy through the fractional occupations of the extra bands, so reproducing an upstream energy at the same input requires reproducing its band count. That equivalence is what the three LSDA cases in tests/validation/test_qe_energy_comparison.py check — they pass no band count to either code. The insulating branch deliberately differs (the upstream default adds no margin there); empty bands cannot move a fixed-occupation total, so nothing observable turns on it.
Definition at line 1202 of file init.hpp.
References number_of_bands_, number_of_electrons_, q3::KohnShamSCFIterator::smearing_, q3::KohnShamSCFIterator::smearing_width_, q3::math::tolerances::smearing_width_threshold, and q3::log::warn().
Referenced by initialize_representation().
|
inlineoverrideprotectedvirtual |
Implements q3::KohnShamSCFIterator.
Reimplemented in q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 921 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_, and convergence_output_density_.
|
pure virtual |
Assemble and return a snapshot of the converged SCF state.
Returns a self-contained state carrying all converged data needed by post-SCF consumers (forces, stress, output writer, binary checkpoints).
Implemented in q3::PlanewavePseudopotentialKohnShamSCFIterator, and q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator.
Referenced by q3::SelfConsistentFieldFlavor::run_calculation().
|
inline |
Rescale the loaded density so it integrates to this system's electron count.
Definition at line 168 of file init.hpp.
References q3::Crystal::cell_volume(), q3::KohnShamSCFIterator::charge_density_real_, q3::KohnShamSCFIterator::crystal_structure(), q3::PlanewaveBasis::fft_rho(), number_of_electrons(), planewave_basis_, and q3::FFTGrid::total_grid_points().
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_charge_density().
|
inlineoverrideprotectedvirtual |
NSCF mode: use the tight override tolerance set by the NSCF flavor instead of the adaptive SCF scheme. The override was requested before run() (when diagonalizer_ was still null), so it is applied here on the first call, once the diagonalizer has been constructed.
Iteration 2+: tighten the eigenvalue threshold to stay an order of magnitude below the self-consistency error, per electron-state: tolerance <- min(tolerance, 0.1 * residual / max(1, electrons)) The min keeps the schedule monotone, so a transient rise in the residual cannot loosen a threshold that has already tightened; the max(1, ...) guard covers a cell with fewer than one electron. The 0.1 margin and the 1e-13 floor applied below are heuristics – the same pair Quantum ESPRESSO uses – and neither is observable in the converged result, which is fixed by convergence_threshold on the residual, not by this tolerance. Iteration 1's loose 1e-2 start is of the same kind: the atomic-superposition potential is far from self-consistent, so precision there is wasted.
Implements q3::KohnShamSCFIterator.
Definition at line 719 of file init.hpp.
References q3::KohnShamSCFIterator::density_residual_, q3::KohnShamSCFIterator::diagonalization_threshold(), diagonalizer_, q3::KohnShamSCFIterator::diagonalizer_tolerance_, q3::math::tolerances::initial_eigenvalue_tolerance, q3::SCFIterator::iteration(), nscf_override_maximum_iterations_, nscf_override_tolerance_, number_of_electrons_, and report_unconverged_bands_.
|
inline |
Inject an externally-constructed diagonalizer.
When set before run(), the iterator skips its internal create_planewave_diagonalizer() call and uses this one instead. Ownership is transferred to the iterator.
Definition at line 96 of file init.hpp.
References diagonalizer_.
|
inlineoverrideprotectedvirtual |
Implements q3::KohnShamSCFIterator.
Definition at line 759 of file init.hpp.
References diagonalizer_, and q3::KohnShamSCFIterator::diagonalizer_tolerance_.
|
inline |
Transfer ownership of an execution policy into this iterator.
After this call the iterator holds the policy for its lifetime and uses it for pool-level collective operations (charge-density reduction, scalar reduction).
Definition at line 84 of file init.hpp.
References execution_policy_, and owned_execution_policy_.
|
inline |
Transfer ownership of a KPointsGrid into this iterator.
Definition at line 72 of file init.hpp.
References kpoint_grid(), and kpoint_grid_.
|
inlineoverrideprotectedvirtual |
Implements q3::KohnShamSCFIterator.
Reimplemented in q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 917 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_, and convergence_output_density_.
|
inline |
Spin degeneracy factor (2.0 for non-spin-polarized, 1.0 for LSDA).
Definition at line 343 of file init.hpp.
References quantum_system_, and q3::PlanewaveKohnShamQuantumSystem::spin_degeneracy().
|
inlineoverrideprotectedvirtual |
Implements q3::KohnShamSCFIterator.
Reimplemented in q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator.
Definition at line 778 of file init.hpp.
References q3::KohnShamSCFIterator::charge_density_real_, density_symmetrizer_, q3::SCFIterator::number_of_spin_components(), planewave_basis_, and q3::PlanewaveChargeDensitySymmetrizer::symmetrize().
|
inlineoverrideprotectedvirtual |
Skip recomputation when V_eff was injected via load_effective_potential(). This path is taken by the NSCF flavor which loads V_eff from a v2 checkpoint.
Compute total_potential_g_ by FFT-ing the spin-averaged potential. This is required by prepare_hamiltonian() (critical for ultrasoft, harmless for NC).
Per-spin copies as well: a checkpoint stores only the average, but real_space_potential_ was loaded per channel, so the nonlocal D can still be built per channel rather than from the average it would otherwise fall back to.
Initialize the cached ionic local potential so that compute_double_counting_correction() does not crash when it is called after solve_single_particle_states(). In the SCF path this is populated lazily inside compute_effective_potential_from_density(), but that function is skipped for NSCF, leaving the cache empty.
Implements q3::KohnShamSCFIterator.
Definition at line 666 of file init.hpp.
References cached_local_ionic_potential_real_, compute_effective_potential_from_density(), q3::KohnShamSCFIterator::has_preloaded_effective_potential_, local_ionic_potential_g(), planewave_basis_, q3::KohnShamSCFIterator::real_space_potential_, q3::PlanewaveBasis::rho_g_to_r(), q3::PlanewaveBasis::rho_r_to_g(), q3::KohnShamSCFIterator::total_potential_g_, and q3::KohnShamSCFIterator::total_potential_g_by_spin_.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), and preload_single_particle_states().
|
inlineoverrideprotectedvirtual |
Implements q3::KohnShamSCFIterator.
Definition at line 764 of file init.hpp.
References q3::PlanewaveFermiEnergyCalculator::calculate_occupations(), and fermi_energy_calculator_.
|
inlineprotected |
Each rank holds the real-space planes of the density it owns: all of them unless reciprocal space is split within the pool, in which case the local sum is a fraction of the charge – about half on two ranks, which is what this used to report as a deviation. The sum is completed within the group before it is compared, so every rank must call this.
Definition at line 1374 of file init.hpp.
References q3::Crystal::cell_volume(), q3::KohnShamSCFIterator::charge_density_real_, q3::KohnShamSCFIterator::crystal_structure(), execution_policy_, q3::PlanewaveBasis::fft_rho(), q3::execution::ExecutionPolicy::is_root(), q3::FFTGrid::local_grid_points(), number_of_electrons_, q3::SCFIterator::number_of_spin_components(), planewave_basis_, q3::execution::ExecutionPolicy::reduce_within_group(), q3::FFTGrid::total_grid_points(), and q3::log::warn().
Referenced by q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::construct_density_from_states().
|
inline |
Access a single wavefunction coefficient Ψ_{k,n}(G).
Definition at line 230 of file init.hpp.
References quantum_system_, and q3::PlanewaveKohnShamQuantumSystem::wavefunction().
|
protected |
Cached real-space ionic local potential (constant during SCF, avoids repeated FFTs).
Definition at line 406 of file init.hpp.
Referenced by compute_delta_escf_correction(), compute_double_counting_correction(), and update_effective_potential().
|
protected |
Accumulates real-space charge density from wavefunctions each SCF iteration.
Definition at line 399 of file init.hpp.
Referenced by construct_density_from_states(), and initialize_representation().
|
protected |
Definition at line 366 of file init.hpp.
Referenced by effective_charge_density_energy_cutoff(), and initialize_representation().
|
protected |
Converged output density snapshot, restored once self-consistency is reached.
Definition at line 404 of file init.hpp.
Referenced by compute_delta_escf_correction(), restore_density_at_convergence(), and snapshot_output_density().
|
protected |
Definition at line 397 of file init.hpp.
Referenced by initialize_representation(), log_representation_summary(), symmetrize_density(), and q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::symmetrize_density().
|
protected |
Definition at line 367 of file init.hpp.
Referenced by initialize_representation(), log_representation_summary(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::setup_hubbard().
|
protected |
Definition at line 395 of file init.hpp.
Referenced by initialize_representation(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), log_representation_summary(), release_scf_workspace(), q3::PlanewavePseudopotentialKohnShamSCFIterator::release_scf_workspace(), set_diagonalization_tolerance(), set_diagonalizer(), set_diagonalizer_tolerance(), q3::PlanewavePseudopotentialKohnShamSCFIterator::setup_hubbard(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::solve_single_particle_states().
|
protected |
Computes band energy and smearing entropy from the occupied Kohn-Sham states.
Definition at line 401 of file init.hpp.
Referenced by compute_energy_components(), and initialize_representation().
|
protected |
Execution policy for pool-level collective operations. Set via set_owned_execution_policy() before run().
Definition at line 373 of file init.hpp.
Referenced by PlanewaveKohnShamSCFIterator(), q3::PlanewavePseudopotentialKohnShamSCFIterator::accumulate_hubbard_occupation_and_potential(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), build_kpoint_plane_wave_data(), compute_delta_escf_correction(), compute_double_counting_correction(), compute_energy_components(), compute_residual_between(), construct_density_from_states(), execution_policy(), global_eigenvalues(), initialize_representation(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), initiate_mixer(), log_representation_summary(), report_convergence_details(), q3::PlanewavePseudopotentialKohnShamSCFIterator::result(), set_owned_execution_policy(), q3::PlanewavePseudopotentialKohnShamSCFIterator::setup_hubbard(), warn_if_total_charge_deviates(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::write_checkpoints().
|
protected |
Definition at line 396 of file init.hpp.
Referenced by initialize_representation(), and update_occupations().
|
protected |
Definition at line 364 of file init.hpp.
Referenced by initialize_representation(), kpoint_grid(), and set_owned_kpoint_grid().
|
protected |
Set by report_convergence_details(); see magnetization() above.
Definition at line 361 of file init.hpp.
Referenced by magnetization(), and report_convergence_details().
|
protected |
The NSCF flavor's per-k-point Davidson cap, pending like the tolerance above and applied at the same point.
Definition at line 433 of file init.hpp.
Referenced by set_diagonalization_tolerance(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::set_diagonalizer_maximum_iterations_for_nscf().
|
protected |
When set (by set_diagonalizer_tolerance_for_nscf), overrides the initial loose tolerance on the first call to set_diagonalization_tolerance(). Stored as a pending value because the diagonalizer_ is not yet constructed when the NSCF flavor calls set_diagonalizer_tolerance_for_nscf() pre-run.
Definition at line 427 of file init.hpp.
Referenced by set_diagonalization_tolerance(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::set_diagonalizer_tolerance_for_nscf().
|
protected |
Definition at line 393 of file init.hpp.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::accumulate_hubbard_occupation_and_potential(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), compute_energy_components(), construct_density_from_states(), initialize_representation(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), log_representation_summary(), number_of_bands(), report_convergence_details(), resolve_number_of_bands(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::solve_single_particle_states().
|
protected |
Definition at line 392 of file init.hpp.
Referenced by initialize_representation(), log_representation_summary(), number_of_electrons(), resolve_number_of_bands(), set_diagonalization_tolerance(), and warn_if_total_charge_deviates().
|
protected |
Number of smooth G-vectors for density residual (matching QE's smooth-grid count). For dual-grid US/PAW calculations, this excludes hard G-vectors above 4*ecutwfc.
Definition at line 411 of file init.hpp.
Referenced by compute_local_residual_between(), and initiate_mixer().
|
protected |
Optional owned execution policy — transfers lifetime from the factory.
IMPORTANT: This member MUST be declared before planewave_basis_ and all other MPI-using members. C++ destroys members in reverse declaration order, so members declared AFTER this one are destroyed BEFORE it. The owned policy calls MPI_Finalize() in its destructor; planewave_basis_ contains MPIFFTGrid which calls fftw_destroy_plan (which internally frees MPI communicators) in its destructor. If planewave_basis_ were destroyed after MPI_Finalize, OpenMPI would report a fatal MPI_Comm_free-after-MPI_Finalize violation.
Definition at line 386 of file init.hpp.
Referenced by initialize_representation(), and set_owned_execution_policy().
|
protected |
Definition at line 389 of file init.hpp.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::accumulate_hubbard_occupation_and_potential(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::add_augmentation_to_charge_density(), allocate_electronic_states(), build_kpoint_plane_wave_data(), compute_delta_escf_correction(), compute_double_counting_correction(), compute_local_residual_between(), g_vector_indices(), g_vector_indices(), initialize_representation(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), initiate_mixer(), kinetic_energy_squared(), loaded_charge_density_fits_grid(), log_representation_summary(), number_of_plane_waves(), number_of_plane_waves(), planewave_basis(), preload_charge_density(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::prepare_hamiltonian(), report_convergence_details(), q3::PlanewavePseudopotentialKohnShamSCFIterator::result(), scale_loaded_charge_density_to_electron_count(), q3::PlanewavePseudopotentialKohnShamSCFIterator::setup_hubbard(), q3::PlanewavePseudopotentialKohnShamSCFIterator::solve_single_particle_states(), symmetrize_density(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::symmetrize_density(), update_effective_potential(), q3::PlanewavePseudopotentialKohnShamSCFIterator::valence_exchange_correlation_potential_g_of(), and warn_if_total_charge_deviates().
|
protected |
Definition at line 390 of file init.hpp.
Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::accumulate_hubbard_occupation_and_potential(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), allocate_electronic_states(), eigenvalue(), eigenvalues(), initialize_representation(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), load_quantum_system(), number_of_occupied_bands_per_spin(), occupation(), preload_single_particle_states(), quantum_system(), q3::PlanewavePseudopotentialKohnShamSCFIterator::refresh_quantum_system_snapshot(), report_convergence_details(), q3::PlanewavePseudopotentialKohnShamSCFIterator::result(), q3::PlanewavePseudopotentialKohnShamSCFIterator::solve_single_particle_states(), spin_degeneracy(), and wavefunction().
|
protected |
Whether band distribution was abandoned during setup because some rank's FFT slab contained no plane waves. Reported in the setup summary, since it silently changes the parallel behaviour of the whole run.
Definition at line 1229 of file init.hpp.
Referenced by build_kpoint_plane_wave_data(), and log_representation_summary().
|
protected |
Set once the NSCF cap is applied: a single pass keeps whatever a solve leaves unconverged, so each such solve is counted and reported.
Definition at line 439 of file init.hpp.
Referenced by set_diagonalization_tolerance().
|
protected |
Definition at line 365 of file init.hpp.
Referenced by build_kpoint_plane_wave_data(), effective_charge_density_energy_cutoff(), initialize_representation(), initiate_mixer(), and log_representation_summary().