@@ -1,88 +1,95 @@ # Tutorial 2.3.2. Spatially dependent values through functions # ============================================================ # # Physics background # ------------------ # transmission through a quantum well # # Kwant features highlighted # -------------------------- # - Functions as values in Builder +import _defs import kwant # For plotting from matplotlib import pyplot #HIDDEN_BEGIN_ehso def make_system(a=1, t=1.0, W=10, L=30, L_well=10): # Start with an empty tight-binding system and a single square lattice. # `a` is the lattice constant (by default set to 1 for simplicity. lat = kwant.lattice.square(a) syst = kwant.Builder() #### Define the scattering region. #### # Potential profile def potential(site, pot): (x, y) = site.pos if (L - L_well) / 2 < x < (L + L_well) / 2: return pot else: return 0 #HIDDEN_END_ehso #HIDDEN_BEGIN_coid def onsite(site, pot): return 4 * t + potential(site, pot) syst[(lat(x, y) for x in range(L) for y in range(W))] = onsite syst[lat.neighbors()] = -t #HIDDEN_END_coid #### Define and attach the leads. #### lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0))) lead[(lat(0, j) for j in range(W))] = 4 * t lead[lat.neighbors()] = -t syst.attach_lead(lead) syst.attach_lead(lead.reversed()) return syst def plot_conductance(syst, energy, welldepths): #HIDDEN_BEGIN_sqvr # Compute conductance data = [] for welldepth in welldepths: smatrix = kwant.smatrix(syst, energy, params=dict(pot=-welldepth)) data.append(smatrix.transmission(1, 0)) - pyplot.figure() + fig = pyplot.figure() pyplot.plot(welldepths, data) - pyplot.xlabel("well depth [t]") - pyplot.ylabel("conductance [e^2/h]") - pyplot.show() + pyplot.xlabel("well depth [t]", + fontsize=_defs.mpl_label_size) + pyplot.ylabel("conductance [e^2/h]", + fontsize=_defs.mpl_label_size) + pyplot.setp(fig.get_axes()[0].get_xticklabels(), + fontsize=_defs.mpl_tick_size) + pyplot.setp(fig.get_axes()[0].get_yticklabels(), + fontsize=_defs.mpl_tick_size) + fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.) + fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15) + for extension in ('pdf', 'png'): + fig.savefig("quantum_well_result." + extension, dpi=_defs.dpi) #HIDDEN_END_sqvr def main(): syst = make_system() - # Check that the system looks as intended. - kwant.plot(syst) - # Finalize the system. syst = syst.finalized() # We should see conductance steps. plot_conductance(syst, energy=0.2, welldepths=[0.01 * i for i in range(100)]) # Call the main function if the script gets executed (as opposed to imported). # See <http://docs.python.org/library/__main__.html>. if __name__ == '__main__': main()