spinguin.core.superoperators#

This module provides functions for calculating Liouville-space superoperators either in full or truncated basis set.

sop_E(dim: int, sparse: bool = True) ndarray | csc_array[source]#

Returns the unit superoperator.

Parameters:
  • dim (int) – Dimension of the basis set.

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

Returns:

unit – A sparse array corresponding to the unit operator.

Return type:

ndarray or csc_array

sop_T_coupled(basis: ndarray, spins: ndarray, l: int, q: int, spin_1: int, spin_2: int = None, sparse: bool = True) ndarray | csc_array[source]#

Computes the product superoperator corresponding to the coupled spherical tensor operator of rank l and projection q, derived from two spherical tensor operators of rank 1.

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

TODO: Mieti, onko cache tarpeellinen. Nyt hyöty tulee vain, kun lasketaan R useaan kertaan samalle systeemille (esim. eri magneettikentissä). Voisi mahdollisesti olla asetus ohjelmassa (cachet päälle / pois).

Parameters:
  • basis (ndarray) – A two-dimensional array where each row contains integers that represent a Kronecker product of single-spin irreducible spherical tensors.

  • spins (ndarray) – A sequence of floats describing the spin quantum numbers of the spin system.

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

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

  • spin_1 (int) – Index of the first spin.

  • spin_2 (int, default=None) – Index of the second spin. Leave empty for linear single-spin interactions (e.g., shielding).

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

Returns:

sop – Coupled spherical tensor superoperator of rank l and projection q.

Return type:

ndarray or csc_array

sop_from_string(operator: str, basis: ndarray, spins: ndarray, side: Literal['comm', 'left', 'right'], sparse: bool = True) ndarray | csc_array[source]#

Generates a superoperator from the user-specified operators string.

Parameters:
  • 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!

  • basis (ndarray) – A two-dimensional array where each row contains integers that represent a Kronecker product of single-spin irreducible spherical tensors.

  • spins (ndarray) – A sequence of floats describing the spin quantum numbers of the spin system.

  • side ({'comm', 'left', 'right'}) – Specifies the type of superoperator: - ‘comm’ – commutation superoperator - ‘left’ – left superoperator - ‘right’ – right superoperator

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

Returns:

sop – The requested superoperator.

Return type:

ndarray or csc_array

sop_prod(op_def: ndarray, basis: ndarray, spins: ndarray, side: Literal['comm', 'left', 'right'], sparse: bool = True) ndarray | csc_array[source]#

Generates a product superoperator corresponding to the product operator defined by op_def.

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

TODO: Vastaava cache pohdinta kuin sop_T_coupled() -funktion kanssa.

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.

  • basis (ndarray) – A two-dimensional array where each row contains integers that represent a Kronecker product of single-spin irreducible spherical tensors.

  • spins (ndarray) – A sequence of floats describing the spin quantum numbers of the spin system.

  • side ({'comm', 'left', 'right'}) – Specifies the type of superoperator: - ‘comm’ – commutation superoperator - ‘left’ – left superoperator - ‘right’ – right superoperator

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

Returns:

sop – Superoperator defined by op_def.

Return type:

ndarray or csc_array

sop_prod_ref(op_def: ndarray, basis: ndarray, spins: ndarray, side: Literal['comm', 'left', 'right']) ndarray[source]#

A reference method for calculating the superoperator.

NOTE: This implementation is very slow and should be used for testing purposes only.

Parameters:
  • op_def (ndarray) – Specifies the product operator to be generated. For example, input (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.

  • basis (ndarray) – A two-dimensional array where each row contains integers that represent a Kronecker product of single-spin irreducible spherical tensors.

  • spins (ndarray) – A sequence of floats describing the spin quantum numbers of the spin system.

  • side ({'comm', 'left', 'right'}) – Specifies the type of superoperator: - ‘comm’ – commutation superoperator - ‘left’ – left superoperator - ‘right’ – right superoperator

Returns:

sop – Superoperator defined by op_def.

Return type:

ndarray

sop_to_truncated_basis(index_map: list, sop: ndarray | csc_array) ndarray | csc_array[source]#

Transforms a superoperator to a truncated basis using the index_map, which contains indices that determine the elements that are retained after the transformation.

Parameters:
  • index_map (list) – Index mapping from the original basis to the truncated basis.

  • sop (ndarray or csc_array) – Superoperators to be transformed.

Returns:

sop_transformed – Superoperator transformed into the truncated basis.

Return type:

ndarray or csc_array

structure_coefficients(spin: float, side: Literal['left', 'right']) ndarray[source]#

Computes the (normalized) structure coefficients of the operator algebra for a single spin. These coefficients are used in constructing product superoperators.

Logic explained in the following paper (Eq. 24, calculate f_ijk): (The paper does not include the normalization) https://doi.org/10.1063/1.3398146

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

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

  • side ({'left', 'right'}) – Specifies the side of the multiplication.

Returns:

c – A 3-dimensional array containing all the structure coefficients.

Return type:

ndarray