quantum_wire_revisited.py 2.26 KB
 Michael Wimmer committed Sep 06, 2013 1 2 3 ``````# Tutorial 2.2.3. Building the same system with less code # ======================================================= # `````` Kwant authors committed Jan 10, 2011 4 5 6 7 8 9 ``````# Physics background # ------------------ # Conductance of a quantum wire; subbands # # Kwant features highlighted # -------------------------- `````` Anton Akhmerov committed Mar 14, 2013 10 ``````# - Using iterables and builder.HoppingKind for making systems `````` Kwant authors committed Jan 10, 2011 11 12 ``````# - introducing `reversed()` for the leads # `````` Christoph Groth committed Jul 31, 2013 13 ``````# Note: Does the same as tutorial1a.py, but using other features of Kwant. `````` Kwant authors committed Jan 10, 2011 14 `````` `````` Christoph Groth committed Nov 17, 2012 15 ``````#HIDDEN_BEGIN_xkzy `````` Kwant authors committed Jan 10, 2011 16 17 18 ``````import kwant # For plotting `````` 19 20 ``````from matplotlib import pyplot `````` Kwant authors committed Jan 10, 2011 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 committed Feb 21, 2013 25 `````` lat = kwant.lattice.square(a) `````` Kwant authors committed Jan 10, 2011 26 27 `````` sys = kwant.Builder() `````` Christoph Groth committed Nov 17, 2012 28 ``````#HIDDEN_END_xkzy `````` Kwant authors committed Jan 10, 2011 29 30 `````` #### Define the scattering region. #### `````` Christoph Groth committed Nov 17, 2012 31 ``````#HIDDEN_BEGIN_vvjt `````` 32 `````` sys[(lat(x, y) for x in range(L) for y in range(W))] = 4 * t `````` Christoph Groth committed Nov 17, 2012 33 34 ``````#HIDDEN_END_vvjt #HIDDEN_BEGIN_nooi `````` Anton Akhmerov committed Apr 28, 2013 35 `````` sys[lat.neighbors()] = -t `````` Christoph Groth committed Nov 17, 2012 36 ``````#HIDDEN_END_nooi `````` Kwant authors committed Jan 10, 2011 37 `````` `````` Christoph Groth committed Apr 15, 2013 38 39 `````` #### Define and attach the leads. #### # Construct the left lead. `````` Christoph Groth committed Nov 17, 2012 40 ``````#HIDDEN_BEGIN_iepx `````` Christoph Groth committed Apr 15, 2013 41 `````` lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0))) `````` Joseph Weston committed Nov 05, 2015 42 `````` lead[(lat(0, j) for j in range(W))] = 4 * t `````` Anton Akhmerov committed Apr 28, 2013 43 `````` lead[lat.neighbors()] = -t `````` Christoph Groth committed Nov 17, 2012 44 ``````#HIDDEN_END_iepx `````` Kwant authors committed Jan 10, 2011 45 `````` `````` Christoph Groth committed Apr 15, 2013 46 `````` # Attach the left lead and its reversed copy. `````` Christoph Groth committed Nov 17, 2012 47 ``````#HIDDEN_BEGIN_yxot `````` Christoph Groth committed Apr 15, 2013 48 49 `````` sys.attach_lead(lead) sys.attach_lead(lead.reversed()) `````` Kwant authors committed Jan 10, 2011 50 `````` `````` Christoph Groth committed Apr 05, 2012 51 `````` return sys `````` Christoph Groth committed Nov 17, 2012 52 ``````#HIDDEN_END_yxot `````` 53 `````` `````` Anton Akhmerov committed Nov 18, 2012 54 55 `````` #HIDDEN_BEGIN_ayuk `````` 56 ``````def plot_conductance(sys, energies): `````` Kwant authors committed Jan 10, 2011 57 58 59 `````` # Compute conductance data = [] for energy in energies: `````` Anton Akhmerov committed Aug 24, 2013 60 `````` smatrix = kwant.smatrix(sys, energy) `````` Kwant authors committed Jan 10, 2011 61 62 `````` data.append(smatrix.transmission(1, 0)) `````` 63 64 `````` pyplot.figure() pyplot.plot(energies, data) `````` Anton Akhmerov committed Mar 18, 2013 65 66 `````` pyplot.xlabel("energy [t]") pyplot.ylabel("conductance [e^2/h]") `````` 67 `````` pyplot.show() `````` Christoph Groth committed Nov 17, 2012 68 ``````#HIDDEN_END_ayuk `````` Kwant authors committed Jan 10, 2011 69 70 `````` `````` Christoph Groth committed Nov 17, 2012 71 ``````#HIDDEN_BEGIN_cjel `````` Kwant authors committed Jan 10, 2011 72 ``````def main(): `````` Christoph Groth committed Apr 05, 2012 73 `````` sys = make_system() `````` Kwant authors committed Jan 10, 2011 74 75 `````` # Check that the system looks as intended. `````` Christoph Groth committed Apr 05, 2012 76 77 78 `````` kwant.plot(sys) # Finalize the system. `````` 79 `````` sys = sys.finalized() `````` Kwant authors committed Jan 10, 2011 80 81 `````` # We should see conductance steps. `````` Joseph Weston committed Nov 05, 2015 82 `````` plot_conductance(sys, energies=[0.01 * i for i in range(100)]) `````` Christoph Groth committed Nov 17, 2012 83 ``````#HIDDEN_END_cjel `````` Kwant authors committed Jan 10, 2011 84 85 86 87 `````` # Call the main function if the script gets executed (as opposed to imported). # See . `````` Christoph Groth committed Nov 17, 2012 88 ``````#HIDDEN_BEGIN_ypbj `````` Kwant authors committed Jan 10, 2011 89 90 ``````if __name__ == '__main__': main() `````` Christoph Groth committed Nov 17, 2012 91 ``#HIDDEN_END_ypbj``