Re: [Kwant] Importing coordinates of the scattering region

2017-07-11 Thread Patrik Arvoy
Hi Adel,

It was very helpful, thank you for the comments!

Regards
Patrik

On 9 July 2017 at 10:39, Abbout Adel  wrote:

> Dear Patrik,
>
> Your program has some mistakes:
>
> 1) When you define a site, you need to use its coordinates, so no need to
> multiply by the lattice constant
> ie  sys[lat(0,0,11)]=3  and  not sys[lat(0,0,11*a]=3
> 2) You should not use the loop "for" when you define the lead. This means
> that you added more than one  site to your cell. Just define one site.
>
> 3) No need to add 2 extra sites to your system in order to attach the
> leads. one site is sufficient. This is not a mistake but it makes your
> program simpler.
>
> 4) You are using a 1D lead and your energies are starting from 0. So, in
> order  to have a conducting mode, you need to change the potential from 4t
> to 2t.
>
> 5) Avoid energy 0 (the bottom of the band) when you calculate the
> scattering matrix otherwise you will get an error  ValueError: Input a
> needs to be a square matrix.
> start from 0.0001 for example.
>
> Now I want to make a comment on your problem. In kwant, the hamiltonian is
> a graph. The position of the sites in your case are not important. only the
> onsite potentials and the hoppings are relevent. In your case, you can put
> all the sites in a line and this will change nothing since you do not have
> a field which depend on space. Your geometry is not relevent. So, if you do
> not intend to put an electric field or magnetic field which will add a
> space dependence to your hoppings, your problem boils down to 1D uniform
> chain and you will get conductance equal to 1 for all the energies (check
> the program below.)
>
> Here is your program with the corrections:
> I hope this helps.
> Adel
> 
> ---
>
>
> import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D
> from scipy.spatial import * from matplotlib import rcParams from numpy
> import * from numpy.linalg import * import pickle import sys import os
> import string import heapq import kwant import tinyarray
> #pb.pltutils.use_style() from matplotlib import pyplot cl_1dl3=True if
> cl_1dl3: a = 0.34 t = 1.0 N = 31 class 
> Amorphous(kwant.builder.SimpleSiteFamily):
> def normalize_tag(self, tag): return tinyarray.array(tag, float) def
> pos(self, tag): return tag atoms = Amorphous() syst = kwant.Builder()
> #coordinates of a chiral chain imported manually sites=atoms(0.0, 0.0,
> 0.0), atoms(-0.1336881039, 0.4114496766, 0.34),
> atoms(-0.4836881039, 0.6657395614, 0.68), atoms(-0.9163118961,
> 0.6657395614, 1.02), atoms(-1.2663118961, 0.4114496766,
> 1.36), atoms(-1.40, 0.00, 1.70),
> atoms(-1.2663118961, -0.4114496766, 2.04), atoms(-0.9163118961,
> -0.6657395614, 2.38), atoms(-0.4836881039, -0.6657395614,
> 2.72), atoms(-0.1336881039, -0.4114496766, 3.06),
> atoms(0.00, -0.00, 3.40), atoms(-0.1336881039,
> 0.4114496766, 3.74), atoms(-0.4836881039, 0.6657395614,
> 4.08), atoms(-0.9163118961, 0.6657395614, 4.42),
> atoms(-1.2663118961, 0.4114496766, 4.76), atoms(-1.40,
> 0.00, 5.10), atoms(-1.2663118961, -0.4114496766,
> 5.44), atoms(-0.9163118961, -0.6657395614, 5.78),
> atoms(-0.4836881039, -0.6657395614, 6.12), atoms(-0.1336881039,
> -0.4114496766, 6.46), atoms(0.00, -0.00,
> 6.80), atoms(-0.1336881039, 0.4114496766, 7.14),
> atoms(-0.4836881039, 0.6657395614, 7.48), atoms(-0.9163118961,
> 0.6657395614, 7.82), atoms(-1.2663118961, 0.4114496766,
> 8.16), atoms(-1.40, 0.00, 8.50),
> atoms(-1.2663118961, -0.4114496766, 8.84), atoms(-0.9163118961,
> -0.6657395614, 9.18), atoms(-0.4836881039, -0.6657395614,
> 9.52), atoms(-0.1336881039, -0.4114496766, 9.86),
> atoms(0.0, 0.0, 10.2) #adding the onsite and hopping to the system for i in
> range(N): syst[sites[i]] = 2 * t if i > 0: syst[sites[i], sites[i-1]] = -t
> #syst[sites[N-1], sites[0]] = -t kwant.plot(syst) # If we want to attach to
> vertical 1D chains to the system # we first add a slice of the down lead to
> the scattering region lat=kwant.lattice.cubic(a) syst[lat(0, 0, -1)] = 2 *
> t # now we add the hopping to the chiral chain syst[sites[0], lat(0, 0,
> -1)] = -t # fWe make a regular down lead and attach it to the system
> dn_lead = kwant.Builder(kwant.TranslationalSymmetry((0, 0, -a))) #for i
> in range(2): dn_lead[lat(0, 0, -2)] = 2 * t dn_lead[lat.neighbors()] = -t
> syst.attach_lead(dn_lead) syst[lat(0, 0, N)] = 2 * t syst[lat(0, 0, N),
> sites[N-1]] = -t # finally we make a regular lead and attach it to the top
> up_lead = kwant.Builder(kwant.TranslationalSymmetry((0, 0, a))) #for i in
> range(N, N+2): up_lead[lat(0, 0, 11)] = 2 * 

