ham_ez#

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

Electron 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 the three magnetic- dipole-moment operator components (mux, muy, muz) in MHz/mT.

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

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

  • device (str) – PyTorch device string.

Returns:

  • H – If B0 is given — Zeeman Hamiltonian matrix (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]