Hi Camilla,  these are good questions.  You wrote:

I was wondering if there is an easy way to define different regions with different hoppings? E.g. what I want to achieve is to make system where the hopping from one of the leads into the scattering region is different from the hopping within the lead and the scattering region. How can this be achieved?

I will first answer your general question, and then the specific one.

On a more general note, if I have two scattering regions in the system. It is easy and efficient to define different onsite energies for the two regions using shape. Is there a similarly easy way to define the hopping differently (using neighbors() within a shape)? And how are these two regions connected, does the connection have to be added “manually”?

There are several ways to do that.

(-1) Of course you can always build your system site-by-site and hopping-by-hopping and use whatever values you like. But you are asking about an “easy” way.

(0) You can always use a function as the value of your hoppings (or sites) and then let that function return the correct values. This is what we call “value functions” in Kwant jargon. But this is best used for things like adding magnetic field, and probably not what you are looking for now.

(1) I guess that not many people know that builders support the “+=” operation, i.e. it’s possible to add one builder to another one. “builder0 += builder1” adds all the sites, hoppings, and leads of builder1 to builder0. Sites and hoppings present in both systems are overwritten by those in builder1. The leads of builder1 are appended to the leads of the system being extended. Thus you can construct several parts of your system in separate builders, and then assemble them together.

(2) Another builder trick is to use their “expand()” method (check out the documentation). Whenever you can do:

syst[some_key] = …

You can also say:

syst[syst.expand(some_key)] = …

The effect will be the same, the only difference is that the call to expand() will expand “magic” keys (like what is returned by lat.neighbors(), which is actually a sequence of HopppingKind instances), into an interable of simple keys (=sites or hoppings).

Now with the second form, you can use a generator expression to filter the sites/hoppings, for example like this:

syst[(h for h in syst.expand(lat.neighbors()) if my_shape(hop[0].pos))] = …

This will set only these hoppings whose left ([0]) site is within the shape defined by the function my_shape().

But wait, you probably want to treat both the left and right sites of each hopping equally. Then we need

syst[(h for h in syst.expand(lat.neighbors()) if my_shape(h[0].pos) or my_shape(h[1].pos))] = …

Or, equivalently:

syst[(h for h in syst.expand(lat.neighbors()) if any(my_shape(s.pos) for s in h))] = …


Now let’s turn to your specific problem of how to “make a system where the hopping from one of the leads into the scattering region is different from the hopping within the lead and the scattering region”. You can use any of the above general approaches, but for this particular problem (where the region of interest is not a geometric shape but a bunch of sites), I recommend another approach:

Let’s say that you already have such a builder (called “syst”) and the lead in question is nr 0. The sites to which the lead is attached are that lead’s “interface”. The interface is available (see documentation) as “syst.leads[0].interface”. So we can do the following:

for a in syst.leads[0].interface:
   for b in syst.neighbors(a):
       syst[a, b] = new_hopping_value

****************************************************************

Note to anyone who has read this far: if you have ideas or comments about how the builder works or should work, we’re happy to discuss them on this list! The way builders work is inspired by Numpy arrays and I was wondering more than once whether we should also support the “slicing” of builders. So far I couldn’t come up with something that seems good enough, but perhaps someone has ideas?

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to