qrunch.chemistry.qrackle.scf.orbital_rotation.occupied_virtual_basis
Pseudo-canonical occupied-virtual orbitals and a compact representation of orbital rotations.
A generator with only occupied-virtual components is represented by its virtual-occupied block \(\sqrt{2} V^{T} X O\), where \(O\) and \(V\) are the pseudo-canonical occupied and virtual orbitals of a spin channel.
Classes
Pseudo-canonical occupied and virtual orbitals of a reference density and Fock matrix. |
|
Cached pseudo-canonical orbitals and energy gaps for one spin channel. |
- class OccupiedVirtualBasis
Bases:
Generic[TSCFMatrix,TSCFVector,TMatrix,TVector],OccupiedVirtualCompactRepresentation[TSCFMatrix]Pseudo-canonical occupied and virtual orbitals of a reference density and Fock matrix.
- __init__(module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector], orthonormal_fock: TSCFMatrix, orthonormal_density: TSCFMatrix, orbital_occupation: OrbitalOccupation) None
Diagonalize the occupied and virtual Fock blocks of each spin channel.
The orbitals are therefore independent of rotations within either subspace. They stay in backend matrices with their native shapes, participate in allocation accounting, and must be released with
free(). Spin channels with no occupied or no virtual orbital have no channel.- Parameters:
module (SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]) – SCF matrix module.
orthonormal_fock (TSCFMatrix) – Reference Fock matrix in the orthonormal basis.
orthonormal_density (TSCFMatrix) – Reference determinant density in the orthonormal basis.
orbital_occupation (OrbitalOccupation) – Electron occupation giving the number of occupied orbitals.
- Return type:
None
- property block_shape: tuple[int, int]
Shape of each spin channel of the compact representation.
- property channels: list[PseudoCanonicalChannel[TMatrix] | None]
Pseudo-canonical orbitals per spin channel, or
Nonefor a channel without rotations.
- free() None
Release the cached backend matrices without freeing the reference inputs.
- Return type:
None
- from_occupied_virtual_block(block: TSCFMatrix) TSCFMatrix
Return the generator \((V B O^{T} - O B^{T} V^{T}) / \sqrt{2}\) of a compact block \(B\).
This inverts
to_occupied_virtual_block()on occupied-virtual generators.- Parameters:
block (TSCFMatrix) – Compact occupied-virtual representation.
- Return type:
TSCFMatrix
- property module: SCFMatrixModuleProtocol[TSCFMatrix, TSCFVector, TMatrix, TVector]
SCF matrix module of the orbitals.
- randomized_inverse_gap_block(*, seed: int = 0, denominator_floor: float = 0.01) TSCFMatrix
Return a compact block with a random factor over each pseudo-canonical occupied-virtual energy gap.
A Davidson search cannot leave the symmetry blocks overlapped by its start, and this rotation overlaps all of them. Pure inverse-gap weights would be equal within degenerate orbital sets, and hence orthogonal to rotations antisymmetric under their exchange. Fixed-seed random factors break that structure deterministically. The caller owns the result.
- Parameters:
seed (int) – Seed of the random factors.
denominator_floor (float) – Minimum absolute gap, bounding the weight of degenerate pairs.
- Return type:
TSCFMatrix
- resize_consuming(matrix: TMatrix, *, shape: tuple[int, int]) TMatrix
Return
matrixcropped or zero-padded toshape, consuming the input.- Parameters:
matrix (TMatrix) – Owned scalar block.
shape (tuple[int, int]) – Target shape.
- Return type:
TMatrix
- rotation_from_block(channel: PseudoCanonicalChannel[TMatrix], block: TMatrix) TMatrix
Return the antisymmetric rotation \(\tfrac{1}{2}(V B O^{T} - O B^{T} V^{T})\) of a native-shaped block.
- Parameters:
channel (PseudoCanonicalChannel[TMatrix]) – Pseudo-canonical orbitals of the spin channel.
block (TMatrix) – Native-shaped virtual-occupied block.
- Return type:
TMatrix
- to_occupied_virtual_block(generator: TSCFMatrix) TSCFMatrix
Return the compact representation \(\sqrt{2} V^{T} X O\) of a generator.
Redundant occupied-occupied and virtual-virtual components are dropped, and the factor \(\sqrt{2}\) makes the representation preserve the Frobenius inner product of occupied-virtual generators. Spin channels are zero-padded to
block_shape.- Parameters:
generator (TSCFMatrix) – Antisymmetric generator in the orthonormal basis.
- Return type:
TSCFMatrix
- virtual_occupied_block(channel: PseudoCanonicalChannel[TMatrix], generator: TMatrix) TMatrix
Return the native-shaped pseudo-canonical block \(V^{T} X O\) of a scalar generator.
- Parameters:
channel (PseudoCanonicalChannel[TMatrix]) – Pseudo-canonical orbitals of the spin channel.
generator (TMatrix) – Scalar generator in the orthonormal basis.
- Return type:
TMatrix
- class PseudoCanonicalChannel
Bases:
Generic[TMatrix]Cached pseudo-canonical orbitals and energy gaps for one spin channel.
The occupied and virtual Fock blocks are diagonalized independently at a fixed reference determinant. This gives an energy basis within each subspace without mixing occupied and virtual orbitals or changing the determinant they define.
The orbital-energy preconditioner reuses these orbitals and gaps for each Davidson residual: it transforms the residual into a virtual-occupied block, divides by shifted, floored energy gaps as an approximation to the Hessian inverse, and transforms back. Caching avoids repeating the subspace diagonalizations for every application.
The same orbitals let Davidson store directions and Hessian responses as compact blocks with
n_virtual * n_occupiedentries rather than full square matrices. Rotations within the occupied or virtual subspace do not change the determinant and need no search coordinates. The cached orbital matrices themselves still contain a complete orbital basis, but keep their native rectangular shapes without padding to match other spin channels. Their backend storage is owned and released byOccupiedVirtualBasis.- Parameters:
occupied – Pseudo-canonical occupied orbitals as columns in the orthonormal basis, with shape
(n_orbitals, n_occupied).virtual – Pseudo-canonical virtual orbitals as columns in the orthonormal basis, with shape
(n_orbitals, n_virtual).gaps – Orbital-energy approximation to the Hessian diagonal,
occupation * (e_a - e_i), with shape(n_virtual, n_occupied). The occupation factor is two for restricted and one for unrestricted calculations. These are unshifted, unfloored gaps.
- __init__(*, occupied: TMatrix, virtual: TMatrix, gaps: TMatrix) None
- Parameters:
occupied (TMatrix)
virtual (TMatrix)
gaps (TMatrix)
- Return type:
None
- gaps: TMatrix
- occupied: TMatrix
- virtual: TMatrix