Re: [Kwant] Regarding smatrix and spin

2017-02-14 Thread Anton Akhmerov
Hi Camilla,

The reason you are seeing different scattering matrices is because
without knowledge of the conservation laws Kwant orders the modes by
their velocities first, and not by their internal degrees of freedom.
Transmissions should be the same, however.

The updated way to specify the conservation laws is much simpler than
in the first draft implementation that we shared. You just need to
provide the conserved quantity on each site when constructing the
system (e.g. s_z). This operator must have integer eigenvalues. Then
the blocks correspond to the eigenvalues of that operator sorted in
ascending order (so (0, 1) comes first, (1, 0) second).

Best,
Anton


On Tue, Feb 14, 2017 at 11:26 AM, Camilla Espedal
<camilla.espe...@ntnu.no> wrote:
> Hi Anton,
>
> Thank you! It is working now. I have one question though, about the 
> conservation laws and Kwant.
>
> So, I tried to add a really small zeeman-field in the leads (delta_z * 
> sigma_z) sot that the two spin states are not degenerate. The idea was that 
> it would be small enough to not affect the physics, but still force the 
> spin-basis. However when I compare the smatrix.submatrix(1,0) in the case 
> where I add the small Zeeman field, and the one I get using the conservation 
> laws, they are not the same.
>
> Do you have any idea as to why?
>
> Also, what is the convention in the numbering of the spins (q_0 and q_1)? Is 
> q_0 = q_1 = 0 upup? It seems that the syntax has changed since you used 
> set_symmetry before?
>
> Best,
> Camilla
> 
> Fra: Anton Akhmerov <anton.akhme...@gmail.com>
> Sendt: 14. februar 2017 09:48
> Til: Camilla Espedal
> Kopi: kwant-discuss@kwant-project.org
> Emne: Re: [Kwant] Regarding smatrix and spin
>
> Hi Camilla,
>
> Sure. You need to install a development version of tinyarray. If you
> got everything via conda, then you can do " conda install -c kwant
> 'tinyarray==dev' ". If you installed kwant via pip, do " pip install
> git+https://gitlab.kwant-project.org/kwant/tinyarray.git@master "
>
> Let me know if it works (both the installation and using the conservation 
> laws).
>
> Best,
> Anton
>
> On Tue, Feb 14, 2017 at 9:40 AM, Camilla Espedal
> <camilla.espe...@ntnu.no> wrote:
>> 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()
>>
&g

Re: [Kwant] Regarding smatrix and spin

2017-02-14 Thread Anton Akhmerov
Hi Camilla,

Sure. You need to install a development version of tinyarray. If you
got everything via conda, then you can do " conda install -c kwant
'tinyarray==dev' ". If you installed kwant via pip, do " pip install
git+https://gitlab.kwant-project.org/kwant/tinyarray.git@master "

Let me know if it works (both the installation and using the conservation laws).

Best,
Anton

On Tue, Feb 14, 2017 at 9:40 AM, Camilla Espedal
<camilla.espe...@ntnu.no> wrote:
> 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 C

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

Re: [Kwant] Regarding smatrix and spin

