The error message says it all :-) 

Using `return ((0 <= x < L) and (0 <= y < W)) ` should fix your problem.

Best, Bas

On Mon, 31 Oct 2016 at 14:29 Camilla Espedal

<
mailto:Camilla Espedal <camilla.espe...@ntnu.no>
> wrote:

a, pre, code, a:link, body { word-wrap: break-word !important; }

Hi again,

Thanks, I will try to write it more clearly. So the script I use to make the 
system is:

L = 100

W = 40

a = 1

t = 1

def make_system(W,L,a,t):

# Make the lattices

# We define two lattices (up and down) with two sublattices A and B

lat_up = kwant.lattice.general([(a,a),(a,-a)],[(0,0),(a,0)], name='up')

A_up, B_up = lat_up.sublattices

lat_down = kwant.lattice.general([(a,a),(a,-a)],[(0,0),(a,0)], name='down')

A_down, B_down = lat_down.sublattices

# Define the shape of the scattering region. Must return true where there are 
sites.

def shape_sr(pos):

x, y = pos

return ((0 < x < L) and (0 < y < W))

sys = kwant.Builder()

sys[lat_up.shape(shape_sr, (1,1))] = 2

sys[lat_down.shape(shape_sr, (1,1))] = 2

sys[A_up(1,1), A_down(2,1)] = 2

return sys

The error message I get is:

KeyError: Site(kwant.lattice.Monoatomic([[1,1], [1,-1]], [0,0]. 'up0'), 
array([1, 1]))

I can not see why the spot should not be created, because it is within the 
bounds of shapre_sr.

Thanks,

Best,

Camilla

-----Original Message-----

From: Anton Akhmerov [mailto:
mailto:anton.akhme...@gmail.com
]

Sent: 31. oktober 2016 12:04

To: Camilla Espedal <
mailto:camilla.espe...@ntnu.no
>

Cc:
mailto:kwant-discuss@kwant-project.org
Subject: Re: [Kwant] Hopping between different lattices and families

Hi Camilla,

Please double-check the error message that you see.

Your assumption why the code doesn't work is not right: it's possible to add a 
hopping from any site to any site, regardless of distance or lattices involved. 
My best guess is that the sites aren't present in the system yet.

As a general advice, when describing a problem try to provide complete 
information required to reproduce this problem. A script and the error message 
would be usually useful.

Best,

Anton

On Mon, Oct 31, 2016 at 6:58 AM, Camilla Espedal <
mailto:camilla.espe...@ntnu.no
> wrote:

> Hi again,

>

> I tried to add

>

> sys[A_up(2,2), B_down(2,2)] = 2

>

> This does not work, and I think it is because A_up and B_down are not

> only on different sublattices, but on different lattices as well. In

> the tutorial on superconductors

> (
https://kwant-project.org/doc/1.0/tutorial/tutorial5#lattice-descript
> ion-using-different-lattices) they define the hopping as

>

> sys[((lat_e(x, y), lat_h(x, y)) for x in range(Deltapos, L)

> for y in range(W))] = Delta

>

> between the lattices but on the same spatial point. But I want to hop between 
> two different lattices from one point in space to another, if that makes 
> sense.

>

> Best,

> Camilla

>

> -----Original Message-----

> From: Anton Akhmerov [mailto:
mailto:anton.akhme...@gmail.com
]

> Sent: 31. oktober 2016 11:48

> To: Camilla Espedal <
mailto:camilla.espe...@ntnu.no
>

> Cc:
mailto:kwant-discuss@kwant-project.org
> Subject: Re: [Kwant] Hopping between different lattices and families

>

> Hi Camilla,

>

> It's exactly like you would expect: syst[A_up(i, j), B_down(i, j)] =

> value. See e.g.
https://kwant-project.org/doc/1/tutorial/tutorial4
>

> Best,

> Anton

>

> On Mon, Oct 31, 2016 at 6:43 AM, Camilla Espedal <
mailto:camilla.espe...@ntnu.no
> wrote:

>> Hi,

>>

>>

>>

>> To explain what I mean. I have a system where I have separated

>> spin-up and spin-down into two lattices (like electron and hole in

>> the example at the kwant site) so that it is would be easier to

>> extract spin-resolved information (G_up/up, Gup/down etc.). In

>> addition, these two lattices consists of two sublattices (A and B).

>> The code is like this

>>

>>

>>

>> lat_up =

>> kwant.lattice.general([(1,0),(s,c)],[(0,0),(0,1/sqrt(3))],

>> name='up')

>>

>> A_up, B_up = lat_up.sublattices

>>

>> lat_down =

>> kwant.lattice.general([(1,0),(s,c)],[(0,0),(0,1/sqrt(3))],

>> name='down')

>>

>> A_down, B_down = lat_down.sublattices

>>

>>

>>

>> What I want to do now, is to add a hopping term between say A_up

>> (i,j) and B_down (i.j). So a hopping term between the two different

>> lattices and sublattices. How can I implement this? Or is there a

>> better way to achieve what I want?

>>

>>

>>

>> Best

>>

>> Camilla Espedal

Reply via email to