Quantum 3xplorer (Q3)
An AI-native quantum simulation engine
Loading...
Searching...
No Matches
q3::PlanewaveBasis Class Reference

#include <init.hpp>

Public Member Functions

 PlanewaveBasis ()=default
 
 PlanewaveBasis (PlanewaveBasisConfig config)
 
Real charge_density_energy_cutoff () const
 
void compute_gk (const Vector3D &k_coordinates, const Crystal &crystal_structure, std::vector< int > &g_vector_indices, std::vector< Real > &kinetic_energy_squared, int band_size=1) const
 
const PlanewaveFFTPair & fft_pair () const
 
FFTGrid & fft_rho ()
 
const FFTGrid & fft_rho () const
 
FFTGrid & fft_wave ()
 
const FFTGrid & fft_wave () const
 
const SerialFFTGrid & fft_wave_serial () const
 
int first_nonzero_g_index () const
 
void g_to_r (const std::vector< Complex > &coefficients_g_space, const std::vector< int > &g_vector_indices, int number_of_plane_waves, std::vector< Complex > &coefficients_real_space) const
 
const std::vector< int > & g_vector_indices_by_kpoint_index (int kpoint_index) const
 
const std::vector< Real > & g_vector_magnitudes () const
 
const std::vector< GVector > & g_vectors () const
 
const GVectorsGrid & g_vectors_grid () const
 
bool gamma_origin_is_local () const
 
void generate (const FFTGridFactory &fft_grid_factory, const Crystal &crystal_structure, Real wavefunction_energy_cutoff, Real charge_density_energy_cutoff, bool is_gamma_only=false, bool use_measured_fft_planning=true, bool use_exact_wavefunction_grid=false)
 
void initialize_kpoint_data (const Crystal &crystal_structure, const KPointsGrid &kpoint_grid, int band_size=1)
 
bool is_gamma_only () const
 
const std::vector< Real > & kinetic_energy_squared_by_kpoint_index (int kpoint_index) const
 
const std::vector< std::vector< int > > & kpoint_g_vector_indices () const
 
const std::vector< std::vector< Real > > & kpoint_kinetic_energy_squared () const
 
const std::vector< int > & kpoint_number_of_plane_waves () const
 
int maximum_plane_waves_per_kpoint () const
 
int number_of_g_vectors () const
 
int number_of_plane_waves_by_kpoint_index (int kpoint_index) const
 
const PlaneWaveTable & plane_wave_table () const
 
void r_to_g (const std::vector< Complex > &coefficients_real_space, const std::vector< int > &g_vector_indices, int number_of_plane_waves, std::vector< Complex > &coefficients_g_space) const
 
void rho_g_to_r (const std::vector< Complex > &charge_density_g_space, std::vector< Real > &charge_density_real_space) const
 
void rho_r_to_g (const std::vector< Real > &charge_density_real_space, std::vector< Complex > &charge_density_g_space) const
 
template<typename Predicate >
std::vector< int > stick_weights_for_grid (const FFTGrid &grid, Predicate accept) const
 
Real wavefunction_energy_cutoff () const
 

Detailed Description

Definition at line 43 of file init.hpp.

Constructor & Destructor Documentation

◆ PlanewaveBasis() [1/2]

q3::PlanewaveBasis::PlanewaveBasis ( )
default

◆ PlanewaveBasis() [2/2]

q3::PlanewaveBasis::PlanewaveBasis ( PlanewaveBasisConfig  config)
inlineexplicit

Definition at line 47 of file init.hpp.

Member Function Documentation

◆ charge_density_energy_cutoff()

◆ compute_gk()

void q3::PlanewaveBasis::compute_gk ( const Vector3D &  k_coordinates,
const Crystal &  crystal_structure,
std::vector< int > &  g_vector_indices,
std::vector< Real > &  kinetic_energy_squared,
int  band_size = 1 
) const
inline

G-vector distribution: when band_size > 1, pass the MPI FFT grid so that PlaneWaveSelector only keeps G-vectors in this rank's slab.

Definition at line 178 of file init.hpp.

References q3::PlanewaveFFTPair::fft_wave(), and q3::PlaneWaveSelector::select().

◆ fft_pair()

const PlanewaveFFTPair & q3::PlanewaveBasis::fft_pair ( ) const
inline

