Dear Developers, Could you help with defining the hopping in the lead, please. My problem is that in the non-finalized system, sites() contains only one copy on the lead unit cell and I fail to write a correct hopping that would make the lead connected. Here's an example of the hopping function that works for finite system but results in disconnected system for the lead. def crit(site1,site2): diff = site1.pos-site2.pos pr=np.dot(diff,symvecty) diff1= diff - symvecty*(int(pr/np.dot(symvecty,symvecty)+0.001+1000)-1000) [x,y,z] = diff1 if 0.9<abs(z)<1.1 and abs(y)<0.1 and abs(x)<0.1: return True else: return False def connect(sys,crit): result=[] for site1 in sys.sites(): for site2 in sys.sites(): if crit(site1,site2): result.append((site1,site2)) return iter(result) lead[connect(lead,crit)] = tz Best wishes, Sergey
Hi,
Dear Developers, Could you help with defining the hopping in the lead, please. My problem is that in the non-finalized system, sites() contains only one copy on the lead unit cell and I fail to write a correct hopping that would make the lead connected.
Yes, because the Builder that you use with the lead has a TranslationalSymmetry, whenever you add sites to the Builder they are first translated to the fundamental domain of the symmetry and *then* actually added. What you can do is to first do as you currently do - connect all sites in a single lead cell - and then connect all sites in a lead cell to all the sites in the neighboring cell. You can do this by using the `act` method of the TranslationalSymmetry to apply an element of the symmetry group to the sites. # import useful modules import functools as ft import itertools as it import kwant # for the sake of argument take this symmetry, but you # should use yours, obviously! T = kwant.TranslationalSymmetry((-1, 0)) # make the lead with your symmetry and fill it with sites # but no hoppings yet! lead = make_lead(T) # g will be the group element that we will act with def connect(sys, crit, g): for site1, site2 in it.prod(sys.sites(), repeat=2): site2 = g(site2) # act with the symmetry if crit(site1, site2): yield (site1, site2) # create identity element of symmetry group and use it id = ft.partial(T.act, 0) lead[connect(lead, crit, id)] = tz # create element of symmetry group which translates 1 # unit cell in the direction of the symmetry (-x direction # in this example left = ft.partial(T.act, 1) lead[connect(lead, crit, left)] = tz Note that I have shortened your "connect" function and turned it into a generator (note the `yield`) instead of having it return a list, but the important change in the logic is that the second site is acted on by the symmetry group element, which we pass in as an extra argument. For reference the docs of the TranslationalSymmetry: kwant-project.org/doc/1.0/reference/generated/kwant.lattice.TranslationalSymmetry this is quite advanced Kwant usage, though! Hope that helps, if there's anything not clear (the code uses quite terse idioms!) just write again, Joe
Thank you, Joe! For others to understand, your answer was: "define hopping not only for the sites that are present, but also between the present and shifted by lead symmetry sites." Your example code had some misprints: it.prod -> it.product and acting on zero was incorrect: (ValueError: Expecting a 1-tuple group element, but got `0` instead.) Unfortunately, I could not find the documentation for "act" function. How should I correct your id = ft.partial(T.act, 0) function? Best wishes, Sergey On 30/07/15 18:44, Joseph Weston wrote:
Hi,
Dear Developers, Could you help with defining the hopping in the lead, please. My problem is that in the non-finalized system, sites() contains only one copy on the lead unit cell and I fail to write a correct hopping that would make the lead connected. Yes, because the Builder that you use with the lead has a TranslationalSymmetry, whenever you add sites to the Builder they are first translated to the fundamental domain of the symmetry and *then* actually added.
What you can do is to first do as you currently do - connect all sites in a single lead cell - and then connect all sites in a lead cell to all the sites in the neighboring cell. You can do this by using the `act` method of the TranslationalSymmetry to apply an element of the symmetry group to the sites.
# import useful modules import functools as ft import itertools as it import kwant
# for the sake of argument take this symmetry, but you # should use yours, obviously! T = kwant.TranslationalSymmetry((-1, 0))
# make the lead with your symmetry and fill it with sites # but no hoppings yet! lead = make_lead(T)
# g will be the group element that we will act with def connect(sys, crit, g): for site1, site2 in it.prod(sys.sites(), repeat=2): site2 = g(site2) # act with the symmetry if crit(site1, site2): yield (site1, site2)
# create identity element of symmetry group and use it id = ft.partial(T.act, 0) lead[connect(lead, crit, id)] = tz
# create element of symmetry group which translates 1 # unit cell in the direction of the symmetry (-x direction # in this example left = ft.partial(T.act, 1) lead[connect(lead, crit, left)] = tz
Note that I have shortened your "connect" function and turned it into a generator (note the `yield`) instead of having it return a list, but the important change in the logic is that the second site is acted on by the symmetry group element, which we pass in as an extra argument.
For reference the docs of the TranslationalSymmetry:
kwant-project.org/doc/1.0/reference/generated/kwant.lattice.TranslationalSymmetry
this is quite advanced Kwant usage, though!
Hope that helps, if there's anything not clear (the code uses quite terse idioms!) just write again,
Joe
Dear Sergey, I don't know exactly how complicated your hoppings are. If you have a regular lattice, then it is much easier to add hoppings in the usual way with kwant.HoppingKind (most of the examples in the tutorial do it like that). This takes also automatically care of the translational symmetry. Or do you need to do anything more complicated? Best, Michael On 31-07-15 10:34, Sergey wrote:
Thank you, Joe! For others to understand, your answer was: "define hopping not only for the sites that are present, but also between the present and shifted by lead symmetry sites." Your example code had some misprints: it.prod -> it.product and acting on zero was incorrect: (ValueError: Expecting a 1-tuple group element, but got `0` instead.)
Unfortunately, I could not find the documentation for "act" function. How should I correct your
id = ft.partial(T.act, 0)
function?
Best wishes, Sergey
On 30/07/15 18:44, Joseph Weston wrote:
Hi,
Dear Developers, Could you help with defining the hopping in the lead, please. My problem is that in the non-finalized system, sites() contains only one copy on the lead unit cell and I fail to write a correct hopping that would make the lead connected. Yes, because the Builder that you use with the lead has a TranslationalSymmetry, whenever you add sites to the Builder they are first translated to the fundamental domain of the symmetry and *then* actually added.
What you can do is to first do as you currently do - connect all sites in a single lead cell - and then connect all sites in a lead cell to all the sites in the neighboring cell. You can do this by using the `act` method of the TranslationalSymmetry to apply an element of the symmetry group to the sites.
# import useful modules import functools as ft import itertools as it import kwant
# for the sake of argument take this symmetry, but you # should use yours, obviously! T = kwant.TranslationalSymmetry((-1, 0))
# make the lead with your symmetry and fill it with sites # but no hoppings yet! lead = make_lead(T)
# g will be the group element that we will act with def connect(sys, crit, g): for site1, site2 in it.prod(sys.sites(), repeat=2): site2 = g(site2) # act with the symmetry if crit(site1, site2): yield (site1, site2)
# create identity element of symmetry group and use it id = ft.partial(T.act, 0) lead[connect(lead, crit, id)] = tz
# create element of symmetry group which translates 1 # unit cell in the direction of the symmetry (-x direction # in this example left = ft.partial(T.act, 1) lead[connect(lead, crit, left)] = tz
Note that I have shortened your "connect" function and turned it into a generator (note the `yield`) instead of having it return a list, but the important change in the logic is that the second site is acted on by the symmetry group element, which we pass in as an extra argument.
For reference the docs of the TranslationalSymmetry:
kwant-project.org/doc/1.0/reference/generated/kwant.lattice.TranslationalSymmetry
this is quite advanced Kwant usage, though!
Hope that helps, if there's anything not clear (the code uses quite terse idioms!) just write again,
Joe
Dear Michael, At least a part of my problem could be solved with HoppingKind , but my "crit" and "connect" interface seems a bit more intuitive for me: no tags, no families, just coordinates. As I understand, it was proposed that "connect" will be added in future kwant versions. Best wishes, Sergey On 31/07/15 09:43, Michael Wimmer wrote:
Dear Sergey,
I don't know exactly how complicated your hoppings are. If you have a regular lattice, then it is much easier to add hoppings in the usual way with kwant.HoppingKind (most of the examples in the tutorial do it like that). This takes also automatically care of the translational symmetry.
Or do you need to do anything more complicated?
Best,
Michael
On 31-07-15 10:34, Sergey wrote:
Thank you, Joe! For others to understand, your answer was: "define hopping not only for the sites that are present, but also between the present and shifted by lead symmetry sites." Your example code had some misprints: it.prod -> it.product and acting on zero was incorrect: (ValueError: Expecting a 1-tuple group element, but got `0` instead.)
Unfortunately, I could not find the documentation for "act" function. How should I correct your
id = ft.partial(T.act, 0)
function?
Best wishes, Sergey
On 30/07/15 18:44, Joseph Weston wrote:
Hi,
Dear Developers, Could you help with defining the hopping in the lead, please. My problem is that in the non-finalized system, sites() contains only one copy on the lead unit cell and I fail to write a correct hopping that would make the lead connected. Yes, because the Builder that you use with the lead has a TranslationalSymmetry, whenever you add sites to the Builder they are first translated to the fundamental domain of the symmetry and *then* actually added.
What you can do is to first do as you currently do - connect all sites in a single lead cell - and then connect all sites in a lead cell to all the sites in the neighboring cell. You can do this by using the `act` method of the TranslationalSymmetry to apply an element of the symmetry group to the sites.
# import useful modules import functools as ft import itertools as it import kwant
# for the sake of argument take this symmetry, but you # should use yours, obviously! T = kwant.TranslationalSymmetry((-1, 0))
# make the lead with your symmetry and fill it with sites # but no hoppings yet! lead = make_lead(T)
# g will be the group element that we will act with def connect(sys, crit, g): for site1, site2 in it.prod(sys.sites(), repeat=2): site2 = g(site2) # act with the symmetry if crit(site1, site2): yield (site1, site2)
# create identity element of symmetry group and use it id = ft.partial(T.act, 0) lead[connect(lead, crit, id)] = tz
# create element of symmetry group which translates 1 # unit cell in the direction of the symmetry (-x direction # in this example left = ft.partial(T.act, 1) lead[connect(lead, crit, left)] = tz
Note that I have shortened your "connect" function and turned it into a generator (note the `yield`) instead of having it return a list, but the important change in the logic is that the second site is acted on by the symmetry group element, which we pass in as an extra argument.
For reference the docs of the TranslationalSymmetry:
kwant-project.org/doc/1.0/reference/generated/kwant.lattice.TranslationalSymmetry
this is quite advanced Kwant usage, though!
Hope that helps, if there's anything not clear (the code uses quite terse idioms!) just write again,
Joe
Hi,
Thank you, Joe! For others to understand, your answer was: "define hopping not only for the sites that are present, but also between the present and shifted by lead symmetry sites."
Yes, that's correct.
Your example code had some misprints: it.prod -> it.product and acting on zero was incorrect: (ValueError: Expecting a 1-tuple group element, but got `0` instead.)
Unfortunately, I could not find the documentation for "act" function. How should I correct your
id = ft.partial(T.act, 0)
function?
Yeah, sorry about the misprints. I've realized now that the "act" method is not actually documented. The symmetry actually expects a *sequence* as its first argument. In our case of a 1-parameter group the sequence only needs *one* element (but it still needs to be a sequence!). The reason it is this way is because Kwant may want to support N-parameter groups in the future (e.g. 2D translational symmetries). So we need to change id = ft.partial(T.act, 0) to id = ft.partial(T.act, [0]) `TranslationalSymmetry.act` is a method which expects 2 arguments. The first argument is a sequence which is a representation of the element of the symmetry group with which to act. The second argument is a site to which to apply the group element. In the above code snippet I bind `[0]` to the first parameter of `act`. The function which I get back, `id`, then can take a site as an argument and will apply the group element to it. I will add some better documentation to the `act` method when I get a moment over the weekend. Thanks, Joe
Dear Joe, I guess it should be [1] instead of [0] in your correction. We need not Id , but a unit shift. By the way, I am modelling the system with 3 symmetry vectors and do that by hand, moving all the k-phase to the hopping between edges. Best wishes, Sergey On 31/07/15 09:47, Joseph Weston wrote:
Hi,
Thank you, Joe! For others to understand, your answer was: "define hopping not only for the sites that are present, but also between the present and shifted by lead symmetry sites." Yes, that's correct.
Your example code had some misprints: it.prod -> it.product and acting on zero was incorrect: (ValueError: Expecting a 1-tuple group element, but got `0` instead.)
Unfortunately, I could not find the documentation for "act" function. How should I correct your
id = ft.partial(T.act, 0)
function?
Yeah, sorry about the misprints. I've realized now that the "act" method is not actually documented. The symmetry actually expects a *sequence* as its first argument. In our case of a 1-parameter group the sequence only needs *one* element (but it still needs to be a sequence!). The reason it is this way is because Kwant may want to support N-parameter groups in the future (e.g. 2D translational symmetries).
So we need to change
id = ft.partial(T.act, 0)
to
id = ft.partial(T.act, [0])
`TranslationalSymmetry.act` is a method which expects 2 arguments. The first argument is a sequence which is a representation of the element of the symmetry group with which to act. The second argument is a site to which to apply the group element.
In the above code snippet I bind `[0]` to the first parameter of `act`. The function which I get back, `id`, then can take a site as an argument and will apply the group element to it.
I will add some better documentation to the `act` method when I get a moment over the weekend.
Thanks,
Joe
Hi,
Dear Joe, I guess it should be [1] instead of [0] in your correction. We need not Id , but a unit shift.
Well you first need to add all hoppings in a unit cell so we need to the identity group element, [0], and then we want hoppings from one unit cell to the next, so the group element [1]. In the example I posted a few mails back we had one then the other.
By the way, I am modelling the system with 3 symmetry vectors and do that by hand, moving all the k-phase to the hopping between edges. Best wishes, Sergey
Ah nice, you can then obtain 3D band structure by diagonalizing the finite problem with different k values yes? Joe
Hi Joe, You are right, I have not noticed that. I rewritten it myself with "connect" doing both "id" and "T" things in one call (thus, there is no need to apply id ). Yes, I am scanning over analytic kx, ky momenta and use kwant's automatic symmetry along z to find evanescent modes in the lead. Degeneracy of evanescent modes will mean the possibility of edge states. Best wishes, Sergey On 31/07/15 15:11, Joseph Weston wrote:
Hi,
Dear Joe, I guess it should be [1] instead of [0] in your correction. We need not Id , but a unit shift. Well you first need to add all hoppings in a unit cell so we need to the identity group element, [0], and then we want hoppings from one unit cell to the next, so the group element [1]. In the example I posted a few mails back we had one then the other.
By the way, I am modelling the system with 3 symmetry vectors and do that by hand, moving all the k-phase to the hopping between edges. Best wishes, Sergey
Ah nice, you can then obtain 3D band structure by diagonalizing the finite problem with different k values yes?
Joe
participants (3)
-
Joseph Weston
-
Michael Wimmer
-
Sergey