Re: [Kwant] Importing coordinates of the scattering region

2017-07-09 Thread Abbout Adel
Dear Patrik,

Your program has some mistakes:

1) When you define a site, you need to use its coordinates, so no need to
multiply by the lattice constant
ie  sys[lat(0,0,11)]=3  and  not sys[lat(0,0,11*a]=3
2) You should not use the loop "for" when you define the lead. This means
that you added more than one  site to your cell. Just define one site.

3) No need to add 2 extra sites to your system in order to attach the
leads. one site is sufficient. This is not a mistake but it makes your
program simpler.

4) You are using a 1D lead and your energies are starting from 0. So, in
order  to have a conducting mode, you need to change the potential from 4t
to 2t.

5) Avoid energy 0 (the bottom of the band) when you calculate the
scattering matrix otherwise you will get an error  ValueError: Input a
needs to be a square matrix.
start from 0.0001 for example.

Now I want to make a comment on your problem. In kwant, the hamiltonian is
a graph. The position of the sites in your case are not important. only the
onsite potentials and the hoppings are relevent. In your case, you can put
all the sites in a line and this will change nothing since you do not have
a field which depend on space. Your geometry is not relevent. So, if you do
not intend to put an electric field or magnetic field which will add a
space dependence to your hoppings, your problem boils down to 1D uniform
chain and you will get conductance equal to 1 for all the energies (check
the program below.)

Here is your program with the corrections:
I hope this helps.
Adel
---



