quantum_wire_revisited.py 2.26 KB
Newer Older
1
2
3
# Tutorial 2.2.3. Building the same system with less code
# =======================================================
#
4
5
6
7
8
9
# Physics background
# ------------------
#  Conductance of a quantum wire; subbands
#
# Kwant features highlighted
# --------------------------
10
#  - Using iterables and builder.HoppingKind for making systems
11
12
#  - introducing `reversed()` for the leads
#
13
# Note: Does the same as tutorial1a.py, but using other features of Kwant.
14

15
#HIDDEN_BEGIN_xkzy
16
17
18
import kwant

# For plotting
19
20
from matplotlib import pyplot

21
22
23
24

def make_system(a=1, t=1.0, W=10, L=30):
    # Start with an empty tight-binding system and a single square lattice.
    # `a` is the lattice constant (by default set to 1 for simplicity.
Christoph Groth's avatar
Christoph Groth committed
25
    lat = kwant.lattice.square(a)
26
27

    sys = kwant.Builder()
28
#HIDDEN_END_xkzy
29
30

    #### Define the scattering region. ####
31
#HIDDEN_BEGIN_vvjt
32
    sys[(lat(x, y) for x in range(L) for y in range(W))] = 4 * t
33
34
#HIDDEN_END_vvjt
#HIDDEN_BEGIN_nooi
35
    sys[lat.neighbors()] = -t
36
#HIDDEN_END_nooi
37

38
39
    #### Define and attach the leads. ####
    # Construct the left lead.
40
#HIDDEN_BEGIN_iepx
41
    lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0)))
Joseph Weston's avatar
Joseph Weston committed
42
    lead[(lat(0, j) for j in range(W))] = 4 * t
43
    lead[lat.neighbors()] = -t
44
#HIDDEN_END_iepx
45

46
    # Attach the left lead and its reversed copy.
47
#HIDDEN_BEGIN_yxot
48
49
    sys.attach_lead(lead)
    sys.attach_lead(lead.reversed())
50

51
    return sys
52
#HIDDEN_END_yxot
53

54
55

#HIDDEN_BEGIN_ayuk
56
def plot_conductance(sys, energies):
57
58
59
    # Compute conductance
    data = []
    for energy in energies:
60
        smatrix = kwant.smatrix(sys, energy)
61
62
        data.append(smatrix.transmission(1, 0))

63
64
    pyplot.figure()
    pyplot.plot(energies, data)
65
66
    pyplot.xlabel("energy [t]")
    pyplot.ylabel("conductance [e^2/h]")
67
    pyplot.show()
68
#HIDDEN_END_ayuk
69
70


71
#HIDDEN_BEGIN_cjel
72
def main():
73
    sys = make_system()
74
75

    # Check that the system looks as intended.
76
77
78
    kwant.plot(sys)

    # Finalize the system.
79
    sys = sys.finalized()
80
81

    # We should see conductance steps.
Joseph Weston's avatar
Joseph Weston committed
82
    plot_conductance(sys, energies=[0.01 * i for i in range(100)])
83
#HIDDEN_END_cjel
84
85
86
87


# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
88
#HIDDEN_BEGIN_ypbj
89
90
if __name__ == '__main__':
    main()
91
#HIDDEN_END_ypbj