First of all, let me express my greatest admiration for the package.. It is really useful!
import pybinding as pb import numpy as np import matplotlib.pyplot as plt def makesys(U): lat=pb.Lattice(a1=[1,0,0],a2=[0,1,0],a3=[0,0,1]) lat.add_sublattices(('A', [0,0,0],U )) lat.add_hoppings( ([1,0,0], 'A', 'A', eye(2)), ([0,1,0], 'A', 'A', eye(2)), ([0,0,1], 'A', 'A', eye(2)) ) model = pb.Model(lat,pb.primitive(a1=2, a2=2,a3=2)) return model
Now I define two models. The first has the identity matrix as onsite term the other has the first Pauli matrix.
model1=makesys([[1,0], [0,1]]) model2=makesys([[0,1], [1,0]])
looking at the first site onsite element of the generated Hamiltonian I get in the first case the expected result:
model1.hamiltonian[:2,:2].todense() >matrix([[ 1., 0.], > [ 0., 1.]], dtype=float32)
in the second case however the zero matrix is returned !
model2.hamiltonian[:2,:2].todense() >matrix([[ 0., 0.], > [ 0., 0.]], dtype=float32)
The text was updated successfully, but these errors were encountered:
Thanks for reporting the bug and for the nice reproducible code example! Looks like the Hamiltonian builder was mistakenly ignoring the onsite matrix if the diagonal elements were all zero. This should be fixed now in 9d511b6.
I'll release v0.9.4 with the bug fix later this week. If you need the fix sooner, you can get it by installing the latest dev version as described here: compiling from source.