monoprop

Circuit

A variational circuit: an ordered sequence of exponential gates, angles, and a state.

A single circuit type serves every gate family, built from the single :class:ExpGate gate. The gates carry the family: a Majorana :class:ExpGate for Majorana/fermionic problems (consumed by :class:~monoprop.majorana_propagator.MajoranaPropagator) and a Pauli :class:ExpGate for qubit problems (consumed by :class:~monoprop.pauli_propagator.PauliPropagator). The two families cannot be mixed in one circuit -- construction rejects it. A fermionic generator is converted to its Majorana form in :meth:ExpGate.__init__, so every gate is already "pauli" or "majorana".

Bundles everything the propagator needs to build or evaluate an evolution:

  • gates: the ordered exponential gates. Each gate is the unit of parameterization -- one gate is driven by one angle, named by its param index.
  • parameters: the angle values (a point in parameter space). Empty means unbound -- author the structure now and supply values at evaluation time.
  • initial_state: the reference Slater determinant / computational-basis state.

The per-gate param indices give the parameter mapping: if no gate sets param, each gate gets its own angle in order (the identity mapping); if any gate sets it, all must, the indices must be contiguous 0..n-1, and gates sharing an index share an angle.

Compose circuits with + (temporal concatenation within the same gate family; the right operand's angles are appended on a fresh axis). A bound circuit is self-consistent: when parameters is non-empty its length must equal :attr:n_parameters.

Attributes

attributegates
= gates

The ordered exponential gates.

attributeparameters
= parameters

The angle values, or empty for an unbound circuit.

attributeinitial_state
= initial_state

The reference state (occupied mode / qubit indices).

attributefamily
= self._resolve_family(gates)

The gate family -- "pauli", "majorana", or "empty" -- computed at construction; the propagators dispatch on it.

attribute__hash__
= None
attributeresolved_mappingtuple[int, ...]

Per-gate angle index, derived from each gate's index.

With no gate setting index this is the identity 0..n-1 (each gate its own angle). Otherwise every gate must set index and the indices must be contiguous.

attributen_parametersint

Number of distinct variational angles the circuit references.

Functions

func__init__(self, gates=(), parameters=(), initial_state=()) -> None

Build the circuit, dropping identity gates and validating family/mapping/params.

paramself
paramgatesSequence[ExpGate]
= ()

The ordered exponential gates.

paramparametersSequence[float]
= ()

The angle values, or empty for an unbound circuit.

paraminitial_stateSequence[int]
= ()

The reference state (occupied mode / qubit indices).

Returns

None
func__eq__(self, other) -> bool

Equal when gates, parameters, and initial state match (family is derived).

paramself
paramotherobject

Returns

bool
func__repr__(self) -> str

Return a string representation listing the gates, parameters, and initial state.

paramself

Returns

str
func__len__(self) -> int

Number of gates.

paramself

Returns

int
func__iter__(self) -> Iterator[ExpGate]

Iterate over the gates in application order.

paramself

Returns

collections.abc.Iterator[monoprop.circuit.ExpGate]
func__add__(self, other) -> Circuit

Concatenate two circuits of the same family, appending other's angles.

The result applies self's gates then other's; other's angle indices are shifted up by self.n_parameters so the two halves keep independent angles (both halves' gates get explicit param indices in the result). Build the whole thing in a single :meth:~monoprop.MajoranaPropagator.build_graph call to avoid the picture-dependent ordering of incremental multi-call building.

The two circuits must share a gate family (both qubit, or both Majorana/fermionic).

paramself
paramotherCircuit

Returns

monoprop.circuit.Circuit
funcfrom_dense_arrays(cls, majoranas, gen_coeffs, param_inds, parameters=(), initial_state=()) -> Circuit

Build a Majorana circuit from flat, per-monomial dense arrays.

This is the native dense/wire format (also the on-disk msgpack-fixture layout): consecutive monomials sharing a param_ind become one Majorana :class:ExpGate whose generator is a :class:~monoprop.majorana.MajoranaOperator carrying those monomials with their (structural) generator coefficients, and each gate's param_ind becomes that gate's index, so weight-tying is preserved and the expanded engine arrays stay identical to the original.

paramcls
parammajoranasSequence[Sequence[int]]

One Majorana-index sequence per monomial.

paramgen_coeffsSequence[float]

Generator coefficient per monomial.

paramparam_indsSequence[int]

Variational-angle index per monomial (contiguous runs group into gates).

paramparametersSequence[float]
= ()

Optional angle values.

paraminitial_stateSequence[int]
= ()

Optional reference state (occupied mode indices).

Returns

monoprop.circuit.Circuit

class:Circuit carrying the grouped gates, angle values, and initial state.

On this page