In [1]:
import sys

sys.path.append("../../code")
from init_mooc_nb import *

init_notebook()
from holoviews.core.options import Cycle

%output size=120
pi_ticks = [(-np.pi, r"$-\pi$"), (0, "0"), (np.pi, r"$\pi$")]


def ts_modulated_wire(L=50):
    """Create an infinite wire with a periodic potential

    Chain lattice, one orbital per site.
    Returns kwant system.

    Arguments required in onsite/hoppings: 
        t, mu, mu_lead, A, phase

    The period of the potential is 2*pi/L.
    """
    omega = 2 * np.pi / L

    def onsite(site, p):
        x = site.pos[0]
        return 2 * p.t - p.mu + p.A * (np.cos(omega * x + p.phase) + 1)

    def hopping(site1, site2, p):
        return -p.t

    sym_lead = kwant.TranslationalSymmetry([-L])

    lat = kwant.lattice.chain()
    syst = kwant.Builder(sym_lead)

    syst[(lat(x) for x in range(L))] = onsite
    syst[lat.neighbors()] = hopping

    return syst


def modulated_wire(L=50, dL=10):
    """Create a pump. 

    Chain lattice, one orbital per site.
    Returns kwant system.

    L is the length of the pump,
    dL is the length of the clean regions next to the pump,
            useful for demonstration purposes.

    Arguments required in onsite/hoppings: 
        t, mu, mu_lead, A, omega, phase
    """

    def onsite(site, p):
        x = site.pos[0]
        return 2 * p.t - p.mu + p.A * (np.cos(p.omega * x + p.phase) + 1)

    lead_onsite = lambda site, p: 2 * p.t - p.mu_lead

    def hopping(site1, site2, p):
        return -p.t

    lat = kwant.lattice.chain()
    syst = kwant.Builder()

    syst[(lat(x) for x in range(L))] = onsite
    syst[lat.neighbors()] = hopping

    sym_lead = kwant.TranslationalSymmetry([-1])
    lead = kwant.Builder(sym_lead)
    lead[lat(0)] = lead_onsite
    lead[lat.neighbors()] = hopping

    syst.attach_lead(lead)
    syst.attach_lead(lead.reversed())

    return syst


def total_charge(value_array):
    """Calculate the pumped charge from the list of reflection matrices."""
    determinants = [np.linalg.det(r) for r in value_array]
    charge = np.cumsum(np.angle(np.roll(determinants, -1) / determinants))
    charge = charge - charge[0]
    return charge / (2 * np.pi)
Populated the namespace with:
np, matplotlib, kwant, holoviews, init_notebook, SimpleNamespace, pprint_matrix, scientific_number, pretty_fmt_complex, plt, pf, display_html
from code/edx_components:
MoocVideo, MoocDiscussion, MoocCheckboxesAssessment, MoocMultipleChoiceAssessment, MoocSelfAssessment
from code/functions:
spectrum, hamiltonian_array, h_k, pauli
Using kwant 1.4.2 and holoviews 1.13.2
Executed on 2021-03-06 at 14:57:39.690067.