Definition at line 354 of file init.hpp.

◆ fft_rho() [1/2]

FFTGrid & q3::PlanewaveBasis::fft_rho ( )
inline

Definition at line 286 of file init.hpp.

References q3::PlanewaveFFTPair::fft_rho().

Referenced by q3::PlanewaveChargeDensity::PlanewaveChargeDensity(), q3::PlanewaveEffectivePotential::PlanewaveEffectivePotential(), q3::PlanewaveChargeDensityAccumulator::accumulate(), q3::PlanewaveEffectivePotentialCalculator::build_exchange_correlation_density(), q3::NormConservingPlanewaveEffectivePotentialCalculator::build_exchange_correlation_density(), q3::build_mean_field_record(), q3::MakovPayneCorrectionCalculator::compute(), q3::MartynaTuckermanCorrectionCalculator::compute(), q3::PlanewaveEffectivePotentialCalculator::compute(), q3::PlanewaveKohnShamSCFIterator::compute_delta_escf_correction(), q3::PlanewaveKohnShamSCFIterator::compute_double_counting_correction(), q3::compute_smooth_grid_potential_from_dense(), q3::GradientCorrectedExchangeCorrelationPotentialCalculator::evaluate_spin_polarized(), q3::GradientCorrectedExchangeCorrelationPotentialCalculator::evaluate_unpolarized(), q3::PlanewaveChargeDensity::get_total_charge(), q3::PlanewaveChargeDensity::grid_size(), q3::PlanewaveEffectivePotential::grid_size(), q3::PlanewaveEffectivePotential::initialize_kinetic_potential(), q3::PlanewaveKohnShamSCFIterator::loaded_charge_density_fits_grid(), q3::PlanewaveKohnShamSCFIterator::log_representation_summary(), q3::PlanewaveKohnShamSCFIterator::preload_charge_density(), q3::PlanewaveKohnShamSCFIterator::report_convergence_details(), q3::PlanewaveChargeDensity::reset(), q3::PlanewaveKohnShamSCFIterator::scale_loaded_charge_density_to_electron_count(), q3::PlanewaveDirectDiagonalizer::solve(), q3::PlanewaveChargeDensity::to_reciprocal_space(), q3::PlanewaveEffectivePotential::to_reciprocal_space(), and q3::PlanewaveKohnShamSCFIterator::warn_if_total_charge_deviates().

◆ fft_rho() [2/2]

const FFTGrid & q3::PlanewaveBasis::fft_rho ( ) const
inline

Definition at line 289 of file init.hpp.

References q3::PlanewaveFFTPair::fft_rho().

◆ fft_wave() [1/2]

◆ fft_wave() [2/2]

const FFTGrid & q3::PlanewaveBasis::fft_wave ( ) const
inline

Definition at line 295 of file init.hpp.

References q3::PlanewaveFFTPair::fft_wave().

◆ fft_wave_serial()

const SerialFFTGrid & q3::PlanewaveBasis::fft_wave_serial ( ) const
inline

Definition at line 298 of file init.hpp.

References q3::PlanewaveFFTPair::fft_wave_serial().

◆ first_nonzero_g_index()

◆ g_to_r()

void q3::PlanewaveBasis::g_to_r ( const std::vector< Complex > &  coefficients_g_space,
const std::vector< int > &  g_vector_indices,
int  number_of_plane_waves,
std::vector< Complex > &  coefficients_real_space 
) const
inline

◆ g_vector_indices_by_kpoint_index()

const std::vector< int > & q3::PlanewaveBasis::g_vector_indices_by_kpoint_index ( int  kpoint_index) const
inline

◆ g_vector_magnitudes()

const std::vector< Real > & q3::PlanewaveBasis::g_vector_magnitudes ( ) const
inline

◆ g_vectors()

const std::vector< GVector > & q3::PlanewaveBasis::g_vectors ( ) const
inline

Definition at line 148 of file init.hpp.

References q3::GVectorsGrid::g_vectors().

