Loading...
Searching...
No Matches
q3::PlanewaveHamiltonianApplicator Class Referenceabstract

#include <init.hpp>

+ Inheritance diagram for q3::PlanewaveHamiltonianApplicator:

Public Member Functions

virtual ~PlanewaveHamiltonianApplicator ()=default
 
virtual void apply_batch (const Complex *input_wavefunctions, Complex *output_hamiltonian_wavefunctions, int number_of_vectors)=0
 
virtual bool gamma_origin_is_local_current () const
 
virtual const q3::Matrix< Complex > * get_cached_projectors (int kpoint_index) const
 
virtual void invalidate_smooth_potential_cache ()=0
 
virtual bool is_gamma_only_current () const
 
virtual bool is_smooth_potential_cache_valid () const
 
virtual void prepare_kpoint (int kpoint_index, int number_of_plane_waves, const std::vector< int > &g_vector_indices, const std::vector< Real > &kinetic_energy_squared)=0
 
virtual void set_cached_hubbard_projectors (int kpoint_index, const q3::Matrix< Complex > *projectors)
 
virtual void set_cached_projectors (int kpoint_index, const q3::Matrix< Complex > *projectors)
 
virtual void set_hubbard_d_matrix (const std::vector< Complex > *dense_d_matrix_column_major)
 
void set_spin_channel (int spin_channel)
 
int spin_channel () const
 
virtual void update_potential (const std::vector< Real > &real_space_potential)=0
 

Protected Attributes

int spin_channel_ {0}
 Spin channel the current potential and D belong to; 0 when unpolarized.
 

Detailed Description

Definition at line 27 of file init.hpp.

Constructor & Destructor Documentation

◆ ~PlanewaveHamiltonianApplicator()

virtual q3::PlanewaveHamiltonianApplicator::~PlanewaveHamiltonianApplicator ( )
virtualdefault

Member Function Documentation

◆ apply_batch()

virtual void q3::PlanewaveHamiltonianApplicator::apply_batch ( const Complex *  input_wavefunctions,
Complex *  output_hamiltonian_wavefunctions,
int  number_of_vectors 
)
pure virtual

Apply H|ψ⟩ in double precision (FP64) to a batch of vectors.

Only takes data that changes per Davidson iteration: the wavefunctions and their output. All other context (potential, k-point data, projectors) was configured via update_potential() and prepare_kpoint().

Implemented in q3::GPUPlanewaveHamiltonianApplicator, and q3::SerialPlanewaveHamiltonianApplicator.

◆ gamma_origin_is_local_current()

virtual bool q3::PlanewaveHamiltonianApplicator::gamma_origin_is_local_current ( ) const
inlinevirtual

Whether this rank's plane-wave list for the current k-point begins with G = 0, so that the gamma trick's origin correction belongs to it. True whenever the coefficients are replicated; under a reciprocal-space distribution exactly one rank answers true. Meaningful only when is_gamma_only_current().

Reimplemented in q3::SerialPlanewaveHamiltonianApplicator.

Definition at line 114 of file init.hpp.

◆ get_cached_projectors()

virtual const q3::Matrix< Complex > * q3::PlanewaveHamiltonianApplicator::get_cached_projectors ( int  kpoint_index) const
inlinevirtual

Get pre-computed KB projectors for a specific k-point, or nullptr if none. Default: nullptr (no cached projectors).

Reimplemented in q3::SerialPlanewaveHamiltonianApplicator, and q3::GPUPlanewaveHamiltonianApplicator.

Definition at line 122 of file init.hpp.

◆ invalidate_smooth_potential_cache()

virtual void q3::PlanewaveHamiltonianApplicator::invalidate_smooth_potential_cache ( )
pure virtual

Invalidate any cached smooth potential. Called when the effective potential changes (e.g., at start of each SCF iteration).

Implemented in q3::GPUPlanewaveHamiltonianApplicator, and q3::SerialPlanewaveHamiltonianApplicator.

Referenced by q3::PlanewaveDavidsonDiagonalizer::invalidate_smooth_potential_cache(), and set_spin_channel().

◆ is_gamma_only_current()

virtual bool q3::PlanewaveHamiltonianApplicator::is_gamma_only_current ( ) const
inlinevirtual

Whether the current k-point uses gamma-only half-sphere G-vectors. Default: false.

Reimplemented in q3::GPUPlanewaveHamiltonianApplicator, and q3::SerialPlanewaveHamiltonianApplicator.

Definition at line 103 of file init.hpp.

◆ is_smooth_potential_cache_valid()

virtual bool q3::PlanewaveHamiltonianApplicator::is_smooth_potential_cache_valid ( ) const
inlinevirtual

Whether the smooth potential cache is currently valid. Default: false (conservative — forces recomputation).

