spinOps package
Module contents
SpinOps top-level package …
- spinOps.number_of_states(two_I)
Computes the total number of quantum states for a given spin system.
- Parameters:
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
Total number of quantum states in the spin system.
- Return type:
int
- Raises:
ValueError – If the input list two_I is empty.
- spinOps.create_single_spin_Ix(spin_index, two_I)
Generates the single-spin Ix operator matrix for the specified spin using quantum_numbers_t.
- spinOps.create_single_spin_Iy(spin_index, two_I)
Generates the single-spin Iy operator matrix for the specified spin using quantum_numbers_t.
- spinOps.create_single_spin_Iz(spin_index, two_I)
Creates the single-spin \(\hat{I}_z\) operator matrix for a single spin in a spin system.
- Parameters:
spin_index (int) – The index of the spin for which the \(\hat{I}_z\) operator is being created.
two_I (list) – A list of integers representing \(2 I\) values for each spin in the system, where I is the spin quantum number.
- Returns:
The \(\hat{I}_z\) operator matrix as a 2D NumPy array.
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If spin_index is out of bounds.
- spinOps.create_single_spin_Ip(spin_index, two_I)
Generates the single-spin raising operator (\(\hat{I}_+\)) matrix for a specified spin within a spin system.
- Parameters:
spin_index (int) – Index of the spin for which the \(\hat{I}_+\) operator is constructed.
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
A 2D NumPy array representing the raising (\(\hat{I}_+\)) operator matrix.
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If spin_index is out of the valid range.
- spinOps.create_single_spin_Im(spin_index, two_I)
Generates the single-spin lowering operator (\(\hat{I}_-\)) matrix for a specified spin within a spin system.
- Parameters:
spin_index (int) – Index of the spin for which the \(\hat{I}_-\) operator is constructed.
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
A 2D NumPy array representing the lowering (\(\hat{I}_-\)) operator matrix.
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If spin_index is out of the valid range.
- spinOps.create_single_spin_Tlm(L, M, spin_index, two_I)
Generates the single-spin irreducible spherical tensor operator (\(\hat{T}_{L,M}\)) matrix for a specified spin within a spin system.
- Parameters:
L (int) – Rank of the tensor operator.
M (int) – Order of the tensor operator.
spin_index (int) – Index of the spin for which the \(\hat{T}_{L,M}\) operator is constructed.
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
A 2D NumPy array representing the \(\hat{T}_{L,M}\) operator matrix.
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If spin_index is out of the valid range.
- spinOps.tlm(l, m, I, m1, m2)
Computes the matrix element
\[\langle I,m_1|\:\hat{T}_{l,m}\:|I,m_2\rangle\]of the irreducible spherical tensor operator \(\hat{T}_{l,m}\).
- Parameters:
l (double) – Rank of the irreducible spherical tensor operator.
m (double) – Order of the irreducible spherical tensor operator.
I (double) – Total angular momentum quantum number of the spin.
m1 (double) – Angular momentum component quantum number of the spin.
m2 (double) – Angular momentum component quantum number of the spin.
- Returns:
The matrix element \(\langle I,m_1|\:\hat{T}_{l,m}\:|I,m_2\rangle\).
- Return type:
double
- spinOps.create_single_spin_Tlm_unit(L, M, spin_index, two_I)
Generates the single-spin unit-normalized irreducible spherical tensor operator (\(\hat{\mathcal{T}}_{L,M}\)) matrix for a specified spin within a spin system.
- Parameters:
L (int) – Rank of the tensor operator.
M (int) – Order of the tensor operator.
spin_index (int) – Index of the spin for which the unit-normalized \(\hat{\mathcal{T}}_{L,M}\) operator is constructed.
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
A 2D NumPy array representing the unit-normalized \(\hat{\mathcal{T}}_{L,M}\) operator matrix.
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If spin_index is out of the valid range.
- spinOps.unit_tlm(l, m, I, m1, m2)
Computes the matrix element
\[\langle j_1,m_1|\:\hat{\mathcal{T}}_{l,m}\:|j_2,m_2\rangle\]of the unit irreducible spherical tensor operator \(\hat{\mathcal{T}}_{l,m}\) between the specified quantum states.
- Parameters:
l (double) – Rank of the irreducible spherical tensor operator.
m (double) – Order of the irreducible spherical tensor operator.
j1 (double) – Total angular momentum quantum number of the first particle.
m1 (double) – Angular momentum component of the first particle.
j2 (double) – Total angular momentum quantum number of the second particle.
m2 (double) – Angular momentum component of the second particle.
- Returns:
The \(\langle j_1,m_1|\:\hat{\mathcal{T}}_{l,m}\:|j_2,m_2\rangle\) matrix element.
- Return type:
double
- spinOps.createEf(r, s, two_I)
Generates the operator matrix \(\hat{E}^{r-s}\) corresponding to the transition from state \(s\) to \(r\) in a fictitious spin-1/2 system.
- Parameters:
r (int) – Index of the first quantum state (row index).
s (int) – Index of the second quantum state (column index).
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
A 2D NumPy array representing the \(\hat{E}^{r-s}\) operator matrix.
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If r or s is out of the valid range.
- spinOps.create_Ixf(r, s, two_I)
Generates the fictitious spin-1/2 operator matrix \(\hat{I}_x^{r-s}\) for a transition from state \(s\) to state \(r\).
- Parameters:
r (int) – Index of the target quantum state (row index).
s (int) – Index of the source quantum state (column index).
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
A 2D NumPy array representing the operator \(\hat{I}_x^{r-s}\).
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If r or s is negative.
- spinOps.create_Iyf(r, s, two_I)
Generates the fictitious spin-1/2 operator matrix \(\hat{I}_y^{r-s}\) for a transition from state \(s\) to state \(r\).
- Parameters:
r (int) – Index of the target quantum state (row index).
s (int) – Index of the source quantum state (column index).
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
A 2D NumPy array representing the operator \(\hat{I}_y^{r-s}\).
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If r or s is negative.
- spinOps.create_Izf(r, s, two_I)
Generates the fictitious spin-1/2 operator matrix \(\hat{I}_z^{r-s}\) for a transition from state \(s\) to state \(r\).
- Parameters:
r (int) – Index of the target quantum state (row index).
s (int) – Index of the source quantum state (column index).
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
A 2D NumPy array representing the operator \(\hat{I}_z^{r-s}\).
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If r or s is negative.
- spinOps.create_Ipf(r, s, two_I)
Generates the fictitious spin-1/2 raising operator matrix \(\hat{I}_+^{r-s}\) for a transition from state \(s\) to state \(r\).
- Parameters:
r (int) – Index of the target quantum state (row index).
s (int) – Index of the source quantum state (column index).
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
A 2D NumPy array representing the operator \(\hat{I}_+^{r-s}\).
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If r or s is negative.
- spinOps.create_Imf(r, s, two_I)
Generates the fictitious spin-1/2 lowering operator matrix \(\hat{I}_-^{r-s}\) for a transition from state \(s\) to state \(r\).
- Parameters:
r (int) – Index of the target quantum state (row index).
s (int) – Index of the source quantum state (column index).
two_I (list of int) – List of integers representing \(2I\) values for each spin in the system, where \(I\) is the spin quantum number.
- Returns:
A 2D NumPy array representing the operator \(\hat{I}_-^{r-s}\).
- Return type:
ndarray[double complex, ndim=2]
- Raises:
ValueError – If the input list two_I is empty.
IndexError – If r or s is negative.
- spinOps.clebsch(j1, m1, j2, m2, j, m)
Computes the Clebsch-Gordan coefficient, \(\langle j,m|j_1,m_1,j_2,m_2\rangle\) for the specified quantum numbers.
- Parameters:
j1 (double) – Total angular momentum of the first particle.
m1 (double) – Magnetic quantum number of the first particle.
j2 (double) – Total angular momentum of the second particle.
m2 (double) – Magnetic quantum number of the second particle.
j (double) – Total angular momentum of the combined system.
m (double) – Magnetic quantum number of the combined system.
- Returns:
The Clebsch-Gordan coefficient for the specified quantum numbers.
- Return type:
double
- spinOps.create_rho1(zeta)
Constructs the rank-1 irreducible spherical tensor \(\rho_{1,m}\) in the principal axis system (PAS) according to the Haeberlen convention.
- Parameters:
zeta (double) – The anisotropy parameter \(\zeta\) for the tensor.
- Returns:
A 1D NumPy array containing the components of the rank-1 irreducible tensor.
- Return type:
cnp.ndarray[double complex, ndim=1]
- Raises:
ValueError – If the input parameter zeta is invalid (validation not currently enforced).
- spinOps.create_rho2(zeta, eta)
Constructs the rank-2 irreducible spherical tensor \(\rho_{2,m}\) in the principal axis system (PAS) according to the Haeberlen convention.
- Parameters:
zeta (double) – The anisotropy parameter \(\zeta\) for the tensor.
eta (double) – The asymmetry parameter \(\eta\) for the tensor.
- Returns:
A 1D NumPy array containing the components of the rank-2 irreducible tensor.
- Return type:
cnp.ndarray[double complex, ndim=1]
- Raises:
ValueError – If the input parameters zeta or eta are invalid (validation not currently enforced).
- spinOps.wigner_d(l, m1, m2, beta)
Computes the reduced Wigner d-matrix element \(d^{(l)}_{m_1,m_2}[\beta]\) for the given quantum numbers and rotation angle.
- Parameters:
l (double) – Rank of the rotation operator.
m1 (double) – Initial magnetic quantum number.
m2 (double) – Final magnetic quantum number.
beta (double) – Rotation angle in radians.
- Returns:
The reduced Wigner d-matrix element \(d^{(l)}_{m_1,m_2}[\beta]\).
- Return type:
double
- spinOps.DLM(l, m1, m2, alpha, beta, gamma)
Computes the Wigner D-matrix element \(\mathcal{D}^{(l)}_{m_1,m_2}[\alpha,\beta,\gamma]\) for the given quantum numbers and Euler angles.
- Parameters:
l (double) – Rank of the rotation operator.
m1 (double) – Initial magnetic quantum number.
m2 (double) – Final magnetic quantum number.
alpha (double) – First Euler angle (rotation about the z-axis) in radians.
beta (double) – Second Euler angle (rotation about the y-axis) in radians.
gamma (double) – Third Euler angle (rotation about the z-axis) in radians.
- Returns:
The Wigner D-matrix element \(\mathcal{D}^{(l)}_{m_1,m_2}[\alpha,\beta,\gamma]\).
- Return type:
double complex
- Raises:
ValueError – If the input quantum numbers do not satisfy the required selection rules (validation not enforced).
- spinOps.Rotate(initial, alpha, beta, gamma)
Rotates a spherical tensor \(\rho_{l,m}\) using the Wigner D-matrix and specified Euler angles.
- Parameters:
initial (cnp.ndarray[double complex, ndim=1]) – A 1D NumPy array representing the spherical tensor components.
alpha (double) – First Euler angle (rotation about the z-axis) in radians.
beta (double) – Second Euler angle (rotation about the y-axis) in radians.
gamma (double) – Third Euler angle (rotation about the z-axis) in radians.
- Returns:
A 1D NumPy array representing the rotated spherical tensor.
- Return type:
cnp.ndarray[double complex, ndim=1]
- Raises:
ValueError – If the input array initial is empty.