2017-01-24 Thread Anton Akhmerov
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
> sigma_0 = tinyarray.array([[1, 0], [0, 1]])
> sigma_x = tinyarray.array([[0, 1], [1, 0]])
> sigma_y = tinyarray.array([[0, 1j], [-1j, 0]])
> sigma_z = tinyarray.array([[1, 0], [0, -1]])
>
>
> def make_system(a=2, t=1.0, alpha=0.1, e_z=0.05, W=10, L=10):
> # Start with an empty tight-binding system and a single square lattice.
> # `a` is the lattice constant (by default set to 1 for simplicity).
> lat = kwant.lattice.square(a)
>
> sys = kwant.Builder()
>
>  Define the scattering region. 
> sys[(lat(x, y) for x in range(L) for y in range(W))] = \
> 4 * t * sigma_0 + e_z * sigma_z
> # hoppings in x-direction
> sys[kwant.builder.HoppingKind((1, 0), lat, lat)] = \
> -t * sigma_0 - 1j * alpha * sigma_y
> # hoppings in y-directions
> sys[kwant.builder.HoppingKind((0, 1), lat, lat)] = \
> -t * sigma_0 + 1j * alpha * sigma_x
>
>  Define the left lead. 
> lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0)))
>
> lead[(lat(0, j) for j in range(W))] = 4 * t * sigma_0
> # hoppings in x-direction
> lead[lat.neighbors()] = \
> -t * sigma_0
>
>  Attach the leads and return the finalized system. 
> sys.attach_lead(lead)
> sys.attach_lead(lead.reversed())
>
> return sys
>
>
> def plot_conductance(sys, energies):
> # Compute conductance
> data = []
> for energy in energies:
> smatrix = kwant.smatrix(sys, energy)
> data.append(smatrix.transmission(1, 0))
>
> pyplot.figure()
> pyplot.plot(energies, data)
> pyplot.xlabel("energy [t]")
> pyplot.ylabel("conductance [e^2/h]")
> pyplot.show()
>
>
> def main():
> sys = make_system()
>
> # Check that the system looks as intended.
> kwant.plot(sys)
>
> # Finalize the system.
> sys = sys.finalized()
> energies = np.linspace(0, 1, 200)
> smatrices = [kwant.smatrix(sys, energy) for energy in energies]
>
> fig = plt.figure(figsize=(13, 8))
> ax = fig.add_subplot(1, 1, 1)
>
> ax.plot(energies, [smatrix.transmission(1,0) for smatrix in
> smatrices], label='total')
>
> ax.set_ylabel('$G [e^2/h]$', fontsize='xx-large')
> ax.set_xlabel('$E/t$', fontsize='xx-large')
> ax.legend(fontsize='x-large')
>
> plt.show()
>
>
>
> # Call the main function if the script gets executed (as opposed to
> imported).
> # See <http://docs.python.org/library/__main__.html>.
> if __name__ == '__main__':
> main()
>
> -Original Message-
> From: anton.akhme...@gmail.com [mailto:anton.akhme...@gmail.com] On
> Behalf Of Anton Akhmerov
> Sent: 17. januar 2017 10:48
> To: Camilla Espedal <camilla.espe...@ntnu.no>
> Cc: kwant-discuss@kwant-project.org
> Subject: Re: [Kwant] Regarding smatrix and spin
>
> Dear Camilla,
>
> It seems that you are trying to install Kwant on windows. This is a very
> hard task, and I fear none of the Kwant developers has enough knowledge of
> it right now (our Windows packages are built by Christoph Gohlke, see [1]
> for the build environment description). However if you are using windows
> 10, I suggest to try to install Kwant using the windows subsystem for
> linux. That way th

Re: [Kwant] Regarding smatrix and spin

2017-01-17 Thread Anton Akhmerov
Dear Camilla,

It seems that you are trying to install Kwant on windows. This is a
very hard task, and I fear none of the Kwant developers has enough
knowledge of it right now (our Windows packages are built by Christoph
Gohlke, see [1] for the build environment description). However if you
are using windows 10, I suggest to try to install Kwant using the
windows subsystem for linux. That way the standard Ubuntu build
procedure should work for you.

Best,
Anton

[1]: http://www.lfd.uci.edu/~gohlke/pythonlibs/

