qarp.operators.integrals¶
Electronic integrals → FermionOperator (the chemistry layer).
Chemists’ notation over spatial orbitals in, qarpx FermionOperator out,
for restricted and unrestricted formalisms. The generic construction lives
in qarp.operators; this module encodes the chemistry
conventions: the abab spin expansion, the chemists’ (pq|rs) index pairing
with its ½ factor, the permutation into the builder’s creators-first operator
order, and the frozen-core active-space reduction.
- qarp.operators.integrals.active_space_integrals(constant: float, one_electron: NDArray, two_electron: NDArray, n_electrons: int, active_electrons: int, active_orbitals: int) tuple[float, NDArray, NDArray][source]¶
Reduce full-space restricted integrals to an active-space set.
Frozen-core embedding over a contiguous window: the lowest
(n_electrons - active_electrons) / 2spatial orbitals are doubly occupied core, the nextactive_orbitalsare active (matching pyscf’smcscf.CASCI.get_h1effconvention). Inputs and outputs are in the spatial-orbital basis, chemists’ notationtwo_electron[p,q,r,s]= (pq|rs).- Parameters:
constant – The scalar term (e.g. nuclear repulsion).
one_electron – Full-space one-electron integral matrix.
two_electron – Full-space two-electron integral tensor.
n_electrons – Total number of electrons in the full space.
active_electrons – Number of electrons in the active space.
active_orbitals – Number of active spatial orbitals.
- Returns:
The (core-embedded constant, effective one-electron matrix, active-block two-electron tensor) tuple.
- qarp.operators.integrals.restricted_integrals_to_fermion_operator(constant: float, one_electron: NDArray, two_electron: NDArray, threshold: float = 1e-12) FermionOperator[source]¶
Given a constant, one- and two-electron integrals, create the corresponding FermionOperator.
Note
Integrals are assumed to be in chemists’ notation and over spatial orbitals, not spin orbitals. Terms with coefficients of absolute value < threshold are dropped.
- Parameters:
constant – The scalar term (e.g. nuclear repulsion).
one_electron – Matrix of one-electron integrals over spatial orbitals.
two_electron – Tensor of two-electron integrals over spatial orbitals.
threshold – Ignore terms with coefficients of absolute value lower than this float.
- Returns:
A qarpx FermionOperator. Assumes alpha-beta-alpha-beta-… ordering.
- qarp.operators.integrals.spatial_to_spin_orbital(tensor: NDArray) NDArray[source]¶
Expand a restricted spatial-orbital 2k-index tensor to abab spin orbitals.
Adjacent index pairs share a spin (particle m owns indices (2m, 2m+1) — the chemists’ (pq|rs) pairing for k=2, trivially (p, q) for k=1), and every per-particle spin assignment carries the same block (the restricted degeneracy). For spin-resolved blocks use
spin_blocks_to_spin_orbital().- Parameters:
tensor – A 2k-index numpy tensor over spatial orbitals.
- Returns:
The (2n,)*2k spin-orbital tensor, abab-interleaved.
- qarp.operators.integrals.spin_blocks_to_spin_orbital(blocks: dict[str, NDArray]) NDArray[source]¶
Expand spin-resolved spatial-orbital blocks to one abab spin-orbital tensor.
The dict is keyed by the per-particle spin pattern — one character per particle,
"a"/"b"— e.g.{"a": h_alpha, "b": h_beta}for one-body or{"aa": g_aa, "ab": g_ab, "ba": g_ba, "bb": g_bb}for two-body; missing patterns are zero blocks. Index pairing as inspatial_to_spin_orbital().- Parameters:
blocks – Per-spin-pattern 2k-index tensors of identical shape.
- Returns:
The (2n,)*2k spin-orbital tensor, abab-interleaved.
- qarp.operators.integrals.spin_orbital_integrals_to_fermion_operator(constant: float, one_electron: NDArray, two_electron: NDArray, threshold: float = 1e-12) FermionOperator[source]¶
Given a constant and spin-orbital integrals, create the corresponding FermionOperator.
The spin-orbital-level entry point (e.g. for FCIDUMP-style data):
one_electron[p, q]contributes \(h_{pq} a^\dagger_p a_q\) and the two-electron tensor is chemists’ notation over spin orbitals, \(H_2 = \tfrac{1}{2} \sum (pq|rs)\, a^\dagger_p a^\dagger_r a_s a_q\). The spatial-orbital wrappers below delegate here after their spin unpack.- Parameters:
constant – The scalar term (e.g. nuclear repulsion).
one_electron – Matrix of one-electron integrals over spin orbitals.
two_electron – Chemists’-notation tensor of two-electron integrals over spin orbitals.
threshold – Ignore terms with coefficients of absolute value lower than this float.
- Returns:
A qarpx FermionOperator.
- qarp.operators.integrals.unrestricted_active_space_integrals(constant: float, one_electron: tuple[NDArray, NDArray], two_electron: tuple[NDArray, NDArray, NDArray], n_electrons: tuple[int, int], active_electrons: tuple[int, int], active_orbitals: int) tuple[float, tuple[NDArray, NDArray], tuple[NDArray, NDArray, NDArray]][source]¶
Reduce full-space unrestricted integrals to an active-space set.
The spin-resolved counterpart of
active_space_integrals(), matching pyscf’smcscf.UCASCI.get_h1effconvention: each spin channel freezes its lowestn_electrons[σ] - active_electrons[σ]orbitals (the core counts are per spin orbital — no factor of two — and may differ between channels), followed by the sameactive_orbitals-wide window. Coulomb folds in from every core electron; exchange from same-spin cores only.- Parameters:
constant – The scalar term (e.g. nuclear repulsion).
one_electron – The (h_alpha, h_beta) pair of full-space matrices.
two_electron – The (g_aa, g_ab, g_bb) full-space triple, chemists’ notation.
n_electrons – Total (alpha, beta) electron counts in the full space.
active_electrons – (alpha, beta) electron counts in the active space.
active_orbitals – Number of active spatial orbitals per spin channel.
- Returns:
The (core-embedded constant, (h_alpha, h_beta) effective pair, (g_aa, g_ab, g_bb) active-block triple) tuple.
- qarp.operators.integrals.unrestricted_integrals_to_fermion_operator(constant: float, one_electron: tuple[NDArray, NDArray], two_electron: tuple[NDArray, NDArray, NDArray], threshold: float = 1e-12) FermionOperator[source]¶
Given a constant and spin-resolved integrals, create the corresponding FermionOperator.
Note
Integrals are assumed to be in chemists’ notation and over spatial orbitals. The two-electron triple is
(g_aa, g_ab, g_bb)— the (αα|ββ) cross block is required (it is not derivable from the same-spin blocks); the (ββ|αα) block is derived by particle exchange,g_ab.transpose(2, 3, 0, 1). This matches pyscf’s UHF block order.- Parameters:
constant – The scalar term (e.g. nuclear repulsion).
one_electron – The (h_alpha, h_beta) pair of one-electron matrices.
two_electron – The (g_aa, g_ab, g_bb) triple of two-electron tensors.
threshold – Ignore terms with coefficients of absolute value lower than this float.
- Returns:
A qarpx FermionOperator. Assumes alpha-beta-alpha-beta-… ordering.