/ pybinding Public

# onsite term not set correctly#5

Closed
opened this issue Jul 9, 2017 · 2 comments
Closed

# onsite term not set correctly #5

opened this issue Jul 9, 2017 · 2 comments

### oroszl commented Jul 9, 2017

 First of all, let me express my greatest admiration for the package.. It is really useful! Specially I would like to express my profound gratitude for implementing the KPM stuff! So I have been playing around with the package. The current problem I am investigating is a 3D lattice with two orbitals on a single site and I have came up on a small bug. Let me illustrate it with the following small bit of code ```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:

### dean0x7d commented Jul 11, 2017

 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.

### oroszl commented Jul 11, 2017

 Thanks for the fix. I think We can close this