Dear Michael,

  That works, thanks! I didn't know you can get around by creating a new SiteFamily :)... Had some problems with the 1.0.0 version but solved it after updating to 1.0.1. 

Best
Yuanxi


2014-07-23 4:43 GMT-04:00 Michael Wimmer <wimmer@lorentz.leidenuniv.nl>:
Dear Yuanxi,

the way that attaching the leads works in kwant requires that the
scattering region contains the same lattice as the leads. However, you
can still easily achieve what you want: You only have to add a thin
slice of lead lattice to the scattering region, this will also allow you
to define all the irregular hoppings from the lead lattice to the
scattering region. Then you can use attach_lead to add the lead to the
system.

Adding a thin slice of lead lattice to the scattering region only
creates a negligible computational overhead, and gives the same physical
result (as what is "scattering region" and what is "lead" is mostly a
matter of definition).

I have included below a small proof-of-principle example that shows how
to do it. (Remark: of course, for a real application the main challenges
are how to organize which hoppings one should take into account, and
which values to give them ... )

Best,

Michael

--------------------------------------------

import kwant
import matplotlib.pyplot

# this is an example how one could handle an amorphous system,
# namely by defining a corresponding new SiteFamily
class Amorphous(kwant.builder.SiteFamily):
    def __init__(self, coords):
        self.coords = coords
        super(Amorphous, self).__init__("amorphous", "")
        # remark: in a production code one should choose a
        #         meaningful and unique represenation name

    def normalize_tag(self, tag):
        try:
            tag = int(tag[0])
        except:
            raise KeyError

        if 0 <= tag < len(coords):
            return tag
        else:
            raise KeyError

    def pos(self, tag):
        return self.coords[tag]


coords = [(1, 0), (1.1, 1.2), (1.7, 0.9), (2.1, 0.2)]
amorphous_lat = Amorphous(coords)
regular_lat = kwant.lattice.square()

sys = kwant.Builder()

# first add some irregular scattering region
for i in xrange(4):
    sys[amorphous_lat(i)] = None
for i in xrange(3):
    sys[amorphous_lat(i), amorphous_lat(i+1)] = None
sys[amorphous_lat(3), amorphous_lat(0)] = None

# now we add the first slice of the lead to the scattering region
for i in xrange(2):
    sys[regular_lat(0, i)] = None
sys[regular_lat.neighbors()] = None

# now we add (by hand) the hopping to the amourphous material
sys[amorphous_lat(0), regular_lat(0, 0)] = None
sys[amorphous_lat(1), regular_lat(0, 1)] = None

# finally we make a regular lead and attach it
lead = kwant.Builder(kwant.TranslationalSymmetry((-1, 0)))
for i in xrange(2):
    lead[regular_lat(0, i)] = None
lead[regular_lat.neighbors()] = None
sys.attach_lead(lead)

def color(site):
    if site.family == amorphous_lat:
        return "orange"
    else:
        return "black"

kwant.plot(sys, site_color=color)

-------------------------------------------------

On 22.07.2014 07:35, Yuanxi Wang wrote:
> Dear all,
>
>   I'd like to know if it is possible to construct/attach leads with
> lattices different from the main scattering region, or even leads with
> custom geometry unrelated to the scattering region?
>
> For example if my scattering region is an amorphous cluster whose
> geometry have defined by hand, and I want to build leads using their own
> lattice to the left and right. Is that allowed in KWANT?
>
>   (Of course in that case one would need define bonds/hoppings between
> and within the leads, and also from the lead to the main scattering
> region... but how..)
>
> Thanks
> Yuanxi
>
> --
> Yuanxi Wang,
> Pennsylvania State University
> Department of Physics
> 104 Davey Lab #117,
> University Park, PA 16802



--
Yuanxi Wang, 
Pennsylvania State University 
Department of Physics 
104 Davey Lab #117, 
University Park, PA 16802