Re: [Kwant] seeking help

2018-09-04 Thread shyam lochan bora
Thank you so much sir for your advice.

On Fri, Aug 31, 2018 at 8:48 PM Anton Akhmerov 
wrote:

> Dear Shyam Lochan Bora,
>
> Right now your question is rather poorly formulated, and not suitable
> for this mailing list. Please read this instruction on how to ask good
> questions: https://stackoverflow.com/help/how-to-ask
> Additionally, it appears that your problem is due the lack of the
> Python knowledge, I recommend you to follow a Python course, or
> otherwise learn the language more systematically.
>
> Best regards,
> Anton Akhmerov
> On Fri, Aug 31, 2018 at 5:08 PM shyam lochan bora
>  wrote:
> >
> > Dear sir,
> > Please help me with the following error in the program
> > from __future__ import print_function
> > from ipywidgets import interact, interactive, fixed, interact_manual
> > import ipywidgets as widgets
> > import kwant
> > from matplotlib import pyplot
> > import numpy as np
> > from holoviews.core.options import Cycle
> > from types import SimpleNamespace
> >
> > def nanowire_chain():
> > lat = kwant.lattice.chain()
> > sys = kwant.Builder(kwant.TranslationalSymmetry(*lat.prim_vecs))
> >
> > def onsite(onsite, p):
> > return (2 * p.t - p.mu) * pauli.szs0 + p.B *
> (np.cos(p.phi)*pauli.s0sz+
> np.sin(p.phi)*np.sin(p.theta)*pauli.s0sy+np.sin(p.phi)*np.sin(p.theta)*pauli.s0sx)+
> p.delta * pauli.sxs0
> >
> > sys[lat(0)] = onsite
> >
> > def hop(site1, site2, p):
> > return -p.t * pauli.szs0 - .5j * p.alpha * pauli.szsx
> >
> > sys[kwant.HoppingKind((1,), lat)] = hop
> >
> > return sys
> >
> >
> > def spinful_kitaev_chain():
> > lat = kwant.lattice.chain()
> > sys = kwant.Builder(kwant.TranslationalSymmetry(*lat.prim_vecs))
> >
> > def onsite(site, p):
> > return (2 * p.t - p.mu) * pauli.szs0 + p.B * pauli.szsz
> >
> > sys[lat(0)] = onsite
> >
> > def hop(site1, site2, p):
> > return -p.t * pauli.szs0 - 1j * p.delta * pauli.sys0
> >
> > sys[kwant.HoppingKind((1,), lat)] = hop
> >
> > return sys
> >
> >
> > def find_gap(sys, p, resolution=1e-4):
> > """Find gap in a system by doing a binary search in energy."""
> >
> > # This tells us if there are modes at a certain energy.
> > if len(sys.modes(energy=0, args=[p])[0].momenta):
> > return 0
> >
> > gap = step = min(abs(kwant.physics.Bands(sys, args=[p])(k=0))) / 2
> > while step > resolution:
> > step /= 2
> > if len(sys.modes(gap, args=[p])[0].momenta):
> > gap -= step
> > else:
> > gap += step
> >
> > return gap
> >
> >
> > def spinorbit_band_gap(sys, mu, t, delta, Bs):
> > sys = sys.finalized()
> > alphas = [0.0, 0.1, 0.2, 0.3]
> > p = SimpleNamespace(mu=mu, t=t, delta=delta,theta=theta,phi=phi)
> >
> > def gap(sys, p, alpha, B):
> > p.alpha = alpha
> > p.B = B
> > return find_gap(sys, p)
> >
> > gaps = [gap(sys, p, alpha, B) for alpha in alphas for B in Bs]
> > gaps = np.reshape(gaps, (len(alphas), -1))
> > dims = {'kdims': [r'$B$'], 'vdims': ['Band gap']}
> > B_crit = holoviews.VLine(np.sqrt(p.delta**2 + p.mu**2))
> > plot = [holoviews.Curve((Bs, gaps[i]), label=r'$\alpha={}$'.format(
> > alphas[i]), **dims) * B_crit for i, alpha in enumerate(alphas)]
> > title = r'$\Delta={delta}$,
> $\mu={mu}$'.format(delta=np.round(p.delta, 2), mu=np.round(p.mu, 2))
> > style = {'xticks': [0, 0.1, 0.2, 0.3], 'yticks': [0, 0.05, 0.1],
> 'fig_size': 150}
> > plot = holoviews.Overlay(plot)
> > return plot(plot=style)
> >
> >
> > def title(p):
> > try:
> > title = r"$\alpha={alpha}$, $\mu={mu}$, $B={B}$,
> $\Delta={delta}$"
> > title = title.format(alpha=np.round(p.alpha, 2),
> >  mu=np.round(p.mu, 2),
> >  B=np.round(p.B, 2),
> >  delta=np.round(p.delta, 2))
> > except AttributeError:
> > title = r"$\mu={mu}$, $B={B}$, $\Delta={delta}$"
> > title = title.format(mu=np.round(p.mu, 2),
> >  B=np.round(p.B, 2),
> >  delta=np.round(p.delta, 2))
> > return title
> >
> > style = {'k_x': np.linspace(-1, 1, 101),
> >  'xdim': r'$k$',
> >  'ydim': r'$E/t$',
> >  'xticks': [-1, 0, 1],
> >  'yticks': [-1, 0, 1],
> >  'xlims': [-1, 1],
> >  'ylims': [-1.5, 1.5],
> >  'title': title}
> > sys = nanowire_chain()
> > p = SimpleNamespace(t=1, mu=0.1, delta=0.1,
> B=0.3,theta=np.pi/2,phi=np.pi/2)
> > alphas = np.linspace(0, 0.4, 10)
> > holoviews.HoloMap({alpha: spectrum(sys, p.update(alpha=alpha), **style)
> for alpha in alphas}, kdims=[r'$\alpha$'])
> >
> > c:\python36\lib\site-packages\kwant\linalg\lll.py:103: FutureWarning:
> `rcond` parameter will change to the default of machine precision times
> ``max(M, N)`` where M and N are the input matrix dimensions.
> > To use the future 

