ham#
- torchspin.ham(sys, B0=None, dtype=torch.complex128, device='cpu')[source]#
Spin Hamiltonian matrix (or field-independent parts + moment operators).
- Parameters:
sys (SpinSystem) – Spin system.
B0 (list | Tensor | None) – Static magnetic field vector in mT, shape
(3,). If given, returns the full HamiltonianH = H0 - |B0| * muzL. IfNone, returns(H0, mux, muy, muz).dtype (dtype) – Output dtype. Default
torch.complex128.device (str) – PyTorch device string.
- Returns:
H – If B0 is given — full Hamiltonian (MHz), shape
(nStates, nStates).(H0, mux, muy, muz) – If B0 is
None— field-independent Hamiltonian and the three magnetic-dipole-moment operators (MHz and MHz/mT respectively), each of shape(nStates, nStates).
- Return type:
Notes
The sign convention follows EasySpin:
H = H0 - B0[0]*mux - B0[1]*muy - B0[2]*muz = H0 - norm(B0) * muzL
where
muzLis the magnetic-moment operator projected alongB0. The nuclear Zeeman has a POSITIVE contribution to mux/muy/muz (opposite sign to electron Zeeman internally, but combined here with the same convention: H = H0 - B · μ_total).