qrunch.chemistry.qrackle.scf.steppers.trust_region_augmented_hessian
Trust-Region Augmented-Hessian (TRAH) SCF stepper.
TRAH and ARH share the same orbital-rotation trust-region framework (see
qrunch.chemistry.qrackle.scf.orbital_rotation.orbital_rotation_solver). The single
difference is the Hessian-vector product: where ARH approximates the
electronic response from stored SCF history, TRAH evaluates the genuine
response for every trial direction.
The exact Hessian-vector product
For a trial rotation \(X\) the induced first-order density change is \(\delta D_{o} = [D_{o}, X]\). Transforming it to the AO basis and running it through the two-electron part of the Fock build gives the exact response
(for Hartree-Fock / exact exchange). The orbital sigma vector is then
The Hessian itself is never built; only the operation \(X \mapsto H[X]\) is needed, exactly as in a CPHF/TDHF sigma-vector routine. This makes each Davidson micro-iteration more expensive than ARH (it costs one two-electron build) but gives an essentially exact Hessian and hence genuine quadratic convergence near the solution.
For a nonlinear Kohn-Sham build, the response includes the exchange-correlation
kernel contribution \(\delta V_{\mathrm{xc}}\). This is supplied through
compute_density_response().
Reference: [HP21].
Functions
Stability analysis of the orbital Hessian using the exact electronic response. |
Classes
Compute exact TRAH Hessian-vector products using effective-matrix response builds. |
|
Options for the Trust-Region Augmented-Hessian SCF stepper. |
|
Create a new density matrix using the Trust-Region Augmented-Hessian (TRAH) method. |
|
Builder for the |
- class TRAHHessianVectorProduct
Bases:
Generic[TSCFMatrix,TSCFVector,TMatrix,TVector],OrbitalHessianVectorProduct[TSCFMatrix]Compute exact TRAH Hessian-vector products using effective-matrix response builds.
For each trial rotation, build \(\delta D_o = [D_o, X]\), transform the density perturbation to the AO basis, evaluate \(F'[D_0](\delta D)\), and assemble the orbital sigma vector.
The Fock builder owns the distinction between Hartree-Fock and Kohn-Sham response. Hartree-Fock returns \(G[\delta D]\), while Kohn-Sham DFT adds the XC-kernel response evaluated at the reference density.
- __init__(module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], fock_builder: FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], orthonormal_basis: OrthonormalBasis[TSCFMatrix, TSCFVector, TMatrix, TVector], orthonormal_fock: TSCFMatrix, orthonormal_density: TSCFMatrix, molecular_configuration: MolecularConfiguration, *, reference_density: TSCFMatrix | None = None) None
Initialise the exact Hessian-vector product.
- Parameters:
module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module.
fock_builder (FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Builder used to form the density response.
orthonormal_basis (OrthonormalBasis[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Orthonormal-basis transformer.
orthonormal_fock (TSCFMatrix) – Current effective matrix in the orthonormal basis.
orthonormal_density (TSCFMatrix) – Current density matrix in the orthonormal basis.
molecular_configuration (MolecularConfiguration) – Molecular configuration.
reference_density (TSCFMatrix | None) – Optional AO form of
orthonormal_density. It is borrowed, never freed, and must outlive this product. WhenNoneit is reconstructed for each response batch.
- Return type:
None
- apply(trial: TSCFMatrix) TSCFMatrix
Compute the exact orbital 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 exact orbital Hessian-vector products for trial rotations.
- Parameters:
trials (list[TSCFMatrix]) – Antisymmetric trial rotations in the orthonormal basis.
- Return type:
list[TSCFMatrix]
- class TrustRegionAugmentedHessianOptions
Bases:
DataclassPublicAPIOptions for the Trust-Region Augmented-Hessian SCF stepper.
- Parameters:
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 (and hence response builds) used at one reference, including rejected-step retries.
micro_convergence_factor – The inner problem is solved only to
micro_convergence_factor * ||g||to avoid wasting response builds while the outer SCF is still far from convergence.use_orbital_energy_preconditioner – Use orbital-energy preconditioning on every TRAH solve. False selects the scalar diagonal-estimate preconditioner.
orbital_energy_preconditioner_denominator_floor – Minimum absolute shifted orbital-energy denominator in Hartree used by the preconditioner. This bounds the approximate inverse without changing the Hessian model or trust-region level shift.
- __init__(*, 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, use_orbital_energy_preconditioner: bool = True, orbital_energy_preconditioner_denominator_floor: float = 0.01) None
- Parameters:
initial_trust_radius (float)
minimum_trust_radius (float)
maximum_trust_radius (float)
maximum_micro_iterations (int)
micro_convergence_factor (float)
use_orbital_energy_preconditioner (bool)
orbital_energy_preconditioner_denominator_floor (float)
- Return type:
None
- 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
- orbital_energy_preconditioner_denominator_floor: float = 0.01
- use_orbital_energy_preconditioner: bool = True
- class TrustRegionAugmentedHessianSCFStepper
Bases:
SCFStepperProtocol[TSCFMatrix,TSCFVector,TMatrix,TVector],SCFTrialAssessmentProtocol[TSCFMatrix]Create a new density matrix using the Trust-Region Augmented-Hessian (TRAH) method.
- __init__(scf_matrix_module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], fock_builder: FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], options: TrustRegionAugmentedHessianOptions | None = None) None
Initialise the TRAH 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 used to evaluate the exact HF or Kohn-Sham density response. The response must be linear in the density perturbation at a fixed reference density. The builder itself need not be linear in the density; for Kohn-Sham DFT, the response includes the XC kernel evaluated at the reference density.
options (TrustRegionAugmentedHessianOptions | None) – Options for the TRAH 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 the evaluated trial before history, convergence or switching.
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
TRAH 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 TRAH trust-region orbital step.
- Parameters:
scf_queue (SCFQueueProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – The shared SCF queue (unused by TRAH).
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.
roothaan_hall_solver (RoothaanHallSolver[TSCFMatrix, TSCFVector, TMatrix, TVector]) – A Roothaan-Hall solver (unused by TRAH).
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) SCFQueue[TSCFMatrix, TSCFVector, TMatrix, TVector]
Create a SCF queue (used by the driver for the gradient/convergence check).
- Parameters:
max_length (int)
- Return type:
SCFQueue[TSCFMatrix, TSCFVector, TMatrix, TVector]
- property is_local_region_indicated: bool
Indicate the local region when the augmented-Hessian level shift vanishes.
- property options: TrustRegionAugmentedHessianOptions
Options used by the TRAH stepper.
- reset() None
Free stored matrices and reset trust-region, solver and trial state.
- Return type:
None
- class TrustRegionAugmentedHessianSCFStepperBuilder
Bases:
SCFStepperBuilderProtocolBuilder for the
TrustRegionAugmentedHessianSCFStepper.- __init__(options: TrustRegionAugmentedHessianOptions | None = None) None
Initialise the TRAH stepper builder.
- Parameters:
options (TrustRegionAugmentedHessianOptions | None) – Options for the TRAH 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) TrustRegionAugmentedHessianSCFStepper[TSCFMatrix, TSCFVector, TMatrix, TVector]
Create a new TRAH 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 used to evaluate the exact two-electron response.
fallback_scf_stepper_builder (SCFStepperBuilderProtocol | None) – Optional fallback builder. Not used by TRAH.
- Return type:
TrustRegionAugmentedHessianSCFStepper[TSCFMatrix, TSCFVector, TMatrix, TVector]
- analyze_orbital_hessian_stability_with_exact_response(module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], fock_builder: FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], density: TSCFMatrix, core_hamiltonian: TSCFMatrix, overlap_matrix: TSCFMatrix, lowdin_orthogonalizer: TSCFMatrix, molecular_configuration: MolecularConfiguration, orbital_occupation: OrbitalOccupation, number_of_eigenpairs: int, trial_directions: list[TSCFMatrix] | None = None, *, full_space: bool = False, current_fock: TSCFMatrix | None = None, maximum_number_of_stability_search_retries: int = 10, maximum_subspace_size: int = 100, random_seed: int = 0, negative_eigenvalue_threshold: float | None = None) OrbitalHessianStabilityResult[TSCFMatrix]
Stability analysis of the orbital Hessian using the exact electronic response.
Builds the exact (TRAH-style) Hessian-vector product at
densityand diagonalizes the Hessian in a subspace of trial rotations to return its lowest eigenpairs. The exact response is used (rather than a history approximation) because at a stationary point the response is precisely what carries the negative-curvature information. The configured builder supplies the required first-order response for either Hartree-Fock or Kohn-Sham DFT.- Parameters:
module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module.
fock_builder (FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Builder used to form the first-order effective-matrix response.
density (TSCFMatrix) – The AO density matrix at which to evaluate the Hessian.
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.
orbital_occupation (OrbitalOccupation) – Electron occupation.
number_of_eigenpairs (int) – Number of lowest eigenpairs to return.
trial_directions (list[TSCFMatrix] | None) – Optional antisymmetric trial generators (orthonormal basis). When
Nonea frontier set of elementary occupied-virtual rotations is generated.full_space (bool) – Search all real occupied-virtual rotations within the selected spin treatment with an orbital-energy-preconditioned Davidson expansion, instead of only the span of the trial directions. Without custom directions, start from randomized inverse-gap rotations; otherwise mix one into each trial direction, using at most
maximum_subspace_size - 1trial directions so the search can expand. Each search retains at mostmaximum_subspace_sizecompact occupied-virtual directions and responses; an inconclusive search restarts from the requested Ritz vectors, each mixed with a fresh random rotation. Restricted-to-unrestricted and complex instabilities are not covered. Arguments marked full-space only are validated but otherwise ignored whenfull_spaceis false.current_fock (TSCFMatrix | None) – Optional caller-owned AO Fock evaluated at
density. Avoids a redundant build and is neither modified nor freed.maximum_number_of_stability_search_retries (int) – Full-space only. Maximum number of additional Davidson searches after an inconclusive full-space search. Seeds differ between searches but are reproducible. Retries reuse the reference and preconditioner, not the full previous subspace. The default permits ten retries after the initial search. Exhaustion returns
converged=False, not a stability certificate.maximum_subspace_size (int) – Full-space only. Maximum number of Davidson directions per search. It must exceed the number of requested eigenpairs.
random_seed (int) – Full-space only. Non-negative seed for reproducible random starting directions.
negative_eigenvalue_threshold (float | None) – Full-space only. Optional non-negative threshold. A search whose unconverged lowest Ritz value lies below its negative is returned with
converged=Falseinstead of retried, because that Ritz value already bounds the lowest Hessian eigenvalue from above.
- Return type:
OrbitalHessianStabilityResult[TSCFMatrix]