qrunch.chemistry.qrackle.scf.builders.kohn_sham_builder
Builder for Kohn-Sham effective matrices.
Functions
|
Create a Kohn-Sham builder with default PySCF calculators. |
Classes
Build Kohn-Sham matrices, interaction potentials, and density responses. |
- class KohnShamBuilder
Bases:
MetadataFromFields,Generic[TSCFMatrix,TSCFVector,TMatrix,TVector]Build Kohn-Sham matrices, interaction potentials, and density responses.
The effective matrix is
\[F[D] = h + J[D] - c_{\mathrm{SR}} K[D] - (c_{\mathrm{LR}} - c_{\mathrm{SR}}) K^{\mathrm{LR}}_{\omega}[D] + V_{\mathrm{xc}}[D].\]The interaction potential \(G[D] = F[D] - h\) is generally nonlinear because of \(V_{\mathrm{xc}}[D]\). Its first-order response at a reference density is therefore evaluated separately as
\[F'[D_0](\delta D) = J[\delta D] - c_{\mathrm{SR}} K[\delta D] - (c_{\mathrm{LR}} - c_{\mathrm{SR}}) K^{\mathrm{LR}}_{\omega}[\delta D] + V_{\mathrm{xc}}'[D_0](\delta D).\]- __init__(scf_matrix_module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], coulomb_calculator: CoulombCalculatorProtocol[TMatrix, TVector], exact_exchange_calculator: ExactExchangeCalculatorProtocol[TMatrix, TVector], exchange_correlation_calculator: ExchangeCorrelationCalculatorProtocol[TMatrix, TVector], *, cache_last_xc_result: bool = True) None
Initialise the builder.
- Parameters:
scf_matrix_module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Matrix module used for SCF matrix operations.
coulomb_calculator (CoulombCalculatorProtocol[TMatrix, TVector]) – Calculator used to build Coulomb matrices.
exact_exchange_calculator (ExactExchangeCalculatorProtocol[TMatrix, TVector]) – Calculator used to build exact-exchange matrices.
exchange_correlation_calculator (ExchangeCorrelationCalculatorProtocol[TMatrix, TVector]) – Calculator used to evaluate XC terms.
cache_last_xc_result (bool) – Whether to cache the last XC result to avoid redundant calculations.
- Return type:
None
- compute(core_hamiltonian: TSCFMatrix, density_matrix: TSCFMatrix, molecular_configuration: MolecularConfiguration) TSCFMatrix
Build one Kohn-Sham matrix.
- Parameters:
core_hamiltonian (TSCFMatrix)
density_matrix (TSCFMatrix)
molecular_configuration (MolecularConfiguration)
- Return type:
TSCFMatrix
- compute_density_response(reference_density_matrix: TSCFMatrix, density_matrix_direction: TSCFMatrix, molecular_configuration: MolecularConfiguration) TSCFMatrix
Apply \(F'[D_0]\) to one density direction.
- Parameters:
reference_density_matrix (TSCFMatrix) – Reference density \(D_0\) in the AO basis.
density_matrix_direction (TSCFMatrix) – Density perturbation \(\delta D\) in the AO basis.
molecular_configuration (MolecularConfiguration) – Molecular configuration.
- Return type:
TSCFMatrix
- compute_density_response_many(reference_density_matrix: TSCFMatrix, density_matrix_directions: list[TSCFMatrix], molecular_configuration: MolecularConfiguration) list[TSCFMatrix]
Apply the Kohn-Sham density response to several density directions.
Computes
\[F'[D_0](\delta D) = J[\delta D] - c_{\mathrm{SR}} K[\delta D] - (c_{\mathrm{LR}} - c_{\mathrm{SR}}) K^{\mathrm{LR}}_{\omega}[\delta D] + V_{\mathrm{xc}}'[D_0](\delta D).\]All directions share one reference density, allowing the XC backend to reuse the response kernel evaluated at \(D_0\).
- Parameters:
reference_density_matrix (TSCFMatrix) – Reference density \(D_0\) in the AO basis.
density_matrix_directions (list[TSCFMatrix]) – Density perturbations in the AO basis.
molecular_configuration (MolecularConfiguration) – Molecular configuration.
- Return type:
list[TSCFMatrix]
- compute_many(core_hamiltonian: TSCFMatrix, density_matrices: list[TSCFMatrix], molecular_configuration: MolecularConfiguration) list[TSCFMatrix]
Build Kohn-Sham matrices for several densities.
- Parameters:
core_hamiltonian (TSCFMatrix)
density_matrices (list[TSCFMatrix])
molecular_configuration (MolecularConfiguration)
- Return type:
list[TSCFMatrix]
- electronic_energy(core_hamiltonian: TSCFMatrix, density_matrix: TSCFMatrix, effective_matrix: TSCFMatrix, molecular_configuration: MolecularConfiguration) float
Compute the Kohn-Sham electronic energy without XC double counting.
Uses
\[E_{\mathrm{el}} = \frac{1}{2}\operatorname{Tr}[D(h + F - V_{\mathrm{xc}})] + E_{\mathrm{xc}}.\]- Parameters:
core_hamiltonian (TSCFMatrix) – Core Hamiltonian in the AO basis.
density_matrix (TSCFMatrix) – Density matrix in the AO basis.
effective_matrix (TSCFMatrix) – Kohn-Sham matrix returned by
compute().molecular_configuration (MolecularConfiguration) – Molecular configuration.
- Return type:
float
- property is_linear_in_density: bool
Whether the two-electron part \(G[D] = F[D] - h\) is linear in the density.
- make_kohn_sham_builder(scf_matrix_module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], functional: str, coulomb_calculator: CoulombCalculatorProtocol[TMatrix, TVector] | None = None, exact_exchange_calculator: ExactExchangeCalculatorProtocol[TMatrix, TVector] | None = None, exchange_correlation_calculator: ExchangeCorrelationCalculatorProtocol[TMatrix, TVector] | None = None, exchange_correlation_grid_options: ExchangeCorrelationGridOptions | None = None) KohnShamBuilder[TSCFMatrix, TSCFVector, TMatrix, TVector]
Create a Kohn-Sham builder with default PySCF calculators.
- Parameters:
scf_matrix_module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module for algebraic operations.
functional (str) – PySCF LibXC functional expression.
coulomb_calculator (CoulombCalculatorProtocol[TMatrix, TVector] | None) – Calculator for the Coulomb matrix. Defaults to PySCF.
exact_exchange_calculator (ExactExchangeCalculatorProtocol[TMatrix, TVector] | None) – Calculator for the exact-exchange matrix. Defaults to PySCF.
exchange_correlation_calculator (ExchangeCorrelationCalculatorProtocol[TMatrix, TVector] | None) – Calculator for the XC potential. Defaults to PySCF.
exchange_correlation_grid_options (ExchangeCorrelationGridOptions | None) – Options for the default PySCF XC integration grid.
- Return type:
KohnShamBuilder[TSCFMatrix, TSCFVector, TMatrix, TVector]