Skip to content

Shorthands for Pauli's LocalOperators

Created by: PhilipVinc

This PR adds shorthands to construct Pauli and bosonic creation/destruction operators as LocalOperators.

It allows one to define a spin hamiltonian and jump operators with the following code:

g = nk.graph.Hypercube(length=L, n_dim=1, pbc=True)
hi = nk.hilbert.Spin(s=0.5, graph=g)

ha = nk.operator.LocalOperator(hi)
j_ops = []
for i in range(L):
    ha += (gp / 2.0) * nk.operator.sigmax(hi, i)
    ha += (Vp / 4.0) * nk.operator.sigmaz(hi, i) * nk.operator.sigmaz(hi, (i + 1) % L)
    j_ops.append(nk.operator.sigmam(hi, i)

This works for arbitrary Spins and similarly for bosons, where create/destroy/number are implemented.

Merge request reports