qrunch.chemistry.qrackle.scf.steppers.augmented_roothaan_hall
Augmented Roothaan-Hall (ARH) SCF stepper.
ARH turns the SCF procedure into a trust-region Newton minimization of the Hartree-Fock/Kohn-Sham energy with respect to orbital rotations.
It is different from the Augmented Hessian (TRAH) method in that it does not require a full electronic-response Fock build for every trial vector. Instead, it reconstructs the response cheaply from the density/Fock pairs collected during previous SCF iterations.
The idea
The Fock matrix of Hartree-Fock is affine in the density, \(F[D] = h + G[D]\) with \(G\) linear. Therefore, for any two stored densities,
i.e. the difference of two stored Fock matrices is exactly the two-electron response to the corresponding density difference – no new integral contraction required. For DFT the response is not exactly linear, but the stored differences still provide a good approximation.
ARH exploits that a trial density change \(\delta D\) is projected onto the subspace spanned by the stored density differences \(\bar D_i = D_i - D_n\), and the response Fock matrix is approximated by the same linear combination of the stored Fock differences \(\bar F_i = F_i - F_n\).
Concretely, with the history overlap \(T_{ij} = \mathrm{Tr}(\bar D_i \bar D_j)\) and projection coefficients \(c = T^{-1} b\), \(b_j = \mathrm{Tr}(\bar D_j \delta D)\),
When the history is empty (first iteration) the response term is zero and the Hessian reduces to the cheap Roothaan-Hall base Hessian, so early ARH behaves like a gap-preconditioned orbital optimizer and becomes more accurate as useful history accumulates.
The history overlap \(T\) becomes ill-conditioned once the stored density differences grow linearly dependent (exactly as DIIS error vectors do), so it is inverted through an eigendecomposition with a small-eigenvalue cutoff rather than a naive linear solve.
Reference: [HOJ+08].
Classes
Rolling store of previous AO density/Fock pairs used by ARH. |
|
ARH Hessian-vector product built from stored SCF history. |
|
Options for the Augmented Roothaan-Hall SCF stepper. |
|
Create a new density matrix using the Augmented Roothaan-Hall (ARH) method. |
|
Builder for the |
- class ARHHistory
Bases:
SCFQueueProtocol[TSCFMatrix,TSCFVector,TMatrix,TVector]Rolling store of previous AO density/Fock pairs used by ARH.
Only the raw pairs \((D_i, F_i)\) are kept, never consecutive differences. This matters because at macro-iteration
nthe differences that reconstruct the response must be formed relative to the current point, \(\bar D_i = D_i - D_n\), and that reference point changes every iteration.In addition to the density/Fock pairs the store keeps the Lowdin-transformed DIIS error matrices, so it satisfies
SCFQueueProtocoland can be fed directly to a DIIS stepper.- __init__(module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], maximum_length: int) None
Initialise the history store.
- Parameters:
module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module (used for copies and frees).
maximum_length (int) – Maximum number of pairs to retain.
- Return type:
None
- property densities: list[TSCFMatrix]
Stored AO density matrices (oldest first).
- property error_matrices: list[TSCFMatrix]
Stored Lowdin-transformed DIIS error matrices (oldest first).
- property fock_matrices: list[TSCFMatrix]
Stored AO Fock matrices (oldest first).
- free_queue() None
Free all stored matrices.
- Return type:
None
- property length: int
The current number of entries in the store.
- remove_oldest() None
Remove and free the oldest density/Fock/error triple.
- Return type:
None
- replace_newest(coefficients: list[float]) None
Replace the newest triple with an affine combination of all stored triples.
The densities are combined with the same coefficients as the Fock and error matrices, which keeps the pair usable for ARH’s response model:
ARH only uses the history through the differences \((D_i - D_\mathrm{ref}, F_i - F_\mathrm{ref})\), which requires \(F_i = F(D_i)\) for every stored pair.
For Hartree-Fock, \(F(D) = h + G(D)\) is affine in \(D\), so with \(\sum_i c_i = 1\) the combined pair satisfies \(\sum_i c_i F_i = F(\sum_i c_i D_i)\) exactly.
For Kohn-Sham DFT the exchange-correlation potential is non-linear in \(D\), so the relation only holds up to second order in the spread of the combined densities.
The combined density preserves the electron count but is generally not idempotent. That is harmless here because ARH only uses it in a linear response model and never as an SCF density.
The combined error is a first-order estimate, see
SCFQueueProtocol.replace_newest().
- Parameters:
coefficients (list[float]) – Coefficients \(c_i\) for the stored triples (oldest first).
- Return type:
None
- update(fock_matrix: TSCFMatrix, density_matrix: TSCFMatrix, overlap_matrix: TSCFMatrix, lowdin_orthogonalizer: TSCFMatrix) None
Store a copy of a density/Fock pair and its error, evicting the oldest if full.
- Parameters:
fock_matrix (TSCFMatrix) – AO Fock matrix to store.
density_matrix (TSCFMatrix) – AO density matrix to store.
overlap_matrix (TSCFMatrix) – The overlap matrix \(S\).
lowdin_orthogonalizer (TSCFMatrix) – The Lowdin orthogonalizer \(L = S^{-1/2}\).
- Return type:
None
- class ArhHessianVectorProduct
Bases:
Generic[TSCFMatrix,TSCFVector,TMatrix,TVector],OrbitalHessianVectorProduct[TSCFMatrix]ARH Hessian-vector product built from stored SCF history.
For each trial rotation \(X\) it forms \(\delta D_{o} = [D_{o}, X]\), transforms it to the AO basis, projects it onto the stored density differences to get the response Fock matrix as a linear combination of stored Fock differences, and finally assembles the orbital sigma vector.
- __init__(module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], orthonormal_basis: OrthonormalBasis[TSCFMatrix, TSCFVector, TMatrix, TVector], orthonormal_fock: TSCFMatrix, orthonormal_density: TSCFMatrix, reference_density: TSCFMatrix, reference_fock: TSCFMatrix, history: ARHHistory[TSCFMatrix, TSCFVector, TMatrix, TVector], eigenvalue_threshold: float) None
Precompute the history differences and the pseudo-inverse of the overlap.
- Parameters:
module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module.
orthonormal_basis (OrthonormalBasis[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Orthonormal-basis transformer.
orthonormal_fock (TSCFMatrix) – Current Fock matrix in the orthonormal basis.
orthonormal_density (TSCFMatrix) – Current density matrix in the orthonormal basis.
reference_density (TSCFMatrix) – Current AO density \(D_n\) (projection reference).
reference_fock (TSCFMatrix) – Current AO Fock \(F_n\) (projection reference).
history (ARHHistory[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Store of previous AO density/Fock pairs.
eigenvalue_threshold (float) – Relative cutoff for the history-overlap inverse.
- Return type:
None
- apply(trial: TSCFMatrix) TSCFMatrix
Compute the ARH Hessian-vector product for a trial rotation.
- Parameters:
trial (TSCFMatrix) – Antisymmetric trial rotation in the orthonormal basis.
- Return type:
TSCFMatrix
- apply_many(trials: list[TSCFMatrix]) list[TSCFMatrix]
Compute the ARH Hessian-vector product for several trial rotations.
- Parameters:
trials (list[TSCFMatrix]) – Antisymmetric trial rotations in the orthonormal basis.
- Return type:
list[TSCFMatrix]
- free() None
Free the per-iteration difference matrices.
- Return type:
None
- class AugmentedRoothaanHallOptions
Bases:
DataclassPublicAPIOptions for the Augmented Roothaan-Hall SCF stepper.
- Parameters:
history_length – Number of previous density/Fock pairs kept to reconstruct the electronic-response part of the Hessian.
initial_trust_radius – Trust radius (Frobenius norm bound on the orbital rotation) used for the first step.
minimum_trust_radius – Lower clamp on the trust radius.
maximum_trust_radius – Upper clamp on the trust radius.
maximum_micro_iterations – Maximum number of Davidson directions used to solve the augmented-Hessian trust-region equations.
micro_convergence_factor – The inner problem is solved only to
micro_convergence_factor * ||g||.history_eigenvalue_threshold – Relative cutoff for discarding small eigenvalues when inverting the (possibly linearly dependent) history overlap matrix.
- __init__(*, history_length: int = 8, initial_trust_radius: float = 0.4, minimum_trust_radius: float = 0.001, maximum_trust_radius: float = 1.0, maximum_micro_iterations: int = 20, micro_convergence_factor: float = 0.1, history_eigenvalue_threshold: float = 1e-10) None
- Parameters:
history_length (int)
initial_trust_radius (float)
minimum_trust_radius (float)
maximum_trust_radius (float)
maximum_micro_iterations (int)
micro_convergence_factor (float)
history_eigenvalue_threshold (float)
- Return type:
None
- history_eigenvalue_threshold: float = 1e-10
- history_length: int = 8
- initial_trust_radius: float = 0.4
- maximum_micro_iterations: int = 20
- maximum_trust_radius: float = 1.0
- micro_convergence_factor: float = 0.1
- minimum_trust_radius: float = 0.001
- class AugmentedRoothaanHallSCFStepper
Bases:
SCFStepperProtocol[TSCFMatrix,TSCFVector,TMatrix,TVector],SCFTrialAssessmentProtocol[TSCFMatrix]Create a new density matrix using the Augmented Roothaan-Hall (ARH) method.
- __init__(scf_matrix_module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], fock_builder: FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], options: AugmentedRoothaanHallOptions | None = None) None
Initialise the ARH SCF stepper.
- Parameters:
scf_matrix_module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module (restricted or unrestricted).
fock_builder (FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Builder that owns the electronic-energy expression used for the trust-radius feedback. ARH does not use it to build the response Hessian (that is reconstructed from stored history).
options (AugmentedRoothaanHallOptions | None) – Options for the ARH stepper. If None, default options are used.
- Return type:
None
- assess_trial(current_density: TSCFMatrix, current_fock: TSCFMatrix, current_energy: float, overlap_matrix: TSCFMatrix, lowdin_orthogonalizer: TSCFMatrix) bool
Accept or reject an evaluated trial before the driver records or switches it.
The actual energy is compared with the trust-region prediction. A rejected trial is retried from the last accepted reference. Returning True accepts the trial; it does not imply SCF convergence.
- Parameters:
current_density (TSCFMatrix) – Evaluated AO trial density.
current_fock (TSCFMatrix) – Fock matrix at the trial density.
current_energy (float) – Electronic energy of the trial.
overlap_matrix (TSCFMatrix) – AO overlap matrix.
lowdin_orthogonalizer (TSCFMatrix) – Lowdin orthogonalizer.
- Return type:
bool
- property can_update_scf_queue: bool
ARH keeps its own history and does not populate the shared SCF queue.
- create_new_density(scf_queue: SCFQueueProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], current_density: TSCFMatrix, current_fock: TSCFMatrix, core_hamiltonian: TSCFMatrix, overlap_matrix: TSCFMatrix, lowdin_orthogonalizer: TSCFMatrix, molecular_configuration: MolecularConfiguration, roothaan_hall_solver: RoothaanHallSolver[TSCFMatrix, TSCFVector, TMatrix, TVector], orbital_occupation: OrbitalOccupation) TSCFMatrix
Produce a new AO density by taking one ARH trust-region orbital step.
- Parameters:
scf_queue (SCFQueueProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – The shared SCF queue.
current_density (TSCFMatrix) – The current AO density matrix \(D_n\).
current_fock (TSCFMatrix) – The current AO Fock matrix \(F_n\).
core_hamiltonian (TSCFMatrix) – The core Hamiltonian \(h = T + V_{\mathrm{nuc}}\).
overlap_matrix (TSCFMatrix) – The overlap matrix \(S\).
lowdin_orthogonalizer (TSCFMatrix) – The Lowdin orthogonalizer \(S^{-1/2}\).
molecular_configuration (MolecularConfiguration) – The molecular configuration (unused by ARH).
roothaan_hall_solver (RoothaanHallSolver[TSCFMatrix, TSCFVector, TMatrix, TVector]) – A Roothaan-Hall solver (unused by ARH).
orbital_occupation (OrbitalOccupation) – Electron occupation giving the number of occupied orbitals per spin channel.
- Return type:
TSCFMatrix
- free() None
Free stored matrices without resetting optimization state.
- Return type:
None
- init_scf_queue(max_length: int) SCFQueueProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]
Create a SCF queue (used by the driver for the gradient/convergence check).
- Parameters:
max_length (int)
- Return type:
SCFQueueProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]
- property is_local_region_indicated: bool
Indicate the local region when the augmented-Hessian level shift vanishes.
- property options: AugmentedRoothaanHallOptions
Options used by the ARH stepper.
- reset() None
Free stored matrices and reset trust-region, solver and trial state.
- Return type:
None
- class AugmentedRoothaanHallSCFStepperBuilder
Bases:
SCFStepperBuilderProtocolBuilder for the
AugmentedRoothaanHallSCFStepper.- __init__(options: AugmentedRoothaanHallOptions | None = None) None
Initialise the ARH stepper builder.
- Parameters:
options (AugmentedRoothaanHallOptions | None) – Options for the ARH stepper. If None, default options are used.
- Return type:
None
- create_stepper(scf_matrix_module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], fock_builder: FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], fallback_scf_stepper_builder: SCFStepperBuilderProtocol | None = None) AugmentedRoothaanHallSCFStepper[TSCFMatrix, TSCFVector, TMatrix, TVector]
Create a new ARH SCF stepper.
- Parameters:
scf_matrix_module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module (restricted or unrestricted).
fock_builder (FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Builder that owns the electronic-energy expression. ARH reconstructs the response Hessian from stored history and only uses the builder to evaluate the energy for the trust-radius feedback.
fallback_scf_stepper_builder (SCFStepperBuilderProtocol | None) – Optional fallback builder. Not used by ARH.
- Return type:
AugmentedRoothaanHallSCFStepper[TSCFMatrix, TSCFVector, TMatrix, TVector]