Dear all,

thanks in advance for the support.

As I already had occasion to explain to Xavier, my problem concerns a ring geometry where changing Hamiltonian values on non-existing sites inside the ring (r<r1) actually changes the conductance behavior, while it should not.

More precisely, I am building a ring, assigning to the ring sites a certain value given by the onsite function, which however in its definition contains a conditional if-instruction involving sites inside the ring.
I was expecting that the if-condition is then never satisfied and thus no change is made, but the conductance curve changes if I change the values of, say, the chemical potential (on-site energy) inside the ring, where no sites exist.

However, If I do the same changes outside the ring (r>r2), no change occurs in the conductance, as it should.

Of course one hypothesis is that I am in fact changing also Hamiltonian elements of the ring, but I don't see why.
As suggested by Xavier, I will try to check that by using plotter.

I attach the piece of code.
I put a comment on the line where I write the conditional instruction for mu.
If you try to run the code for different values of mu_inside, and/or different physical sub-regions inside the ring, you should see different conductance behavior.

I am using python 2.7.5 on a Mac OS X 10.6.8 and the same holds true for a Mac OS X 10.8.5.

Thanks a lot in advance for any hint on how to understand this misbehavior.
Diego



==============================================================================
import kwant
import scipy, scipy.io
from numpy import *
from pylab import *
import sys
from numpy import mod
from math import pi,atan2
import matplotlib as mpl
from matplotlib import pyplot
import random; import pickle

params = {'backend': 'pdf',
          'ytick.direction': 'out',
          'text.usetex': True,
          'font.size':16}
rcParams.update(params)
matplotlib.rcParams.update({'font.size': 20})
im=0+1j

import tinyarray
import scipy.sparse.linalg


class SimpleNamespace(object):
    """A simple container for parameters."""
    def __init__(self, **kwargs):
        self.__dict__.update(kwargs)
       
s_0 = identity(2)
s_z = array([[1, 0], [0, -1]])
s_x = array([[0, 1], [1, 0]])
s_y = array([[0, -1j], [1j, 0]])

#=================================================================================

def make_system(a=1, W=10, r1=10, r2=20):

    lat = kwant.lattice.square(a)
    sys = kwant.Builder()

    def ring(pos):
        (x, y) = pos
        rsq = x ** 2 + y ** 2
        return (r1 ** 2 < rsq < r2 ** 2)

    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

    def onsite(site, p):
        return ( 4.0 * p.t - mu(site, p)) * s_0
   
    def hopping(site0, site1, p):
        return -p.t * s_0
   
#   ===============================================================================

    sys[lat.shape(ring, (0, r1 + 1))] = onsite
    sys[lat.neighbors()] = hopping
   
# ===================================================================================

    sym_lead = kwant.TranslationalSymmetry((-a, 0))
    lead = kwant.Builder(sym_lead)
   
    def lead_shape(pos):
        (x, y) = pos
        return (-W / 2 < y < W / 2)

    lead[lat.shape(lead_shape, (0, 0))] = onsite
    lead[lat.neighbors()]               = hopping

    sys.attach_lead(lead)
    sys.attach_lead(lead.reversed())

    return sys


def plot_conductance(sys, energies, p):
    data = []
    for energy in energies:
        smatrix = kwant.smatrix(sys, energy, args=[p])
        data.append(smatrix.transmission(1, 0))
   
    axes([0.12, 0.12, 0.8, 0.8])
    hold(True)
    pyplot.plot(energies, data, 'bo-', ms=2.8, linewidth=0.5,markeredgewidth=0.03)
    pyplot.axis([0, 3.0, 0, 10.1])  
    pyplot.xlabel(r'$eV[t]$')
    pyplot.ylabel(r'$G[e^2/h]$')
    savefig('Ring_G(e).pdf')
   
   

def main():
    sys = make_system()
    kwant.plot(sys)
    sys = sys.finalized()
    params = SimpleNamespace(t=1.0, mu_ring=0.0, mu_inside=-1.62)
    pyplot.figure()
    plot_conductance(sys, energies=[0.01 * i for i in xrange(300)], p=params)

if __name__ == '__main__':
    main()
==================================================================================