[Kwant] Using args in hamiltonian-function

2017-03-27 Thread Camilla Espedal
Dear Kwant team,


(am using the development version, 1.3)


I am trying to plot the potential of my system and I want to use the 
hamiltonian(ind,ind,*args) function, but I don't understand how to use the 
args. Normally, I would give a vector with the values of the args as input, but 
this doesn't work in the case of hamiltonian (it does with 
hamiltonian_submatrix). What am I doing wrong?


I also have a problem using the kwant.plot(sys) after I switched to Linux, I 
get the error message "NameError: name 'mplot3d' is not defined", is there 
something I need to install?


Sincerely,
Camilla


Re: [Kwant] Regarding smatrix and spin

2017-02-14 Thread Camilla Espedal
Dear Anton,

sorry for troubling you again.

so I finally got hold of a linux-computer, and managed to run the commands and 
install all the things in the notebook. When I try to run the code you have in 
your notebook however, I get the following error message:

  File "/home/camilla/.local/lib/python3.5/site-packages/kwant/builder.py", 
line 1371, in attach_lead
self.leads.append(BuilderLead(lead_builder, tuple(interface)))
  File "/home/camilla/.local/lib/python3.5/site-packages/kwant/builder.py", 
line 565, in __init__
self.interface = tuple(sorted(interface))
TypeError: unorderable types: tinyarray.ndarray_int() < tinyarray.ndarray_int()

Do you know what the problem could be?

Best,

Camilla

The code if needed:

import kwant
import tinyarray as ta
import numpy as np
from scipy import sparse
from matplotlib import pyplot
import matplotlib

s0 = ta.array([[1, 0], [0, 1]])
sx = ta.array([[0, 1], [1, 0]])
sy = ta.array([[0, 1j], [-1j, 0]])
sz = ta.array([[1, 0], [0, -1]])



# Adapted from https://kwant-project.org/doc/1/tutorial/tutorial2

def make_system(t=1.0, W=10, L=10):
# Now we must specify the number of orbitals per site.
lat = kwant.lattice.square(norbs=2)
syst = kwant.Builder()

syst[(lat(x, y) for x in range(L) for y in range(W))] = \
lambda s, alpha, E_z: 4 * t * s0 + E_z * sz
syst[kwant.builder.HoppingKind((1, 0), lat, lat)] = \
lambda s1, s2, alpha, E_z: -t * s0 - 1j * alpha * sy
syst[kwant.builder.HoppingKind((0, 1), lat, lat)] = \
lambda s1, s2, alpha, E_z: -t * s0 + 1j * alpha * sx

# The new bit: specifying the conservation law.
lead = kwant.Builder(kwant.TranslationalSymmetry((-1, 0)),
 conservation_law=-sz, time_reversal=s0)
lead[(lat(0, j) for j in range(W))] = 4 * t * s0
lead[lat.neighbors()] = -t * s0 # Note: no spin-orbit in the lead.

syst.attach_lead(lead)
syst.attach_lead(lead.reversed())

syst = syst.finalized()


return syst

syst = make_system(t=1.0, W=10, L=10)
energies = np.linspace(0, 1, 200)
smatrices = [kwant.smatrix(syst, energy, args=(0.2, 0.05)) for energy in 
energies]

fig = pyplot.figure(figsize=(13, 8))
ax = fig.add_subplot(1, 1, 1)

# Like previously smatrix.transmission(lead1, lead0) is transmission from lead0 
to lead1
ax.plot(energies, [smatrix.transmission(1, 0) for smatrix in smatrices], 
label='total')

# The new bit: smatrix.transmission((lead1, q1), (lead0, q0)) is the 
transmission from the
# q0 block of the lead0 into the q1 block of lead1. The subblock ordering is 
same as we used
# in set_symmetry.
ax.plot(energies, [smatrix.transmission((1, 0), (0, 0)) for smatrix in 
smatrices], label='$G_{↑↑}$')
ax.plot(energies, [smatrix.transmission((1, 1), (0, 0)) for smatrix in 
smatrices], label='$G_{↑↓}$')
ax.plot(energies, [smatrix.transmission((1, 0), (0, 1)) for smatrix in 
smatrices], label='$G_{↓↑}$')
ax.plot(energies, [smatrix.transmission((1, 1), (0, 1)) for smatrix in 
smatrices], label='$G_{↓↓}$')
ax.set_ylabel('$G [e^2/h]$', fontsize='xx-large')
ax.set_xlabel('$E/t$', fontsize='xx-large')
ax.legend(fontsize='x-large');


On 24. jan. 2017 13:18, Anton Akhmerov wrote:

OK, please double-check the remaining simulation parameters.

Anton

On Tue, Jan 24, 2017 at 1:00 PM, Camilla Espedal
<camilla.espe...@ntnu.no> wrote:


Dear Anton,