Referenced by q3::PlanewaveWannierCapture::PlanewaveWannierCapture(), q3::UltrasoftPlanewaveBasis::add_augmentation_charges(), q3::PlanewaveHydrogenicOrbitalSet::build(), q3::build_atomic_orbitals_g_space(), q3::build_mean_field_record(), q3::PlanewaveChargeDensitySymmetrizer::build_shells(), q3::EwaldStressTensorCalculator::compute(), q3::HartreeStressTensorCalculator::compute(), q3::KineticStressTensorCalculator::compute(), q3::CoreCorrectionStressTensorCalculator::compute(), q3::LocalPseudopotentialStressTensorCalculator::compute(), q3::EwaldForceCalculator::compute(), q3::HubbardForceCalculator::compute(), q3::NonlocalPseudopotentialForceCalculator::compute(), q3::UltrasoftForceCalculator::compute(), q3::MartynaTuckermanCorrectionCalculator::compute(), q3::LocalPseudopotentialForceCalculator::compute(), q3::CoreCorrectionForceCalculator::compute(), q3::PlanewaveBlochOverlapCalculator::compute(), q3::NormConservingPlanewaveWavefunctionInitializer::compute_atomic_wavefunctions(), q3::compute_ewald(), q3::compute_g_to_fft_index_mapping(), q3::compute_kleinman_bylander_projectors(), q3::PlanewaveKohnShamSCFIterator::compute_local_residual_between(), q3::compute_ultrasoft_effective_d_matrix(), q3::find_g_zero_plane_wave_index(), q3::NormConservingPlanewaveBasis::init(), q3::SphericalHarmonicsTable::init(), q3::CoreChargeData::initialize(), q3::PlanewaveKohnShamSCFIterator::initiate_mixer(), q3::UltrasoftPlanewaveEffectivePotential::precompute_structure_factors(), q3::PlanewaveDirectDiagonalizer::solve(), q3::tabulate_core_charge_density_in_g_space(), and q3::tabulate_local_potential_in_g_space().

◆ g_vectors_grid()

const GVectorsGrid & q3::PlanewaveBasis::g_vectors_grid ( ) const
inline

Definition at line 351 of file init.hpp.

◆ gamma_origin_is_local()

bool q3::PlanewaveBasis::gamma_origin_is_local ( ) const
inline

Whether this rank's plane-wave list begins with G = 0.

The gamma trick sums 2 Re over the stored half sphere and removes the origin, which the half sphere holds once, from the double count. When reciprocal space is distributed by stick exactly one rank holds the origin, and only that rank may remove it. Serial and replicated layouts always hold it, so the default is true; initialize_kpoint_data() sets it from the list actually kept. Meaningful only when is_gamma_only().

Definition at line 172 of file init.hpp.

Referenced by q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), q3::UltrasoftPseudopotentialOverlapOperator::apply(), q3::UltrasoftPseudopotentialOverlapOperator::apply_batch(), q3::SerialPlanewaveHamiltonianApplicator::prepare_kpoint(), and q3::NormConservingPlanewaveWavefunctionInitializer::rotate_wavefunctions().

◆ generate()

void q3::PlanewaveBasis::generate ( const FFTGridFactory &  fft_grid_factory,
const Crystal &  crystal_structure,
Real  wavefunction_energy_cutoff,
Real  charge_density_energy_cutoff,
bool  is_gamma_only = false,
bool  use_measured_fft_planning = true,
bool  use_exact_wavefunction_grid = false 
)
inline

Generate G-vectors and FFT grids for given cutoffs.

Charge density G-vectors must remain replicated on all band ranks. Only wavefunction coefficients (per k-point) are distributed via FFT slab decomposition — see PlaneWaveSelector::select().

Tell the density grid which sticks carry G-vectors, so a stick layout can balance them and skip the empty ones. A grid that does not distribute by stick ignores this.

Definition at line 58 of file init.hpp.

References q3::FFTGrid::assign_sticks(), charge_density_energy_cutoff(), q3::GVectorsGrid::estimate_maximum_plane_waves_per_kpoint(), q3::PlanewaveFFTPair::fft_rho(), q3::GVectorsGrid::generate(), q3::FFTGrid::grid_dimension_1(), q3::FFTGrid::grid_dimension_2(), q3::FFTGrid::grid_dimension_3(), q3::PlanewaveFFTPair::initialize(), is_gamma_only(), stick_weights_for_grid(), q3::Crystal::two_pi_over_lattice_parameter_squared(), and wavefunction_energy_cutoff().

Referenced by q3::PlanewaveKohnShamSCFIterator::build_kpoint_plane_wave_data(), and q3::PlanewaveKohnShamSCFIterator::initialize_representation().

