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)<ipython-input-3-9ff9219a759e> in <module>()      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

Reply via email to