spinguin.core.basis#

This module provides functionality for constructing a basis set.

coherence_order(op_def: ndarray) int[source]#

Determines the coherence order of a given product operator in the basis set, defined by an array of integers op_def.

Parameters:

op_def (ndarray) – Contains the indices that describe the product operator.

Returns:

order – Coherence order of the operator.

Return type:

int

idx_to_lq(idx: int) tuple[int, int][source]#

Converts the given operator index to rank l and projection q.

Parameters:

idx (int) – Index that describes the irreducible spherical tensor.

Returns:

  • l (int) – Operator rank.

  • q (int) – Operator projection.

lq_to_idx(l: int, q: int) int[source]#

Returns the index of a single-spin irreducible spherical tensor operator determined by rank l and projection q.

Parameters:
  • l (int) – Operator rank.

  • q (int) – Operator projection.

Returns:

idx – Index of the operator.

Return type:

int

make_basis(spins: ndarray, max_spin_order: int)[source]#

Constructs a Liouville-space basis set, where the basis is spanned by all possible Kronecker products of irreducible spherical tensor operators, up to the defined maximum spin order.

The Kronecker products themselves are not calculated. Instead, the operators are expressed as sequences of integers, where each integer represents a spherical tensor operator of rank l and projection q using the following relation: N = l^2 + l - q. The indexing scheme has been adapted from:

Hogben, H. J., Hore, P. J., & Kuprov, I. (2010): https://doi.org/10.1063/1.3398146

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

  • max_spin_order (int) – Defines the maximum spin entanglement that is considered in the basis set.

make_subsystem_basis(spins: ndarray, subsystem: tuple) Iterator[source]#

Generates the basis set for a given subsystem.

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

  • subsystem (tuple) – Indices of the spins involved in the subsystem.

Returns:

basis – An iterator over the basis set for the given subsystem, represented as tuples.

For example, identity operator and z-operator for the 3rd spin: [(0, 0, 0), (0, 0, 2), …]

Return type:

Iterator

parse_operator_string(operator: str, nspins: int)[source]#

Parses operator strings and returns their definitions in the basis set as well as their corresponding coefficients. 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!

Parameters:
  • operator (str) – String that defines the operator to be generated.

  • nspins (int) – Number of spins in the system.

Returns:

  • op_defs (list of ndarray) – A list that contains arrays, which describe the requested operator with integers. Example: [[2, 0, 1]] –> T_1_0 * E * T_1_1

  • coeffs (list of floats) – Coefficients that account for the different norms of operator relations.

spin_order(op_def: ndarray) int[source]#

Finds out the spin order of a given operator defined by op_def.

Parameters:

op_def (ndarray) – Contains the indices that describe the product operator.

Returns:

order – Spin order of the operator

Return type:

int

state_idx(basis: ndarray, op_def: ndarray) int[source]#

Finds the index of the state defined by the op_def in the basis set.

Parameters:
  • basis (ndarray) – Two dimensional array containing the basis set that consists of rows of integers defining the products of irreducible spherical tensors.

  • op_def (ndarray) – A one-dimensional array of integers that describes the operator of interest.

Returns:

idx – Index of the given state in the basis set.

Return type:

int

truncate_basis_by_coherence(basis: ndarray, coherence_orders: list) list[source]#

Truncates the basis set by retaining only the product operators that correspond to coherence orders specified in the coherence_orders list.

The function generates an index map from the original basis to the truncated basis. This map can be used to transform superoperators or state vectors to the new basis.

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

  • coherence_orders (list) – List of coherence orders to be retained in the basis.

Returns:

  • truncated_basis (ndarray) – A two-dimensional array containing the basis set with only the specified coherence orders retained.

  • index_map (list) – List that contains an index map from the original basis to the truncated basis.