spinguin.core.operators#

This module provides functions for calculating quantum mechanical spin operators in Hilbert space. It includes functions for single-spin operators as well as many-spin product operators.

op_E(S: float, sparse: bool = True) ndarray | csc_array[source]#

Generates the unit operator for a given spin quantum number S.

Parameters:
  • S (float) – Spin quantum number.

  • sparse (bool, default=True) – Specifies whether to return the operator as sparse or dense array.

Returns:

E – An array representing the unit operator.

Return type:

ndarray or csc_array

op_Sm(S: float, sparse: bool = True) ndarray | csc_array[source]#

Generates the spin lowering operator for a given spin quantum number S.

Parameters:
  • S (float) – Spin quantum number.

  • sparse (bool, default=True) – Specifies whether to return the operator as sparse or dense array.

Returns:

Sm – An array representing the lowering operator.

Return type:

ndarray or csc_array

op_Sp(S: float, sparse: bool = True) ndarray | csc_array[source]#

Generates the spin raising operator for a given spin quantum number S.

Parameters:
  • S (float) – Spin quantum number.

  • sparse (bool, default=True) – Specifies whether to return the operator as sparse or dense array.

Returns:

Sp – An array representing the raising operator.

Return type:

ndarray or csc_array

op_Sx(S: float, sparse: bool = True) ndarray | csc_array[source]#

Generates the spin operator Sx for a given spin quantum number S.

Parameters:
  • S (float) – Spin quantum number.

  • sparse (bool, default=True) – Specifies whether to return the operator as sparse or dense array.

Returns:

Sx – An array representing the x-component spin operator.

Return type:

ndarray or csc_array

op_Sy(S: float, sparse: bool = True) ndarray | csc_array[source]#

Generates the spin operator Sy for a given spin quantum number S.

Parameters:
  • S (float) – Spin quantum number.

  • sparse (bool, default=True) – Specifies whether to return the operator as sparse or dense array.

Returns:

Sy – An array representing the y-component spin operator.

Return type:

ndarray or csc_array

op_Sz(S: float, sparse: bool = True) ndarray | csc_array[source]#

Generates the spin operator Sz for a given spin quantum number S.

Parameters:
  • S (float) – Spin quantum number.

  • sparse (bool, default=True) – Specifies whether to return the operator as sparse or dense array.

Returns:

Sz – An array representing the z-component spin operator.

Return type:

ndarray or csc_array

op_T(S: float, l: int, q: int, sparse: bool = True) ndarray | csc_array[source]#

Generates the numerical spherical tensor operator for a given spin quantum number S, rank l, and projection q. The operator is obtained by sequential lowering of the maximum projection operator.

Source: Kuprov (2023) - Spin: From Basic Symmetries to Quantum Optimal Control, page 94.

This function is called frequently and is cached for high performance.

Parameters:
  • S (float) – Spin quantum number.

  • l (int) – Operator rank.

  • q (int) – Operator projection.

  • sparse (bool, default=True) – Specifies whether to return the operator as sparse or dense array.

Returns:

T – An array representing the spherical tensor operator.

Return type:

ndarray or csc_array

op_T_coupled(l: int, q: int, l1: int, s1: float, l2: int, s2: float, sparse: bool = True) ndarray | csc_array[source]#

Computes the coupled irreducible spherical tensor of rank l and projection q from two irreducible spherical tensors of ranks l1 and l2.

Parameters:
  • l (int) – Rank of the coupled operator.

  • q (int) – Projection of the coupled operator.

  • l1 (int) – Rank of the first operator to be coupled.

  • s1 (float) – Spin quantum number of the first spin.

  • l2 (int) – Rank of the second operator to be coupled.

  • s2 (float) – Spin quantum number of the second spin.

  • sparse (bool, default=True) – Specifies whether to return the operator as sparse or dense array.

Returns:

T – Coupled spherical tensor operator of rank l and projection q.

Return type:

ndarray or csc_array

op_from_string(spins: ndarray, operator: str, sparse: bool = True) ndarray | csc_array[source]#

Generates an operator for the spin_system in Hilbert space from the user- specified operators string.

Parameters:
  • spins (ndarray) – A one-dimensional array containing the spin quantum numbers of the spin system.

  • operator (str) –

    Defines the operator to be generated. The operator string must follow the rules below:

    • Cartesian and ladder operators: I(component,index) or I(component). Examples:

      • I(x,4) –> Creates x-operator for spin at index 4.

      • I(x)–> Creates x-operator for all spins.

    • Spherical tensor operators: T(l,q,index) or T(l,q). Examples:

      • T(1,-1,3) –> Creates operator with l=1, q=-1 for spin at index 3.

      • T(1, -1) –> Creates operator with l=1, q=-1 for all spins.

    • Product operators have * in between the single-spin operators: I(z,0) * I(z,1)

    • Sums of operators have + in between the operators: I(x,0) + I(x,1)

    • Unit operators are ignored in the input. Interpretation of these two is identical: E * I(z,1), I(z,1)

    Special case: An empty operator string is considered as unit operator.

    Whitespace will be ignored in the input.

    NOTE: Indexing starts from 0!

  • sparse (bool, default=True) – Specifies whether to construct the operator as a sparse or dense array.

Returns:

op – An array representing the requested operator.

Return type:

ndarray or csc_array

op_prod(op_def: ndarray, spins: ndarray, include_unit: bool = True, sparse: bool = True) ndarray | csc_array[source]#

Generates a product operator defined by op_def in the Zeeman eigenbasis.

Parameters:
  • op_def (ndarray) – Specifies the product operator to be generated. For example, input np.array([0, 2, 0, 1]) will generate E*T_10*E*T_11. The indices are given by N = l^2 + l - q, where l is the rank and q is the projection.

  • spins (ndarray) – Spin quantum numbers. Must match the length of op_def.

  • include_unit (bool, default=True) – Specifies whether unit operators are included in the product operator.

  • sparse (bool, default=True) – Specifies whether the operator is returned as sparse or dense array.

Returns:

op – Product operator in the Zeeman eigenbasis.

Return type:

ndarray or csc_array