Dear kwant users,
Hello, I am a new user of kwant, I want to build a 3d structure model, and add
leads, I refer to a similar code, but I keep getting errors during the process,
the program says "RuntimeError: All sites of this builder have been deleted
because an exception occurred during the execution of fill(): see above. ", I
feel that it may be the position of the lead, but I do not know how to modify
it, can you give me some suggestions to modify it? Thank you very much!
*This is the code I have errors in:
----------------------------------------
import kwant
import numpy as np
from matplotlib import pyplot
#3d test
def syst_3d(a=16, b=16, c=10,t=1):
lat = kwant.lattice.general([(0, 0.5, 0.5), (0.5, 0, 0.5), (0.5, 0.5, 0)])
# [(0,0,0),(0.25, 0.25, 0.25)])
# a,b= lat.sublattices
syst = kwant.Builder()
def cuboid_shape(pos):
x, y, z = pos
return 0 <= x < a and 0 <= y < b and 0 <= z < c
syst[lat.shape(cuboid_shape, (0, 0, 0))] = 4 * t
syst[lat.neighbors()] = -t
sym_lead0 = kwant.TranslationalSymmetry(lat.vec((1, 0, 0)))
lead0 = kwant.Builder(sym_lead0)
lead_shape = lambda pos: (-b / 2 <= pos[1] < b / 2) and abs(pos[2]) < c
lead0[lat.shape(lead_shape, (-1, 0, 0))] = 4 * t
lead0[lat.neighbors()] = -t
lead1 = lead0.reversed()
syst.attach_lead(lead0)
syst.attach_lead(lead1)
return syst
def main():
syst = syst_3d()
kwant.plot(syst)
if __name__ == '__main__':
main()
---------------------------------------------------
*This is the code I refer to, as if this works correctly:
-------------------------------------------------------
import kwant
import numpy as np
from matplotlib import pyplot
def syst_3d(W=3, r1=2, r2=4, a=1, t=1.0):
lat = kwant.lattice.general(((a, 0, 0), (0, a, 0), (0, 0, a)))
syst = kwant.Builder()
def ring(pos):
(x, y, z) = pos
rsq = x**2 + y**2
return (r1**2 < rsq < r2**2) and abs(z) < 2
syst[lat.shape(ring, (0, -r2 + 1, 0))] = 4 * t
syst[lat.neighbors()] = -t
sym_lead0 = kwant.TranslationalSymmetry(lat.vec((-1, 0, 0)))
lead0 = kwant.Builder(sym_lead0)
lead_shape = lambda pos: (-W / 2 < pos[1] < W / 2) and abs(pos[2]) < 2
lead0[lat.shape(lead_shape, (0, 0, 0))] = 4 * t
lead0[lat.neighbors()] = -t
lead1 = lead0.reversed()
syst.attach_lead(lead0)
syst.attach_lead(lead1)
return syst
def main():
syst = syst_3d()
kwant.plot(syst)
if __name__ == '__main__':
main()
Sincerely,
Yue Xiang