qrunch.chemistry.qrackle.integrals.pyscf_density_fitting

Packed density-fitted Coulomb and full- or range-separated exchange contractions.

Classes

DensityFittingOptions

Options for in-memory density-fitted Coulomb and exchange contractions.

PySCFDensityFittedCoulombCalculator

Compute only Coulomb matrices, sharing fitted factors with an exchange calculator.

PySCFDensityFittedExactExchangeCalculator

Compute full- or range-separated exchange from shared kernel-specific factors.

PySCFDensityFitting

Contract symmetric AO densities from packed, metric-factorized three-index integrals.

class DensityFittingOptions

Bases: DataclassPublicAPI

Options for in-memory density-fitted Coulomb and exchange contractions.

Configure storage of the metric-factorized three-index integrals. The auxiliary basis is taken from the molecular configuration, including its automatic basis selection when no explicit auxiliary basis is provided.

Parameters:

max_cache_megabytes – Optional limit on estimated packed-factor storage in MB, used only for this pre-check; None (the default) disables it. PySCF keeps its own working-memory default. Bounds the sum across retained full- and range-separated kernels, not temporary memory or process RSS. Checked before each kernel is built, using the full auxiliary basis, so it can overestimate when PySCF drops linearly dependent auxiliary functions. Exceeding it raises an error rather than switching to disk storage.

__init__(*, max_cache_megabytes: float | None = None) → None
Parameters:

max_cache_megabytes (float | None)

Return type:

None

max_cache_megabytes: float | None = None
class PySCFDensityFittedCoulombCalculator

Bases: CoulombCalculatorProtocol[TMatrix, TVector]

Compute only Coulomb matrices, sharing fitted factors with an exchange calculator.

__init__(matrix_module: MatrixModuleProtocol[TMatrix, TVector], density_fitting: PySCFDensityFitting) → None

Initialise with a shared packed-factor cache.

Parameters:
Return type:

None

compute_restricted(density_matrix: RestrictedMatrix[TMatrix], molecular_configuration: MolecularConfiguration) → RestrictedMatrix[TMatrix]

Build one fitted Coulomb matrix.

Parameters:
Return type:

RestrictedMatrix[TMatrix]

compute_restricted_many(density_matrices: list[RestrictedMatrix[TMatrix]], molecular_configuration: MolecularConfiguration) → list[RestrictedMatrix[TMatrix]]

Build fitted Coulomb matrices for signed, fractional or determinant densities.

Parameters:
Return type:

list[RestrictedMatrix[TMatrix]]

compute_unrestricted(density_matrix: UnrestrictedMatrix[TMatrix], molecular_configuration: MolecularConfiguration) → UnrestrictedMatrix[TMatrix]

Build the total-density Coulomb matrix in both spin channels.

Parameters:
Return type:

UnrestrictedMatrix[TMatrix]

compute_unrestricted_many(density_matrices: list[UnrestrictedMatrix[TMatrix]], molecular_configuration: MolecularConfiguration) → list[UnrestrictedMatrix[TMatrix]]

Build total-density Coulomb matrices with independently owned spin channels.

Parameters:
Return type:

list[UnrestrictedMatrix[TMatrix]]

class PySCFDensityFittedExactExchangeCalculator

Bases: ExactExchangeCalculatorProtocol[TMatrix, TVector]

Compute full- or range-separated exchange from shared kernel-specific factors.

__init__(matrix_module: MatrixModuleProtocol[TMatrix, TVector], density_fitting: PySCFDensityFitting) → None

Initialise with a shared packed-factor cache.

Parameters:
Return type:

None

compute_restricted(density_matrix: RestrictedMatrix[TMatrix], molecular_configuration: MolecularConfiguration, *, omega: float | None = None) → RestrictedMatrix[TMatrix]

Build one fitted exchange matrix.

Parameters:
  • density_matrix (RestrictedMatrix[TMatrix]) – Spin-summed AO density.

  • molecular_configuration (MolecularConfiguration) – Molecular configuration.

  • omega (float | None) – Finite range-separation parameter; None or zero selects full-range exchange.