Reimplemented in q3::GPUPlanewaveHamiltonianApplicator, and q3::SerialPlanewaveHamiltonianApplicator.

Definition at line 95 of file init.hpp.

◆ prepare_kpoint()

virtual void q3::PlanewaveHamiltonianApplicator::prepare_kpoint ( int  kpoint_index,
int  number_of_plane_waves,
const std::vector< int > &  g_vector_indices,
const std::vector< Real > &  kinetic_energy_squared 
)
pure virtual

Configure for a specific k-point. Must be called before apply_batch(). Sets up k+G vectors, kinetic factors, KB projectors, FFT mappings. For GPU implementations, copies per-kpoint data to GPUDeviceBuffer.

Implemented in q3::GPUPlanewaveHamiltonianApplicator, and q3::SerialPlanewaveHamiltonianApplicator.

◆ set_cached_hubbard_projectors()

virtual void q3::PlanewaveHamiltonianApplicator::set_cached_hubbard_projectors ( int  kpoint_index,
const q3::Matrix< Complex > *  projectors 
)
inlinevirtual

Set pre-computed DFT+U (Hubbard) atomic-orbital projectors for a specific k-point. Geometry-only (like KB projectors): set once per k-point at SCF setup. Default: no-op – only the CPU serial applicator implements DFT+U (v1: NC + CPU only).

Reimplemented in q3::SerialPlanewaveHamiltonianApplicator.

Definition at line 141 of file init.hpp.

Referenced by q3::PlanewaveDavidsonDiagonalizer::set_cached_hubbard_projectors().

◆ set_cached_projectors()

virtual void q3::PlanewaveHamiltonianApplicator::set_cached_projectors ( int  kpoint_index,
const q3::Matrix< Complex > *  projectors 
)
inlinevirtual

Set pre-computed KB projectors for a specific k-point. Default: no-op (implementations that cache projectors override this).

Reimplemented in q3::SerialPlanewaveHamiltonianApplicator, and q3::GPUPlanewaveHamiltonianApplicator.

Definition at line 131 of file init.hpp.

Referenced by q3::PlanewaveDavidsonDiagonalizer::set_cached_projectors().

◆ set_hubbard_d_matrix()

virtual void q3::PlanewaveHamiltonianApplicator::set_hubbard_d_matrix ( const std::vector< Complex > *  dense_d_matrix_column_major)
inlinevirtual

Set the dense block-diagonal Hubbard D-matrix (Dudarev V_U coefficients), spanning all Hubbard-active orbitals across all manifolds. Column-major (Fortran/BLAS convention), dimension total_hubbard_orbitals x total_hubbard_orbitals. Unlike the KB D-matrix (fixed, lazily built from geometry), this depends on the occupation matrix and is refreshed once per SCF iteration (not per k-point). Default: no-op.

Reimplemented in q3::SerialPlanewaveHamiltonianApplicator.

Definition at line 154 of file init.hpp.

Referenced by q3::PlanewaveDavidsonDiagonalizer::set_hubbard_d_matrix().

◆ set_spin_channel()

void q3::PlanewaveHamiltonianApplicator::set_spin_channel ( int  spin_channel)
inline

Which spin channel the following applications belong to.

The nonlocal D matrix is spin-dependent for ultrasoft and PAW — D_ij = D_ion + ∫v_eff·Q_ij, and v_eff differs between channels — so applying H needs to know which channel it is in. The caller sets this beside update_potential, which already receives that channel's potential; the cached dense D is dropped whenever it changes, since it was built for the other channel.

Unpolarized runs never call it and stay on channel 0.

Definition at line 74 of file init.hpp.

References invalidate_smooth_potential_cache(), spin_channel(), and spin_channel_.

◆ spin_channel()

int q3::PlanewaveHamiltonianApplicator::spin_channel ( ) const
inline

Definition at line 81 of file init.hpp.

References spin_channel_.

Referenced by set_spin_channel().

◆ update_potential()

virtual void q3::PlanewaveHamiltonianApplicator::update_potential ( const std::vector< Real > &  real_space_potential)
pure virtual

Update the effective potential for a new SCF iteration. Must be called before prepare_kpoint() / apply_batch().

Internally computes the smooth-grid potential (FFT → filter → inverse FFT) and caches the result. For GPU implementations, copies the smooth potential to a GPUDeviceBuffer.

Implemented in q3::GPUPlanewaveHamiltonianApplicator, and q3::SerialPlanewaveHamiltonianApplicator.

Member Data Documentation

◆ spin_channel_

int q3::PlanewaveHamiltonianApplicator::spin_channel_ {0}
protected

Spin channel the current potential and D belong to; 0 when unpolarized.

Definition at line 160 of file init.hpp.

Referenced by set_spin_channel(), and spin_channel().


The documentation for this class was generated from the following file: