Example #1
0
    def _refl_LR(self, d, E, params, complete=True):
        '''
        create a reflection matrix by rotating scattering matrices into a consistent basis. Note that while the kwant basis is arbitrary, kwant perserves independent modes for conservation laws.
        - kwant_smat: kwant.SMatrix object
        - d: either -1 or 1 for left/right scattering interface

        '''
        if self.interpolated(d):
            if len(params) > 0:
                print(
                    'warning: params passed to an interpolated function, values will be ignored'
                )
            if self._Ebounds[0] <= E <= self._Ebounds[1]:
                return self.interpolators[d](E)
            else:
                raise Exception(
                    f"Energy {E} is outside bounds ({self._Ebounds})")

        if self.systs[d] is None:
            raise Exception("Right system is not defined")

        try:
            ksmat = kwant.smatrix(self.systs[d], E, params=params)
        except ValueError:
            ksmat = kwant.smatrix(
                self.systs[d], E + 1e-4,
                params=params)  # this is to counter a bug in kwant

        lead_num = 1 if d == L else 0
        modes = ksmat.lead_info[lead_num].wave_functions
        wf_in, wf_out = np.split(modes, 2, axis=1)
        krmat = ksmat.submatrix(lead_num, lead_num)

        return SystemInfo._rotate_smat(krmat, wf_in, wf_out)
Example #2
0
def t_wiger(sys, en, df):
    s1 = kwant.smatrix(sys, en).data
    s2 = kwant.smatrix(sys, en + df).data
    #    tw=s2.transpose().conj()@(s2-s1)/df
    #    return np.trace(tw)
    p1 = np.angle(np.linalg.det(s1))
    p2 = np.angle(np.linalg.det(s2))
    return (p2 - p1) / df
Example #3
0
def t_mode(sys,e1,df,o,i):   # only one mode case
    g=kwant.smatrix(sys,e1)
    g1=kwant.smatrix(sys,e1+df)
    try:
        gf=g.submatrix(o,i)
        u0, s0, vh0=np.linalg.svd(gf, full_matrices=True, compute_uv=True)
        gf1=g1.submatrix(o,i)
        u1, s1, vh1=np.linalg.svd(gf1, full_matrices=True, compute_uv=True)        
        t=np.diag(eigentime(u0,u1,vh0,vh1,df))  # time ,not dos
    except:
        t=0  
    return t
Example #4
0
def calc_G_11_12_S_A(sys_,
                     p,
                     ppar,
                     i,
                     var_name,
                     elapsed_time,
                     biasenergies_asymm=False):
    """	Computing conductance. Returns G_11.

		Parameters
		----------
		sys_ :  	finalized system with all parts and leads.
		p :  		same parameters as are given to the functions making up the hamiltonian (which is also the parameters given to the kwant.Hamiltonian method).
		energies : 	computed eigenenergies in main().
		biasenergies_symm : 	is True if an odd number of biasenergies where every negative value has a corresponding positive value at the same number of places from the value zero, and vice versa. E.g. biasenergies = -3,-2,-1,0,1,2,3. Is False by default. User needs to ensure that biasenergies are "symmetric" like this before entering biasenergies_symm=True as input.
	
		Notes
		-----
		 - if ppar.Sclead = True, SC lead is attached to the middle region. The lead index for the SC lead is 2, because it is atted after the normal leads. Thus, use index 2 if wanting to access the SC lead values in e.g. the smatrix.
	"""

    print("%.0f'th %s-value, Dt=%.1f" % (i, var_name, elapsed_time))
    G_11 = []
    G_12 = []

    if ppar.oneNLead == True:  # One lead means no nonlocal conductance is to be calculated
        for biasenergy in p.biasenergies:
            smatrix = kwant.smatrix(sys_, biasenergy,
                                    args=[p])  #Takes longer for larger system

            G_11.append(2 - \
                smatrix.transmission((0,0),(0,0)) + \
                smatrix.transmission((0,1),(0,0)))
    else:
        for biasenergy in p.biasenergies:
            smatrix = kwant.smatrix(sys_, biasenergy,
                                    args=[p])  #Takes longer for larger system
            # New in kwant version 1.4: args=[p]-->params=[p] inside kwant.smatrix

            G_11.append(2 - \
                smatrix.transmission((0,0),(0,0)) + \
                smatrix.transmission((0,1),(0,0)))

            G_12.append( - smatrix.transmission((0,0),(1,0)) + \
                smatrix.transmission((0,1),(1,0)))

    G_11_S = [(G_11[i] + G_11[-1 - i]) / 2. for i in range(0, len(G_11))]
    G_11_A = [(G_11[i] - G_11[-1 - i]) / 2. for i in range(0, len(G_11))]
    G_12_S = [(G_12[i] + G_12[-1 - i]) / 2. for i in range(0, len(G_12))]
    G_12_A = [(G_12[i] - G_12[-1 - i]) / 2. for i in range(0, len(G_12))]

    return G_11, G_12, G_11_S, G_11_A, G_12_S, G_12_A
Example #5
0
def test_multiterminal_input():
    """Input checks for two_terminal_shotnoise"""

    syst = twoterminal_system()
    syst.attach_lead(syst.leads[0].builder)
    sol = kwant.smatrix(syst.finalized(), out_leads=[0], in_leads=[0])
    raises(ValueError, two_terminal_shotnoise, sol)
