ham_ezho#

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

Higher-order Zeeman interaction Hamiltonian.

Parameters:
  • sys (SpinSystem) – Spin system with Ham dict containing higher-order Zeeman parameters.

  • B0 (list | Tensor | None) – Magnetic field vector in mT, shape (3,). If given, returns the full Hamiltonian. If None, returns the tensor decomposition (G0, G1, G2, G3).

  • eSpins (list[int] | None) – 1-based electron spin indices (default: all).

  • lB_select (int | list[int] | None) – Select specific orders in B (0, 1, 2, 3). Default: all orders present in sys.Ham.

  • dtype (dtype) – Output dtype.

  • device (str) – PyTorch device.

Returns:

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

  • (G0, G1, G2, G3) (tuple) – If B0 is None — field-derivative tensors:

    • G0: zero-field Hamiltonian (MHz)

    • G1: [dH/dBx, dH/dBy, dH/dBz] (MHz/mT)

    • G2: [[d²H/dBidBj]] 3×3 list (MHz/mT²)

    • G3: [[[d³H/dBidBjdBk]]] 3×3×3 list (MHz/mT³)

Return type:

Tensor | tuple