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

Abstract base class for XC functionals. More...

#include <init.hpp>

+ Inheritance diagram for q3::XCFunctional:

Public Member Functions

virtual ~XCFunctional ()=default
 
virtual void compute (const std::vector< Real > &density, std::vector< Real > &xc_potential, std::vector< Real > &xc_energy_density) const =0
 Compute XC potential and energy density (LDA interface, unpolarized).
 
virtual void compute_exchange_correlation_kernel (const std::vector< Real > &density, std::vector< Real > &exchange_correlation_kernel) const
 
virtual void compute_fxc_spin (const std::vector< Real > &density_up, const std::vector< Real > &density_down, std::vector< Real > &fxc_uu, std::vector< Real > &fxc_ud, std::vector< Real > &fxc_dd) const
 
virtual void compute_gradient_corrected (const std::vector< Real > &density, const std::vector< Real > &gradient_density_squared, std::vector< Real > &xc_potential, std::vector< Real > &gradient_correction_density, std::vector< Real > &xc_energy_density) const
 
virtual void compute_gradient_corrected_spin (const std::vector< Real > &density_up, const std::vector< Real > &density_down, const std::vector< Real > &grho2_uu, const std::vector< Real > &grho2_ud, const std::vector< Real > &grho2_dd, std::vector< Real > &xc_potential_up, std::vector< Real > &xc_potential_down, std::vector< Real > &gradient_correction_up_up, std::vector< Real > &gradient_correction_up_down, std::vector< Real > &gradient_correction_down_down, std::vector< Real > &xc_energy_density) const
 
virtual void compute_spin (const std::vector< Real > &density_up, const std::vector< Real > &density_down, std::vector< Real > &xc_potential_up, std::vector< Real > &xc_potential_down, std::vector< Real > &xc_energy_density) const
 
virtual std::string name () const =0
 
virtual int number_of_spin_components () const
 
virtual bool requires_density_gradient () const
 Whether this is a GGA functional (needs gradients).
 

Detailed Description

Abstract base class for XC functionals.

Definition at line 23 of file init.hpp.

Constructor & Destructor Documentation

◆ ~XCFunctional()

virtual q3::XCFunctional::~XCFunctional ( )
virtualdefault

Member Function Documentation

◆ compute()

virtual void q3::XCFunctional::compute ( const std::vector< Real > &  density,
std::vector< Real > &  xc_potential,
std::vector< Real > &  xc_energy_density 
) const
pure virtual

◆ compute_exchange_correlation_kernel()

virtual void q3::XCFunctional::compute_exchange_correlation_kernel ( const std::vector< Real > &  density,
std::vector< Real > &  exchange_correlation_kernel 
) const
inlinevirtual

Compute XC kernel f_xc(r) = d²E_xc/dρ² for DFPT linear response. Default: compute via numerical differentiation of V_xc.

Definition at line 148 of file init.hpp.

References compute().

◆ compute_fxc_spin()

virtual void q3::XCFunctional::compute_fxc_spin ( const std::vector< Real > &  density_up,
const std::vector< Real > &  density_down,
std::vector< Real > &  fxc_uu,
std::vector< Real > &  fxc_ud,
std::vector< Real > &  fxc_dd 
) const
inlinevirtual

Compute spin-resolved XC kernel for LSDA.

Definition at line 172 of file init.hpp.

References compute_spin().

◆ compute_gradient_corrected()

virtual void q3::XCFunctional::compute_gradient_corrected ( const std::vector< Real > &  density,
const std::vector< Real > &  gradient_density_squared,
std::vector< Real > &  xc_potential,
std::vector< Real > &  gradient_correction_density,
std::vector< Real > &  xc_energy_density 
) const
inlinevirtual

Compute XC potential and energy density (GGA interface, unpolarized). gradient_density_squared[i] = |∇ρ|² at grid point i.

This default body is refused rather than reached: a GGA calculation using a functional that did not override compute_gradient_corrected() would silently fall back to LDA, producing numerically wrong results with no error.

