qrunch.chemistry.qrackle.scf.orbital_rotation.orbital_rotation_solver
Shared orbital-rotation optimizer used by the ARH and TRAH SCF steppers.
Both the Augmented Roothaan-Hall (ARH) and the Trust-Region Augmented-Hessian (TRAH) methods view the SCF problem not as the usual “diagonalize the Fock matrix” fixed-point iteration, but as a direct minimization of the Hartree-Fock energy with respect to orbital rotations.
Parametrization
The occupied orbitals are rotated by an antisymmetric generator \(X\),
Equivalently the (idempotent) density is rotated as \(D' = \exp(-X) D \exp(X)\). This automatically preserves both the number of electrons and idempotency, so no constraint has to be enforced by hand.
Working basis
All of the algebra below is carried out in the Lowdin orthonormal basis,
where the overlap metric is the identity. This removes the generalized-metric
bookkeeping (the S factors) from every commutator and makes the density an
exact orthogonal projector. Transforming to/from the AO basis is done with the
Lowdin orthogonalizer \(L = S^{-1/2}\):
Because \(D_{o}\) is an exact projector in this basis, every commutator with \(D_{o}\) automatically lands in the non-redundant occupied-virtual space, so the redundant occupied-occupied and virtual-virtual rotations never have to be projected out explicitly.
Gradient and Hessian
The orbital gradient (conjugate to \(X\) under the Frobenius inner product) is the commutator
At convergence \([F, D] = 0\), i.e. the occupied-virtual block of the Fock matrix vanishes. A first-order change of the density along \(X\) is \(\delta D_{o} = [D_{o}, X]\), which induces a response Fock matrix \(\delta F\). Differentiating \(G\) gives the Hessian-vector product
The only thing that distinguishes ARH from TRAH is how \(\delta F\) is
obtained (from SCF history, or from a genuine response build). That operation is
injected through OrbitalHessianVectorProduct; everything else in this
module is shared.
Trust region
An approximate (ARH) or exact (TRAH) Newton step is only trustworthy inside a region where the quadratic model is accurate. The step is therefore obtained from an augmented-Hessian eigenproblem,
whose lowest eigenpair simultaneously delivers a search direction and a level shift \(\mu\) that regularizes an indefinite Hessian. The scale factor \(\alpha\) is tuned (by bisection) so the resulting step length matches the current trust radius. The eigenproblem is never built in the full \(N_{\mathrm{occ}} N_{\mathrm{virt}}\) space; it is solved in a small Davidson subspace where changing \(\alpha\) is cheap.
Davidson expansion can optionally use orbital-energy preconditioning, which
approximates the shifted inverse using occupied-virtual orbital-energy gaps.
This changes the subspace expansion, not the Hessian model or trust-region
problem. By default, ScalarDiagonalPreconditioner uses a scalar
diagonal estimate.
References: ARH [HOJ+08]; TRAH [HP21].
Classes
Davidson solver for the augmented-Hessian trust-region step. |
|
The reduced space problem Hessian and gradient. |
|
Adaptive trust-radius controller shared by ARH and TRAH. |
|
Result of a single augmented-Hessian trust-region solve. |
- class AugmentedHessianTrustRegionSolver
Bases:
Generic[TSCFMatrix,TSCFVector,TMatrix,TVector]Davidson solver for the augmented-Hessian trust-region step.
The solver never forms the full orbital Hessian. It maintains a small set of orthonormal trial directions, applies the (injected) Hessian-vector product once per new direction, and solves the tiny augmented eigenproblem in that subspace. The trust radius is enforced by scaling the augmented gradient block (the
alphaparameter), which is cheap because it only touches the reduced problem and needs no extra Hessian-vector products.Retained directions and responses may be reused when retrying at the same reference. The caller must release them with
freeorresetwhen done.- __init__(module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], maximum_micro_iterations: int, micro_convergence_factor: float) None
Initialise the solver.
- Parameters:
module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module.
maximum_micro_iterations (int) – Maximum number of Davidson directions to build at one reference, including any rejected-step retries.
micro_convergence_factor (float) – Solve the inner problem only to
micro_convergence_factor * ||g||; there is no point solving the Newton equations tightly while the outer SCF is still far from convergence.
- Return type:
None
- free() None
Free retained directions and responses without resetting the level shift.
- Return type:
None
- property level_shift: float | None
Level shift from the most recent trust-region solve.
- reset() None
Free retained directions and responses and clear the most recent level shift.
- Return type:
None
- solve(gradient: TSCFMatrix, gradient_norm: float, hessian_vector_product: OrbitalHessianVectorProduct[TSCFMatrix], trust_radius: float, *, retain_subspace: bool = False, retry: bool = False, preconditioner: OrbitalStepPreconditioner[TSCFMatrix] | None = None) TrustRegionStep[TSCFMatrix]
Solve for the trust-region orbital step.
- Parameters:
gradient (TSCFMatrix) – The orbital gradient \(G\) (antisymmetric, orthonormal basis).
gradient_norm (float) – Frobenius norm of the gradient.
hessian_vector_product (OrbitalHessianVectorProduct[TSCFMatrix]) – The injected Hessian-vector product.
trust_radius (float) – Current trust radius (Frobenius norm bound on the step).
retain_subspace (bool) – Keep directions and responses for a possible rejected-step retry. Call
freeorresetto release them after the final retained solve.retry (bool) – Reuse the subspace from the previous retained solve at exactly the same reference density and Fock matrix. Requires
retain_subspace. When False, any retained subspace is discarded.preconditioner (OrbitalStepPreconditioner[TSCFMatrix] | None) – Optional shifted-Hessian inverse for Davidson expansion. If omitted, use a scalar diagonal preconditioner.
- Return type:
TrustRegionStep[TSCFMatrix]
- class ReducedProblem
Bases:
objectThe reduced space problem Hessian and gradient.
- Parameters:
hessian – The Hessian.
gradient – The gradient.
- __init__(hessian: NDArray[float64], gradient: NDArray[float64]) None
- Parameters:
hessian (NDArray[float64])
gradient (NDArray[float64])
- Return type:
None
- gradient: NDArray[float64]
- hessian: NDArray[float64]
- class TrustRadiusController
Bases:
objectAdaptive trust-radius controller shared by ARH and TRAH.
After a step is taken the true energy change is compared with the change predicted by the quadratic model,
\[\rho = \frac{\Delta E_{\mathrm{actual}}}{\Delta E_{\mathrm{predicted}}}.\]A ratio near one means the model is accurate and the region can be grown; a poor or negative ratio means the region should shrink. When \(\rho \le 0\) (the step increased the energy or was contrary to prediction), the step should be rejected.
- __init__(initial_radius: float, minimum_radius: float, maximum_radius: float) None
Initialise the controller.
- Parameters:
initial_radius (float) – Trust radius used for the first step.
minimum_radius (float) – Lower clamp on the trust radius.
maximum_radius (float) – Upper clamp on the trust radius.
- Return type:
None
- property radius: float
Current trust radius.
- register_prediction(current_energy: float, predicted_change: float) None
Record the model prediction made at the current point.
- Parameters:
current_energy (float) – Energy at the current point (before the step).
predicted_change (float) – Predicted energy change of the step just taken.
- Return type:
None
- reset() None
Reset the trust radius and clear registered predictions.
- Return type:
None
- update_from_actual_energy(current_energy: float) bool
Adapt the trust radius using the realized energy change and report acceptance.
- Parameters:
current_energy (float) – Energy at the new point (after the previous step).
- Return type:
bool
- class TrustRegionStep
Bases:
Generic[TSCFMatrix]Result of a single augmented-Hessian trust-region solve.
- Parameters:
step – Antisymmetric rotation generator in the orthonormal basis.
predicted_energy_change – The quadratic-model energy change \(g^{T} x + \tfrac{1}{2} x^{T} H x\).
- __init__(step: TSCFMatrix, predicted_energy_change: float) None
- Parameters:
step (TSCFMatrix)
predicted_energy_change (float)
- Return type:
None
- predicted_energy_change: float
- step: TSCFMatrix