Re: [Kwant] Plotting Hamiltonian for overlapping lattices

2016-11-08 Thread Tómas Örn Rosdahl
Dear Camilla,

Your motivation for introducing two sublattices is to obtain spin-resolved
data. If it is transport you're interested in, i.e. essentially lead modes
that have definite spin projections, then I can suggest an alternative
method.

If spin up and down states in a lead are degenerate, kwant computes lead
modes with arbitrary spin projections, so it is generally not possible to
ask the scattering matrix for e.g. a transmission probability from a spin
up state in one lead to a spin down state in another, without some extra
work. In general, this is a problem when dealing with conservation laws. My
colleagues and I made a module which extends some kwant objects, allowing
for the creation of leads that host scattering states which have definite
values of a conservation law. The module is attached.

The basic idea is the following: if the lead Hamiltonian has a conservation
law in the form of a Hermitian matrix that commutes with the lead unit cell
Hamiltonian, then it is possible to block diagonalize the lead Hamiltonian,
such that each block corresponds to an eigenvalue of the conservation law.
If we compute the lead modes independently within each block, then each
mode is guaranteed to have a definite value of the conservation law. In
your case, the conservation law is spin, so the lead Hamiltonian may be
block diagonalized to have two blocks (spin up and down).

The extra input needed to do this is a list of projectors that block
diagonalize the lead Hamiltonian, one projector for each value of the
conservation law. Basically, the projectors pick out the sites relevant for
each value of the conservation law in the unit cell Hamiltonian. For
example, in a system where spin is conserved, the projector onto the spin
up block picks out tight binding amplitudes in the Hamiltonian that
correspond to the discretized spin-up wave function. Suppose for instance
that the lead consists of two sites, each with onsite spin sigma_z, such
that the lead Hamiltonian is 4x4. Then, the projector onto the spin up
block is

P1 = [1, 0, 0, 0
  0, 0, 1, 0]^T,

and onto the spin down block

P1 = [0, 1, 0, 0
  0, 0, 0, 1]^T.

This is done with the class ConservationInfiniteSystem in the module, which
takes a normal kwant lead and a list of projectors as input when it is
initialized. The module also modifies the scattering matrix, allowing one
to ask for transmission not only between leads, but also between blocks of
the leads. To do this, one feeds the methods of SymmetricSMatrix tuples of
(lead_index, block_index) instead of just an integer lead_index.

Here is a notebook with a simple example to illustrate how the module is
used:
http://nbviewer.jupyter.org/urls/dl.dropbox.com/s/tj79un6pbqgyk1j/symm_leads.ipynb

Lastly, I'd like to add that we're working on making it possible to
construct symmetric scattering states directly using kwant. The
work-in-progress merge request is here:
https://gitlab.kwant-project.org/kwant/kwant/merge_requests/38

Hope this helps,
Tómas

On Tue, Nov 8, 2016 at 2:18 PM, Camilla Espedal <camilla.espe...@ntnu.no>
wrote:

> 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
>
>
>
"""
This modules extends kwant.system.InfiniteSystem and kwant.solvers.common.SMatrix,
to allow for the construction of lead modes with a conservation law and a scattering
matrix that understands the conservation law.

By Tómas Örn Rosdahl, Adriaan Vuik and Anton Akhmerov (TU Delft).
"""

import kwant
from kwant import physics
import numpy as np
import warnings

# TODO: When the numpy behavior is updated and widespread, remove the fix
with warnings.catch_warnings():
warnings.simplefilter("ignore")
split_fixed = np.split(np.zeros((0, 2)), 2)[0].shape == (0, 2)
if split_fixed:
split = np.

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
>


Re: [Kwant] conservation law in the case of a spinfull Nambu basis

2017-12-08 Thread Tómas Örn Rosdahl
Hi Tibor,

The number of projectors is the same as the number of distinct eigenvalues
in the specified conservation law. Note that the eigenvalues themselves are
not important, only the order in which they appear and whether they are
distinct or not. In your case, you could set conservation_law =
np.diag([-2, -1, 1, 2]) to get projectors onto e_up, e_down, h_up and
h_down, respectively, using lead.discrete_symmetry().projectors.To get
subblocks of the scattering matrix between conservation law values, you can
use the submatrix(lead_out, lead_in) method of kwant.solvers.common.SMatrix
,
where lead_in and lead_out can be tuples of (lead index, projector index).

Best,
Tómas

On Fri, Dec 8, 2017 at 4:02 PM, Tibor Sekera  wrote:

> Dear all,
>
> as is explained in
> https://kwant-project.org/doc/dev/tutorial/superconductors
> the conservation law argument in Builder (e.g. a lead) is
>
> conservation_law=-tau_z
>
> with eigenvalues -1 and 1 yields scattering states of electron and hole
> type, respectively.
> This leads to a block form of the scattering matrix. One can also get the
> electron and hole projectors as
>
> (projector_e, projector_h) = lead.discrete_symmetry().projectors
>
> In presence of spin (described by sigma matrices) and a magnetic field
> (giving rise to a Zeeman term) we could
> have a conservation law of the following form
>
> conservation_law=np.kron(-tau_z,-sigma_z)
>
> where the Hamiltonian is written in the Nambu basis (e up, e down, h up,
> -h down). Eigenvalues of this conservation law
> are now 1,-1,1,-1, which are degenerate.
>
> Question 1: How can one resolve the four-by-four block structure of the
> scattering matrix in the electron-hole ⊗ spin up-down space?
>
> Question 2: How can one get the four projectors? I am looking for
> something like:
> (projector_e_up, projector_e_down, projector_h_up,
> projector_h_down) = lead.discrete_symmetry().projectors
>
>
>