Re: [Kwant] seeking help

2018-08-31 Thread Anton Akhmerov
Dear Shyam Lochan Bora,

Right now your question is rather poorly formulated, and not suitable
for this mailing list. Please read this instruction on how to ask good
questions: https://stackoverflow.com/help/how-to-ask
Additionally, it appears that your problem is due the lack of the
Python knowledge, I recommend you to follow a Python course, or
otherwise learn the language more systematically.

Best regards,
Anton Akhmerov
On Fri, Aug 31, 2018 at 5:08 PM shyam lochan bora
 wrote:
>
> Dear sir,
> Please help me with the following error in the program
> from __future__ import print_function
> from ipywidgets import interact, interactive, fixed, interact_manual
> import ipywidgets as widgets
> import kwant
> from matplotlib import pyplot
> import numpy as np
> from holoviews.core.options import Cycle
> from types import SimpleNamespace
>
> def nanowire_chain():
> lat = kwant.lattice.chain()
> sys = kwant.Builder(kwant.TranslationalSymmetry(*lat.prim_vecs))
>
> def onsite(onsite, p):
> return (2 * p.t - p.mu) * pauli.szs0 + p.B * 
> (np.cos(p.phi)*pauli.s0sz+ 
> np.sin(p.phi)*np.sin(p.theta)*pauli.s0sy+np.sin(p.phi)*np.sin(p.theta)*pauli.s0sx)+
>  p.delta * pauli.sxs0
>
> sys[lat(0)] = onsite
>
> def hop(site1, site2, p):
> return -p.t * pauli.szs0 - .5j * p.alpha * pauli.szsx
>
> sys[kwant.HoppingKind((1,), lat)] = hop
>
> return sys
>
>
> def spinful_kitaev_chain():
> lat = kwant.lattice.chain()
> sys = kwant.Builder(kwant.TranslationalSymmetry(*lat.prim_vecs))
>
> def onsite(site, p):
> return (2 * p.t - p.mu) * pauli.szs0 + p.B * pauli.szsz
>
> sys[lat(0)] = onsite
>
> def hop(site1, site2, p):
> return -p.t * pauli.szs0 - 1j * p.delta * pauli.sys0
>
> sys[kwant.HoppingKind((1,), lat)] = hop
>
> return sys
>
>
> def find_gap(sys, p, resolution=1e-4):
> """Find gap in a system by doing a binary search in energy."""
>
> # This tells us if there are modes at a certain energy.
> if len(sys.modes(energy=0, args=[p])[0].momenta):
> return 0
>
> gap = step = min(abs(kwant.physics.Bands(sys, args=[p])(k=0))) / 2
> while step > resolution:
> step /= 2
> if len(sys.modes(gap, args=[p])[0].momenta):
> gap -= step
> else:
> gap += step
>
> return gap
>
>
> def spinorbit_band_gap(sys, mu, t, delta, Bs):
> sys = sys.finalized()
> alphas = [0.0, 0.1, 0.2, 0.3]
> p = SimpleNamespace(mu=mu, t=t, delta=delta,theta=theta,phi=phi)
>
> def gap(sys, p, alpha, B):
> p.alpha = alpha
> p.B = B
> return find_gap(sys, p)
>
> gaps = [gap(sys, p, alpha, B) for alpha in alphas for B in Bs]
> gaps = np.reshape(gaps, (len(alphas), -1))
> dims = {'kdims': [r'$B$'], 'vdims': ['Band gap']}
> B_crit = holoviews.VLine(np.sqrt(p.delta**2 + p.mu**2))
> plot = [holoviews.Curve((Bs, gaps[i]), label=r'$\alpha={}$'.format(
> alphas[i]), **dims) * B_crit for i, alpha in enumerate(alphas)]
> title = r'$\Delta={delta}$, $\mu={mu}$'.format(delta=np.round(p.delta, 
> 2), mu=np.round(p.mu, 2))
> style = {'xticks': [0, 0.1, 0.2, 0.3], 'yticks': [0, 0.05, 0.1], 
> 'fig_size': 150}
> plot = holoviews.Overlay(plot)
> return plot(plot=style)
>
>
> def title(p):
> try:
> title = r"$\alpha={alpha}$, $\mu={mu}$, $B={B}$, $\Delta={delta}$"
> title = title.format(alpha=np.round(p.alpha, 2),
>  mu=np.round(p.mu, 2),
>  B=np.round(p.B, 2),
>  delta=np.round(p.delta, 2))
> except AttributeError:
> title = r"$\mu={mu}$, $B={B}$, $\Delta={delta}$"
> title = title.format(mu=np.round(p.mu, 2),
>  B=np.round(p.B, 2),
>  delta=np.round(p.delta, 2))
> return title
>
> style = {'k_x': np.linspace(-1, 1, 101),
>  'xdim': r'$k$',
>  'ydim': r'$E/t$',
>  'xticks': [-1, 0, 1],
>  'yticks': [-1, 0, 1],
>  'xlims': [-1, 1],
>  'ylims': [-1.5, 1.5],
>  'title': title}
> sys = nanowire_chain()
> p = SimpleNamespace(t=1, mu=0.1, delta=0.1, B=0.3,theta=np.pi/2,phi=np.pi/2)
> alphas = np.linspace(0, 0.4, 10)
> holoviews.HoloMap({alpha: spectrum(sys, p.update(alpha=alpha), **style) for 
> alpha in alphas}, kdims=[r'$\alpha$'])
>
> c:\python36\lib\site-packages\kwant\linalg\lll.py:103: FutureWarning: `rcond` 
> parameter will change to the default of machine precision times ``max(M, N)`` 
> where M and N are the input matrix dimensions.
> To use the future default and silence this warning we advise to pass 
> `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
>   coefs = np.linalg.lstsq(vecs_orig.T, vecs.T)[0]
> c:\python36\lib\site-packages\kwant\linalg\lll.py:144: FutureWarning: `rcond` 
> parameter will change to the default of machine precision times ``max(M, N)`` 
> where M and N are 

[Kwant] seeking help

2018-08-31 Thread shyam lochan bora
Dear sir,
Please help me with the following error in the program
from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
import kwant
from matplotlib import pyplot
import numpy as np
from holoviews.core.options import Cycle
from types import SimpleNamespace

def nanowire_chain():
lat = kwant.lattice.chain()
sys = kwant.Builder(kwant.TranslationalSymmetry(*lat.prim_vecs))

def onsite(onsite, p):
return (2 * p.t - p.mu) * pauli.szs0 + p.B *
(np.cos(p.phi)*pauli.s0sz+
np.sin(p.phi)*np.sin(p.theta)*pauli.s0sy+np.sin(p.phi)*np.sin(p.theta)*pauli.s0sx)+
p.delta * pauli.sxs0

sys[lat(0)] = onsite

def hop(site1, site2, p):
return -p.t * pauli.szs0 - .5j * p.alpha * pauli.szsx

sys[kwant.HoppingKind((1,), lat)] = hop

return sys


def spinful_kitaev_chain():
lat = kwant.lattice.chain()
sys = kwant.Builder(kwant.TranslationalSymmetry(*lat.prim_vecs))

def onsite(site, p):
return (2 * p.t - p.mu) * pauli.szs0 + p.B * pauli.szsz

sys[lat(0)] = onsite

def hop(site1, site2, p):
return -p.t * pauli.szs0 - 1j * p.delta * pauli.sys0

sys[kwant.HoppingKind((1,), lat)] = hop

return sys


def find_gap(sys, p, resolution=1e-4):
"""Find gap in a system by doing a binary search in energy."""

# This tells us if there are modes at a certain energy.
if len(sys.modes(energy=0, args=[p])[0].momenta):
return 0

gap = step = min(abs(kwant.physics.Bands(sys, args=[p])(k=0))) / 2
while step > resolution:
step /= 2
if len(sys.modes(gap, args=[p])[0].momenta):
gap -= step
else:
gap += step

return gap


def spinorbit_band_gap(sys, mu, t, delta, Bs):
sys = sys.finalized()
alphas = [0.0, 0.1, 0.2, 0.3]
p = SimpleNamespace(mu=mu, t=t, delta=delta,theta=theta,phi=phi)

def gap(sys, p, alpha, B):
p.alpha = alpha
p.B = B
return find_gap(sys, p)

gaps = [gap(sys, p, alpha, B) for alpha in alphas for B in Bs]
gaps = np.reshape(gaps, (len(alphas), -1))
dims = {'kdims': [r'$B$'], 'vdims': ['Band gap']}
B_crit = holoviews.VLine(np.sqrt(p.delta**2 + p.mu**2))
plot = [holoviews.Curve((Bs, gaps[i]), label=r'$\alpha={}$'.format(
alphas[i]), **dims) * B_crit for i, alpha in enumerate(alphas)]
title = r'$\Delta={delta}$, $\mu={mu}$'.format(delta=np.round(p.delta,
2), mu=np.round(p.mu, 2))
style = {'xticks': [0, 0.1, 0.2, 0.3], 'yticks': [0, 0.05, 0.1],
'fig_size': 150}
plot = holoviews.Overlay(plot)
return plot(plot=style)


def title(p):
try:
title = r"$\alpha={alpha}$, $\mu={mu}$, $B={B}$, $\Delta={delta}$"
title = title.format(alpha=np.round(p.alpha, 2),
 mu=np.round(p.mu, 2),
 B=np.round(p.B, 2),
 delta=np.round(p.delta, 2))
except AttributeError:
title = r"$\mu={mu}$, $B={B}$, $\Delta={delta}$"
title = title.format(mu=np.round(p.mu, 2),
 B=np.round(p.B, 2),
 delta=np.round(p.delta, 2))
return title

style = {'k_x': np.linspace(-1, 1, 101),
 'xdim': r'$k$',
 'ydim': r'$E/t$',
 'xticks': [-1, 0, 1],
 'yticks': [-1, 0, 1],
 'xlims': [-1, 1],
 'ylims': [-1.5, 1.5],
 'title': title}
sys = nanowire_chain()
p = SimpleNamespace(t=1, mu=0.1, delta=0.1, B=0.3,theta=np.pi/2,phi=np.pi/2)
alphas = np.linspace(0, 0.4, 10)
holoviews.HoloMap({alpha: spectrum(sys, p.update(alpha=alpha), **style) for
alpha in alphas}, kdims=[r'$\alpha$'])

c:\python36\lib\site-packages\kwant\linalg\lll.py:103: FutureWarning:
`rcond` parameter will change to the default of machine precision
times ``max(M, N)`` where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass
`rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
  coefs = np.linalg.lstsq(vecs_orig.T, vecs.T)[0]
