The `kwant.discretize` is devoted to discrete k.p Hamiltonians. In your case, I'd recommend to write the tight-binding version of that Hamiltonian instead.

I don't understand what you mean by "finding the hopping terms". You should set that, and not find it.


On Sat, 6 Feb 2021, 12:16 Victor Regis, <> wrote:
Hi all,

I need to use the following hamiltonian to test if the rest of my code is correct, however I haven't been able to implement it in Kwant. Reading the examples, all the discretize ones are for polynomial dependences on k but mine isn't.

H = sin(k_x)*sigma_x +sin(k_y)*sigma_y +B*(2+M-cos(k_x)-cos(k_y))*sigma_z

When I implement it on a square grid I obtain the following output:

# Discrete coordinates: x y

# Onsite element:
_cache_0 = (
array([[ 1.+0.j,  0.+0.j],
       [ 0.+0.j, -1.+0.j]]))
_cache_1 = (
array([[-1.+0.j,  0.+0.j],
       [ 0.+0.j,  1.+0.j]]))
_cache_2 = (
array([[-1.+0.j,  0.+0.j],
       [ 0.+0.j,  1.+0.j]]))
_cache_3 = (
array([[ 2.+0.j,  0.+0.j],
       [ 0.+0.j, -2.+0.j]]))
_cache_4 = (
array([[0.+0.j, 1.+0.j],
       [1.+0.j, 0.+0.j]]))
_cache_5 = (
array([[0.+0.j, 0.-1.j],
       [0.+1.j, 0.+0.j]]))
def onsite(site, B, M, cos, k_x, k_y, sin):
    _const_0 = (cos(k_x))
    _const_1 = (cos(k_y))
    _const_2 = (sin(k_x))
    _const_3 = (sin(k_y))
    return (B*M) * (_cache_0) + (B*_const_0) * (_cache_1) + (B*_const_1) * (_cache_2) + (B) * (_cache_3) + (_const_2) * (_cache_4) + (_const_3) * (_cache_5)

My issues are:

1. The constants are just my sines and cosines of k_x/k_y, so what happened here?
2. I think because of that it can't find the hopping terms;
3. It doesn't plot any lattice, however if I set hamiltonian = "k_x+k_y" i does plot the square lattice.

I know the hamiltonian can be linearized in k, but if possible I want to implement it as it is.

Thanks in advance.