◆ initialize_kpoint_data()

void q3::PlanewaveBasis::initialize_kpoint_data ( const Crystal &  crystal_structure,
const KPointsGrid &  kpoint_grid,
int  band_size = 1 
)
inline

Under a shared pool the wavefunction grid must know its sticks before the selector asks it who owns what. A stick counts if any G-vector on it can fall inside the wavefunction cutoff at some k-point, which is |G| within sqrt(E_cut) plus the largest |k| on the grid – a superset that costs a few empty sticks and never drops a plane wave.

Gamma-only means a single k-point, so one list decides: the origin is local when the first entry – the list is sorted by |k+G|^2, and at Gamma nothing else has zero kinetic energy – is G = 0.

Definition at line 202 of file init.hpp.

References q3::FFTGrid::assign_sticks(), q3::math::tolerances::energy_cutoff_rounding_tolerance, q3::PlanewaveFFTPair::fft_wave(), q3::PlaneWaveTable::g_vector_indices_by_kpoint_index(), q3::GVectorsGrid::g_vectors(), q3::PlaneWaveTable::initialize(), q3::Vector3D::norm2(), q3::KPointsGrid::number_of_kpoints(), q3::math::tolerances::numerical_zero_threshold, q3::Crystal::reciprocal_lattice_vectors(), stick_weights_for_grid(), q3::Crystal::two_pi_over_lattice_parameter_squared(), and q3::Vector3D::x.

Referenced by q3::PlanewaveKohnShamSCFIterator::build_kpoint_plane_wave_data().

◆ is_gamma_only()

bool q3::PlanewaveBasis::is_gamma_only ( ) const
inline

Definition at line 157 of file init.hpp.

Referenced by q3::PlanewavePseudopotentialKohnShamSCFIterator::accumulate_hubbard_occupation_and_potential(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), q3::UltrasoftPseudopotentialOverlapOperator::apply(), q3::UltrasoftPseudopotentialOverlapOperator::apply_batch(), q3::GPUPlanewaveHamiltonianApplicator::apply_batch_single_precision(), q3::PlanewaveKohnShamSCFIterator::build_kpoint_plane_wave_data(), q3::build_mean_field_record(), q3::PlanewaveChargeDensitySymmetrizer::build_shells(), q3::EwaldStressTensorCalculator::compute(), q3::HartreeStressTensorCalculator::compute(), q3::KineticStressTensorCalculator::compute(), q3::CoreCorrectionStressTensorCalculator::compute(), q3::HubbardStressTensorCalculator::compute(), q3::LocalPseudopotentialStressTensorCalculator::compute(), q3::NonlocalPseudopotentialStressTensorCalculator::compute(), q3::EwaldForceCalculator::compute(), q3::HubbardForceCalculator::compute(), q3::NonlocalPseudopotentialForceCalculator::compute(), q3::UltrasoftPlanewaveEffectivePotential::compute(), q3::UltrasoftForceCalculator::compute(), q3::MartynaTuckermanCorrectionCalculator::compute(), q3::LocalPseudopotentialForceCalculator::compute(), q3::CoreCorrectionForceCalculator::compute(), q3::compute_ewald(), q3::PlanewaveKohnShamSCFIterator::compute_local_residual_between(), generate(), q3::PlanewaveKohnShamSCFIterator::initiate_mixer(), q3::GPUPlanewaveHamiltonianApplicator::is_gamma_only_current(), q3::GPUPlanewaveHamiltonianApplicator::prepare_kpoint(), q3::SerialPlanewaveHamiltonianApplicator::prepare_kpoint(), q3::NormConservingPlanewaveWavefunctionInitializer::rotate_wavefunctions(), and q3::PlanewavePseudopotentialKohnShamSCFIterator::setup_hubbard().

◆ kinetic_energy_squared_by_kpoint_index()

const std::vector< Real > & q3::PlanewaveBasis::kinetic_energy_squared_by_kpoint_index ( int  kpoint_index) const
inline

◆ kpoint_g_vector_indices()

const std::vector< std::vector< int > > & q3::PlanewaveBasis::kpoint_g_vector_indices ( ) const
inline

◆ kpoint_kinetic_energy_squared()

const std::vector< std::vector< Real > > & q3::PlanewaveBasis::kpoint_kinetic_energy_squared ( ) const
inline