Reimplemented in q3::XC_LibXC.

Definition at line 84 of file init.hpp.

Referenced by q3::paw_one_center::compute_one_center_xc_gradient_corrected(), and q3::GradientCorrectedExchangeCorrelationPotentialCalculator::evaluate_unpolarized().

◆ compute_gradient_corrected_spin()

virtual void q3::XCFunctional::compute_gradient_corrected_spin ( const std::vector< Real > &  density_up,
const std::vector< Real > &  density_down,
const std::vector< Real > &  grho2_uu,
const std::vector< Real > &  grho2_ud,
const std::vector< Real > &  grho2_dd,
std::vector< Real > &  xc_potential_up,
std::vector< Real > &  xc_potential_down,
std::vector< Real > &  gradient_correction_up_up,
std::vector< Real > &  gradient_correction_up_down,
std::vector< Real > &  gradient_correction_down_down,
std::vector< Real > &  xc_energy_density 
) const
inlinevirtual

Compute XC potential and energy density (GGA interface, spin-polarized). grho2_uu = |∇ρ↑|², grho2_ud = ∇ρ↑·∇ρ↓, grho2_dd = |∇ρ↓|²

This default body is refused rather than reached: a spin-polarized GGA calculation using a functional that did not override compute_gradient_corrected_spin() would silently produce wrong physics.

Reimplemented in q3::XC_LibXC.

Definition at line 110 of file init.hpp.

Referenced by q3::paw_one_center::compute_one_center_xc_gradient_corrected_spin(), and q3::GradientCorrectedExchangeCorrelationPotentialCalculator::evaluate_spin_polarized().

◆ compute_spin()

virtual void q3::XCFunctional::compute_spin ( const std::vector< Real > &  density_up,
const std::vector< Real > &  density_down,
std::vector< Real > &  xc_potential_up,
std::vector< Real > &  xc_potential_down,
std::vector< Real > &  xc_energy_density 
) const
inlinevirtual

Compute XC potential and energy density (LDA interface, spin-polarized). density_up/density_down are spin-up/spin-down densities. xc_potential_up/xc_potential_down are the spin-resolved XC potentials. xc_energy_density is the XC energy density (per unit volume, evaluated at total density).

This default body is refused rather than reached: a spin-polarized calculation using a functional that did not override compute_spin() would silently produce wrong physics (LDA-unpolarized result for a spin-polarized input).

Reimplemented in q3::XC_LibXC.

Definition at line 38 of file init.hpp.

Referenced by compute_fxc_spin(), q3::paw_one_center::compute_one_center_xc_spin(), and q3::LocalDensityExchangeCorrelationPotentialCalculator::evaluate_spin_polarized().

◆ name()

virtual std::string q3::XCFunctional::name ( ) const
pure virtual

Implemented in q3::XC_LibXC.

◆ number_of_spin_components()

virtual int q3::XCFunctional::number_of_spin_components ( ) const
inlinevirtual

The spin mode this functional was constructed for: 1 or 2.

A LibXC handle is initialized once for a fixed mode and cannot be used in the other — a polarized handle driven through compute() misreads the interleaved (ρ↑, ρ↓) array it expects, and returns numbers that are finite, plausible and wrong. Callers that pick between the unpolarized and spin-polarized routines must branch on this rather than on how many densities they happen to hold.

Reimplemented in q3::XC_LibXC.

Definition at line 76 of file init.hpp.

◆ requires_density_gradient()

virtual bool q3::XCFunctional::requires_density_gradient ( ) const
inlinevirtual

Whether this is a GGA functional (needs gradients).

Reimplemented in q3::XC_LibXC.

Definition at line 62 of file init.hpp.

Referenced by q3::paw_one_center::PawOneCenterTerms::build(), q3::create_exchange_correlation_gradient_stress_calculator(), and q3::create_exchange_correlation_potential_calculator().


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