Builder silently fails to conjugate hoppings, if they are not true arrays
This issue is mostly visible, if user constructs system with different lattice orbitals. For example, we construct a system with a hopping between two lattices with different number of orbitals:
import kwant lat1 = kwant.lattice.chain(norbs=1) lat2 = kwant.lattice.chain(norbs=2) syst = kwant.Builder() syst[lat1(0)] = 0 syst[lat1(2)] = 0 syst[lat2(1)] = np.array([[0, 0], [0, 0]]) syst[lat2(1), lat1(0)] = np.array([[0.5], [0.5]]) syst[lat1(2), lat2(1)] = np.array([[0.5, 0.5]]) syst.finalized().hamiltonian_submatrix()
The snippet above works. However, if we replace Numpy arrays with array-like list of lists:
... syst[lat2(1)] = [[0, 0], [0, 0]] syst[lat2(1), lat1(0)] = [[0.5], [0.5]] syst[lat1(2), lat2(1)] = [[0.5, 0.5]] ...
we get an exception:
ValueError: Hopping from site 1 to site 2 does not match the dimensions of onsite Hamiltonians of these sites.
because hopping from
lat1 is erroneously not conjugated.
This is an issue with high severity, because it can lead to silent generation of wrong Hamiltonian, if
lat2 have the same
norbs and hoppings are not Hermitian matrices, which is the case in general.