Return type:

RestrictedMatrix[TMatrix]

compute_restricted_many(density_matrices: list[RestrictedMatrix[TMatrix]], molecular_configuration: MolecularConfiguration, *, omega: float | None = None) → list[RestrictedMatrix[TMatrix]]

Build fitted exchange for signed, fractional or determinant densities.

Parameters:
  • density_matrices (list[RestrictedMatrix[TMatrix]]) – Spin-summed AO densities.

  • molecular_configuration (MolecularConfiguration) – Molecular configuration.

  • omega (float | None) – Finite range-separation parameter; None or zero selects full-range exchange.

Return type:

list[RestrictedMatrix[TMatrix]]

compute_unrestricted(density_matrix: UnrestrictedMatrix[TMatrix], molecular_configuration: MolecularConfiguration, *, omega: float | None = None) → UnrestrictedMatrix[TMatrix]

Build fitted exchange for each spin channel.

Parameters:
  • density_matrix (UnrestrictedMatrix[TMatrix]) – Spin-resolved AO density.

  • molecular_configuration (MolecularConfiguration) – Molecular configuration.

  • omega (float | None) – Finite range-separation parameter; None or zero selects full-range exchange.

Return type:

UnrestrictedMatrix[TMatrix]

compute_unrestricted_many(density_matrices: list[UnrestrictedMatrix[TMatrix]], molecular_configuration: MolecularConfiguration, *, omega: float | None = None) → list[UnrestrictedMatrix[TMatrix]]

Build fitted exchange independently for each spin channel.

Parameters:
  • density_matrices (list[UnrestrictedMatrix[TMatrix]]) – Spin-resolved AO densities.

  • molecular_configuration (MolecularConfiguration) – Molecular configuration.

  • omega (float | None) – Finite range-separation parameter; None or zero selects full-range exchange.

Return type:

list[UnrestrictedMatrix[TMatrix]]

class PySCFDensityFitting

Bases: object

Contract symmetric AO densities from packed, metric-factorized three-index integrals.

Retain only factors with shape (naux, nao * (nao + 1) // 2) for the most recent molecule and auxiliary basis, separately for each exchange kernel. Packing stores the lower-triangular AO pairs, including the diagonal, exploiting their symmetry instead of retaining all nao * nao pairs. Positive omega selects erf long-range exchange, negative omega selects erfc short-range exchange, and None or zero selects the full-range kernel. J always uses the full-range factors. Both the auxiliary metric and three-center integrals use the requested kernel. PySCF contracts from these packed factors in blocks; no full four-index tensor or permanently unpacked factors are built. Verified positive low-rank densities can use PySCF’s factorized exchange contraction. Other densities use the general contraction. No density-dependent results are cached. Restricted inputs are spin-summed. Unrestricted J uses the total density and K remains spin-specific.

__init__(options: DensityFittingOptions | None = None) → None

Initialise without evaluating integrals until the first nonempty request.

Parameters:

options (DensityFittingOptions | None) – Retained packed-factor memory limit.

Return type:

None

property cache_bytes: int

Report retained factor storage, excluding temporary contraction memory and process RSS.

compute_coulomb(molecular_configuration: MolecularConfiguration, densities: NDArray[float64]) → NDArray[float64]

Contract only Coulomb matrices using the shared packed factors.

Parameters:
  • molecular_configuration (MolecularConfiguration) – Molecular and auxiliary-basis configuration.

  • densities (NDArray[float64]) – Nonempty batch of spin-summed densities.

Return type:

NDArray[float64]

compute_exchange(molecular_configuration: MolecularConfiguration, densities: NDArray[float64], *, omega: float | None = None) → NDArray[float64]

Contract only exchange matrices using the shared packed factors.

Parameters:
  • molecular_configuration (MolecularConfiguration) – Molecular and auxiliary-basis configuration.

  • densities (NDArray[float64]) – Nonempty density batch, with optional leading spin dimensions.

  • omega (float | None) – Range-separation parameter; None or zero selects full-range exchange.

Return type:

NDArray[float64]