qrunch.chemistry.qrackle.scf.steppers.diis
A DIIS SCF stepper.
It selects the best linear combination of Fock matrices from the DIIS queue and solves the Roothaan-Hall equation to get the new molecular orbitals and orbital energies.
Using a Lowdin orthogonalizer \(S^{-1/2}\) to transform the Fock matrix into an orthonormal basis:
Classes
Options for the DIIS SCF stepper. |
|
Can create a new density matrix based on the Direct Inversion in the Iterative Subspace (DIIS). |
|
Build a DIIS stepper with a configurable fallback. |
- class DIISOptions
Bases:
DataclassPublicAPIOptions for the DIIS SCF stepper.
- Parameters:
min_diis_queue_length – Minimum number of Fock/error pairs required in the DIIS queue to perform DIIS extrapolation. If the queue has fewer entries, the fallback SCF stepper will be used instead.
max_coefficient_threshold – Maximum allowed absolute value of any DIIS coefficient. If exceeded, the oldest error vector is removed and DIIS is retried.
condition_number_threshold – Maximum allowed condition number of the DIIS matrix. If exceeded, the oldest error vector is removed and DIIS is retried.
- __init__(*, min_diis_queue_length: int = 2, max_coefficient_threshold: float = 10.0, condition_number_threshold: float = 1000000000000.0) None
- Parameters:
min_diis_queue_length (int)
max_coefficient_threshold (float)
condition_number_threshold (float)
- Return type:
None
- condition_number_threshold: float = 1000000000000.0
- max_coefficient_threshold: float = 10.0
- min_diis_queue_length: int = 2
- class DIISSCFStepper
Bases:
SCFStepperProtocol[TSCFMatrix,TSCFVector,TMatrix,TVector],SCFTrialAssessmentProtocol[TSCFMatrix],SCFFallbackStepperProtocol[TSCFMatrix,TSCFVector,TMatrix,TVector]Can create a new density matrix based on the Direct Inversion in the Iterative Subspace (DIIS).
- __init__(scf_matrix_module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], fallback_scf_stepper: SCFStepperProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], options: DIISOptions | None = None) None
Initialise the DIIS SCF stepper.
- Parameters:
scf_matrix_module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module (restricted or unrestricted).
fallback_scf_stepper (SCFStepperProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – A fallback SCF stepper to use when the DIIS queue has insufficient entries or when the DIIS extrapolation fails.
options (DIISOptions | None) – Options for the DIIS 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
Forward assessment when the fallback proposed the current trial.
The driver calls this after evaluating the trial’s Fock matrix and energy. A rejected fallback trial must be retried by the same fallback before DIIS extrapolation resumes. 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
DIIS stepping does not add extra Fock/density pairs to the 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 density via DIIS extrapolation, falling back if needed.
The DIIS B-matrix is scaled by \(1 / \\max|B_{ij}|\) to avoid numerical issues when error norms become very small near convergence. If the resulting linear system is ill-conditioned or produces extreme coefficients, the oldest error vector is removed and the solve is retried. When too few vectors remain for DIIS, the fallback stepper is used instead.
- Parameters:
scf_queue (SCFQueueProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – The SCF queue containing Fock matrices and their associated error matrices.
current_density (TSCFMatrix) – The current density matrix.
current_fock (TSCFMatrix) – The current Fock (or Kohn-Sham) matrix.
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 to solve the Roothaan-Hall equation.
orbital_occupation (OrbitalOccupation) – Electron occupation specifying how many orbitals are occupied.
- Return type:
TSCFMatrix
- property fallback_scf_stepper: SCFStepperProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]
Fallback used when DIIS extrapolation cannot propose a density.
- free() None
Free any retained matrices.
- Return type:
None
- init_scf_queue(max_length: int) SCFQueueProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]
Create a SCF queue.
- Parameters:
max_length (int)
- Return type:
SCFQueueProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]
- property is_local_region_indicated: bool
Indicate the local region when the SCF gradient is sufficiently small.
- property options: DIISOptions
Options used by the DIIS stepper.
- reset() None
Reset the internal state of the SCF stepper.
- Return type:
None
- class DIISSCFStepperBuilder
Bases:
SCFStepperBuilderProtocolBuild a DIIS stepper with a configurable fallback.
- __init__(options: DIISOptions | None = None) None
Initialise the DIIS SCF stepper builder.
- Parameters:
options (DIISOptions | None) – Options for the DIIS 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) DIISSCFStepper[TSCFMatrix, TSCFVector, TMatrix, TVector]
Create a new DIISSCFStepper.
- Parameters:
scf_matrix_module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module (restricted or unrestricted).
fock_builder (FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Builder for the Fock/Kohn-Sham matrix.
fallback_scf_stepper_builder (SCFStepperBuilderProtocol | None) – Optional builder for a fallback SCF stepper.
- Return type:
DIISSCFStepper[TSCFMatrix, TSCFVector, TMatrix, TVector]