Hi,


Hi again,

Sorry if I am spamming you a bit, but I have new informations about my issue :
- my cell hamiltonian is not hermician, but my full hamiltonian is hermician (tested with 'np.allclose(ham, ham.conjugate().transpose())' for both hamiltonians)
- if I put a random magnitude on my second nearest neighbors hopping terms, not a single of these hopping terms remains 'hermician' in my cell hamiltonian, even in the core of the cell (checked by plotting the cell hamiltonian)
   Using real random hopping terms leads to the same result.

I still don't understand why this is happening and how to fix it.
I guess it has something to do with how Kwant construct the hamiltonian depending on the symmetries of the system.

This does indeed seem quite mysterious; Kwant should ensure that the cell Hamiltonian is indeed Hermitian.

I have observed that if you use 'kwant.digest.uniform' (a hash function), rather than using an RNG then the Hamiltonian is properly Hermitian. You can replace 'random_uni' with 'hash_uniform':

    def hash_uniform(site1, site2=None, amplitude=0):
        # Just some unique array per site/hopping
        arr = site1.tag if site2 is None else np.vstack((site1.tag, site2.tag))
        return 2 * amplitude * (kwant.digest.uniform(arr) - 0.5)

The fact that this produces a Hermitian cell Hamiltonian strongly suggests that the behaviour you observe has something to do with the use of the RNG. The use of the hashing function still has the property that it assigns completely independent (i.e. not conjugate) values to hoppings (i, j) and (j, i), so the behaviour you observe cannot be due to this. The use of hashes, however, ensures that the same onsite/hopping is always assigned the *same* value (You can control this using the 'salt' parameter to 'kwant.digest.uniform', if required).

It will require more investigation to figure out exactly why using an RNG in this case causes unexpected results.

Happy Kwanting,

Joe