c:\python36\lib\site-packages\kwant\linalg\lll.py:144: FutureWarning:
`rcond` parameter will change to the default of machine precision
times ``max(M, N)`` where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass
`rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
  center_coords = np.array(np.round(np.linalg.lstsq(basis.T, vec)[0]), int)

---NameError
Traceback (most recent call
last) in ()  2 p =
SimpleNamespace(t=1, mu=0.1, delta=0.1,
B=0.3,theta=np.pi/2,phi=np.pi/2)  3 alphas = np.linspace(0, 0.4,
10)> 4 holoviews.HoloMap({alpha: spectrum(sys,
p.update(alpha=alpha), **style) for alpha in alphas},
kdims=[r'$\alpha$'])
NameError: name 'holoviews' is not defined


[Kwant] seeking help

2018-08-27 Thread shyam lochan bora
dear sir,
I am working on the assignment problem " tweaking the nanowire" from the
online course in topology in condensed matter
I am trying to apply the magnetic filed in the nanowire using the following
code but I am unable to plot the graph.Please help me in this regard.The
code is given below..
import kwant
import matplotlib
from matplotlib import pyplot
import numpy as np


def nanowire_chain():
lat = kwant.lattice.chain()
sys = kwant.Builder(kwant.TranslationalSymmetry(*lat.prim_vecs))

def onsite(onsite, p):
return (2 * p.t - p.mu) * pauli.szs0 + p.B *
(np.cos(p.phi)*pauli.s0sz+
np.sin(p.phi)*np.sin(p.theta)*pauli.s0sy+np.sin(p.phi)*np.sin(p.theta)*pauli.s0sx)+
p.delta * pauli.sxs0

sys[lat(0)] = onsite

def hop(site1, site2, p):
return -p.t * pauli.szs0 - .5j * p.alpha * pauli.szsx

sys[kwant.HoppingKind((1,), lat)] = hop

return sys


def spinful_kitaev_chain():
lat = kwant.lattice.chain()
sys = kwant.Builder(kwant.TranslationalSymmetry(*lat.prim_vecs))

def onsite(site, p):
return (2 * p.t - p.mu) * pauli.szs0 + p.B * pauli.szsz

sys[lat(0)] = onsite

def hop(site1, site2, p):
return -p.t * pauli.szs0 - 1j * p.delta * pauli.sys0

sys[kwant.HoppingKind((1,), lat)] = hop

return sys


def find_gap(sys, p, resolution=1e-4):
"""Find gap in a system by doing a binary search in energy."""

# This tells us if there are modes at a certain energy.
if len(sys.modes(energy=0, args=[p])[0].momenta):
return 0

gap = step = min(abs(kwant.physics.Bands(sys, args=[p])(k=0))) / 2
while step > resolution:
step /= 2
if len(sys.modes(gap, args=[p])[0].momenta):
gap -= step
else:
gap += step

return gap


def spinorbit_band_gap(sys, mu, t, delta, Bs):
sys = sys.finalized()
alphas = [0.0, 0.1, 0.2, 0.3]
p = SimpleNamespace(mu=mu, t=t, delta=delta,theta=theta,phi=phi)

def gap(sys, p, alpha, B):
p.alpha = alpha
p.B = B
return find_gap(sys, p)

gaps = [gap(sys, p, alpha, B) for alpha in alphas for B in Bs]
gaps = np.reshape(gaps, (len(alphas), -1))
dims = {'kdims': [r'$B$'], 'vdims': ['Band gap']}
B_crit = holoviews.VLine(np.sqrt(p.delta**2 + p.mu**2))
plot = [holoviews.Curve((Bs, gaps[i]), label=r'$\alpha={}$'.format(
alphas[i]), **dims) * B_crit for i, alpha in enumerate(alphas)]
title = r'$\Delta={delta}$, $\mu={mu}$'.format(delta=np.round(p.delta,
2), mu=np.round(p.mu, 2))
style = {'xticks': [0, 0.1, 0.2, 0.3], 'yticks': [0, 0.05, 0.1],
'fig_size': 150}
plot = holoviews.Overlay(plot)
return plot(plot=style)


def title(p):
try:
title = r"$\alpha={alpha}$, $\mu={mu}$, $B={B}$, $\Delta={delta}$"
title = title.format(alpha=np.round(p.alpha, 2),
 mu=np.round(p.mu, 2),
 B=np.round(p.B, 2),
 delta=np.round(p.delta, 2))
except AttributeError:
title = r"$\mu={mu}$, $B={B}$, $\Delta={delta}$"
title = title.format(mu=np.round(p.mu, 2),
 B=np.round(p.B, 2),
 delta=np.round(p.delta, 2))
return title

style = {'k_x': np.linspace(-1, 1, 101),
 'xdim': r'$k$',
 'ydim': r'$E/t$',
 'xticks': [-1, 0, 1],
 'yticks': [-1, 0, 1],
 'xlims': [-1, 1],
 'ylims': [-1.5, 1.5],
 'title': title}


Regards
Shyam Lochan Bora


Re: [Kwant] seeking help

2018-05-18 Thread Joseph Weston
Hi,


> Dear Sir,
>   
>      I want to model a bi2se3 nanowire in kwant to investigate the
> transport properties.
>    
> Please help me in this regard.

Your question may have several interpretations:

1. How do I make a tight-binding model for Bi2Se3 that includes all
relevant physics for my application?
2. How do I write down a (known) tight-binding model in Kwant, in general?
3. How do I write down a (known) tight-binding model in Kwant,
specifically for my nanowire setup?

If your question is really (1) then I am afraid that this mailing list
is probably not the right place
to be asking, as this mailing list is about Kwant-specific questions.

If your question is really (2) then I recommend going through the Kwant
tutorial [1].

If your question is really (3) then I recommend going through the Kwant
tutorial [1]. If there are
some intricacies in your model that you don't know how to express in
Kwant, then by all means
post back to this mailing list with your specific question.

Happy Kwanting,

Joe


[1]: https://kwant-project.org/doc/1/tutorial/