qarp.operators.onv

Occupation-number vectors as plain lists.

An ONV is a list[int] of spin-orbital occupations in abab (alpha/beta interleaved) ordering: spin orbital 2p is spatial orbital p alpha, 2p + 1 its beta partner. Index i = spin orbital i = qubit i (LSB, qarp_conventions.md §1) — mappings’ encode_state and state- preparation blocks consume these lists positionally.

qarp.operators.onv.active_space(onv: list[int], active_electrons: int | tuple[int, int], active_orbitals: int) list[int][source]

Return an Aufbau-obeying ONV for an active space carved from onv.

Parameters:
  • onv – The full-space occupation-number vector.

  • active_electrons – Number of active electrons, or an (alpha, beta) tuple.

  • active_orbitals – Number of active spatial orbitals.

Returns:

The active-space ONV, obeying the Aufbau principle.

qarp.operators.onv.freeze(onv: list[int], indices: Sequence[int]) list[int][source]

Return a new ONV with the given spin-orbital indices removed.

Parameters:
  • onv – The occupation-number vector.

  • indices – Spin-orbital indices to freeze out.

Returns:

A new ONV without the frozen entries.

qarp.operators.onv.freeze_spatial(onv: list[int], spatial_indices: Sequence[int]) list[int][source]

Return a new ONV with the given spatial orbitals (abab pairs) removed.

Freezing spatial orbital p removes spin orbitals 2p and 2p + 1.

Parameters:
  • onv – The occupation-number vector.

  • spatial_indices – Spatial-orbital indices to freeze out.

Returns:

A new ONV without the frozen spin-orbital pairs.

qarp.operators.onv.is_alpha(spin_orbital: int) bool[source]

True if the spin orbital sits on the alpha (even-index) sublattice of the abab layout.

qarp.operators.onv.is_beta(spin_orbital: int) bool[source]

True if the spin orbital sits on the beta (odd-index) sublattice of the abab layout.

qarp.operators.onv.onv_from_spatial_occupations(occupations: Sequence[int]) list[int][source]

Build an abab spin-orbital ONV from spatial-orbital occupations.

Occupation 2 fills both spin orbitals, 1 fills the alpha spin orbital (matching the open-shell convention of restricted references), 0 neither: [2, 1, 0] -> [1, 1, 1, 0, 0, 0].

Parameters:

occupations – Per-spatial-orbital occupations, each 0, 1 or 2.

Returns:

The spin-orbital ONV.

qarp.operators.onv.same_spin(spin_orbital: int, other: int) bool[source]

True if two spin orbitals carry the same spin (same abab sublattice).