import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D
from scipy.spatial import * from matplotlib import rcParams from numpy
import * from numpy.linalg import * import pickle import sys import os
import string import heapq import kwant import tinyarray
#pb.pltutils.use_style() from matplotlib import pyplot cl_1dl3=True if
cl_1dl3: a = 0.34 t = 1.0 N = 31 class
Amorphous(kwant.builder.SimpleSiteFamily): def normalize_tag(self, tag):
return tinyarray.array(tag, float) def pos(self, tag): return tag atoms =
Amorphous() syst = kwant.Builder() #coordinates of a chiral chain imported
manually sites=atoms(0.0, 0.0, 0.0), atoms(-0.1336881039, 0.4114496766,
0.34), atoms(-0.4836881039, 0.6657395614, 0.68),
atoms(-0.9163118961, 0.6657395614, 1.02), atoms(-1.2663118961,
0.4114496766, 1.36), atoms(-1.40, 0.00,
1.70), atoms(-1.2663118961, -0.4114496766, 2.04),
atoms(-0.9163118961, -0.6657395614, 2.38), atoms(-0.4836881039,
-0.6657395614, 2.72), atoms(-0.1336881039, -0.4114496766,
3.06), atoms(0.00, -0.00, 3.40),
atoms(-0.1336881039, 0.4114496766, 3.74), atoms(-0.4836881039,
0.6657395614, 4.08), atoms(-0.9163118961, 0.6657395614,
4.42), atoms(-1.2663118961, 0.4114496766, 4.76),
atoms(-1.40, 0.00, 5.10), atoms(-1.2663118961,
-0.4114496766, 5.44), atoms(-0.9163118961, -0.6657395614,
5.78), atoms(-0.4836881039, -0.6657395614, 6.12),
atoms(-0.1336881039, -0.4114496766, 6.46), atoms(0.00,
-0.00, 6.80), atoms(-0.1336881039, 0.4114496766,
7.14), atoms(-0.4836881039, 0.6657395614, 7.48),
atoms(-0.9163118961, 0.6657395614, 7.82), atoms(-1.2663118961,
0.4114496766, 8.16), atoms(-1.40, 0.00,
8.50), atoms(-1.2663118961, -0.4114496766, 8.84),
atoms(-0.9163118961, -0.6657395614, 9.18), atoms(-0.4836881039,
-0.6657395614, 9.52), atoms(-0.1336881039, -0.4114496766,
9.86), atoms(0.0, 0.0, 10.2) #adding the onsite and hopping to the
system for i in range(N): syst[sites[i]] = 2 * t if i > 0: syst[sites[i],
sites[i-1]] = -t #syst[sites[N-1], sites[0]] = -t kwant.plot(syst) # If we
want to attach to vertical 1D chains to the system # we first add a slice
of the down lead to the scattering region lat=kwant.lattice.cubic(a)
syst[lat(0, 0, -1)] = 2 * t # now we add the hopping to the chiral chain
syst[sites[0], lat(0, 0, -1)] = -t # fWe make a regular down lead and
attach it to the system dn_lead =
kwant.Builder(kwant.TranslationalSymmetry((0, 0, -a))) #for i in range(2):
dn_lead[lat(0, 0, -2)] = 2 * t dn_lead[lat.neighbors()] = -t
syst.attach_lead(dn_lead) syst[lat(0, 0, N)] = 2 * t syst[lat(0, 0, N),
sites[N-1]] = -t # finally we make a regular lead and attach it to the top
up_lead = kwant.Builder(kwant.TranslationalSymmetry((0, 0, a))) #for i in
range(N, N+2): up_lead[lat(0, 0, 11)] = 2 * t up_lead[lat.neighbors()] = -t
syst.attach_lead(up_lead) kwant.plot(syst) trans=True if trans: syst =
syst.finalized() energies = [] data = [] for ie in range(1,100): energy =
ie * 0.01 smatrix = kwant.smatrix(syst, energy=energy)
energies.append(energy) data.append(smatrix.transmission(1, 0))

Re: [Kwant] Importing coordinates of the scattering region

2017-07-08 Thread Patrik Arvoy
Hi Anton,

Thank you for the reply!
I used your suggestion to attach two 1D leads along the z axis to a chiral
1D chain.

I inserted my code in the following and added comments to each part.

I have two questions:
1- I successfully add a 1D chain to the lower part of the chiral system but
when I try to add a 1D chain as the upper lead to the top of the system, it
is automatically added
somewhere in the middle, which is not clear to me why.

2- How can I avoid zero conductance?

Thanks in advance
Patrik


--
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.spatial import *
from matplotlib import rcParams
from numpy import *
from numpy.linalg import *
import pickle
import sys
import os
import string
import heapq
import kwant
import tinyarray
pb.pltutils.use_style()



cl_1dl3=True
if cl_1dl3:
a = 0.34
t = 1.0
N = 31


class Amorphous(kwant.builder.SimpleSiteFamily):
def normalize_tag(self, tag):
return tinyarray.array(tag, float)

def pos(self, tag):
return tag


atoms = Amorphous()
syst = kwant.Builder()
#coordinates of a chiral chain imported manually
sites=atoms(0.0, 0.0, 0.0), atoms(-0.1336881039, 0.4114496766,
0.34), atoms(-0.4836881039, 0.6657395614, 0.68),
atoms(-0.9163118961, 0.6657395614, 1.02), atoms(-1.2663118961,
0.4114496766, 1.36), atoms(-1.40, 0.00,
1.70), atoms(-1.2663118961, -0.4114496766, 2.04),
atoms(-0.9163118961, -0.6657395614, 2.38), atoms(-0.4836881039,
-0.6657395614, 2.72), atoms(-0.1336881039, -0.4114496766,
3.06), atoms(0.00, -0.00, 3.40),
atoms(-0.1336881039, 0.4114496766, 3.74), atoms(-0.4836881039,
0.6657395614, 4.08), atoms(-0.9163118961, 0.6657395614,
4.42), atoms(-1.2663118961, 0.4114496766, 4.76),
atoms(-1.40, 0.00, 5.10), atoms(-1.2663118961,
-0.4114496766, 5.44), atoms(-0.9163118961, -0.6657395614,
5.78), atoms(-0.4836881039, -0.6657395614, 6.12),
atoms(-0.1336881039, -0.4114496766, 6.46), atoms(0.00,
-0.00, 6.80), atoms(-0.1336881039, 0.4114496766,
7.14), atoms(-0.4836881039, 0.6657395614, 7.48),
atoms(-0.9163118961, 0.6657395614, 7.82), atoms(-1.2663118961,
0.4114496766, 8.16), atoms(-1.40, 0.00,
8.50), atoms(-1.2663118961, -0.4114496766, 8.84),
atoms(-0.9163118961, -0.6657395614, 9.18), atoms(-0.4836881039,
-0.6657395614, 9.52), atoms(-0.1336881039, -0.4114496766,
9.86), atoms(0.0, 0.0, 10.2)

