Dear KWANT community, Recently I have used KWANT to simulate electronic transport in T-junction with the perpendicular magnetic field applied to the nanostructure. As well known, the inclusion of the orbital effects in this case (by the peierls substitution) is not easy due to appropriate gauge which should be applied for the vertical leads. So I decided to use the newest functionality of KWANT included in kwant.physics.magnetic_gauge. I started testing this function from a simple nanowire (NW) with two leads applied on both sides of NW and the magnetic field perpendicular to NW. When calling ham=sys.hamiltonian_submatrix(params=params), similarly as in documentation, everything works OK. The problem appears when I am trying to calculate transport and call the function smatrix = kwant.smatrix(sys, energy=energy, params=params). Then, an following error occurs i = syst.id_by_site[a] j = syst.id_by_site[b]# We only store *either* (i, j) *or* (j, i). If not presentKeyError: Site(kwant.lattice.Monatomic([[75.58904535685008, 0.0], [0.0, 75.58904535685008]], [0.0, 0.0], '', None), array([-1, -9])) The above exception was the direct cause of the following exception: And I don't know how is the reason of this error. Below I paste my code nw = SimpleNamespace(\ W = 10, L = 100, dx = nm2au(4), m = 0.015, B = T2au(.5), ) def make_system_transport_gauge(nw): W=nw.W L=nw.L dx=nw.dx m=nw.m B=nw.B def onsite(sitei,peierls): x,y=sitei.pos t=1.0/(2.0*nw.m*nw.dx*nw.dx) return 4*t def hopping(sitei, sitej, peierls): xi,yi=sitei.pos xj,yj=sitej.pos t=1.0/(2.0*nw.m*nw.dx*nw.dx) return -t*peierls(sitei,sitej) lat=kwant.lattice.square(dx) sys = kwant.Builder() sys[(lat(i,j) for i in range(L) for j in range(-W+1,W))]=onsite sys[lat.neighbors()] = hopping syml = kwant.TranslationalSymmetry((-dx, 0)) l_lead=kwant.Builder(syml) l_lead[(lat(0,y) for y in range(-W+1,W))]=onsite l_lead[lat.neighbors()]=hopping l_lead.substituted(peierls='peierls_llead') sys.attach_lead(l_lead) symr = kwant.TranslationalSymmetry((dx, 0)) r_lead=kwant.Builder(symr) r_lead[(lat(0,y) for y in range(-W+1,W))]=onsite r_lead[lat.neighbors()]=hopping r_lead.substituted(peierls='peierls_rlead') sys.attach_lead(r_lead) sys = sys.finalized() return sys def B_syst(pos): return nw.B sys=make_system_transport_gauge(nw) gauge = kwant.physics.magnetic_gauge(sys) peierls_sys, peierls_llead, peierls_rlead = gauge(B_syst, B_syst, B_syst) params = dict(t=1, peierls=peierls_sys, peierls_llead=peierls_llead, peierls_rlead=peierls_rlead) ham=sys.hamiltonian_submatrix(params=params) #this works #I tried to calculate transport energy=eV2au(3e-3) smatrix = kwant.smatrix(sys, energy=energy, params=params) #this generates an error I would be grateful for any help or hint what is wrong. Best regards, Pawel Wojcik