3d structure model and add 3d leads

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

Hi Yue, Take a look at the full traceback. Above you'll see the original error: "Builder does not interrupt the lead, this lead cannot be attached." In order for it to be possible to attach a lead to a system, the system must interrupt the lead cross-section. For that you need to add more sites to the system, for example by changing its shape function.

Dear Anton, Thank you very much for your advice. As I am a novice, I am not familiar enough with using kwant, so I can't correct this mistake now. I would appreciate it if you could give me an example. This will be very helpful to understand the error. Best wishes. Sincerely, Yue Xiang

Dear Yue, I think it would be useful to you if you visit Kwant frequently asked questions*. If you do so, I guess you would be able to solve your issue. Best Adel * https://kwant-project.org/doc/dev/tutorial/faq Le jeu. 28 déc. 2023 à 12:57, <araya0sun@gmail.com> a écrit :
Dear Anton,
Thank you very much for your advice. As I am a novice, I am not familiar enough with using kwant, so I can't correct this mistake now. I would appreciate it if you could give me an example. This will be very helpful to understand the error. Best wishes.
Sincerely, Yue Xiang

Dear Adel, Thank you very much for your advice, I am looking at this tutorial now, but I have a doubt. From https://kwant-project.org/doc/dev/tutorial/faq, I saw an example code: --------------------------------------------- a = 1 lat = kwant.lattice.square(a) syst = kwant.Builder() syst[lat(1, 0)] = 4 syst[lat(1, 1)] = 4 kwant.plot(syst) --------------------------------------------- And explained, In the above snippet we added 2 sites: lat(1, 0) and lat(0, 1). Both of these sites belong to the same family, lat, but have different tags: (1, 0) and (0, 1) respectively. syst[lat(1, 0)] and syst[lat(1, 1)] are written in the Code, why is site lat(1, 0) and lat(1, 1)? Sincerely, Yue Xiang

Dear Yue, Thank you. If you see the figure in the FAQ, you have a square lattice. The primitive vectors are v1=[a, 0] and v2=[0, a], so the first site is at the discretized position (i=1, j=0, along the x axis) and the second site is at (i=1, j=1, along the y axis). That is why you see them lined along the y direction. you have several choices to adopt. syst[lat(0, 0)] = 4, syst[lat(0, 1)] = 4 It depends on the way you define your system. I guess the link is very useful to you in order to become familiar with kwant. best Le jeu. 28 déc. 2023 à 14:43, <araya0sun@gmail.com> a écrit :
Dear Adel,
Thank you very much for your advice, I am looking at this tutorial now, but I have a doubt.
From https://kwant-project.org/doc/dev/tutorial/faq, I saw an example code:
a = 1 lat = kwant.lattice.square(a) syst = kwant.Builder() syst[lat(1, 0)] = 4 syst[lat(1, 1)] = 4 kwant.plot(syst) --------------------------------------------- And explained, In the above snippet we added 2 sites: lat(1, 0) and lat(0, 1). Both of these sites belong to the same family, lat, but have different tags: (1, 0) and (0, 1) respectively. syst[lat(1, 0)] and syst[lat(1, 1)] are written in the Code, why is site lat(1, 0) and lat(1, 1)?
Sincerely, Yue Xiang

Dear Adel, Ok, thank you so much for your patient answer, I will carefully read this tutorial. Sincerely, Yue Xiang
participants (3)
-
Adel Belayadi
-
Anton Akhmerov
-
araya0sun@gmail.com