qrunch.chemistry.qrackle.scf.steppers.crop

A CROP SCF stepper.

Like DIIS, it selects an affine combination of Fock matrices by minimizing the norm of their combined commutator errors. It then solves the Roothaan-Hall equation to obtain the next density. Unlike DIIS, CROP retains the optimized Fock and estimated error after each step rather than only raw trial pairs, preserving earlier information when the history is truncated.

With optimize="iterations" (separate optimized history), each solve combines the retained optimized pairs with the newest raw pairs from the shared SCF queue. With optimize="memory" (compressed queue), no separate history is kept: the optimized pair replaces the newest raw pair in the shared SCF queue. Older raw pairs whose errors add almost no new direction to the subspace are dropped before solving.

\[F C = S C e\]

Using a Lowdin orthogonalizer \(S^{-1/2}\) to transform the mixed Fock matrix into an orthonormal basis:

\[\tilde{F} \tilde{C} = \tilde{C} e\]

Classes

CROPOptions

Options for the CROP SCF stepper.

CROPSCFStepper

Minimize CROP commutator residuals over retained optimized Fock matrices.

CROPSCFStepperBuilder

Build a CROP stepper with a configurable fallback.

class CROPOptions

Bases: DataclassPublicAPI

Options for the CROP SCF stepper.

Parameters:
  • optimize –

    What CROP is tuned for.

    • "iterations" (default): performance-optimal separate optimized history. Optimized Fock/error pairs are kept in their own history next to the raw pairs in the shared SCF queue, and each solve uses both. This usually needs the fewest SCF iterations, at the cost of storing up to max_history_length extra pairs.

    • "memory": memory-efficient compressed queue. No separate history is kept; the optimized pair replaces the newest entry in the shared SCF queue and entries older than those used in the solve are removed, so CROP never stores more pairs than the queue length. This typically needs a few more iterations than "iterations". The queue applies the coefficients to everything it stores; an ARH history also combines its densities, which is exact for Hartree-Fock but only approximate for DFT (see ARHHistory.replace_newest).

  • min_crop_queue_length – Minimum number of Fock/error pairs in the shared SCF queue before CROP starts. Once it has local optimized history, CROP combines that history with the raw pairs regardless of queue length.

  • max_history_length – Maximum number of retained local optimized Fock/error pairs. None removes the cap. Pairs are still dropped, oldest first, when the solve skips them as ill-conditioned or out of coefficient bounds. The whole history is cleared on reset and after repeated fallbacks. Only used with optimize="iterations".

  • max_raw_length – Maximum number of newest raw Fock/error pairs from the shared SCF queue in each solve. None uses the whole queue. Only used with optimize="iterations"; "memory" always uses the whole queue.

  • raw_redundancy_tolerance – An older raw pair is skipped when the squared norm of its error outside the span of the kept errors is below this fraction of its own squared error norm.

  • max_coefficient_threshold – Largest permitted absolute mixing coefficient.

  • clear_history_after_n_consecutive_fallbacks – Number of consecutive fallback steps before discarding local optimized history.

  • condition_number_threshold – Largest permitted residual matrix condition number.

__init__(*, optimize: Literal['iterations', 'memory'] = 'iterations', min_crop_queue_length: int = 2, max_history_length: int | None = 4, max_raw_length: int | None = None, raw_redundancy_tolerance: float = 1e-08, max_coefficient_threshold: float = 10.0, clear_history_after_n_consecutive_fallbacks: int = 3, condition_number_threshold: float = 1000000000000.0) → None
Parameters:
  • optimize (Literal['iterations', 'memory'])

  • min_crop_queue_length (int)

  • max_history_length (int | None)

  • max_raw_length (int | None)

  • raw_redundancy_tolerance (float)

  • max_coefficient_threshold (float)

  • clear_history_after_n_consecutive_fallbacks (int)

  • condition_number_threshold (float)

Return type:

None

clear_history_after_n_consecutive_fallbacks: int = 3
condition_number_threshold: float = 1000000000000.0
max_coefficient_threshold: float = 10.0
max_history_length: int | None = 4
max_raw_length: int | None = None
min_crop_queue_length: int = 2
optimize: Literal['iterations', 'memory'] = 'iterations'
raw_redundancy_tolerance: float = 1e-08
class CROPSCFStepper

Bases: SCFStepperProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], SCFTrialAssessmentProtocol[TSCFMatrix], SCFFallbackStepperProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]

Minimize CROP commutator residuals over retained optimized Fock matrices.

__init__(scf_matrix_module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], fallback_scf_stepper: SCFStepperProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], options: CROPOptions | None = None) → None

Initialize the CROP stepper.

Parameters:
  • scf_matrix_module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Restricted or unrestricted SCF matrix module.

  • fallback_scf_stepper (SCFStepperProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Stepper used when residual minimization cannot be performed.

  • options (CROPOptions | None) – CROP subspace and stability settings.

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 CROP 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

Whether CROP writes its optimized pairs into the shared SCF queue (optimize="memory").

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

Mix optimized Fock pairs with the newest raw queue pairs and diagonalize, falling back if needed.

Redundant older raw pairs are dropped before solving. The retained error is the same affine combination of queued DIIS commutators; it is not re-evaluated at the mixed Fock matrix.

Parameters:
  • scf_queue (SCFQueueProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Shared raw Fock/commutator history.

  • current_density (TSCFMatrix) – Current density for the fallback stepper.

  • current_fock (TSCFMatrix) – Current Fock for the fallback stepper.

  • core_hamiltonian (TSCFMatrix) – Core Hamiltonian for the fallback stepper.

  • overlap_matrix (TSCFMatrix) – AO overlap for the fallback stepper.

  • lowdin_orthogonalizer (TSCFMatrix) – Lowdin orthogonalizer.

  • molecular_configuration (MolecularConfiguration) – Molecular configuration for the fallback stepper.

  • roothaan_hall_solver (RoothaanHallSolver[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Solver for the optimized Fock.

  • orbital_occupation (OrbitalOccupation) – Electron occupation.

Return type:

TSCFMatrix

property fallback_scf_stepper: SCFStepperProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]

Fallback used when CROP residual minimization cannot propose a density.

free() → None

Free optimized history and fallback resources without resetting stepping state.

Return type:

None

init_scf_queue(max_length: int) → SCFQueueProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]

Create the shared raw SCF queue.

Parameters:

max_length (int) – Number of raw Fock/error pairs to retain.

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: CROPOptions

Options used by the CROP stepper.

reset() → None

Discard optimized history on a new calculation or when leaving local stepping.

Return type:

None

class CROPSCFStepperBuilder

Bases: SCFStepperBuilderProtocol

Build a CROP stepper with a configurable fallback.

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

Initialize the CROP builder.

Parameters:

options (CROPOptions | None) – CROP subspace and stability settings.

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) → CROPSCFStepper[TSCFMatrix, TSCFVector, TMatrix, TVector]

Create a CROP stepper.

Parameters:
  • scf_matrix_module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Restricted or unrestricted SCF matrix module.

  • fock_builder (FockBuilderProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – Fock builder passed to the fallback stepper.

  • fallback_scf_stepper_builder (SCFStepperBuilderProtocol | None) – Optional fallback builder, defaulting to damped SCF.

Return type:

CROPSCFStepper[TSCFMatrix, TSCFVector, TMatrix, TVector]