def ConductanceAndTV(args_dict, junction):
    voltage = args_dict['voltage']
    S_matrix = kwant.smatrix(junction, voltage, check_hermiticity=False)
    R = S_matrix.submatrix(0, 0)
    if (args_dict['multiband'] == 0):
        G = 2.0
        for (i, j) in [(0, 0), (0, 1), (1, 0), (1, 1)]:
            G = G - abs(R[i, j])**2 + abs(R[2 + i, j])**2
    else:
        G = 4.0
        for (i, j) in [(0, 0), (0, 1), (1, 0), (1, 1)]:
            G = G - abs(R[i, j])**2 - abs(R[2 + i, j])**2 - abs(
                R[2 + i, 2 + j])**2 - abs(R[i, 2 + j])**2 + abs(
                    R[4 + i, j])**2 + abs(R[4 + i + 2, j])**2 + abs(
                        R[4 + i, j + 2])**2 + abs(R[4 + i + 2, j + 2])**2

    tv0 = LA.det(R)
    basis_wf = S_matrix.lead_info[0].wave_functions
    normalize_dict = {0: 0, 1: 0, 2: 3, 3: 3, 4: 0, 5: 0, 6: 3, 7: 3}
    phase_dict = {}
    for n in range(8):
        m = normalize_dict[n]
        phase_dict[n] = (-1)**m * basis_wf[m, n] / abs(basis_wf[m, n])

    tv = tv0 * np.conjugate(
        phase_dict[0] * phase_dict[1] * phase_dict[2] * phase_dict[3]
    ) * phase_dict[4] * phase_dict[5] * phase_dict[6] * phase_dict[7]

    return G, tv
Example #7
0
def plot_conductance_vs_disorder(bar, energy):
    probabilities = np.linspace(0, 0.1, 20)
    disorder = 500
    conductances = []
    errors = []
    
    for counter, prob in enumerate(probabilities):
        print(counter),
        cond = []
        n_sim = 100
        for i in range(n_sim):
            seed = str(np.random.rand())
            smatrix = kwant.smatrix(bar, energy, args = [disorder, prob, seed])
            cond.append(smatrix.transmission(1, 0))
        conductances.append(np.average(cond))
        errors.append(np.std(cond))

    ax = plt.subplot(111)
#    ax.set_xscale('log')
    ax.errorbar(probabilities, conductances, yerr=errors)
#    ax.set_xlim(xmin=1)
    ax.set_ylim(ymin=-0.1, ymax=1.1)
    plt.show()

    out = open('conductances_plot', 'wb')
    np.savez(out, probabilities=probabilities, conductances=conductances, errors=errors)
def con(n):    
    en=energies[n]
    gf=kwant.greens_function(sys,en).submatrix(1,0)
    t=kwant.smatrix(sys,en).transmission(1,0) 
    myDict = {'gf':gf,'t':t}
    completeName = os.path.join('E:/fano/15/', str(n)+".mat")
    sio.savemat(completeName,myDict,oned_as='row') 
def trans_all(sys, e1):
    t = kwant.smatrix(sys, e1)
    t10 = t.transmission(1, 0)
    t01 = t.transmission(0, 1)
    t00 = t.transmission(0, 0)
    t11 = t.transmission(1, 1)
    return np.array([t10, t01, t00, t11])
def getSMatrix(parameters, junction):
    vBias = parameters['vBias']
    sMatrix = kwant.smatrix(junction,
                            parameters['vBias'],
                            check_hermiticity=False)
    R = sMatrix.data
    basis_wf = sMatrix.lead_info[0].wave_functions

    normalize_dict = {0: 0, 1: 0, 2: 3, 3: 3, 4: 0, 5: 0, 6: 3, 7: 3}
    phase_dict = {}

    for n in range(8):
        m = normalize_dict[n]
        phase_dict[n] = (-1)**m * basis_wf[m, n] / abs(basis_wf[m, n])

    fixphase = np.conjugate(
        phase_dict[0] * phase_dict[1] * phase_dict[2] * phase_dict[3]
    ) * phase_dict[4] * phase_dict[5] * phase_dict[6] * phase_dict[7]
    R = R
    TVL, TVR = LA.det(R[:4, :4]), LA.det(R[4:, 4:])
    assert (np.imag(TVL) < 1e-10 and np.imag(TVR) < 1e-10
            ), 'TVL and TVR are not real with the imag=({:e},{:e})'.format(
                np.imag(TVL), np.imag(TVR))
    TVL, TVR = np.real((fixphase * TVL, fixphase * TVR))
    return R, TVL, TVR
Example #11
0
def test_opservables_scattering():
    # Disordered system with two ordered strips on the left/right.  We check
    # that the current on the right of the disorder due to incoming mode `m` is
    # equal to Σ_n |t_nm|^2. Similarly the current on the left of the disorder
    # is checked against 1 - Σ_n |r_nm|^2

    N = 10
    lat, syst = _random_square_system(N)
    # add extra sites so we can calculate the current in a region
    # where there is no backscattering
    syst[(lat(i, j) for i in [-1, N] for j in range(N))] = 2
    syst[((lat(-1, j), lat(0, j)) for j in range(N))] = -1
    syst[((lat(N-1, j), lat(N, j)) for j in range(N))] = -1

    lat, lead = _perfect_lead(3)
    syst.attach_lead(lead)
    syst.attach_lead(lead.reversed())
    fsyst = syst.finalized()

    # currents on the left and right of the disordered region
    J_right = ops.Current(fsyst, where=[(lat(N, j), lat(N-1, j))
                                        for j in range(3)])
    J_left = ops.Current(fsyst, where=[(lat(0, j), lat(-1, j))
                                       for j in range(3)])

    smatrix = kwant.smatrix(fsyst, energy=1.0)
    t = smatrix.submatrix(1, 0).T  # want to iterate over the columns
    r = smatrix.submatrix(0, 0).T  # want to iterate over the columns
    wfs = kwant.wave_function(fsyst, energy=1.0)(0)
    for rv, tv, wf in zip(r, t, wfs):
        _test(J_right, wf, reduced_val=np.sum(np.abs(tv)**2))
        _test(J_left, wf, reduced_val=(1 - np.sum(np.abs(rv)**2)))
Example #12
0
    def conductances(
        self,
        bValues=np.linspace(0, 1.0, 201),
        energies=[1e-6 * i for i in range(-120, 120)],
    ):
        syst = NISIN(self.parameters)
        data = []
        critB = 0
        for energy in tqdm(
                energies,
                desc="Cond",
        ):
            cond = []
            for b in bValues:
                self.parameters["B"] = b
                smatrix = kwant.smatrix(syst, energy, params=self.parameters)
                conduct = (
                    smatrix.submatrix((0, 0), (0, 0)).shape[0]  # N
                    - smatrix.transmission((0, 0), (0, 0))  # R_ee
                    + smatrix.transmission((0, 1), (0, 0))  # R_he
                )
                cond.append(conduct)
                if (np.isclose(energy, 0, rtol=1e-6) and critB == 0
                        and np.abs(2 - conduct) < 0.01):
                    critB = b
            data.append(cond)

        outcome = dict(B=bValues, BiasV=energies, Cond=data, CritB=critB)
        return outcome
def conductance(syst, energies):
    # Compute conductance
    data = []
    for energy in energies:
        smatrix = kwant.smatrix(syst, energy)
        data.append(smatrix.transmission(1, 0))
    return data
Example #14
0
def spec(cishu):
    #    t=dnlr.tranmission_DIY(sys,ens[cishu])
    t = kwant.smatrix(sys, ens[cishu]).submatrix(1, 0)
    myDict = {'t': t}
    completeName = os.path.join('E:/channel time/63/' + str(cishu) +
                                '.mat')  #7_tracet
    sio.savemat(completeName, myDict, oned_as='row')
def transmission(a,cishu):
    salt=np.random.randint(10000)
#    salt=5
    sys = make_cuboid(a,str(salt))
    gf_mode = kwant.smatrix(sys, en)
    T=gf_mode.transmission(1,0)
    return T
Example #16
0
def test_multiterminal_input():
    """Input checks for two_terminal_shotnoise"""

    sys = twoterminal_system()
    sys.attach_lead(sys.leads[0].builder)
    sol = kwant.smatrix(sys.finalized(), out_leads=[0], in_leads=[0])
    assert_raises(ValueError, two_terminal_shotnoise, sol)
Example #17
0
def andreev_conductance(syst, params, E):
    """The Andreev conductance is N - R_ee + R_he."""
    smatrix = kwant.smatrix(syst, energy=E, params=params)
    r_ee = smatrix.transmission((0, 0), (0, 0))
    r_he = smatrix.transmission((0, 1), (0, 0))
    N_e = smatrix.submatrix((0, 0), (0, 0)).shape[0]
    return N_e - r_ee + r_he
Example #18
0
def plot_conductance(syst, energies, L_barrier=100, pot=0, shift=0):
    def potential_barrier(x, y):
        if abs(x) < L_barrier / 2:
            return -(pot - shift)
        else:
            return 0

    params = dict(A=364.5,
                  B=-686.0,
                  D=-512.0,
                  M=-10.0,
                  C=potential_barrier,
                  C_const=-shift)

    # Compute conductance
    data = []
    for energy in energies:
        smatrix = kwant.smatrix(syst, energy, params=params)
        data.append(smatrix.transmission(1, 0))

    plt.figure()
    plt.plot(energies, data, linestyle='', marker='o', color='red')
    plt.xlabel(r"E$_F$ [meV]")
    plt.ylabel(r"conductance $[e^2/h]$")
    plt.show()
Example #19
0
def test_ModesLead_and_SelfEnergyLead():
    lat = builder.SimpleSiteFamily()
    hoppings = [builder.HoppingKind((1, 0), lat),
                builder.HoppingKind((0, 1), lat)]
    rng = Random(123)
    L = 5
    t = 1
    energies = [0.9, 1.7]

    syst = builder.Builder()
    for x in range(L):
        for y in range(L):
            syst[lat(x, y)] = 4 * t + rng.random() - 0.5
    syst[hoppings] = -t

    # Attach a lead from the left.
    lead = builder.Builder(VerySimpleSymmetry(-1))
    for y in range(L):
        lead[lat(0, y)] = 4 * t
    lead[hoppings] = -t
    syst.attach_lead(lead)

    # Make the right lead and attach it.
    lead = builder.Builder(VerySimpleSymmetry(1))
    for y in range(L):
        lead[lat(0, y)] = 4 * t
    lead[hoppings] = -t
    syst.attach_lead(lead)

    fsyst = syst.finalized()
    ts = [kwant.smatrix(fsyst, e).transmission(1, 0) for e in energies]

    # Replace lead with it's finalized copy.
    lead = fsyst.leads[1]
    interface = [lat(L-1, lead.sites[i].tag[1]) for i in range(L)]

    # Re-attach right lead as ModesLead.
    syst.leads[1] = builder.ModesLead(lead.modes, interface)
    fsyst = syst.finalized()
    ts2 = [kwant.smatrix(fsyst, e).transmission(1, 0) for e in energies]
    assert_almost_equal(ts2, ts)

    # Re-attach right lead as SelfEnergyLead.
    syst.leads[1] = builder.SelfEnergyLead(lead.selfenergy, interface)
    fsyst = syst.finalized()
    ts2 = [kwant.greens_function(fsyst, e).transmission(1, 0) for e in energies]
    assert_almost_equal(ts2, ts)
Example #20
0
def calculate_transmission(W, params, nsamples):

  def disorder(x,y):
    return np.random.uniform(-W/2, W/2)
  
  params['V'] = disorder

  t1 = []
  t2 = []
  t3 = []
  for k in range(nsamples):
    print_t("Calculating transmissions for W={0}, sample {1}".format(W, k))
    t1.append(kwant.smatrix(syst, energy=e_1, params=params).transmission(1,0))
    t2.append(kwant.smatrix(syst, energy=e_2, params=params).transmission(1,0))
    t3.append(kwant.smatrix(syst, energy=e_3, params=params).transmission(1,0))

  return [[np.mean(t1), np.std(t1)], [np.mean(t2), np.std(t2)], [np.mean(t3), np.std(t3)]]
Example #21
0
def spec(cishu):
    #    t=dn2.tranmission_DIY(sys,ens[cishu])
    t = kwant.smatrix(sys, ens[cishu]).submatrix(1,
                                                 0)  #,check_hermiticity=False
    myDict = {'t': t}
    completeName = os.path.join('E:/channel time/102/' + str(cishu) +
                                '.mat')  #7_tracet
    sio.savemat(completeName, myDict, oned_as='row')
Example #22
0
def plot_local_dos(bar, energy, disorder, probability, seed):
    smatrix = kwant.smatrix(bar, energy, args = [disorder, probability, seed])
    print('seed : {}, transmission: {}'.format(seed, smatrix.transmission(1, 0)))

    local_dos = kwant.ldos(bar, energy=energy, args=[disorder, probability, seed])
    kwant.plot(bar, #site_color = -local_dos,
               site_color=np.minimum(-np.log(local_dos), 10*np.ones_like(local_dos)),
               hop_color='white', cmap='afmhot')
Example #23
0
def conductance_matrix(sys, energy, args=()):
    n = len(sys.leads)
    s = kwant.smatrix(sys, energy, args)
    cond = np.array([[s.transmission(i, j) for j in range(n)]
                     for i in range(n)])
    # Correct the reflection blocks, so that rows and columns sum to zero.
    cond -= np.diag(cond.sum(axis=0))
    return cond
Example #24
0
def test_pickling():
    syst = kwant.Builder()
    lead = kwant.Builder(symmetry=kwant.TranslationalSymmetry([1.]))
    lat = kwant.lattice.chain()
    syst[lat(0)] = syst[lat(1)] = 0
    syst[lat(0), lat(1)] = 1
    lead[lat(0)] = syst[lat(1)] = 0
    lead[lat(0), lat(1)] = 1
    syst.attach_lead(lead)
    syst.attach_lead(lead.reversed())
    syst_copy1 = copy.copy(syst).finalized()
    syst_copy2 = pickle.loads(pickle.dumps(syst)).finalized()
    syst = syst.finalized()
    syst_copy3 = copy.copy(syst)
    syst_copy4 = pickle.loads(pickle.dumps(syst))
    s = kwant.smatrix(syst, 0.1)
    for other in (syst_copy1, syst_copy2, syst_copy3, syst_copy4):
        assert np.all(kwant.smatrix(other, 0.1).data == s.data)
Example #25
0
def test_pickling():
    syst = kwant.Builder()
    lead = kwant.Builder(symmetry=kwant.TranslationalSymmetry([1.]))
    lat = kwant.lattice.chain()
    syst[lat(0)] = syst[lat(1)] = 0
    syst[lat(0), lat(1)] = 1
    lead[lat(0)] = syst[lat(1)] = 0
    lead[lat(0), lat(1)] = 1
    syst.attach_lead(lead)
    syst.attach_lead(lead.reversed())
    syst_copy1 = copy.copy(syst).finalized()
    syst_copy2 = pickle.loads(pickle.dumps(syst)).finalized()
    syst = syst.finalized()
    syst_copy3 = copy.copy(syst)
    syst_copy4 = pickle.loads(pickle.dumps(syst))
    s = kwant.smatrix(syst, 0.1)
    for other in (syst_copy1, syst_copy2, syst_copy3, syst_copy4):
        assert np.all(kwant.smatrix(other, 0.1).data == s.data)
Example #26
0
def s_matrix(sys, energies):
    """Compute the S-Matrix as a function of energy.
    Return a list of s of type
    <class 'kwant.solvers.common.SMatrix'>.
    """
    s = []
    for energy in energies:
        s.append(kwant.smatrix(sys, energy))
    return s
def trans_spin_up(cishu):
    en = 0.5
    salt = cishu + random.random() * 100
    sys = make_system2(width, length, str(salt))
    tm = kwant.smatrix(sys, en)
    t10_uu = tm.transmission((1, 0), (0, 0))
    #    t10_du=tm.transmission((1, 1), (0, 0))
    #    t00_uu=tm.transmission((0, 0), (0, 0))
    #    t00_du=tm.transmission((0, 1), (0, 0))
    return np.array([t10_uu, salt])  #t10_du,t00_uu,t00_du,
Example #28
0
def plot_conductance(syst, energies):  # Compute conductance
    data = []
    for energy in energies:
        smatrix = kwant.smatrix(syst, 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()
Example #29
0
def main():
    sys = System((10, 5), 1)
    energies = [0.04 * i for i in xrange(100)]
    data = [kwant.smatrix(sys, energy).transmission(1, 0)
            for energy in energies]

    pyplot.plot(energies, data)
    pyplot.xlabel("energy [in units of t]")
    pyplot.ylabel("conductance [in units of e^2/h]")
    pyplot.show()
Example #30
0
def plot_conductance(sys, energies):
    # Compute conductance
    data = []
    for energy in energies:
        smatrix = kwant.smatrix(sys, energy)
        # Conductance is N - R_ee + R_he
        data.append(
            smatrix.submatrix(0, 0).shape[0] - smatrix.transmission(0, 0) +
            smatrix.transmission(1, 0))
    pyplot.plot(data)
Example #31
0
def test_twoterminal():
    """Shot noise in a two-terminal conductor"""

    fsys = twoterminal_system().finalized()

    sol = kwant.smatrix(fsys)
    t = sol.submatrix(1, 0)
    Tn = np.linalg.eigvalsh(np.dot(t, t.conj().T))
    noise_should_be = np.sum(Tn * (1 - Tn))

    assert_almost_equal(noise_should_be, two_terminal_shotnoise(sol))
Example #32
0
def stat_wf(salt):
    wf_spec=np.zeros((f_num,length),dtype=complex)
    t_spec=[]
    sys=od.make_system(length,dis,str(salt))
    sys=sys.finalized()
    for i in range(f_num):
        wf_spec[i,]=kwant.wave_function(sys,ens[i])(0)
        t_spec.append(kwant.smatrix(sys,ens[i]).transmission(1,0))
    myDict = {'wf':wf_spec,'t':t_spec} 
    completeName = os.path.join('E:/pt/5/',str(salt)+'.mat')
    sio.savemat(completeName,myDict,oned_as='row') 
Example #33
0
def test_twoterminal():
    """Shot noise in a two-terminal conductor"""

    fsyst = twoterminal_system().finalized()

    sol = kwant.smatrix(fsyst)
    t = sol.submatrix(1, 0)
    Tn = np.linalg.eigvalsh(np.dot(t, t.conj().T))
    noise_should_be = np.sum(Tn * (1 - Tn))

    assert_almost_equal(noise_should_be, two_terminal_shotnoise(sol))
Example #34
0
def plot_conductance(sys, energies):
    # Compute transmission as a function of energy
    data = []
    for energy in energies:
        smatrix = kwant.smatrix(sys, energy)
        data.append(smatrix.transmission(0, 1))

    pyplot.figure()
    pyplot.plot(energies, data)
    pyplot.xlabel("energy [t]")
    pyplot.ylabel("conductance [e^2/h]")
    pyplot.show()
def plot_conductance(sys, energies):
    # Compute conductance
    data = []
    for energy in energies:
        smatrix = kwant.smatrix(sys, 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()
def plot_conductance(sys, energies):
    
    data = []
    for energy in energies:
        smatrix = kwant.smatrix(sys, energy)
        data.append(smatrix.transmission(2, 0)+smatrix.transmission(3, 0)+smatrix.transmission(2, 1)+smatrix.transmission(3, 1))

    pyplot.figure()
    pyplot.plot(energies, data)
    pyplot.xlabel("energy [t]")
    pyplot.ylabel("conductance [e^2/h]")
    pyplot.show()
def plot_conductance(i,j):
    # Compute conductance
    wb=Workbook()
    sh=wb.active
    sh.title="ads"    

    syst = make_system(i,j,acos(1/sqrt(3)),40,40)
    smatrix = kwant.smatrix(syst, 0, args=["=.="])
    sh.cell(row=i+1,column=1).value=i
    #sh.cell(row=i+1,column=2).value=smatrix.transmission(3,0)
    sh.cell(row=i+1,column=j+2).value=smatrix.transmission(0,3)
    wb.save("2_node_Weyl"+str(i)+"_"+str(j)+".xlsx")
Example #38
0
def calculate_conductance(sys,Ef, out_leads, in_leads, pars):
    """
    :param
            sys : 利用kwant产生的体系
            EF : 费米能的大小
            out_leads : 电子出射的导线 序列或者是一个整数
            in_leads : 入射的导线 序列或者是一个整数
    :return
            T: kwant.solvers.common.SMatrix ,如果只有单个入射出射导线的话就是一个实数
    """
    smatrix = kwant.smatrix(sys, Ef, args=[pars] )
    T = smatrix.transmission(out_leads, in_leads)
    return T
Example #39
0
def plot_conductance(sys, energy, welldepths):
#HIDDEN_BEGIN_sqvr

    # Compute conductance
    data = []
    for welldepth in welldepths:
        smatrix = kwant.smatrix(sys, energy, args=[-welldepth])
        data.append(smatrix.transmission(1, 0))

    pyplot.figure()
    pyplot.plot(welldepths, data)
    pyplot.xlabel("well depth [t]")
    pyplot.ylabel("conductance [e^2/h]")
    pyplot.show()
Example #40
0
def plot_conductance(syst, energy, fluxes):
    # compute conductance

    normalized_fluxes = [flux / (2 * pi) for flux in fluxes]
    data = []
    for flux in fluxes:
        smatrix = kwant.smatrix(syst, energy, args=[flux])
        data.append(smatrix.transmission(1, 0))

    pyplot.figure()
    pyplot.plot(normalized_fluxes, data)
    pyplot.xlabel("flux [flux quantum]")
    pyplot.ylabel("conductance [e^2/h]")
    pyplot.show()
def plot_conductance(syst, energies):
    # Compute conductance
    data = []
    for energy in energies:
        smatrix = kwant.smatrix(syst, energy)
        # Conductance is N - R_ee + R_he
        data.append(smatrix.submatrix(0, 0).shape[0] -
                    smatrix.transmission(0, 0) +
                    smatrix.transmission(1, 0))
#HIDDEN_END_jbjt

    pyplot.figure()
    pyplot.plot(energies, data)
    pyplot.xlabel("energy [t]")
    pyplot.ylabel("conductance [e^2/h]")
    pyplot.show()
Example #42
0
def transport(ht,energy):
  """Define a Kwant heterostructure using an input one"""
  # create kwant objects
  lat = kwant.lattice.square()
  sys = kwant.Builder() 
  # create the two leads
  sym_L = kwant.TranslationalSymmetry((-1, 0))
  sym_R = kwant.TranslationalSymmetry((1, 0))
  lead_L = kwant.Builder(sym_L) # create the lead
  lead_R = kwant.Builder(sym_R) # create the lead
  lead_R[lat(0,0)] = ht.right_intra
  lead_L[lat(0,0)] = ht.left_intra
  lead_R[lat(0,0),lat(1,0)] = ht.right_inter
#  lead_R[lat.neighbors()] = ht.right_inter
  lead_L[lat(0,0),lat(-1,0)] = ht.left_inter
#  lead_L[lat.neighbors()] = ht.left_inter
  # The scattering region will be three sites
  # add the onsites of the leads
  if not ht.block_diagonal: # dense scattering region
    # and create the coupling to the central region
    # create central and scattering regions
    sys[lat(-1,0)] = ht.left_intra
    sys[lat(1,0)] = ht.right_intra
    sys[lat(0,0)] = ht.central_intra
    sys[lat(0,0), lat(-1,0)] = ht.left_coupling
    sys[lat(0,0), lat(1,0)] = ht.right_coupling
    # now attach the two leads
    sys.attach_lead(lead_L, lat(-1, 0))
    sys.attach_lead(lead_R, lat(1, 0))
  else: # block diagonal form
    nb = len(ht.central_intra)
    sys[lat(-1,0)] = ht.left_intra
    sys[lat(nb,0)] = ht.right_intra
    for i in range(nb):
      sys[lat(i,0)] = ht.central_intra[i][i]
    for i in range(nb-1):
      sys[lat(i,0),lat(i+1,0)] = ht.central_intra[i][i+1]
    sys[lat(0,0), lat(-1,0)] = ht.left_coupling
    sys[lat(nb-1,0), lat(nb,0)] = ht.right_coupling
    sys.attach_lead(lead_L, lat(-1, 0))
    sys.attach_lead(lead_R, lat(nb, 0))
  sys = sys.finalized()
#  kwant.plot(sys)
  smatrix = kwant.smatrix(sys, energy)
  return smatrix.transmission(1, 0)
Example #43
0
def test_qhe(W=16, L=8):
    def central_region(pos):
        x, y = pos
        return -L < x < L and abs(y) < W - 5.5 * math.exp(-x**2 / 5**2)

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

    syst[lat.shape(central_region, (0, 0))] = onsite
    syst[lat.neighbors()] = hopping

    lead = kwant.Builder(kwant.TranslationalSymmetry((-1, 0)))
    lead[(lat(0, y) for y in range(-W + 1, W))] = 4
    lead[lat.neighbors()] = hopping

    syst.attach_lead(lead)
    syst.attach_lead(lead.reversed())
    syst = syst.finalized()

    #### The following chunk of code can be uncommented to visualize the
    #### conductance plateaus.
    # from matplotlib import pyplot
    # import numpy
    # reciprocal_phis = numpy.linspace(0.1, 7, 200)
    # conductances = []
    # for phi in 1 / reciprocal_phis:
    #     smatrix = kwant.smatrix(syst, 1.0, [phi, ""])
    #     conductances.append(smatrix.transmission(1, 0))
    # pyplot.plot(reciprocal_phis, conductances)
    # pyplot.show()

    for r_phis, T_nominal, max_err in [((1.3, 2.1), 1, 1e-7),
                                       ((3.2, 3.7), 2, 1e-3),
                                       ((5.2, 5.5), 3, 1e-1)]:
        for r_phi in r_phis:
            args = (1.0 / r_phi, "")
            pc = syst.precalculate(1.0, args, what='all')
            for result in [kwant.smatrix(pc, 1, args),
                           kwant.solvers.default.greens_function(pc, 1, args)]:
                assert abs(T_nominal - result.transmission(1, 0)) < max_err
Example #44
0
 def calc_transmission(system, energy, v=None):
     args = [v] if v is not None else ()
     smatrix = kwant.smatrix(system, energy, args=args)
     return smatrix.transmission(1, 0)
Example #45
0
    def transmission(self, start_energy, end_energy, number_of_points=500,
                     print_to_commandline=True):
        """Calculate transmission through system.

        Calculates the transmission in `number_of_points` equidistant points
        on the intervall [`start_energy`, `end_energy`).

        
        Parameters
        ----------
        wire : :class:`~garn.Wire2D` or :class:`~garn.Wire3D`
            The wire model for with the transmission is calculated and
            energy and transmission attributes are changed.
        start_energy : float
        end_energy : float, optional
        number_of_points : int, optional
        print_to_commandline : bool
            If true the resulting transmission energy pairs are printed
            in the terminal. (Default Ture beacuse good for monitoring progress)

        Notes
        -----
        The energy is given in units of :math:`t`. 

        .. math::

            t = \dfrac{\hbar^2}{2 m_e^* step\_length^2}

        :math:`m_e^*` is the effective mass of the semiconduction and step_length
        is the discretization step that is set on initialization of
        :class:`~garn.Wire2D` and :class:`~garn.Wire3D` instanses.

        The transmission is given in units of :math:`\dfrac{e^2}{\hbar}`. 

        The function changes the attributes energy and transmission of
        *wire* and saves to the file "data-" + `wire.identifier`. If the
        transmission function have been called before or the wire.energies
        attribute is non-empty the
        :meth:`~garn.system_wide._energy_exist_dialog` is called asking
        what to do.

        
        """

        # handel case when the wire has calculated before
        if self.energies != []:
            if (not _energy_exist_dialog()):
                return

        intervall_length = end_energy - start_energy
        stepsize = intervall_length / float(number_of_points)
        start_step = int(start_energy / float(stepsize))
        end_step = int(end_energy / float(stepsize))

        self.energies = [stepsize * i for i in range(start_step, end_step)]
        self.transmission_data = []
            
        in_leads, out_leads = self._in_out_nums()

        if print_to_commandline:
            print("Transmission_Data calculated for energies [t]: ")
            
        for en in self.energies:
            smatrix = kwant.smatrix(self.sys, en, in_leads=in_leads,
                                        out_leads=out_leads) 
            con_tot = 0
            for i in range(0,len(in_leads)):
                for j in range(len(in_leads), len(in_leads) +
                               len(out_leads)):
                    con = smatrix.transmission(j, i)
                    con_tot = con_tot + con
                    #print(str(i) + "-" + str(j) + "= " + str(con)) 
            self.transmission_data.append(con_tot)
            self._save_to_file(en, con_tot)

            if print_to_commandline:
                print(str(en) + " " + str(con_tot))
def main():
    syst = make_system(100)
    print(kwant.smatrix(syst, 1.1, [0.1]).transmission(0, 1))
Example #47
0
def test_hamiltonian_submatrix():
    sys = kwant.Builder()
    chain = kwant.lattice.chain()
    for i in xrange(3):
        sys[chain(i)] = 0.5 * i
    for i in xrange(2):
        sys[chain(i), chain(i + 1)] = 1j * (i + 1)

    sys2 = sys.finalized()
    mat = sys2.hamiltonian_submatrix()
    assert mat.shape == (3, 3)
    # Sorting is required due to unknown compression order of builder.
    perm = np.argsort(sys2.onsite_hamiltonians)
    mat_should_be = np.array([[0, 1j, 0], [-1j, 0.5, 2j], [0, -2j, 1]])

    mat = mat[perm, :]
    mat = mat[:, perm]
    np.testing.assert_array_equal(mat, mat_should_be)

    mat = sys2.hamiltonian_submatrix(sparse=True)
    assert sparse.isspmatrix_coo(mat)
    mat = mat.todense()
    mat = mat[perm, :]
    mat = mat[:, perm]
    np.testing.assert_array_equal(mat, mat_should_be)

    mat = sys2.hamiltonian_submatrix((), perm[[0, 1]], perm[[2]])
    np.testing.assert_array_equal(mat, mat_should_be[:2, 2:3])

    mat = sys2.hamiltonian_submatrix((), perm[[0, 1]], perm[[2]], sparse=True)
    mat = mat.todense()
    np.testing.assert_array_equal(mat, mat_should_be[:2, 2:3])

    # Test for correct treatment of matrix input.
    sys = kwant.Builder()
    sys[chain(0)] = np.array([[0, 1j], [-1j, 0]])
    sys[chain(1)] = np.array([[1]])
    sys[chain(2)] = np.array([[2]])
    sys[chain(1), chain(0)] = np.array([[1, 2j]])
    sys[chain(2), chain(1)] = np.array([[3j]])
    sys2 = sys.finalized()
    mat_dense = sys2.hamiltonian_submatrix()
    mat_sp = sys2.hamiltonian_submatrix(sparse=True).todense()
    np.testing.assert_array_equal(mat_sp, mat_dense)

    # Test precalculation of modes.
    np.random.seed(5)
    lead = kwant.Builder(kwant.TranslationalSymmetry((-1,)))
    lead[chain(0)] = np.zeros((2, 2))
    lead[chain(0), chain(1)] = np.random.randn(2, 2)
    sys.attach_lead(lead)
    sys2 = sys.finalized()
    smatrix = kwant.smatrix(sys2, .1).data
    sys3 = sys2.precalculate(.1, what='modes')
    smatrix2 = kwant.smatrix(sys3, .1).data
    np.testing.assert_almost_equal(smatrix, smatrix2)
    assert_raises(ValueError, kwant.solvers.default.greens_function, sys3, 0.2)

    # Test for shape errors.
    sys[chain(0), chain(2)] = np.array([[1, 2]])
    sys2 = sys.finalized()
    assert_raises(ValueError, sys2.hamiltonian_submatrix)
    assert_raises(ValueError, sys2.hamiltonian_submatrix, sparse=True)
    sys[chain(0), chain(2)] = 1
    sys2 = sys.finalized()
    assert_raises(ValueError, sys2.hamiltonian_submatrix)
    assert_raises(ValueError, sys2.hamiltonian_submatrix, sparse=True)

    # Test for passing parameters to hamiltonian matrix elements
    def onsite(site, p1, p2=0):
        return site.pos + p1 + p2

    def hopping(site1, site2, p1, p2=0):
        return p1 - p2

    sys = kwant.Builder()
    sys[(chain(i) for i in xrange(3))] = onsite
    sys[((chain(i), chain(i + 1)) for i in xrange(2))] = hopping
    sys2 = sys.finalized()
    mat = sys2.hamiltonian_submatrix((2, 1))
    mat_should_be = [[3, 1, 0], [1, 4, 1], [0, 1, 5]]

    # Sorting is required due to unknown compression order of builder.
    onsite_hamiltonians = mat.flat[::4]
    perm = np.argsort(onsite_hamiltonians)
    mat = mat[perm, :]
    mat = mat[:, perm]
    np.testing.assert_array_equal(mat, mat_should_be)
Example #48
0
pasma(W, dx, m, alfa, Fz, Bx, By, Bz, 0.2/f_nm2au, 1000, Vg1, Vg2, 0)

sys=make_system_SOI(W, L, dx, m, alfa, Fz, Bx, By, Bz, Vg1, Vg2)
#kwant.plot(sys)

#Obliczenie ladunku
#energy=1.0e-3*f_eV2au
#plot_psi(sys, energy, dx, W, L, [dx, m, alfa, Fz, Bx, By, Bz, Vg1, Vg2])
#plot_spin(sys, energy, dx, W, L, [dx, m, alfa, Fz, Bx, By, Bz, Vg1, Vg2])


##Obliczenie konduktancji
f1=open("G.dat","w")
f2=open("T.dat","w")
dE=0.01e-3*f_eV2au
ne=500
for ie in range(ne):
   print(ie)
   energy = dE+ie*dE
   smatrix = kwant.smatrix(sys, energy, [dx, m, alfa, Fz, Bx, By, Bz, Vg1, Vg2])
   tupup=smatrix.transmission(2, 0)
   tupdown=smatrix.transmission(3, 0)
   tdownup=smatrix.transmission(2, 1)
   tdowndown=smatrix.transmission(3, 1)
   j_up=tupup+tdownup
   j_down=tdowndown+tupdown
   f2.write("%e %e %e %e %e %e\n"%(energy/f_eV2au, tupup, tupdown, tdownup, tdowndown, tupup + tupdown + tdownup + tdowndown))
   f1.write("%e %e %e %e\n"%(energy/f_eV2au, j_up, j_down, j_up+j_down))
f1.close()
f2.close()
Example #49
0
#HIDDEN_END_wsgh

# Finalize the system
#HIDDEN_BEGIN_dngj
sys = sys.finalized()
#HIDDEN_END_dngj

# Now that we have the system, we can compute conductance
#HIDDEN_BEGIN_buzn
energies = []
data = []
for ie in xrange(100):
    energy = ie * 0.01

    # compute the scattering matrix at a given energy
    smatrix = kwant.smatrix(sys, energy)

    # compute the transmission probability from lead 0 to
    # lead 1
    energies.append(energy)
    data.append(smatrix.transmission(1, 0))
#HIDDEN_END_buzn

# Use matplotlib to write output
# We should see conductance steps
#HIDDEN_BEGIN_lliv
pyplot.figure()
pyplot.plot(energies, data)
pyplot.xlabel("energy [t]")
pyplot.ylabel("conductance [e^2/h]")
pyplot.show()