spinguin.core.chem#

This module contains functions responsible for chemical kinetics.

associate(basis_A: ndarray, basis_B: ndarray, basis_C: ndarray, rho_A: ndarray | csc_array, rho_B: ndarray | csc_array, spin_map_A: list | tuple | ndarray, spin_map_B: list | tuple | ndarray) ndarray | csc_array[source]#

Combines two state vectors when spin systems associate in a chemical reaction A + B -> C.

Example. We have spin system A that has two spins and spin system B that has three spins. These systems associate to form a composite spin system C that has five spins that are indexed (0, 1, 2, 3, 4). Of these, spins (0, 2) are from subsystem A and (1, 3, 4) from subsystem B. We have to choose how the spin systems A and B will be indexed in spin system C by defining the spin maps as follows:

spin_map_A = np.ndarray([0, 2])
spin_map_B = np.ndarray([1, 3, 4])
Parameters:
  • basis_A (ndarray) – Basis set for the subsystem A. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • basis_B (ndarray) – Basis set for the subsystem B. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • basis_C (ndarray) – Basis set for the composite system C. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • rho_A (ndarray or csc_array) – State vector of spin system A.

  • rho_B (ndarray or csc_array) – State vector of spin system B.

  • spin_map_A (list or tuple or ndarray) – Indices of spin system A within spin system C.

  • spin_map_B (list or tuple or ndarray) – Indices of spin system B within spin system C.

Returns:

rho_C – State vector of the composite spin system C.

Return type:

ndarray or csc_array

associate_index_map(basis_A: ndarray, basis_B: ndarray, basis_C: ndarray, spin_map_A: ndarray, spin_map_B: ndarray) tuple[ndarray, ndarray, ndarray][source]#

Generates arrays that map the state indices from spin systems A and B to the composite spin system C. This function is used in associate().

Example. We have spin system A that has two spins and spin system B that has three spins. These systems associate to form a composite spin system C that has five spins that are indexed (0, 1, 2, 3, 4). Of these, spins (0, 2) are from subsystem A and (1, 3, 4) from subsystem B. We have to choose how the spin systems A and B will be indexed in spin system C by defining the spin maps as follows:

spin_map_A = np.ndarray([0, 2])
spin_map_B = np.ndarray([1, 3, 4])
Parameters:
  • basis_A (ndarray) – Basis set for the subsystem A. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • basis_B (ndarray) – Basis set for the subsystem B. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • basis_C (ndarray) – Basis set for the composite system C. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • spin_map_A (ndarray) – Indices of spin system A within spin system C.

  • spin_map_B (ndarray) – Indices of spin system B within spin system C.

Returns:

  • index_map_A (ndarray) – Mapping of indices for spin system A.

  • index_map_B (ndarray) – Mapping of indices for spin system B.

  • index_map_C (ndarray) – Mapping of indices for spin system C.

dissociate(basis_A: ndarray, basis_B: ndarray, basis_C: ndarray, spins_A: ndarray, spins_B: ndarray, rho_C: ndarray | csc_array, spin_map_A: list | tuple | ndarray, spin_map_B: list | tuple | ndarray) tuple[ndarray | csc_array, ndarray | csc_array][source]#

Dissociates the density vector of composite system C into density vectors of two subsystems A and B in a chemical reaction C -> A + B.

Example. Spin system C has five spins, which are indexed as (0, 1, 2, 3, 4). We want to dissociate this into two subsystems A and B. Spins 0 and 2 should go to subsystem A and the rest to subsystem B. In this case, we define the following spin maps:

spin_map_A = np.array([0, 2])
spin_map_B = np.array([1, 3, 4])
Parameters:
  • basis_A (ndarray) – Basis set for the subsystem A. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • basis_B (ndarray) – Basis set for the subsystem B. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • basis_C (ndarray) – Basis set for the composite system C. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • spins_A (ndarray) – Spin quantum numbers for each spin in system A.

  • spins_B (ndarray) – Spin quantum numbers for each spin in system B.

  • rho_C (ndarray or csc_array) – State vector of the composite spin system C.

  • spin_map_A (list or tuple or ndarray) – Indices of spin system A within spin system C.

  • spin_map_B (list or tuple or ndarray) – Indices of spin system B within spin system C.

Returns:

  • rho_A (ndarray or csc_array) – State vector of spin system A.

  • rho_B (ndarray or csc_array) – State vector of spin system B.

dissociate_index_map(basis_A: ndarray, basis_B: ndarray, basis_C: ndarray, spin_map_A: ndarray, spin_map_B: ndarray) tuple[ndarray, ndarray, ndarray, ndarray][source]#

Generates arrays that map the state indices from the basis set C to basis sets A and B. This function is used in dissociate().

Example. Basis set C contains five spins, which are indexed as (0, 1, 2, 3, 4). We want to dissociate this into two subsystems A and B. Spins 0 and 2 should go to subsystem A and the rest to subsystem B. In this case, we define the following spin maps:

spin_map_A = np.array([0, 2])
spin_map_B = np.array([1, 3, 4])
Parameters:
  • basis_A (ndarray) – Basis set for the subsystem A. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • basis_B (ndarray) – Basis set for the subsystem B. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • basis_C (ndarray) – Basis set for the composite system C. It is a 2-dimensional array containing sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • spin_map_A (ndarray) – Indices of spin system A within spin system C.

  • spin_map_B (ndarray) – Indices of spin system B within spin system C.

Returns:

  • index_map_A (ndarray) – Indices of states in A that also appear in C.

  • index_map_CA (ndarray) – Corresponding indices of the matching elements in C. The array length is equal to index_map_A.

  • index_map_B (ndarray) – Indices of states in B that also appear in C.

  • index_map_CB (ndarray) – Corresponding indices of the matching elements in C. The array length is equal to index_map_B.

permutation_matrix(basis: ndarray, spin_map: list | tuple | ndarray) csc_array[source]#

Creates a permutation matrix to reorder the spins in the system.

Example. Our spin system has three spins, which are indexed (0, 1, 2). We want to perform the following permulation:

  • 0 –> 2 (Spin 0 goes to position 2)

  • 1 –> 0 (Spin 1 goes to position 0)

  • 2 –> 1 (Spin 2 goes to position 1)

In this case, we want to assign the following map:

spin_map = np.array([2, 0, 1])

The permutation can be applied by:

rho_permuted = perm @ rho
Parameters:
  • basis (ndarray) – A 2-dimensional array containing the basis set that contains sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • spin_map (list or tuple or ndarray) – Indices of the spins in the spin system after permutation.

Returns:

perm – The permutation matrix.

Return type:

csc_array

permute_spins(basis: ndarray, rho: ndarray | csc_array, spin_map: list | tuple | ndarray) ndarray | csc_array[source]#

Permutes the state vector of a spin system to correspond to a reordering of the spins in the system.

Example. Our spin system has three spins, which are indexed (0, 1, 2). We want to perform the following permulation:

  • 0 –> 2 (Spin 0 goes to position 2)

  • 1 –> 0 (Spin 1 goes to position 0)

  • 2 –> 1 (Spin 2 goes to position 1)

In this case, we want to assign the following map:

spin_map = np.array([2, 0, 1])
Parameters:
  • basis (ndarray) – A 2-dimensional array containing the basis set that contains sequences of integers describing the Kronecker products of irreducible spherical tensors.

  • rho (ndarray or csc_array) – State vector of the spin system.

  • spin_map (list or tuple or ndarray) – Indices of the spins in the spin system after permutation.

Returns:

rho – Permuted state vector of the spin system.

Return type:

ndarray or csc_array