qrunch.chemistry.qrackle.scf.builders.fock_builder

Builder for the Fock matrix (core hamiltonian + Coulomb + Exchange).

Functions

make_fock_builder(scf_matrix_module[, ...])

Create a Fock builder with separate Coulomb and exact-exchange calculators.

Classes

FockBuilder

Build the Fock matrix.

class FockBuilder

Bases: MetadataFromFields, Generic[TSCFMatrix, TSCFVector, TMatrix, TVector]

Build the Fock matrix.

\[F^{\alpha} = h + J[D^{\alpha} + D^{\beta}] - K[D^{\alpha}] F^{\beta} = h + J[D^{\alpha} + D^{\beta}] - K[D^{\beta}]\]

The builder requests Coulomb and exact exchange separately and adds the results.

__init__(scf_matrix_module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], coulomb_calculator: CoulombCalculatorProtocol[TMatrix, TVector], exact_exchange_calculator: ExactExchangeCalculatorProtocol[TMatrix, TVector]) → None

Initialise the builder.

Parameters:
Return type:

None

compute(core_hamiltonian: TSCFMatrix, density_matrix: TSCFMatrix, molecular_configuration: MolecularConfiguration) → TSCFMatrix

Build the Fock matrix.

\[F^{\alpha} = h + J[D^{\alpha} + D^{\beta}] - K[D^{\alpha}] F^{\beta} = h + J[D^{\alpha} + D^{\beta}] - K[D^{\beta}]\]

Where \(h = T + V_{\\mathrm{nuc}}\).

Parameters:
  • core_hamiltonian (TSCFMatrix) – The core Hamiltonian matrix in the AO basis.

  • density_matrix (TSCFMatrix) – The density matrix (restricted or unrestricted) in the AO basis.

  • molecular_configuration (MolecularConfiguration) – The molecular configuration.

Return type:

TSCFMatrix

compute_density_response(reference_density_matrix: TSCFMatrix, density_matrix_direction: TSCFMatrix, molecular_configuration: MolecularConfiguration) → TSCFMatrix

Apply the Hartree-Fock density response to one density direction.

Because the Hartree-Fock interaction operator \(G[D]\) is linear, the response is independent of the reference density and satisfies \(F'[D_0](\delta D) = G[\delta D]\).

Parameters:
  • reference_density_matrix (TSCFMatrix) – Reference density in the AO basis.

  • density_matrix_direction (TSCFMatrix) – Density perturbation 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 Hartree-Fock density response to several density directions.

For Hartree-Fock, \(G[D]\) is linear in the density, so the exact first-order response is simply \(G[\delta D]\) for every direction.

Parameters:
  • reference_density_matrix (TSCFMatrix) – Reference density 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_g(density_matrix: TSCFMatrix, molecular_configuration: MolecularConfiguration) → TSCFMatrix

Build the 2 electron part of the effective one-particle matrix \(G[D]\).

\[G^{\alpha} = J[D^{\alpha} + D^{\beta}] - K[D^{\alpha}] G^{\beta} = J[D^{\alpha} + D^{\beta}] - K[D^{\beta}]\]
Parameters:
  • density_matrix (TSCFMatrix) – The density matrix (restricted or unrestricted) in the AO basis.

  • molecular_configuration (MolecularConfiguration) – The molecular configuration.

Return type:

TSCFMatrix

compute_g_many(density_matrices: list[TSCFMatrix], molecular_configuration: MolecularConfiguration) → list[TSCFMatrix]

Build the two-electron part of the effective one-particle matrix for a density batch.

Parameters:
  • density_matrices (list[TSCFMatrix]) – Density matrices in the AO basis.

  • molecular_configuration (MolecularConfiguration) – The molecular configuration.

Return type:

list[TSCFMatrix]

compute_many(core_hamiltonian: TSCFMatrix, density_matrices: list[TSCFMatrix], molecular_configuration: MolecularConfiguration) → list[TSCFMatrix]

Build Fock matrices for a batch of AO density matrices.

Parameters:
  • core_hamiltonian (TSCFMatrix) – The core Hamiltonian matrix in the AO basis.

  • density_matrices (list[TSCFMatrix]) – Density matrices in the AO basis.

  • molecular_configuration (MolecularConfiguration) – The molecular configuration.

Return type:

list[TSCFMatrix]

electronic_energy(core_hamiltonian: TSCFMatrix, density_matrix: TSCFMatrix, effective_matrix: TSCFMatrix, molecular_configuration: MolecularConfiguration) → float

Compute the Hartree-Fock electronic energy \(E = \tfrac{1}{2}\mathrm{Tr}[D(h + F)]\).

This expression is exact because the two-electron energy of a Fock build assembled from Coulomb and exact exchange is \(\tfrac{1}{2}\mathrm{Tr}[D\,G[D]]\), i.e. the build is linear in the density. The molecular configuration is unused here but is part of the protocol so that a Kohn-Sham builder can add the exchange-correlation energy \(E_{\mathrm{xc}}[\rho]\).

Parameters:
  • core_hamiltonian (TSCFMatrix) – The core Hamiltonian \(h = T + V_{\mathrm{nuc}}\).

  • density_matrix (TSCFMatrix) – The density matrix (restricted or unrestricted) in the AO basis.

  • effective_matrix (TSCFMatrix) – The Fock matrix returned by compute().

  • molecular_configuration (MolecularConfiguration) – The molecular configuration (unused for Hartree-Fock).

Return type:

float

property is_linear_in_density: bool

Whether the two-electron part \(G[D] = F[D] - h\) is linear in the density.

The Fock matrix is built purely from Coulomb \(J[D]\) and exact exchange \(K[D]\), both of which are linear in the density, so this is always True. A Kohn-Sham builder with a nonlinear exchange-correlation functional returns False.

make_fock_builder(scf_matrix_module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], coulomb_calculator: CoulombCalculatorProtocol[TMatrix, TVector] | None = None, exact_exchange_calculator: ExactExchangeCalculatorProtocol[TMatrix, TVector] | None = None) → FockBuilder[TSCFMatrix, TSCFVector, TMatrix, TVector]

Create a Fock builder with separate Coulomb and exact-exchange calculators.

Parameters:
  • scf_matrix_module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module for algebraic operations.

  • coulomb_calculator (CoulombCalculatorProtocol[TMatrix, TVector] | None) – Calculator for Coulomb matrices. Defaults to PySCF.

  • exact_exchange_calculator (ExactExchangeCalculatorProtocol[TMatrix, TVector] | None) – Calculator for exact-exchange matrices. Defaults to PySCF.

Return type:

FockBuilder[TSCFMatrix, TSCFVector, TMatrix, TVector]