◆ kpoint_number_of_plane_waves()

◆ maximum_plane_waves_per_kpoint()

int q3::PlanewaveBasis::maximum_plane_waves_per_kpoint ( ) const
inline

Definition at line 198 of file init.hpp.

◆ number_of_g_vectors()

int q3::PlanewaveBasis::number_of_g_vectors ( ) const
inline

Definition at line 145 of file init.hpp.

References q3::GVectorsGrid::number_of_g_vectors().

Referenced by q3::PlanewaveChargeDensity::PlanewaveChargeDensity(), q3::PlanewaveEffectivePotential::PlanewaveEffectivePotential(), q3::UltrasoftPlanewaveBasis::add_augmentation_charges(), q3::PlanewaveEffectivePotentialCalculator::build_exchange_correlation_density(), q3::NormConservingPlanewaveEffectivePotentialCalculator::build_exchange_correlation_density(), q3::PlanewaveChargeDensitySymmetrizer::build_shells(), q3::ExchangeCorrelationStressTensorCalculator::build_total_charge_density_g(), q3::EwaldStressTensorCalculator::compute(), q3::HartreeStressTensorCalculator::compute(), q3::CoreCorrectionStressTensorCalculator::compute(), q3::LocalPseudopotentialStressTensorCalculator::compute(), q3::EwaldForceCalculator::compute(), q3::UltrasoftPlanewaveEffectivePotential::compute(), q3::UltrasoftForceCalculator::compute(), q3::MartynaTuckermanCorrectionCalculator::compute(), q3::LocalPseudopotentialForceCalculator::compute(), q3::CoreCorrectionForceCalculator::compute(), q3::compute_ewald(), q3::PlanewaveKohnShamSCFIterator::compute_local_residual_between(), q3::compute_ultrasoft_effective_d_matrix(), q3::NormConservingPlanewaveBasis::init(), q3::SphericalHarmonicsTable::init(), q3::PlanewaveKohnShamSCFIterator::initiate_mixer(), q3::PlanewaveKohnShamSCFIterator::log_representation_summary(), q3::UltrasoftPlanewaveBasis::precompute_q_functions_g(), q3::UltrasoftPlanewaveEffectivePotential::precompute_structure_factors(), and q3::tabulate_local_potential_in_g_space().

◆ number_of_plane_waves_by_kpoint_index()

int q3::PlanewaveBasis::number_of_plane_waves_by_kpoint_index ( int  kpoint_index) const
inline

◆ plane_wave_table()

const PlaneWaveTable & q3::PlanewaveBasis::plane_wave_table ( ) const
inline

Definition at line 357 of file init.hpp.

◆ r_to_g()

void q3::PlanewaveBasis::r_to_g ( const std::vector< Complex > &  coefficients_real_space,
const std::vector< int > &  g_vector_indices,
int  number_of_plane_waves,
std::vector< Complex > &  coefficients_g_space 
) const
inline

◆ rho_g_to_r()

◆ rho_r_to_g()

◆ stick_weights_for_grid()

template<typename Predicate >
std::vector< int > q3::PlanewaveBasis::stick_weights_for_grid ( const FFTGrid &  grid,
Predicate  accept 
) const
inline

Count the G-vectors on each stick of a grid, by wrapped first and second Miller index, for those the predicate accepts and that fit in the grid.

Every stick is owned, balanced by how much of the sphere it carries. A stick outside the sphere could be dropped, but two consumers here still read the whole grid box – the dense-to-smooth potential copy and the smooth-to-dense density transfer – and truncating would change their answer against a serial run. Transporting the empty sticks costs the all-to-all the same volume the slab transpose moved; skipping them is a later optimisation that wants those two loops made sphere-only first.

Definition at line 109 of file init.hpp.

References q3::GVectorsGrid::g_vectors(), q3::FFTGrid::grid_dimension_1(), q3::FFTGrid::grid_dimension_2(), and q3::FFTGrid::grid_dimension_3().

Referenced by generate(), and initialize_kpoint_data().

◆ wavefunction_energy_cutoff()

Real q3::PlanewaveBasis::wavefunction_energy_cutoff ( ) const
inline

Definition at line 342 of file init.hpp.

Referenced by q3::build_mean_field_record(), and generate().


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