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