Dear kwant community:

I have encountered this error in my code.  Basically I don't want to redefine 
the hop in the y direction, so I use the existing function `hop`. However, the 
code throw me an error which I don't know how to fix.  Below is a simplest code 
example, the real situation is more complex but the spirit is the same.

```
lat = kwant.lattice.square()

def make_system(r=10, t=1):

    def circle(pos):
        x, y = pos
        return x**2+y**2<r**2

    syst = kwant.Builder()

    def onsite(site):
        return 0
    
    syst[lat.shape(circle, (0, 0))] = onsite

    def hop(site1, site2, some_param):
        # some complex calculations not shown.
        return t

    def modified_hop(alpha, hop):
        # I don't want to define a hopy function, just use the exist hop
        return lambda *a, **kw: alpha*hop(*a, **kw)

    alpha = 0.5
    syst[kwant.builder.HoppingKind(lat.prim_vecs[0], lat, lat)] = hop
    syst[kwant.builder.HoppingKind(lat.prim_vecs[1], lat, lat)] = 
modified_hop(alpha, hop)  # alpha*hop would be very nice, but it won't work!
    syst.eradicate_dangling()
    
    return syst

syst = make_system()
fsyst = syst.finalized()

H = fsyst.hamiltonian_submatrix(params=dict(some_param=1))
```

Best, 
   Wilson

Reply via email to