On Mon, Jan 16, 2017 at 9:45 AM, Camilla Espedal
<camilla.espe...@ntnu.no> wrote:
> Thanks a lot. I tried to install the cons_laws_combined, but I get the 
> following error message:
>
> "LINK: fatal error LNK1181: cannot open input file 'lapack.lib'"
>
> Is there some package or installation I am missing?
>
> Best regards,
> Camilla
>
> -Original Message-
> From: anton.akhme...@gmail.com [mailto:anton.akhme...@gmail.com] On Behalf Of 
> Anton Akhmerov
> Sent: 8. januar 2017 16:35
> To: Tómas Örn Rosdahl <torosd...@gmail.com>
> Cc: Camilla Espedal <camilla.espe...@ntnu.no>; kwant-discuss@kwant-project.org
> Subject: Re: [Kwant] Regarding smatrix and spin
>
> Hi Camilla, everyone,
>
> I've slightly modified Tómas's example to a case where the spins do get 
> coupled, check it out:
> http://nbviewer.jupyter.org/url/antonakhmerov.org/misc/spin_conductance.ipynb
>
> I've also provided more detailed installation instructions in the notebook.
>
> Cheers,
> Anton
>
> On Sun, Jan 8, 2017 at 2:45 PM, Tómas Örn Rosdahl <torosd...@gmail.com> wrote:
>> Dear Camilla,
>>
>> For a Hamiltonian with degeneracies due to a conservation law, the
>> scattering states will in general not have a definite value of the
>> conservation law. In your case, Kwant returns scattering states that
>> are arbitrary linear combinations of spin up and down, so it is not
>> possible to label the amplitudes in the scattering matrix by spin.
>>
>> However, in Kwant 1.3 a feature will be added that allows for the
>> construction of scattering states with definite values of a
>> conservation law. See here for an explanation of the basic idea behind the 
>> algorithm.
>>
>> We're currently working on implementing this feature in Kwant itself.
>> The good news is that we're practically done - here is a link to a git
>> repo with a functioning implementation. After you clone the repo,
>> check out the branch cons_laws_combined, which contains a version of
>> Kwant with conservation laws implemented. This notebook contains a
>> simple example to illustrate how to work with conservation laws and the 
>> scattering matrix.
>>
>> I invite you and anyone else who is interested to give it a try. We'd
>> appreciate any feedback!
>>
>> In your case specifically, there would be two projectors in the new
>> implementation - P0 which projects out the spin up block, and P1 that
>> projects out the spin down block. If they are specified in this order,
>> then the spin up and down blocks in the Hamiltonian have block indices
>> 0 and 1, respectively. In the new implementation, it is possible to
>> ask for subblocks of the scattering matrix relating not only any two
>> leads, but also any two conservation law blocks in any leads. To get
>> the reflection amplitude of an incident spin up electron from lead 0
>> into an outgoing spin down electron in lead 0, you could simply do
>> smat.submatrix((0, 1), (0, 0)). Here, the arguments are tuples of indices 
>> (lead index, block index).
>>
>> Best regards,
>> Tómas
>>
>> On Fri, Jan 6, 2017 at 3:46 PM, Camilla Espedal
>> <camilla.espe...@ntnu.no>
>> wrote:
>>>
>>> Hi again,
>>>
>>>
>>>
>>> This question is basically the same as this:
>>> https://www.mail-archive.com/kwant-discuss@kwant-project.org/msg00076
>>> .html
>>>
>>>
>>>
>>> I want to calculate some things using the scattering matrix. I
>>> started out with a very simple system, most basic two-terminal
>>> system. For some energy there is one propagating mode. I now add
>>> matrix structure to the mix (just multiply by s_0 everywhere) and
>>> there are now 2 propagating modes (which makes sense).
>>>
>>>
>>>
>>> Now, if I look at the reflection coefficients for lead 0 by using
>>> submatrix(0,0), it is now a 2x2 matrix after I introduced the
>>> matrices. How are the elements ordered? Is it
>>>
>>>
>>>
>>> [[r_upup, r_updown],[r_downup, r_downdown]]
>>>
>>>
>>>
>>> I know that I could make two lattices, but since I do not plan to use
>>> the other functions such as transmission. I  just want the smatrix.
>>>
>>>
>>>
>>> Hope you can help me, and thanks in advance.
>>>
>>>
>>>
>>> Best regards,
>>>
>>> Camilla
>>
>>


Re: [Kwant] Regarding smatrix and spin

2017-01-08 Thread Anton Akhmerov
Hi Camilla, everyone,

I've slightly modified Tómas's example to a case where the spins do
get coupled, check it out:
http://nbviewer.jupyter.org/url/antonakhmerov.org/misc/spin_conductance.ipynb

I've also provided more detailed installation instructions in the notebook.

Cheers,
Anton

