Operators and States

Python operator and state primitives.

Generated operators use sparse storage internally where that preserves the structure of common open-system models. The public to_numpy and __array__ interfaces still expose dense arrays for convenient inspection and interoperability.

class openquantumsim.operators.Operator(data, space=None, label=None)[source]

Bases: object

Linear operator with an optional Hilbert-space descriptor.

Parameters:
data: Any
space: HilbertSpace | None = None
label: str | None = None
property shape: tuple[int, int]

Matrix shape.

property dim: int

Matrix dimension.

dag()[source]

Return the Hermitian adjoint.

Return type:

Operator

to_numpy()[source]

Return a dense NumPy array representation.

Return type:

ndarray[tuple[Any, …], dtype[complex128]]

openquantumsim.operators.eye(space_or_dim)[source]

Identity operator.

Parameters:

space_or_dim (HilbertSpace | int)

Return type:

Operator

openquantumsim.operators.destroy(space_or_dim)[source]

Bosonic annihilation operator for a finite-dimensional truncation.

Parameters:

space_or_dim (HilbertSpace | int)

Return type:

Operator

openquantumsim.operators.create(space_or_dim)[source]

Bosonic creation operator.

Parameters:

space_or_dim (HilbertSpace | int)

Return type:

Operator

openquantumsim.operators.identity(space_or_dim)[source]

Identity operator (alias of eye()).

Parameters:

space_or_dim (HilbertSpace | int)

Return type:

Operator

openquantumsim.operators.position(space_or_dim)[source]

Dimensionless position quadrature (a + a^dagger) / sqrt(2).

Parameters:

space_or_dim (HilbertSpace | int)

Return type:

Operator

openquantumsim.operators.momentum(space_or_dim)[source]

Dimensionless momentum quadrature -i (a - a^dagger) / sqrt(2).

Parameters:

space_or_dim (HilbertSpace | int)

Return type:

Operator

openquantumsim.operators.num(space_or_dim)[source]

Bosonic number operator.

Parameters:

space_or_dim (HilbertSpace | int)

Return type:

Operator

openquantumsim.operators.sigmax(space_or_dim=None)[source]

Pauli sigma-x operator.

Parameters:

space_or_dim (HilbertSpace | int | None)

Return type:

Operator

openquantumsim.operators.sigmay(space_or_dim=None)[source]

Pauli sigma-y operator.

Parameters:

space_or_dim (HilbertSpace | int | None)

Return type:

Operator

openquantumsim.operators.sigmaz(space_or_dim=None)[source]

Pauli sigma-z operator.

Parameters:

space_or_dim (HilbertSpace | int | None)

Return type:

Operator

openquantumsim.operators.sigmam(space_or_dim=None)[source]

Two-level lowering operator |down><up|.

Parameters:

space_or_dim (HilbertSpace | int | None)

Return type:

Operator

openquantumsim.operators.sigmap(space_or_dim=None)[source]

Two-level raising operator |up><down|.

Parameters:

space_or_dim (HilbertSpace | int | None)

Return type:

Operator

openquantumsim.operators.spin_jm(space_or_dim)[source]

Spin-S lowering operator in the Dicke basis ordered by descending m.

Parameters:

space_or_dim (SpinSpace | DickeSpace | int)

Return type:

Operator

openquantumsim.operators.spin_jp(space_or_dim)[source]

Spin-S raising operator.

Parameters:

space_or_dim (SpinSpace | DickeSpace | int)

Return type:

Operator

openquantumsim.operators.spin_jx(space_or_dim)[source]

Spin-S x operator.

Parameters:

space_or_dim (SpinSpace | DickeSpace | int)

Return type:

Operator

openquantumsim.operators.spin_jz(space_or_dim)[source]

Spin-S z operator in the Dicke basis ordered by descending m.

Parameters:

space_or_dim (SpinSpace | DickeSpace | int)

Return type:

Operator

openquantumsim.operators.dicke_jm(space_or_dim)[source]

Collective Dicke lowering operator J_-.

Parameters:

space_or_dim (DickeSpace | int)

Return type:

Operator

openquantumsim.operators.dicke_jp(space_or_dim)[source]

Collective Dicke raising operator J_+.

Parameters:

space_or_dim (DickeSpace | int)

Return type:

Operator

openquantumsim.operators.dicke_jx(space_or_dim)[source]

Collective Dicke drive operator J_x.

Parameters:

space_or_dim (DickeSpace | int)

Return type:

Operator

openquantumsim.operators.dicke_jz(space_or_dim)[source]

Collective Dicke inversion operator J_z.

Parameters:

space_or_dim (DickeSpace | int)

Return type:

Operator

openquantumsim.operators.dicke_excitation(space_or_dim)[source]

Collective excitation-number operator in the symmetric Dicke manifold.

Parameters:

space_or_dim (DickeSpace | int)

Return type:

Operator

openquantumsim.operators.collective_lowering(space_or_dim)[source]

Alias for the Dicke collective lowering operator J_-.

Parameters:

space_or_dim (DickeSpace | int)

Return type:

Operator

openquantumsim.operators.collective_raising(space_or_dim)[source]

Alias for the Dicke collective raising operator J_+.

Parameters:

space_or_dim (DickeSpace | int)

Return type:

Operator

openquantumsim.operators.collective_x(space_or_dim)[source]

Alias for the Dicke collective drive operator J_x.

Parameters:

space_or_dim (DickeSpace | int)

Return type:

Operator

openquantumsim.operators.collective_z(space_or_dim)[source]

Alias for the Dicke collective inversion operator J_z.

Parameters:

space_or_dim (DickeSpace | int)

Return type:

Operator

openquantumsim.operators.collective_excitation(space_or_dim)[source]

Alias for the Dicke collective excitation-number operator.

Parameters:

space_or_dim (DickeSpace | int)

Return type:

Operator

openquantumsim.operators.tensor(*items)[source]

Kronecker product of operators.

Parameters:

items (Operator)

Return type:

Operator

openquantumsim.operators.basis(space_or_dim, index)[source]

Basis ket as a column vector.

Parameters:
Return type:

ndarray[tuple[Any, …], dtype[complex128]]

openquantumsim.operators.fock(space_or_dim, n)[source]

Fock basis state |n>.

Parameters:
Return type:

ndarray[tuple[Any, …], dtype[complex128]]

openquantumsim.operators.dicke_state(space, excitations)[source]

Symmetric Dicke state with a fixed number of excited spins.

Parameters:
Return type:

ndarray[tuple[Any, …], dtype[complex128]]

openquantumsim.operators.ket2dm(ket)[source]

Convert a ket to a density matrix.

Parameters:

ket (ndarray[tuple[Any, ...], dtype[complex128]])

Return type:

ndarray[tuple[Any, …], dtype[complex128]]

openquantumsim.operators.coherent(space_or_dim, alpha)[source]

Truncated coherent state.

Parameters:
  • space_or_dim (FockSpace | int)

  • alpha (complex)

Return type:

ndarray[tuple[Any, …], dtype[complex128]]

openquantumsim.operators.coherent_dm(space_or_dim, alpha)[source]

Density matrix of a truncated coherent state.

Parameters:
  • space_or_dim (FockSpace | int)

  • alpha (complex)

Return type:

ndarray[tuple[Any, …], dtype[complex128]]

openquantumsim.operators.thermal_dm(space_or_dim, nbar)[source]

Truncated thermal density matrix for a bosonic mode.

Parameters:
  • space_or_dim (FockSpace | int)

  • nbar (float)

Return type:

ndarray[tuple[Any, …], dtype[complex128]]