Skip to content

Commit

Permalink
temp custom nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
austingmhuang committed Sep 20, 2024
1 parent b4a0f9c commit 0d49388
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pennylane/spin/spin_hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def kitaev(n_cells, coupling=None, boundary_condition=False):
return hamiltonian.simplify()


def spin_hamiltonian(lattice):
def spin_hamiltonian(lattice, custom_nodes=None):
r"""Generates a spin Hamiltonian for a custom lattice.
Args:
Expand Down Expand Up @@ -440,4 +440,10 @@ def spin_hamiltonian(lattice):

hamiltonian += coeff * (opmap[op1](v1) @ opmap[op2](v2))

for node in custom_nodes:
n = node[0]
op = node[1]
coeff = node[2]
hamiltonian += coeff * opmap[op](n)

return hamiltonian.simplify()

0 comments on commit 0d49388

Please sign in to comment.