I triend changing it, but that does not solve the problem.



Best,

Camilla

From: Anton Akhmerov [mailto:anton.akhmerov...@gmail.com]
Sent: 24. januar 2017 12:36


To: Camilla Espedal <camilla.espe...@ntnu.no>
Cc: kwant-discuss@kwant-project.org
Subject: Re: [Kwant] Regarding smatrix and spin



Dear Camilla,



Could the difference originate from you using a lattice constant of 2
instead of 1?



Anton



On Tue, Jan 24, 2017, 10:41 Camilla Espedal <camilla.espe...@ntnu.no> wrote:

Dear Anton,

Thanks again for all your help. I will try to do it the linux way. Just one
more thing regarding this. I wrote a script in the old Kwant to find the
total conductance and compare it to the one in your notebook. While the two
plots are qualitatively similar, they are not the same. Am I missing
something, or am I calculating different things?

Best, Camilla

(my code):

# Tutorial 2.3.1. Matrix structure of on-site and hopping elements
# 
#
# Physics background
# --
#  Gaps in quantum wires with spin-orbit coupling and Zeeman splititng,
#  as theoretically predicted in
#   http://prl.aps.org/abstract/PRL/v90/i25/e256601
#  and (supposedly) experimentally oberved in
#   http://www.nature.com/nphys/journal/v6/n5/abs/nphys1626.html
#
# Kwant features highlighted
# --
#  - Numpy matrices as values in Builder

import kwant

# For plotting
import matplotlib.pyplot as plt

# For matrix support
import tinyarray
import numpy as np

# define Pauli-matrices for convenience

[Kwant] Question regarding orbitals and scattering matrix

2016-11-25 Thread Camilla Espedal
Hi again,

This question is sort of related to one of mye previous questions 
(https://www.mail-archive.com/kwant-discuss@kwant-project.org/msg01029.html) 
but I am writing it as a new one. The questions relates to the sites in the 
lead unit cell and the scattering matrix.

Say I have a system (simple 2D wire), where I have 3 sites in my unit cell (3 
orbitals). I then make a system at an energy which is so low that I only have 
one propagating mode in the system. If I then run

smatrix.lead_info[0]

it returns a 2x3 matrix (which corresponds to left/right going and number of 
orbitals). If I then run

smatrix.submatrix(0,0)

I only get one element, which orbital does this element "belong" to, or how 
does it relate to these orbitals? Is the scattering matrix the same for all 
orbitals? Is the probability of scattering from say orbital 1 in one lead to 
orbital 2 in another the same as from orbital 1 to orbital 1?

Hope my question makes sens.

Best regards,
Camilla


Re: [Kwant] Question about lead_info[].wave_functions[]

2016-11-17 Thread Camilla Espedal
Hi again,

So my final question is then. What is the unit cell? Doesn't a square lattice 
only have one site per unit cell? Or is it the number of interface sites?

Best,
Camilla


Re: [Kwant] Question about lead_info[].wave_functions[]

2016-11-16 Thread Camilla Espedal
Hi Joe,

Thank you. This might be a silly question, but what is the meaning of orbitals 
here? Is it not only 1? The orbital elements seem to be conjugate of each other.

Best,
Camilla


[Kwant] Question about lead_info[].wave_functions[]

2016-11-16 Thread Camilla Espedal
Hi all,

I have a question regarding the lead_info[x].wave_functions[x]. I am not sure 
what this is actually returning? I tried to run the function on your 
quantum_wire_revisited.py-system, like this

prop = sm.lead_info[0]
print(prop.wave_functions[0])

with W = 2, if that is important. It then returns a 1x2 array or 2x2 matrix 
depending on the energy. What does this matrix contain? I read about 
propagatingmodes in the documentation, but I am not sure what it meant.

Best,
Camilla


Re: [Kwant] Plotting Hamiltonian for overlapping lattices

2016-11-08 Thread Camilla Espedal
Hello Antônio,

So here is what I want to do. I have a system where I have defined two 
lattices, lat_up and lat_down, and they overlap spatially (instead of using 
matrices in the voltage and hopping, so that it is easier to obtain 
spin-resolved data). They are defined like this:

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+d,0),(a+d,0+d)], 
name='down')
A_down, B_down = lat_down.sublattices

I want to calculate the trace of the dot product between sigma_z and the spinor 
psi = (psi_up psi_down), and plot it over the system.  That is H(lat_up(i,i)) - 
H(lat_down(i,i)).

This was easy to do, when I used matrices for spin, but now that I have 
implemented it using two lattices instead I don't know how to do it. If I use 
the same approach as before, I get two values for each (spatial) lattice point, 
and the result looks completely random.

I hope my explanation was understandable.

Best,
Camilla



[Kwant] Spatially dependent hopping

2016-11-03 Thread Camilla Espedal
Hi again,

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?

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"?