#adding the onsite and hopping to the system
for i in range(N):
syst[sites[i]] = 4 * t
if i > 0:
syst[sites[i], sites[i-1]] = -t
syst[sites[N-1], sites[0]] = -t
kwant.plot(syst)

# If we want to attach to vertical 1D chains to the system
# we first add a slice of the down lead to the scattering region
lat=kwant.lattice.cubic(a)

for i in range(2):   #number of atoms added to the bottom of the chiral
chain
syst[lat(0, 0, -(i+1)*a)] = 4 * t
syst[lat.neighbors()] = -t
# now we add the hopping to the chiral chain
syst[sites[0], lat(0, 0, -a)] = -t
kwant.plot(syst)

# fWe make a regular down lead and attach it to the system
dn_lead = kwant.Builder(kwant.TranslationalSymmetry((0, 0, -a)))
for i in range(2):
dn_lead[lat(0, 0, -(i+1)*a)] = 4 * t
dn_lead[lat.neighbors()] = -t
syst.attach_lead(dn_lead)
kwant.plot(syst)



#Here is wwhere the problem arises!!!
#I want to add a similar 1D chain to the top of the chiral system
#but instead it is automatically added somewhere in the middle.



for i in range(N, N+2):   #number of atoms added to the top
syst[lat(0, 0, i*a)] = 4 * t
syst[lat.neighbors()] = -t
# now we add the hopping to the systeml
syst[lat(0, 0, N*a), sites[N-1]] = -t
kwant.plot(syst)

# finally we make a regular lead and attach it to the top
up_lead = kwant.Builder(kwant.TranslationalSymmetry((0, 0, a)))
for i in range(N, N+2):
up_lead[lat(0, 0, i*a)] = 4 * t
up_lead[lat.neighbors()] = -t
syst.attach_lead(up_lead)

kwant.plot(syst)

trans=True
if trans:
syst = syst.finalized()
energies = []
data = []

for ie in range(0,100):
energy = ie * 0.01
smatrix = kwant.smatrix(syst, energy)
energies.append(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()


On 6 July 2017 at 18:13, Anton Akhmerov  wrote:

> Hi Patrik,
>
> You can use site coordinates that don't 

Re: [Kwant] Importing coordinates of the scattering region

2017-07-06 Thread Anton Akhmerov
Hi Patrik,

You can use site coordinates that don't belong to any lattice. For
that you need to define your own SiteFamily, see for example the
script below that achieves this goal.

---
from matplotlib import pyplot
import kwant
import tinyarray

class Amorphous(kwant.builder.SimpleSiteFamily):
def normalize_tag(self, tag):
return tinyarray.array(tag, float)

def pos(self, tag):
return tag


atoms = Amorphous()

syst = kwant.Builder()
sites = atoms(0.01, 0.05), atoms(1.01, -.5)
syst[sites[0]] = syst[sites[1]] = 2
syst[sites[1], sites[0]] = 1

kwant.plot(syst)
-

Of course it's now your responsibility to specify the Hamiltonian,
leads, attaching leads, etc.

Best,
Anton

On Thu, Jul 6, 2017 at 4:12 PM, Patrik Arvoy  wrote:
>
> Dear users and developers,
>
> I was wondering if I can import the coordinates of a scattering region
> without any particular symmetry and compute the conductance via kwant.
> If yes, how does one do that?
> Let's say the scattering region does not have any symmetry after optimizing
> the structure via MD or ... and I have a list of coordinates of all the
> sites.
> I appreciate any help.
>
> Regards
> Patrik


[Kwant] Importing coordinates of the scattering region

2017-07-06 Thread Patrik Arvoy
Dear users and developers,

I was wondering if I can import the coordinates of a scattering region
without any particular symmetry and compute the conductance via kwant.
If yes, how does one do that?
Let's say the scattering region does not have any symmetry after optimizing
the structure via MD or ... and I have a list of coordinates of all the
sites.
I appreciate any help.

Regards
Patrik