
Dear Diego, short answer is: No, kwant does not repack the sites after finalization - the coordinates of the sites stay where they were put in the beginning. To be honest, I don't fully understand now in which situations you see the dependence on p.mu_inside. But the problem can only be either in the system itself or in the leads. Let me give some examples on how to figure out where is the culprit: Check the onsite Hamiltonian of the system itself -------------------------------------------------- In addition to plotting the system geometry, one can also plot any function defined on the system, and correspondingly also the onsite Hamiltonian elements. In your example, the easiest is to do this after finalization using kwant.plotter.map: vals = [sys.hamiltonian(i, i, params)[0, 0] for i in xrange(sys.graph.num_nodes)] kwant.plotter.map(sys, vals) (Note: this is for interacitve use, hence after removing the backend "pdf" from the beginning of your file) This plots the 0, 0 entry of your onsite matrix, and of course you can easily plot any entry you like. Using this plot you can see if you changed the onsite Hamiltonian somewhere in your system. As a side note, it is also possible to do this before finalization using kwant.plot: kwant.plot(sys, site_color=lambda site: sys[site](site, params)[0,0], site_symbol="s", site_size=0.5, cmap="jet") This just looks a bit more involved: with sys[site] you get the value at site, which in this case is a function (hence the function call afterwards) that returns a matrix (hence the [...]). Checking the leads ------------------- There is indeed one additional issue with your original code as noted by Joseph: You use the onsite-function also in the lead. Now, the lead has translational invariance, and it is required (but not checked right now by kwant) that in this case also the onsite-function must have translational invariance along the lead. The tricky thing here is that when we say translational invariance, this means not just going outwards in the lead: The lead is originally considered as infinite to both sides, and the Hamiltonian matrix elements must reflect this translational symmetry to both + and -infinity. In practice this means that kwant takes some unit cell (with coordinates usually close to the origin of the coordinate system), and then repeats it to infinity. Now in your situation, this probably meant that the lead unit cell was affected by p.mu_inside. In your case this should be solved by simply assigning a constant value directly to the lead onsite values (instead of a function). However, you said this didn't solve your problem, so maybe there's something else. To check the leads, it is right now not easily possible to plot the onsite values as for the system. Instead, I advise you to check the resulting band structure of the leads using kwant.plotter.bands - if you see a difference in the band structures, you know you changed something in the leads. Best, Michael On 25.03.2014 00:35, diego wrote:
Elaborating on that:
If one tries the same hamiltonian modification for different regions, one notices that:
1) for the inner square regions of the type
if abs(x) < a and abs(y) < a:
there is always an effect on the system, for any value of a, down to a=0.
2) Instead, surprisingly, if one makes modifications in the "outer" regions:
if abs(x) > b and abs(y) > b:
then there is no change in the system if b is BELOW r2, but above a certain threshold, in my system being b* = (r2-6).
3) Further, if instead one makes the changes in regions outside a circular domain,
if x**2 + y**2 > (r2-2)**2:
then THERE IS a modification to the system conductance.
All this leads one to think that, maybe after the system finalization, the annulus sites have in fact been reshuffled and "packed" into a more convenient rectangular (square) shape, whose dimensions are determined by the total amount of sites. Here the annulus area is pi*(r2^2-r1^2) ~ 950 sites, if one wants to pack them in a square, this gives a square side of 31, not far from my empirical estimate 2b*= 2(r2-6) = 28... (and the circle of radius (r2-2) tried above indeed crosses that square)
Is it possible?
On 24/3/14 11:47 PM, Joseph Weston wrote:
Hi,
Seems to me that in your onsite function::
def mu(site, p): (x, y) = site.pos if abs(x) < r1 and abs(y) < r1: return p.mu_inside # this is the critical line: changing mu values inside the ring should not change the ring conductance else: return p.mu_ring
the condition ``abs(x) < r1 and abs(y) < r1`` actually describes a *square* centred on (0, 0) with sides of length ``2 * r1``, and **not** a circle centred on (0, 0) with radius ``r1``. There are thus some sites at the corners which are included in this square, the onsites of which are affected when you change the value of ``mu_inside``. Changing the onsite function to the following should fix your problem::
def mu(site, p): (x, y) = site.pos if x**2 + y**2 < r1**2: return p.mu_inside # this is the critical line: changing mu values inside the ring should not change the ring conductance else: return p.mu_ring
Regards,
Joe
P.S. I have not tested the above code. You may need to change your shape function to::
def ring(pos): (x, y) = pos rsq = x ** 2 + y ** 2 return (r1 ** 2 <= rsq < r2 ** 2) # changed `<` to `<=`
to avoid some possible annoying edge case