Loading...
Searching...
No Matches
q3::PlanewaveChargeDensityAccumulator Class Reference

#include <accumulator.hpp>

Public Member Functions

 PlanewaveChargeDensityAccumulator (const PlanewaveBasis &basis, const KPointsGrid &kpoint_grid, const PlanewaveKohnShamQuantumSystem &quantum_system)
 
void accumulate (int number_of_bands, int number_of_spin_components, Real inverse_cell_volume, std::vector< std::vector< Real > > &charge_density_out) const
 

Detailed Description

Accumulates the smooth plane-wave charge density from the occupied Kohn-Sham bands.

Holds non-owning const references — all referenced objects must remain alive for the lifetime of this accumulator.

Definition at line 37 of file accumulator.hpp.

Constructor & Destructor Documentation

◆ PlanewaveChargeDensityAccumulator()

q3::PlanewaveChargeDensityAccumulator::PlanewaveChargeDensityAccumulator ( const PlanewaveBasis &  basis,
const KPointsGrid &  kpoint_grid,
const PlanewaveKohnShamQuantumSystem &  quantum_system 
)
inline

Construct an accumulator bound to the given basis, k-point grid, and quantum system.

Definition at line 42 of file accumulator.hpp.

Member Function Documentation

◆ accumulate()

void q3::PlanewaveChargeDensityAccumulator::accumulate ( int  number_of_bands,
int  number_of_spin_components,
Real  inverse_cell_volume,
std::vector< std::vector< Real > > &  charge_density_out 
) const
inline

Compute the real-space charge density and write it into charge_density_out.

Uses the smooth (wave) FFT grid for band transforms when available, then upscales to the rho grid. This is 3-4x faster than transforming each band on the full rho grid.

For gamma-only calculations, uses the two-band packing trick to halve the number of FFT calls: two real bands f1, f2 are packed as f1(G) + i*f2(G), transformed together, then |f1|^2 and |f2|^2 recovered from Re/Im parts.

Parameters
number_of_bandsTotal number of bands per k-point state.
number_of_spin_components1 (non-polarized) or 2 (LSDA).
inverse_cell_volume1.0 / crystal cell volume in a.u.
charge_density_outOutput: [spin_index][grid_index]. Resized and zeroed by this call.

The rho-grid path scatters each plane wave straight into the density grid, which is right only if this rank holds, on the density grid, every stick it holds on the wavefunction grid. Serial, pool and band layouts hold every stick. Ranks sharing a pool split the two grids by stick independently, so a plane wave whose density-grid stick belonged to another rank was dropped: silicon with the density cutoff at twice the wavefunction cutoff, where the two grids are the same size, was 0.79 Ry off on two ranks. On the exact wavefunction grid (QE-format input) they are the same size whenever the density cutoff is at most four times the wavefunction cutoff. The smooth path goes through reciprocal space and is right for any ownership. Every rank of a split grid holds less than the whole of it, so all of them choose the same path, as the collective transforms on either path require.

Definition at line 64 of file accumulator.hpp.

References q3::PlanewaveBasis::fft_rho(), q3::PlanewaveBasis::fft_wave(), q3::FFTGrid::local_grid_points(), and q3::FFTGrid::total_grid_points().


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