I hope my  question makes sense.

Best,
Camilla


[Kwant] The reference distance a is too small

2016-11-01 Thread Camilla Espedal
Hi again,

I am trying to make sense of the error message I get when trying to plot using 
kwant.plotter map(). The error message is "the reference distance a is too 
small", and a is the lattice spacing. What is the meaning of this error message?

Best,
Camilla


Re: [Kwant] Hopping between different lattices and families

2016-10-31 Thread Camilla Espedal
Thank you!



That worked, but I still don't see why the last thing I did didn't work?



I added a hopping for two points that were within bounds even if shape_sr 
started at 1 instead of 0? What am I missing?



Best,

Camilla


From: Bas Nijholt [mailto:basnijh...@gmail.com]
Sent: 31. oktober 2016 14:41
To: Camilla Espedal <camilla.espe...@ntnu.no>; Anton Akhmerov 
<anton.akhme...@gmail.com>
Cc: kwant-discuss@kwant-project.org
Subject: Re: [Kwant] Hopping between different lattices and families

[https://share.polymail.io/v2/z/a/NTgxNzQ5YTNkNTEz/xUmVK-i26NNEAv--i_LM1Plxebyu8uAoC6DbmD79H5dGTrf-kVfHcrHgZTNWF_OjMz4geOWxyljAMWAlegWTqcgJMJI8eMyXr-Ez8eIHo-gW3HG5GbkpLLAdt_w22PY3DobInlRQhU_v_vUt_PJ9RMFO.png]
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%20espedal%20%3ccamilla.espe...@ntnu.no%3e> > wrote:

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:anton.akhme...@gmail.com<mailto:anton.akhme...@gmail.com>]
Sent: 31. oktober 2016 12:04
To: Camilla Espedal <camilla.espe...@ntnu.no<mailto:camilla.espe...@ntnu.no>>
Cc: kwant-discuss@kwant-project.org<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 
<camilla.espe...@ntnu.no<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:anton.akhme...@gmail.com<mailto:anton.akhme...@gmail.com>]
> Sent: 31. oktober 2016 11:48
> To: Camilla Espedal <camilla.espe...@ntnu.no<mailto:camilla.espe...@ntnu.no>>
> Cc: kwant-discuss@kwant-project.org<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 
> <camilla.espe...@ntnu.no<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 =
>> kw

Re: [Kwant] Hopping between different lattices and families

2016-10-31 Thread Camilla Espedal
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-description-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:anton.akhme...@gmail.com] 
Sent: 31. oktober 2016 11:48
To: Camilla Espedal <camilla.espe...@ntnu.no>
Cc: 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 <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


Re: [Kwant] Family-dependent onsite potential

2016-10-27 Thread Camilla Espedal
Thanks, I now changed the order, but I still get the same error message. So now 
the code reads

kwant.plotter.map(sys, V)
sys = sys.finalized()

but now it seems to be in a different place the error message is now 'int' 
object has no attribute 'site', and the V-function is still

def V(sys):
Hd = onsite(site)
return (Hd[0,0] - Hd[1,1]).real

Best,
Camilla


Re: [Kwant] Family-dependent onsite potential

2016-10-27 Thread Camilla Espedal
The problem occurs when I try to plot a map of the voltage on the sample, to 
check that everything is working. The problem does not seem to occur when 
assigning it to a builder element

sys[lattice.shape(shape_sr, (1,1))] = onsite

gives no error messages.

This is what I am trying to do, I write a function that calculates the voltage 
(I followed one of your tutorials)

def V(sys):
Hd = onsite(site)
return (Hd[0,0] - Hd[1,1]).real

and then

sys = sys.finalized()
kwant.plotter.map(sys, V)

to try to plot it, but then I get the error.

-Original Message-
From: Christoph Groth [mailto:christoph.gr...@cea.fr] 
Sent: 27. oktober 2016 12:15
To: Camilla Espedal <camilla.espe...@ntnu.no>
Cc: kwant-discuss@kwant-project.org
Subject: Re: [Kwant] Family-dependent onsite potential

Camilla Espedal wrote:

> (...)
> but it does not work. I get error message: ‘int’ object has no
> attribute ‘family’. How can I solve this, or what am I doing 
> wrong?

This shouldn’t be.  Can you provide a complete script that 
demostrates the problem?

Christoph


[Kwant] Family-dependent onsite potential

2016-10-27 Thread Camilla Espedal
Hello,

I am making a system with 2 sublattices, so they belong to different families 
(a and b), and I wish to define a sublattice-dependent onsite energy. I tried 
using the following code for the onsite function.

def onsite(site):

onsite_a = 2
onsite_b = 2

return onsite_a if site.family == a else onsite_b

but it does not work. I get error message: 'int' object has no attribute 
'family'. How can I solve this, or what am I doing wrong?

Best,
Camilla