On Sun, Jan 8, 2017 at 2:45 PM, Tómas Örn Rosdahl  wrote:
> Dear Camilla,
>
> For a Hamiltonian with degeneracies due to a conservation law, the
> scattering states will in general not have a definite value of the
> conservation law. In your case, Kwant returns scattering states that are
> arbitrary linear combinations of spin up and down, so it is not possible to
> label the amplitudes in the scattering matrix by spin.
>
> However, in Kwant 1.3 a feature will be added that allows for the
> construction of scattering states with definite values of a conservation
> law. See here for an explanation of the basic idea behind the algorithm.
>
> We're currently working on implementing this feature in Kwant itself. The
> good news is that we're practically done - here is a link to a git repo with
> a functioning implementation. After you clone the repo, check out the branch
> cons_laws_combined, which contains a version of Kwant with conservation laws
> implemented. This notebook contains a simple example to illustrate how to
> work with conservation laws and the scattering matrix.
>
> I invite you and anyone else who is interested to give it a try. We'd
> appreciate any feedback!
>
> In your case specifically, there would be two projectors in the new
> implementation - P0 which projects out the spin up block, and P1 that
> projects out the spin down block. If they are specified in this order, then
> the spin up and down blocks in the Hamiltonian have block indices 0 and 1,
> respectively. In the new implementation, it is possible to ask for subblocks
> of the scattering matrix relating not only any two leads, but also any two
> conservation law blocks in any leads. To get the reflection amplitude of an
> incident spin up electron from lead 0 into an outgoing spin down electron in
> lead 0, you could simply do smat.submatrix((0, 1), (0, 0)). Here, the
> arguments are tuples of indices (lead index, block index).
>
> Best regards,
> Tómas
>
> On Fri, Jan 6, 2017 at 3:46 PM, Camilla Espedal 
> wrote:
>>
>> Hi again,
>>
>>
>>
>> This question is basically the same as this:
>> https://www.mail-archive.com/kwant-discuss@kwant-project.org/msg00076.html
>>
>>
>>
>> I want to calculate some things using the scattering matrix. I started out
>> with a very simple system, most basic two-terminal system. For some energy
>> there is one propagating mode. I now add matrix structure to the mix (just
>> multiply by s_0 everywhere) and there are now 2 propagating modes (which
>> makes sense).
>>
>>
>>
>> Now, if I look at the reflection coefficients for lead 0 by using
>> submatrix(0,0), it is now a 2x2 matrix after I introduced the matrices. How
>> are the elements ordered? Is it
>>
>>
>>
>> [[r_upup, r_updown],[r_downup, r_downdown]]
>>
>>
>>
>> I know that I could make two lattices, but since I do not plan to use the
>> other functions such as transmission. I  just want the smatrix.
>>
>>
>>
>> Hope you can help me, and thanks in advance.
>>
>>
>>
>> Best regards,
>>
>> Camilla
>
>


Re: [Kwant] Regarding smatrix and spin

2017-01-08 Thread Tómas Örn Rosdahl
Dear Camilla,

For a Hamiltonian with degeneracies due to a conservation law, the
scattering states will in general not have a definite value of the
conservation law. In your case, Kwant returns scattering states that are
arbitrary linear combinations of spin up and down, so it is not possible to
label the amplitudes in the scattering matrix by spin.

However, in Kwant 1.3 a feature will be added that allows for the
construction of scattering states with definite values of a conservation
law. See here

for
an explanation of the basic idea behind the algorithm.

We're currently working on implementing this feature in Kwant itself. The
good news is that we're practically done - here
 is a link to a git
repo with a functioning implementation. After you clone the repo, check out
the branch cons_laws_combined, which contains a version of Kwant with
conservation laws implemented. This

notebook
contains a simple example to illustrate how to work with conservation laws
and the scattering matrix.

I invite you and anyone else who is interested to give it a try. We'd
appreciate any feedback!

In your case specifically, there would be two projectors in the new
implementation - P0 which projects out the spin up block, and P1 that
projects out the spin down block. If they are specified in this order, then
the spin up and down blocks in the Hamiltonian have block indices 0 and 1,
respectively. In the new implementation, it is possible to ask for
subblocks of the scattering matrix relating not only any two leads, but
also any two conservation law blocks in any leads. To get the reflection
amplitude of an incident spin up electron from lead 0 into an outgoing spin
down electron in lead 0, you could simply do smat.submatrix((0, 1), (0,
0)). Here, the arguments are tuples of indices (lead index, block index).

Best regards,
Tómas

On Fri, Jan 6, 2017 at 3:46 PM, Camilla Espedal 
wrote:

> Hi again,
>
>
>
> This question is basically the same as this: https://www.mail-archive.com/
> kwant-discuss@kwant-project.org/msg00076.html
>
>
>
> I want to calculate some things using the scattering matrix. I started out
> with a very simple system, most basic two-terminal system. For some energy
> there is one propagating mode. I now add matrix structure to the mix (just
> multiply by s_0 everywhere) and there are now 2 propagating modes (which
> makes sense).
>
>
>
> Now, if I look at the reflection coefficients for lead 0 by using
> submatrix(0,0), it is now a 2x2 matrix after I introduced the matrices. How
> are the elements ordered? Is it
>
>
>
> [[r_upup, r_updown],[r_downup, r_downdown]]
>
>
>
> I know that I could make two lattices, but since I do not plan to use the
> other functions such as transmission. I  just want the smatrix.
>
>
>
> Hope you can help me, and thanks in advance.
>
>
>
> Best regards,
>
> Camilla
>