spinguin.core.hamiltonian#
This module provides functions for calculating Hamiltonian superoperators.
- sop_H(basis: ndarray, spins: ndarray, gammas: ndarray = None, B: float = None, chemical_shifts: ndarray = None, J_couplings: ndarray = None, interactions: list[Literal['zeeman', 'chemical_shift', 'J_coupling']] = ['zeeman', 'chemical_shift', 'J_coupling'], side: Literal['comm', 'left', 'right'] = 'comm', sparse: bool = True, zero_value: float = 1e-12) ndarray | csc_array [source]#
Computes the coherent part of the Hamiltonian superoperator, including the Zeeman interaction, isotropic chemical shift, and J-couplings.
- Parameters:
basis (ndarray) – A 2-dimensional array containing the basis set that contains sequences of integers describing the Kronecker products of irreducible spherical tensors.
spins (ndarray) – A 1-dimensional array containing the spin quantum numbers of each spin.
gammas (ndarray) – A 1-dimensional array containing the gyromagnetic ratios of each spin in the units of rad/s/T.
B (float) – External magnetic field in the units of T.
chemical_shifts (ndarray) – A 1-dimensional array containing the chemical shifts of each spin in the units of ppm.
J_couplings (ndarray) – A 2-dimensional array containing the scalar J-couplings between each spin in the units of Hz. Only the bottom triangle is considered.
interactions (list, default=["zeeman", "chemical_shift", "J_coupling"]) – Specifies which interactions are taken into account. The options are: - ‘zeeman’ – Zeeman interaction - ‘chemical_shift’ – Isotropic chemical shift - ‘J_coupling’ – Scalar J-coupling
side ({'comm', 'left', 'right'}) – Specifies the type of superoperator: - ‘comm’ – commutation superoperator (default) - ‘left’ – left superoperator - ‘right’ – right superoperator
sparse (bool, default=True) – Specifies whether to construct the Hamiltonian as sparse or dense array.
zero_value (float, default=1e-12) – Smaller values than this threshold are made equal to zero after calculating the Hamiltonian. When using sparse arrays, larger values decrease the memory requirement at the cost of accuracy.
- Returns:
sop_H – The coherent Hamiltonian.
- Return type:
ndarray or csc_array
- sop_H_CS(basis: ndarray, gammas: ndarray, spins: ndarray, chemical_shifts: ndarray, B: float, side: Literal['comm', 'left', 'right'] = 'comm', sparse: bool = True) ndarray | csc_array [source]#
Computes the Hamiltonian superoperator for the chemical shift.
- Parameters:
basis (ndarray) – A 2-dimensional array containing the basis set that contains sequences of integers describing the Kronecker products of irreducible spherical tensors.
gammas (ndarray) – A 1-dimensional array containing the gyromagnetic ratios of each spin in the units of rad/s/T
spins (ndarray) – A 1-dimensional array containing the spin quantum numbers of each spin.
chemical_shifts (ndarray) – A 1-dimensional array containing the chemical shifts of each spin in the units of ppm.
B (float) – External magnetic field in the units of T.
side ({'comm', 'left', 'right'}) – Specifies the type of superoperator: - ‘comm’ – commutation superoperator (default) - ‘left’ – left superoperator - ‘right’ – right superoperator
sparse (bool, default=True) – Specifies whether to construct the Hamiltonian as sparse or dense array.
- Returns:
sop_Hz – The Hamiltonian superoperator for the chemical shift.
- Return type:
ndarray or csc_array
- sop_H_J(basis: ndarray, spins: ndarray, J_couplings: ndarray, side: Literal['comm', 'left', 'right'] = 'comm', sparse: bool = True) ndarray | csc_array [source]#
Computes the J-coupling term of the Hamiltonian.
- Parameters:
basis (ndarray) – A 2-dimensional array containing the basis set that contains sequences of integers describing the Kronecker products of irreducible spherical tensors.
spins (ndarray) – A 1-dimensional array containing the spin quantum numbers of each spin.
J_couplings (ndarray) – A 2-dimensional array containing the scalar J-couplings between each spin in the units of Hz. Only the bottom triangle is considered.
side ({'comm', 'left', 'right'}) – Specifies the type of superoperator: - ‘comm’ – commutation superoperator (default) - ‘left’ – left superoperator - ‘right’ – right superoperator
sparse (bool, default=True) – Specifies whether to construct the Hamiltonian as sparse or dense array.
- Returns:
sop_Hj – The J-coupling Hamiltonian superoperator.
- Return type:
ndarray or csc_array
- sop_H_Z(basis: ndarray, gammas: ndarray, spins: ndarray, B: float, side: Literal['comm', 'left', 'right'] = 'comm', sparse: bool = True) ndarray | csc_array [source]#
Computes the Hamiltonian superoperator for the Zeeman interaction.
- Parameters:
basis (ndarray) – A 2-dimensional array containing the basis set that contains sequences of integers describing the Kronecker products of irreducible spherical tensors.
gammas (ndarray) – A 1-dimensional array containing the gyromagnetic ratios of each spin in the units of rad/s/T
spins (ndarray) – A 1-dimensional array containing the spin quantum numbers of each spin.
B (float) – External magnetic field in the units of T.
side ({'comm', 'left', 'right'}) – Specifies the type of superoperator: - ‘comm’ – commutation superoperator (default) - ‘left’ – left superoperator - ‘right’ – right superoperator
sparse (bool, default=True) – Specifies whether to construct the Hamiltonian as sparse or dense array.
- Returns:
sop_Hz – The Hamiltonian superoperator for the Zeeman interaction.
- Return type:
ndarray or csc_array