Hello everyone
I want to create a lead for a 3D structure, but when I run the program, I get the following error:
###No sites close to (0, 0, 14) are inside the desired shape.###
Please help me find the mistake.
Thanks in advance for your reply.
####
import kwant from matplotlib import pyplot
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)], name=['a1', 'a2']) a1, a2 = lat.sublattices
def make_cuboid(a=10, b=10, c=15): def cuboid_shape(pos): x, y, z = pos return 0 <= x < a and 0 <= y < b and 0 <= z < c
syst = kwant.Builder() syst[a1.shape(cuboid_shape, (0, 0, 0))] = 1 ## the same onsite foar a1 and b1 syst[a2.shape(cuboid_shape, (0, 0, 0))] = 1 syst[lat.neighbors()] = 1
def lead_shape(pos): x,y,z = pos return 0 <= x < a and 0 <= y < b and 14 <= z < c
lead = kwant.Builder(kwant.TranslationalSymmetry([1,0,0])) lead[lat.shape(lead_shape, (0, 0, 14))] = 1 lead[lat.neighbors()] = 1
return syst,lead
def main():
syst,lead = make_cuboid()
kwant.plot(syst)
syst = syst.finalized()
syst = make_cuboid(a=1.1, b=1.1, c=1.1)
def family_colors(site): return 'r' if site.family == a1 else 'g'
syst.attach_lead(lead)
kwant.plot(syst, site_size=0.18, site_lw=0.01, hop_lw=0.05, site_color=family_colors)
if __name__ == '__main__': main()
#####
Hi!
Please check the documentation for lattice.shape over here: https://kwantproject.org/doc/1/reference/generated/kwant.lattice.Polyatomic...
Let me know if the documentation or the error message are unclear then.
Best, Anton
On Mon, 16 Dec 2019 at 10:09, tavakkolidjawad tavakkolidjawad@ut.ac.ir wrote:
Hello everyone
I want to create a lead for a 3D structure, but when I run the program, I get the following error:
###No sites close to (0, 0, 14) are inside the desired shape.###
Please help me find the mistake.
Thanks in advance for your reply.
####
import kwant from matplotlib import pyplot
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)], name=['a1', 'a2']) a1, a2 = lat.sublattices
def make_cuboid(a=10, b=10, c=15): def cuboid_shape(pos): x, y, z = pos return 0 <= x < a and 0 <= y < b and 0 <= z < c
syst = kwant.Builder() syst[a1.shape(cuboid_shape, (0, 0, 0))] = 1 ## the same onsite foar a1 and b1 syst[a2.shape(cuboid_shape, (0, 0, 0))] = 1 syst[lat.neighbors()] = 1
def lead_shape(pos): x,y,z = pos return 0 <= x < a and 0 <= y < b and 14 <= z < c
lead = kwant.Builder(kwant.TranslationalSymmetry([1,0,0])) lead[lat.shape(lead_shape, (0, 0, 14))] = 1 lead[lat.neighbors()] = 1
return syst,lead
def main():
syst,lead = make_cuboid()
kwant.plot(syst)
syst = syst.finalized()
syst = make_cuboid(a=1.1, b=1.1, c=1.1)
def family_colors(site): return 'r' if site.family == a1 else 'g'
syst.attach_lead(lead)
kwant.plot(syst, site_size=0.18, site_lw=0.01, hop_lw=0.05, site_color=family_colors)
if __name__ == '__main__': main()
#####
On 20191216 12:42, Anton Akhmerov wrote:
Hi!
Please check the documentation for lattice.shape over here: https://kwantproject.org/doc/1/reference/generated/kwant.lattice.Polyatomic...
Let me know if the documentation or the error message are unclear then.
Best, Anton
On Mon, 16 Dec 2019 at 10:09, tavakkolidjawad tavakkolidjawad@ut.ac.ir wrote:
Hello everyone
I want to create a lead for a 3D structure, but when I run the program, I get the following error:
###No sites close to (0, 0, 14) are inside the desired shape.###
Please help me find the mistake.
Thanks in advance for your reply.
####
import kwant from matplotlib import pyplot
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)], name=['a1', 'a2']) a1, a2 = lat.sublattices
def make_cuboid(a=10, b=10, c=15): def cuboid_shape(pos): x, y, z = pos return 0 <= x < a and 0 <= y < b and 0 <= z < c
syst = kwant.Builder() syst[a1.shape(cuboid_shape, (0, 0, 0))] = 1 ## the same onsite foar a1 and b1 syst[a2.shape(cuboid_shape, (0, 0, 0))] = 1 syst[lat.neighbors()] = 1
def lead_shape(pos): x,y,z = pos return 0 <= x < a and 0 <= y < b and 14 <= z < c
lead = kwant.Builder(kwant.TranslationalSymmetry([1,0,0])) lead[lat.shape(lead_shape, (0, 0, 14))] = 1 lead[lat.neighbors()] = 1
return syst,lead
def main():
syst,lead = make_cuboid()
kwant.plot(syst)
syst = syst.finalized()
syst = make_cuboid(a=1.1, b=1.1, c=1.1)
def family_colors(site): return 'r' if site.family == a1 else 'g'
syst.attach_lead(lead)
kwant.plot(syst, site_size=0.18, site_lw=0.01, hop_lw=0.05, site_color=family_colors)
if __name__ == '__main__': main()
#####
Hi
I found out that the previous error was due to Dimension and got the following error after changing the code:
Changes:
#####
def lead_shape(pos): x,y,z = pos return 0 <= x < a and 0 <= y < b and 0 <= z < c
lead = kwant.Builder(kwant.TranslationalSymmetry((1,0,0))) lead[lat.shape(lead_shape, (0, 0, 0))] = 1 lead[lat.neighbors()] = 1
#####
Error:
#####
AttributeError: 'tuple' object has no attribute 'attach_lead'
#####
Dear Tavakkol,
Your function make_cuboid returns a tuple: sys and lead. You put syst = make_cuboid(a=1.1, b=1.1, c=1.1) ! you need to put: syst, lead= .............
Please, try to eliminate the unnecessary functions until you find the one which returns the issue. Try also to put the error message in google search engine, it may be just a simple python question. I hope this helps, Adel
On Mon, Dec 16, 2019 at 6:53 PM tavakkolidjawad tavakkolidjawad@ut.ac.ir wrote:
On 20191216 12:42, Anton Akhmerov wrote:
Hi!
Please check the documentation for lattice.shape over here:
https://kwantproject.org/doc/1/reference/generated/kwant.lattice.Polyatomic...
Let me know if the documentation or the error message are unclear then.
Best, Anton
On Mon, 16 Dec 2019 at 10:09, tavakkolidjawad tavakkolidjawad@ut.ac.ir wrote:
Hello everyone
I want to create a lead for a 3D structure, but when I run the program, I get the following error:
###No sites close to (0, 0, 14) are inside the desired shape.###
Please help me find the mistake.
Thanks in advance for your reply.
####
import kwant from matplotlib import pyplot
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)], name=['a1', 'a2']) a1, a2 = lat.sublattices
def make_cuboid(a=10, b=10, c=15): def cuboid_shape(pos): x, y, z = pos return 0 <= x < a and 0 <= y < b and 0 <= z < c
syst = kwant.Builder() syst[a1.shape(cuboid_shape, (0, 0, 0))] = 1 ## the same onsite foar a1 and b1 syst[a2.shape(cuboid_shape, (0, 0, 0))] = 1 syst[lat.neighbors()] = 1
def lead_shape(pos): x,y,z = pos return 0 <= x < a and 0 <= y < b and 14 <= z < c
lead = kwant.Builder(kwant.TranslationalSymmetry([1,0,0])) lead[lat.shape(lead_shape, (0, 0, 14))] = 1 lead[lat.neighbors()] = 1
return syst,lead
def main():
syst,lead = make_cuboid()
kwant.plot(syst)
syst = syst.finalized()
syst = make_cuboid(a=1.1, b=1.1, c=1.1)
def family_colors(site): return 'r' if site.family == a1 else 'g'
syst.attach_lead(lead)
kwant.plot(syst, site_size=0.18, site_lw=0.01, hop_lw=0.05, site_color=family_colors)
if __name__ == '__main__': main()
#####
Hi
I found out that the previous error was due to Dimension and got the following error after changing the code:
Changes:
#####
def lead_shape(pos): x,y,z = pos return 0 <= x < a and 0 <= y < b and 0 <= z < c
lead = kwant.Builder(kwant.TranslationalSymmetry((1,0,0))) lead[lat.shape(lead_shape, (0, 0, 0))] = 1 lead[lat.neighbors()] = 1
#####
Error:
#####
AttributeError: 'tuple' object has no attribute 'attach_lead'
#####
participants (3)

Abbout Adel

Anton Akhmerov

tavakkolidjawad