qarp.operators.pyscf¶
Adapters from a converged pyscf mean-field object onto qarp’s tensor/ONV surface.
pyscf is optional and imported lazily inside each function (conventions §15);
this module imports without it. Inputs are the user’s own mf — nothing
here runs SCF. Spin orbitals are abab (2i = orbital i alpha, 2i+1 = beta,
§1) throughout; the unrestricted helper returns per-spin spatial blocks and
leaves the interleave to spin_blocks_to_spin_orbital downstream.
- qarp.operators.pyscf.active_space_from_mf(mf: Any, active_electrons: int, active_orbitals: int) tuple[tuple[float, NDArray, NDArray], list[int]][source]¶
Frozen-core active-space integrals and the matching reference ONV (restricted).
The two calls every active-space example makes together:
active_space_integrals(*integrals_from_mf(mf), n_electrons, e, o)andactive_space(onv_from_mf(mf), e, o).
- qarp.operators.pyscf.fermion_operator_from_mf(mf: Any, threshold: float = 1e-12) FermionOperator[source]¶
Molecular FermionOperator straight from a restricted mean-field.
- qarp.operators.pyscf.integrals_from_mf(mf: Any) tuple[float, NDArray, NDArray][source]¶
(constant, one-electron, two-electron) in the MO spatial basis, chemists’ notation.
- qarp.operators.pyscf.onv_coefficients_from_civec(civec: NDArray, n_orbitals: int, nelec: tuple[int, int] | int, *, threshold: float = 1e-12, n_core: int = 0) dict[tuple[int, ...], complex][source]¶
Convert a pyscf FCI/CASCI vector to abab ONV coefficients for
MultiONVStateBlock.civecis the(n_alpha_strings, n_beta_strings)array pyscf’sfci.FCI(mf).kernel()/mcscf.CASCI(...).cireturn overn_orbitalsspatial orbitals withnelec = (n_alpha, n_beta)(anintis split like pyscf: β getsnelec // 2). Each row/column address is decoded withpyscf.fci.cistring(bitiset ⇔ spatial orbitalioccupied) and placed on the abab register — active orbitali→ spin-orbitals2(n_core + i)(α) and2(n_core + i) + 1(β) — aftern_coredoubly occupied core orbitals, so the ONV has length2 (n_core + n_orbitals).Sign convention: pyscf’s determinant is
(α string)(β string)|vac⟩, all α creation operators to the left of the β ones; qarp’s (MultiONVStateBlock,FermionOperator) is ascending spin-orbital index, which interleaves the two. Moving each β operator on spatialpleft past the α operators onq > pgives the per-determinant sign(−1)^{#{(p ∈ occ_β, q ∈ occ_α) : q > p}}applied here (within-string conventions only contribute a global sign). Confirmed by the CASCI energy oracle intests/test_operators/test_pyscf_helpers.py.pyscf is imported lazily; entries with
|c| < thresholdare dropped.
- qarp.operators.pyscf.onv_from_mf(mf: Any) list[int][source]¶
Reference determinant as an abab ONV, from
mf.mol.nelec; RHF, ROHF and UHF alike.
- qarp.operators.pyscf.unrestricted_integrals_from_mf(mf: Any) tuple[float, tuple[NDArray, NDArray], tuple[NDArray, NDArray, NDArray]][source]¶
(constant, (h_a, h_b), (g_aa, g_ab, g_bb)) in the UHF MO bases, chemists’ notation.
Per-spin spatial blocks — no spin-orbital index exists here. The abab interleave happens once, in
spin_blocks_to_spin_orbital(viaunrestricted_integrals_to_fermion_operator); never an aabb layout.