ham_nz#

torchspin.ham_nz(sys, B0=None, nSpins=None, dtype=torch.complex128, device='cpu')[source]#

Nuclear Zeeman Hamiltonian (or magnetic-moment operators).

Parameters:
  • sys (SpinSystem) – Spin system.

  • B0 (list | Tensor | None) – Magnetic field vector in mT, shape (3,). If given, returns the Zeeman Hamiltonian matrix. If None, returns (mux, muy, muz).

  • nSpins (list[int] | None) – 1-based indices of nuclear spins to include. Defaults to all.

  • dtype (dtype) – Output dtype. Default torch.complex128.

  • device (str) – PyTorch device string.

Returns:

  • H – If B0 is given — nuclear Zeeman Hamiltonian (MHz), shape (nStates, nStates).

  • (mux, muy, muz) – If B0 is None — three magnetic-dipole-moment operator matrices (MHz/mT), each of shape (nStates, nStates).

Return type:

Tensor | tuple[Tensor, Tensor, Tensor]

Notes

The sign convention is positive (opposite to electron Zeeman):

H = mux*B[0] + muy*B[1] + muz*B[2]

Prefactor: pre = +NMAGN/PLANCK * gn * gnscale  [Hz/T] * 1e-9  →  [MHz/mT]