def main(): syst = make_system() # Check that the system looks as intended. kwant.plot(syst) # Finalize the system. syst = syst.finalized() # The following try-clause can be removed once SciPy 0.9 becomes uncommon. try: # We should observe energy levels that flow towards Landau # level energies with increasing magnetic field. plot_spectrum(syst, [iB * 0.002 for iB in range(100)]) # Plot an eigenmode of a circular dot. Here we create a larger system for # better spatial resolution. syst = make_system(r=30).finalized() plot_wave_function(syst) except ValueError as e: if e.message == "Input matrix is not real-valued.": print("The calculation of eigenvalues failed because of a bug in SciPy 0.9.") print("Please upgrade to a newer version of SciPy.") else: raise
def main(): syst = make_system() # Check that the system looks as intended. kwant.plot(syst) # Finalize the system. syst = syst.finalized() plot_conductance(syst, energies=[0.002 * i for i in range(100)])
def main(): sys = make_system() # Check that the system looks as intended. kwant.plot(sys) # Finalize the system. sys = sys.finalized() # We should see conductance steps. plot_conductance(sys, energies=[0.01 * i for i in xrange(100)])
def main(): syst = make_system() # Check that the system looks as intended. kwant.plot(syst) # Finalize the system. syst = syst.finalized() # We should see non-monotonic conductance steps. plot_conductance(syst, energies=[0.01 * i - 0.3 for i in range(100)])
def main(): syst = make_system() # Check that the system looks as intended. kwant.plot(syst) # Finalize the system. syst = syst.finalized() # We should see a conductance that is periodic with the flux quantum plot_conductance(syst, energy=0.15, fluxes=[0.01 * i * 3 * 2 * pi for i in range(100)])
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)])
def plot_system(sys): kwant.plot(sys) #HIDDEN_END_plotsys1 # the standard plot is ok, but not very intelligible. One can do # better by playing wioth colors and linewidths # use color and linewidths to get a better plot #HIDDEN_BEGIN_plotsys2 def family_color(site): return 'black' if site.family == a else 'white' def hopping_lw(site1, site2): return 0.04 if site1.family == site2.family else 0.1 kwant.plot(sys, site_lw=0.1, site_color=family_color, hop_lw=hopping_lw)
def main(): # the standard plotting style for 3D is mainly useful for # checking shapes: #HIDDEN_BEGIN_plot1 syst = make_cuboid() kwant.plot(syst) #HIDDEN_END_plot1 # visualize the crystal structure better for a very small system #HIDDEN_BEGIN_plot2 syst = make_cuboid(a=1.5, b=1.5, c=1.5) def family_colors(site): return 'r' if site.family == a else 'g' kwant.plot(syst, site_size=0.18, site_lw=0.01, hop_lw=0.05, site_color=family_colors)
def measure_kwant(width, length, electron_energy, barrier_heights, plot=False): def make_system(): t = 2.8 a_cc = 0.142 a = a_cc * math.sqrt(3) graphene_lattice = kwant.lattice.general( [(a, 0), (a / 2, a / 2 * math.sqrt(3))], [(0, -a_cc / 2), (0, a_cc / 2)]) def shape(pos): x, y = pos return -length / 2 <= x <= length / 2 and -width / 2 <= y <= width / 2 def onsite(site, v0): x, _ = site.pos return v0 if -length / 4 <= x <= length / 4 else 0 builder = kwant.Builder() builder[graphene_lattice.shape(shape, (0, 0))] = onsite builder[graphene_lattice.neighbors()] = -t def lead_shape(pos): x, y = pos return -width / 2 <= y <= width / 2 lead = kwant.Builder( kwant.TranslationalSymmetry(graphene_lattice.vec((-1, 0)))) lead[graphene_lattice.shape(lead_shape, (0, 0))] = 0 lead[graphene_lattice.neighbors()] = -t builder.attach_lead(lead) builder.attach_lead(lead.reversed()) return builder.finalized() system = make_system() if plot: kwant.plot(system) transmission = [] for v in barrier_heights: smatrix = kwant.smatrix(system, energy=electron_energy, args=[v]) transmission.append(smatrix.transmission(1, 0)) return transmission
def make_system_DC(a=1, t=1.0, L=6, W=3, V0=0.5, lx=5): lat = kwant.lattice.square(a=1, norbs=1) syst = kwant.Builder() x0 = L / 2 def onsite(site): (x, y) = site.pos return np.exp(-((x - x0) / lx)**2) * V0 + 4 * t syst[(lat(x, y) for x in range(0, L) for y in range(0, W))] = onsite syst[lat.neighbors()] = -t lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0))) lead[(lat(0, y) for y in range(0, W))] = 4 * t lead[lat.neighbors()] = -t syst.attach_lead(lead) syst.attach_lead(lead.reversed()) time_dependent_hopping = (lat(2, 0), lat(3, 0)) #tkwant.leads.add_voltage(syst, 0, gaussian) colormap = plt.cm.inferno def region_colors(site): if V0 == 0: return 'k' else: (x, y) = site.pos maxpot = V0 rap = (onsite(site) - 4 * t) / maxpot return colormap(rap * 0.8) kwant.plot(syst, site_color=region_colors, lead_color='grey', hop_color=lambda a, b: 'red' if (a, b) in [time_dependent_hopping] else 'k', hop_lw=lambda a, b: 0.3 if (a, b) in [time_dependent_hopping] else 0.1, fig_size=(20, 15), colorbar=0) # lead_fin = lead.finalized() return syst
def plot(self): """Illustrative plot of wire sites and hoppings. Basic plot of all the sites and hopping is the system. Semi-infinite contacts are plotted in read. Parameters ---------- wire : :class:`~garn.Wire2D` or :class:`~garn.Wire3D` System to be plotted. Notes ----- For more advanced settings pass wire.sys to the `kwant.plotter.plot <http://kwant-project.org/doc/1/reference/generated/kwant.plotter.plot#kwant.plotter.plot>`_. method. """ kwant.plot(self.sys) # site_size=0.18, site_lw=0.01, hop_lw=0.01)
def measure_kwant(num_sites, warmup=False, plot=False): def make_system(radius, potential=0.2, magnetic_field=3): def circle(pos): x, y = pos return x**2 + y**2 < radius**2 def onsite(site): x, y = site.pos if x**2 + y**2 < (radius / 2)**2: return potential else: return 0 def hopping(site_i, site_j): xi, yi = site_i.pos xj, yj = site_j.pos phi_ij = 0.5 * magnetic_field * (xi + xj) * (yi - yj) const = 1.519e-3 # 2*pi*e/h*[nm^2] return -2.8 * cmath.exp(1j * phi_ij * const) a_cc = 0.142 a = a_cc * math.sqrt(3) graphene_lattice = kwant.lattice.general( [(a, 0), (a / 2, a / 2 * math.sqrt(3))], [(0, -a_cc / 2), (0, a_cc / 2)]) builder = kwant.Builder() builder[graphene_lattice.shape(circle, (0, 0))] = onsite builder[graphene_lattice.neighbors()] = hopping builder.eradicate_dangling() return builder.finalized() with pb.utils.timed() as time: system = make_system(radius=calc_radius(num_sites)) h = system.hamiltonian_submatrix(sparse=True) if not warmup: print(" {:7} <-> atoms = {}, non-zeros = {}".format( str(time), h.shape[0], h.nnz)) if plot: kwant.plot(system) return time.elapsed
def make_system(): a = 1 # 晶格常数 lat = kwant.lattice.square(a) # 创建晶格,方格子 syst = kwant.Builder() # 建立中心体系 t = 1.0 # hopping值 W = 5 # 中心体系宽度 L = 40 # 中心体系长度 # 给中心体系赋值 for i in range(L): for j in range(W): syst[lat(i, j)] = 0 if j > 0: syst[lat(i, j), lat(i, j - 1)] = -t # hopping in y-direction if i > 0: syst[lat(i, j), lat(i - 1, j)] = -t # hopping in x-direction sym_left_lead = kwant.TranslationalSymmetry( (-a, 0)) # 电极的平移对称性,(-a, 0)代表远离中心区的方向,向左 left_lead = kwant.Builder(sym_left_lead) # 建立左电极体系 # 给电极体系赋值 for j in range(W): left_lead[lat(0, j)] = 0 if j > 0: left_lead[lat(0, j), lat(0, j - 1)] = -t left_lead[lat(1, j), lat(0, j)] = -t # 这里写一个即可,因为平移对称性已经声明了 syst.attach_lead(left_lead) # 把左电极接在中心区 sym_right_lead = kwant.TranslationalSymmetry((a, 0)) right_lead = kwant.Builder(sym_right_lead) for j in range(W): right_lead[lat(0, j)] = 0 if j > 0: right_lead[lat(0, j), lat(0, j - 1)] = -t right_lead[lat(1, j), lat(0, j)] = -t syst.attach_lead(right_lead) # 把右电极接在中心区 kwant.plot(syst) # 把电极-中心区-电极图画出来,通过图像可以看出有没有写错 syst = syst.finalized() # 结束体系的制作。这个语句不可以省。这个语句是把Builder对象转换成可计算的对象。 return syst
def main(): # Define the system raio_simples = 10 * shapes.A_STD # raio_nm = 150 # raio_std = raio_nm * 10/shapes.A0 print("QD radius: ", raio_simples, " Bohr radia.") # lattice_const_Bohr_radia = 200 lattice_const_Bohr_radia = shapes.A_STD formato = shapes.Circular(raio_simples) H = gasb.hamiltonian_97_k_plus() quantum_dot = gasb.just_system_builder(H, formato, a_lattice=lattice_const_Bohr_radia) # Check that the system looks as intended. kwant.plot(quantum_dot) # Define parameters min_field = 0 max_field = 1000 N_pts = 1000 eF_values = np.linspace(min_field, max_field, N_pts) parametros = gasb.params_97 # Calculate and save energy levels of the dot energies = calc_spectrum(quantum_dot, eF_values, parametros) np.savez( "circular_quantum_dot_energies_around_445_meV_field_0_62_and_200_eigenstates_R_150nm_a_200A0.npz", Ef_values=eF_values, Energies=energies) # and plot the results plt.figure() plt.plot(eF_values, energies, linestyle=' ', marker=',', color='k') plt.xlabel("E. field [meV]") plt.ylabel(r"$\varepsilon$ [meV]") plt.tight_layout() plt.show()
def make_system(): a = 1 lat = kwant.lattice.square(a) syst = kwant.Builder() t = 1.0 W = 5 L = 50 syst[(lat(x, y) for x in range(L) for y in range(W))] = 0 syst[lat.neighbors()] = -t # 几何形状如下所示: # lead2 lead3 # lead1(L) lead4(R) # lead6 lead5 move = 0 # the step of leads 2,3,6,5 moving to center lead1 = kwant.Builder(kwant.TranslationalSymmetry((-a, 0))) lead1[(lat(0, j) for j in range(W))] = 0 lead1[lat.neighbors()] = -t syst.attach_lead(lead1) lead2 = kwant.Builder(kwant.TranslationalSymmetry((0, -a))) lead2[(lat(move + j, 0) for j in range(W))] = 0 lead2[lat.neighbors()] = -t syst.attach_lead(lead2) lead3 = kwant.Builder(kwant.TranslationalSymmetry((0, -a))) lead3[(lat(j + (L - W - move), 0) for j in range(W))] = 0 lead3[lat.neighbors()] = -t syst.attach_lead(lead3) syst.attach_lead(lead1.reversed()) # lead4 syst.attach_lead(lead3.reversed()) # lead5 syst.attach_lead(lead2.reversed()) # lead6 kwant.plot(syst) syst = syst.finalized() return syst
def plot_amplitude(sys, wf, sitesize=0.5, hopsize=0.05): """Plot the total wavefunction amplitude. Parameters: ----------- sys : <kwant.builder.FiniteSystem> object. Finalized system, as returned by build_system(). wf : numpy.ndarray. Array of wafefunction amplitudes. sitesize : real. Scale factor setting the maximum area of a site. hopsize : real. Scale factor setting the maximum width of a link. """ minwf = np.min(wf) maxwf = np.max(wf) def site_size(site): """Set the size of a site based on total wavefunction amplitude.""" return (wf[site] - minwf) / (maxwf - minwf) * sitesize def site_col(site): """Set the color of a site based on total wavefunction amplitude.""" return (wf[site] - minwf) / (maxwf - minwf) def hop_lw(site1, site2): """Set the thickness of hoppings to show the positions of Kitaev chains. """ x1, y1 = sys.sites[site1].pos x2, y2 = sys.sites[site2].pos return stripe_hopping(x1 / 2 + x2 / 2) * hopsize kwant.plot(sys, site_size=site_size, site_color=site_col, cmap='gist_heat_r', hop_lw=hop_lw)
def make_system_with_less_code(): a = 1 # 晶格常数 lat = kwant.lattice.square(a) # 创建晶格,方格子 syst = kwant.Builder() # 建立中心体系 t = 1.0 # hopping值 W = 5 # 中心体系宽度 L = 40 # 中心体系长度 # 中心区 syst[(lat(x, y) for x in range(L) for y in range(W))] = 0 syst[lat.neighbors()] = -t # 用neighbors()方法 # 电极 lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0))) lead[(lat(0, j) for j in range(W))] = 0 lead[lat.neighbors()] = -t # 用neighbors()方法 syst.attach_lead(lead) # 左电极 syst.attach_lead(lead.reversed()) # 用reversed()方法得到右电极 kwant.plot(syst) # 把电极-中心区-电极图画出来,通过图像可以看出有没有写错 syst = syst.finalized() # 结束体系的制作。这个语句不可以省。这个语句是把Builder对象转换成可计算的对象。 return syst
def main(): # i=sys.argv[1] # j=sys.argv[2] # i=int(i) # j=int(j) # plot_conductance(i,j) syst=make_system(10,0,acos(1/sqrt(3)),30,30) # smatrix = kwant.smatrix(syst, 0, args=[""]) # x=smatrix.transmission(3,0) # print(x) # syst2=make_system2(30) # kwant.plot(syst2) # wf = kwant.wave_function(syst, energy=0,args=[""]) # psi=wf(0)[0] # def surface1(site_in,site_out): # return site_in.pos[0] == 0 and site_out.pos[0] == 0 # J_1 = kwant.operator.Current(syst,where=surface1) # def surface2(site_in,site_out): # return site_in.pos[1] == 29 and site_out.pos[1] == 29 # J_2 = kwant.operator.Current(syst,where=surface2) # def surface3(site_in,site_out): # return site_in.pos[0] == 29 and site_out.pos[0] == 29 # J_3 = kwant.operator.Current(syst,where=surface3) # def surface4(site_in,site_out): # return site_in.pos[1] == 0 and site_out.pos[1] == 0 # J_4 = kwant.operator.Current(syst,where=surface4) # current1 = J_1(psi) # current2 = J_2(psi) # current3 = J_3(psi) # current4 = J_4(psi) #print(density) # kwant.plotter.current(syst2, current1, colorbar=True) # kwant.plotter.current(syst2, current2, colorbar=True) # kwant.plotter.current(syst2, current3, colorbar=True) # kwant.plotter.current(syst2, current4, colorbar=True) kwant.plot(syst)
def plot_data(sys, n): import scipy.linalg as la sys = sys.finalized() ham = sys.hamiltonian_submatrix() evecs = la.eigh(ham)[1] wf = abs(evecs[:, n])**2 #HIDDEN_END_plotdata1 # the usual - works great in general, looks just a bit crufty for # small systems #HIDDEN_BEGIN_plotdata2 kwant.plotter.map(sys, wf, oversampling=10, cmap='gist_heat_r') #HIDDEN_END_plotdata2 # use two different sort of triangles to cleanly fill the space #HIDDEN_BEGIN_plotdata3 def family_shape(i): site = sys.sites[i] return ('p', 3, 180) if site.family == a else ('p', 3, 0) def family_color(i): return 'black' if sys.site(i).family == a else 'white' kwant.plot(sys, site_color=wf, site_symbol=family_shape, site_size=0.5, hop_lw=0, cmap='gist_heat_r') #HIDDEN_END_plotdata3 # plot by changing the symbols itself #HIDDEN_BEGIN_plotdata4 def site_size(i): return 3 * wf[i] / wf.max() kwant.plot(sys, site_size=site_size, site_color=(0, 0, 1, 0.3), hop_lw=0.1)
def main(): pot = 0.1 sys, leads = make_system(pot=pot) # To highlight the two sublattices of graphene, we plot one with # a filled, and the other one with an open circle: def family_colors(site): return 0 if site.family == a else 1 # Plot the closed system without leads. kwant.plot(sys, site_color=family_colors, site_lw=0.1, colorbar=False) # Compute some eigenvalues. compute_evs(sys.finalized()) # Attach the leads to the system. for lead in leads: sys.attach_lead(lead) # Then, plot the system with leads. kwant.plot(sys, site_color=family_colors, site_lw=0.1, lead_site_lw=0, colorbar=False) # Finalize the system. sys = sys.finalized() # Compute the band structure of lead 0. momenta = [-pi + 0.02 * pi * i for i in xrange(101)] plot_bandstructure(sys.leads[0], momenta) # Plot conductance. energies = [-2 * pot + 4. / 50. * pot * i for i in xrange(51)] plot_conductance(sys, energies)
def main(): pot = 0.1 syst, leads = make_system(pot=pot) # To highlight the two sublattices of graphene, we plot one with # a filled, and the other one with an open circle: def family_colors(site): return 0 if site.family == a else 1 # Plot the closed system without leads. kwant.plot(syst, site_color=family_colors, site_lw=0.1, colorbar=False) #HIDDEN_END_itkk # Compute some eigenvalues. #HIDDEN_BEGIN_jmbi compute_evs(syst.finalized()) #HIDDEN_END_jmbi # Attach the leads to the system. for lead in leads: syst.attach_lead(lead) # Then, plot the system with leads. kwant.plot(syst, site_color=family_colors, site_lw=0.1, lead_site_lw=0, colorbar=False) # Finalize the system. syst = syst.finalized() # Compute the band structure of lead 0. momenta = [-pi + 0.02 * pi * i for i in range(101)] plot_bandstructure(syst.leads[0], momenta) # Plot conductance. energies = [-2 * pot + 4. / 50. * pot * i for i in range(51)] plot_conductance(syst, energies)
def main(): L = 3 W = 2 lat = kwant.lattice.square(a=1, norbs=1) # 定义lattice print('\nlat:\n', lat) syst = kwant.Builder() # 定义中心区的Builder print('\nsyst:\n', syst) syst_finalized = syst.finalized() hamiltonian = syst_finalized.hamiltonian_submatrix() # 查看哈密顿量 print('\nhamiltonian_1(定义):\n', hamiltonian) syst[(lat(x, y) for x in range(L) for y in range(W))] = 0 # 晶格初始化为0 kwant.plot(syst) # 画出syst的示意图 syst_finalized = syst.finalized() hamiltonian = syst_finalized.hamiltonian_submatrix() # 查看哈密顿量 print('\nhamiltonian_2(初始化):\n', hamiltonian) syst[lat.neighbors()] = 1 # 添加最近邻跃迁 kwant.plot(syst) # 画出syst的示意图 syst_finalized = syst.finalized() hamiltonian = syst_finalized.hamiltonian_submatrix() # 查看哈密顿量 print('\nhamiltonian_3(最近邻赋值):\n', hamiltonian) lead = kwant.Builder(kwant.TranslationalSymmetry((-1, 0))) # 定义电极的Builder lead[(lat(0, j) for j in range(W))] = 0 # 电极晶格初始化 lead[lat.neighbors()] = 1 # 添加最近邻跃迁 syst.attach_lead(lead) # 中心区加上左电极 syst.attach_lead(lead.reversed()) # 用reversed()方法得到右电极 # 画出syst的示意图 kwant.plot(syst) # 查看哈密顿量(加了电极后,并不影响syst哈密顿量) syst_finalized = syst.finalized() hamiltonian = syst_finalized.hamiltonian_submatrix() print('\nhamiltonian_4(加了电极后):\n', hamiltonian)
vlead = kwant.builder.SelfEnergyLead(selfenergy_func, vlead_interface) sys.leads.append(vlead) def vshape(pos): x, = pos return x == 0 #vlead = kwant.Builder(kwant.TranslationalSymmetry((a/2, a/2*np.sqrt(3)))) lat = kwant.lattice.chain(dx) vlead = kwant.Builder() vlead[lat.shape( vshape, (0, ) )] = 0 # just define shape, self energy is defined in kwant.builder.SelfEnergyLead kwant.plot(vlead, fig_size=(10, 3)) #vlead[(lat(i) for i in range(L))]=0 gf_sites = vlead.sites() syst = make_system() mount_vlead(syst, gf_sites, 1) sys = syst.finalized() #sys=make_system() kwant.plot(sys, fig_size=(10, 3)) kwant.greens_function(sys, 1.6).submatrix(0, 0) ##en=2 wf = kwant.wave_function(sys, 1.613)(0) ##kwant.plotter.map(sys,(abs(np.array(wf))**2), fig_size=(10, 3)) #plt.plot(abs(np.array(wf[0,]))**2)
if j > 0: right_lead[lat(0, j), lat(0, j - 1)] = -t right_lead[lat(1, j), lat(0, j)] = -t syst.attach_lead(right_lead) # Finalize the system syst = syst.finalized() # Now that we have the system, we can compute conductance energies = [] data = [] for ie in range(100): energy = ie * 0.01 # compute the scattering matrix at a given energy smatrix = kwant.smatrix(syst, energy) # compute the transmission probability from lead 0 to # lead 1 energies.append(energy) data.append(smatrix.transmission(1, 0)) # Plot it, to make sure it's OK kwant.plot(syst) # Use matplotlib to write output # We should see conductance steps plt.figure() plt.plot(energies, data) plt.xlabel("energy [t]") plt.ylabel("conductance [e^2/h]") plt.show()
# -*- coding: utf-8 -*- """ Created on Thu Oct 17 13:10:00 2019 @author: ykang """ import kwant import stru_QSH as dg import numpy as np width=2.3 length=4 salt='2' dis=2.4 graphene = kwant.lattice.general([[1, 0], [1/2, np.sqrt(3)/2]], # lattice vectors [[0, 0], [0, 1/np.sqrt(3)]]) # Coordinates of the sites a, b = graphene.sublattices #sys=dg.make_system_all(width, length, salt,dis) syst=dg.make_system(width, length, salt,dis) dg.attach_lead(syst,width) def family_color(site): return 'black' if site.family == a else 'white' def hopping_lw(site1, site2): return 0.04 if site1.family == site2.family else 0.1 kwant.plot(syst, site_lw=0.1, site_color=family_color, hop_lw=hopping_lw,fig_size=(15, 10)) #kwant.plot(sys)
#HIDDEN_BEGIN_xhqc sym_right_lead = kwant.TranslationalSymmetry((a, 0)) right_lead = kwant.Builder(sym_right_lead) for j in range(W): right_lead[lat(0, j)] = 4 * t if j > 0: right_lead[lat(0, j), lat(0, j - 1)] = -t right_lead[lat(1, j), lat(0, j)] = -t syst.attach_lead(right_lead) #HIDDEN_END_xhqc # Plot it, to make sure it's OK #HIDDEN_BEGIN_wsgh kwant.plot(syst) #HIDDEN_END_wsgh # Finalize the system #HIDDEN_BEGIN_dngj syst = syst.finalized() #HIDDEN_END_dngj # Now that we have the system, we can compute conductance #HIDDEN_BEGIN_buzn energies = [] data = [] for ie in range(100): energy = ie * 0.01 # compute the scattering matrix at a given energy
lead1[B.neighbors()] = hopp2a #kwant.plot(lead1) lead2 = kwant.Builder(kwant.TranslationalSymmetry( (a / 2, -a / 2 * np.sqrt(3)))) lead2[A.shape(edge0, (0, 0))] = onsite1 lead2[B.shape(edge0, (0, 0))] = onsite2 lead2[lat.neighbors()] = -s0 * 2 / 3 lead2[A.neighbors()] = hoppa lead2[B.neighbors()] = hopp2a #kwant.plot(lead2) sys.attach_lead(lead0) sys.attach_lead(lead1) sys.attach_lead(lead2) pyplot.rcParams["figure.figsize"] = [20, 15] kwant.plot(sys) #pyplot.savefig('testplot.png') #sys=sys.finalized() #en=0.1 ## #sca=kwant.smatrix(sys,en).data # #wf=kwant.wave_function(sys,en)(0) #wavef1=[] #for i in range(wf.shape[1]//2): # wavef1.append(wf[0,2*i]) #kwant.plotter.map(sys,(abs(np.array(wavef1))**2)) # #wavef2=[] #for i in range(wf.shape[1]//2):
def main2(): syst = make_system( pi / 2, 0, 0) # with phi=pi/2 we get fig3(a) and phi=pi/3 we get fig3(b) kwant.plot(syst) bandstructure(syst)
def main_En_gG12A(ppar): """ Main function that focuses on calculating, saving/reading and plotting the following quantities for a system defined by the parameters in par and the program specific parameters from ppar: - The par.k lowest |Energy eigenvalues| (absolute value) and the corresponding eigenvectors of the system. - The eigenenergies E_1 and E_m1 of the ppar.n'th states (ppar.n has to be an iterable of the lowest pair of energies that are symmetric around the lambda(chemical potential or magnetic field)-axis, such that the energies can be correctly defined.) - The Cooper charge u^2-v^2 of the ppar.n'th states (ppar.n is an iterable of integers or may in general be changed after determining E_1 and E_m1 to specify only one integer). - The non-local antisymmetric conductance G_12A of the tight-binding (TB) model from Kwant, for the parameters in par. - The non-local antisymmetric conductance g_12A of the analytical model for the same parameters (parameters in par). Notes ----- - Both par and ppar are SimpleNamespace objects. - filename: REMEMBER to update the filename if new parameters are introduced or similarly. If not, writing files will overwrite old ones, and reading files, you might read the wrong file. """ """ Creating a filename based on the rules specified in the following function : """ misc.set_filename_skeleton(par, ppar) """ 'Building' system, using the Kwant package : The way the system is created is specified in ppar (see bottom of this file). These parameters in ppar are input in the make_system function. This function will make different types of systems depending on how ppar is specified. """ sys = make.make_system(par, ppar) sys = sys.finalized() print("%s: sys finalized" % misc.round_time(datetime.datetime.now(), round_to=60)) par.N = 4 * len( sys.sites) # par.N is used in calc_E1_Em1_from_E0_E0prime_var # in order to set correct dimension of evec1_cut and evecm1_cut. # - Plotting system graph : import matplotlib.pylab as plt from kwant import wraparound ax = kwant.plot(sys, site_symbol='o', hop_color=['orange'], site_edgecolor='red', site_lw=0.01, hop_lw=misc.hopping_lw) ax.savefig("N-SC_sys.pdf") """ Calculating and loading, as a function of mu or Ez - eigenenergies - eigenvectors (if ppar.Eonly = False) """ ppar.Eonly = False if ppar.generate_En_mu != None: # reading or writing energy data vs. chem. pot. if ppar.generate_En_mu == False: read_or_write.read_or_write_energies_mu(sys, par, ppar) elif ppar.generate_En_mu == True: for ppar.generate_En_mu in [True, False]: # first time in loop: generating energy data # second time in loop: reading the before generated energy data read_or_write.read_or_write_energies_mu(sys, par, ppar) ppar.generate_En_mu = True if ppar.doubleres == False: # plots energies on one set of mu-axes # (there is no second sets of data for the energy. # The user may use ppar.doubleres is True, if wanting # a second set of data that is zoomed in on one area in # mu-space) plt.figure() plt.tight_layout() plt.plot(par.mu_values, par.energies_mu) plt.xlabel("$\mu\ [meV]$") plt.ylabel("$E_n\ [meV]$") plt.savefig("energies_mu_%s.pdf" % ppar.filename) plt.plot(par.mu_values_2, par.energies_mu) # Cuts and pastes from the energies that are only positive, # with those that are only negative, for the pair of two # lowest energy modes, which oscillate around zero bias : read_or_write.read_or_write_E1m1(par, ppar) if ppar.generate_En_Ez != None: # reading or writing energy data vs. field if ppar.generate_En_Ez == False: read_or_write.read_or_write_energies_Ez(sys, par, ppar) elif ppar.generate_En_Ez == True: for ppar.generate_En_Ez in [True, False]: # first time in loop: generating data # second time in loop: reading already generated data. read_or_write.read_or_write_energies_Ez(sys, par, ppar) # cuts and pastes from the energies as above : read_or_write.read_or_write_E1m1(par, ppar) """ Calculating/loading - g0_12_a : analytical conductance at zero temperature (see arXiv:1905.05438), inserted for TB-model parameters. - E1, Em1, evec1, evecm1 : two lowest eigenenergies, 'cut and pasted' such that they oscillate around zero bias in the topological region. The corresponding eigenvectors, similarly 'cut and pasted'. - u, v, u^2 - v^2 : Coherence factors and BCS charge for the two lowest energy eigenvectors above. """ # misc.addto_filename(ppar,"n") ## Optional if ppar.var_name == "mu": read_or_write.read_or_write_g012a_mu(sys, par, ppar) elif ppar.var_name == "Ez": read_or_write.read_or_write_g012a_Ez(sys, par, ppar) read_or_write.read_or_write_u2mv2_u2_v2(par, ppar) if ppar.generate_E1m1_mu == True: ppar.generate_E1m1_mu = False read_or_write.read_or_write_u2mv2_u2_v2(par, ppar) """ Plotting eigenenergies if they are read or generated, for mu (can do similarly for field variable, Ez) : """ if ppar.generate_En_mu != None: if ppar.doubleres == True: plot.pplot_E_vs_var( par, ppar, par.energies_mu, par.mu_values_2, figfilename="energies_mu_%s" % ppar.filename, xlim=[par.mu_values_2[0], par.mu_values_2[-1]], ylim=[np.min(par.energies_mu), np.max(par.energies_mu)], title="", xlabel="$\mu\ [meV]$", ylabel="$E_n\ [meV]$", add_zoom=True, ylim_zoom=[-par.bias_maxmin, par.bias_maxmin], yticks=[-par.bias_maxmin, 0, par.bias_maxmin], file_extension=".pdf", u2mv2=par.u2mv2_E1_mu, u2_mu=[], v2_mu=[]) """ Computing/reading - G_ij(_S/A) : local/nonlocal conductances as functions of some variable for some set of parameters, versus biasenergy - all these variables are specified in the par SimpleNamespace object - how the user chooses to calculate and represent the data is specified in the ppar Simple namespace object : """ # Specifying the constant and the independent variable in this manner # is general (the user may for instance change between mu and field being constant/variable) : exec("par.%s = %g" % (ppar.par_const_name, ppar.par_const)) # Generating or reading the local and nonlocal conductances : exec_str = \ "par.G_11_%s,par.G_12_%s,par.G_11_S_%s,par.G_11_A_%s,par.G_12_S_%s,par.G_12_A_%s = "\ % (ppar.var_name, ppar.var_name, ppar.var_name, ppar.var_name, ppar.var_name, ppar.var_name) +\ "read_or_write.read_or_write_G_11_12_S_A_var( \ sys,par,ppar, \ ppar.generating_G_11_12_S_A_var, \ ppar.generating_G_11_12_S_A_var, \ ppar.var_name, \ ppar.filename_11, \ ppar.filename_12, \ ppar.filename_11_S, \ ppar.filename_11_A, \ ppar.filename_12_S, \ ppar.filename_12_A)" exec(exec_str) # Plotting contour plot of the differential conductances and # their symmetry-decomposed versions, in chem.pot.-bias space : if ppar.generating_G_11_12_S_A_var[1] == True: for G_, G_filename_, G_title_str in zip(\ # nonlocal conductance, local conductance, local antisymmetric conductance, local symmetric conductance, # nonlocal antisymmetric conductance, nonlocal symmetric conductance, respectively. [par.G_12_mu, par.G_11_mu, par.G_11_A_mu, par.G_11_S_mu, par.G_12_A_mu, par.G_12_S_mu],\ ["G_12_vsEbias1mu_", "G_11_vsEbias1mu_", "G_11_A_vsEbias1mu_", "G_11_S_vsEbias1mu_", "G_12_A_vsEbias1mu_", "G_12_S_vsEbias1mu_"],\ ["$G_{LR}^0\ [e^2/h]$", "$G_{LL}^0\ [e^2/h]$", \ "$G_{LL}^{0,asym}\ [e^2/h]$","$G_{LL}^{0,sym}\ [e^2/h]$",\ "$G_{LR}^{0,asym}\ [e^2/h]$", "$G_{LR}^{0,sym}\ [e^2/h]$"]\ ): plot.plot_G_ij_var(par, scaling="SymLogNorm", G_ij=G_, var_values_str="mu_values", filename=G_filename_ + ppar.filename, figtitle=G_title_str, xlabel="$\mu\ [meV]$", ylabel="$V\ [meV]$", cm="seismic", colorbar_ticks=[-1e-1, -1e-2, 0, 1e-2, 1e-1]) """ mu_cut_index is the index in the chemical potential variable (mu), where the user chooses to make a line-cut. This cut is then plotted as a function of the biasenergy in the following. """ G_full_absmax = np.max( np.abs(par.G_11_mu[ppar.mu_cut_index, :], par.G_12_mu[ppar.mu_cut_index, :])) # Line-cut plot of the total local and total nonlocal conductances : plot.plot_G_1_G_2_varconst( par, G_1=par.G_11_mu, # total local cond. G_2=par.G_12_S_mu + par.G_12_A_mu, # total nonlocal cond. index_of_varconst=ppar.mu_cut_index, filename="G_11_12_mu_0_vs_bias" + ppar.filename, figtitle=" ", xlabel=r"$V\ [meV]$", # bias axis ylabel=r"$G_{\alpha \beta}^0(V)\ [e^2/h]$", legend=[r"$G_{LL}^0$", r"$G_{LR}^0$"], ylim=[-1.1 * G_full_absmax, 1.1 * G_full_absmax], colors=['--k', "C0"]) # Line-cut plot of the symmetry-decomposed differential conductances : plot.plot_G_1_G_2_varconst(par, G_1=par.G_12_S_mu, # nonlocal symmetric G_2=par.G_12_A_mu, # nonlocal antisymmetric G_3=par.G_11_S_mu, # local symmetric G_4=par.G_11_A_mu, # local antisymmetric index_of_varconst=ppar.mu_cut_index, filename="G_11_12_A_S_mu_0_vs_bias", figtitle=" ", xlabel=r"$V\ [meV]$", ylabel=r"$G_{\alpha \beta}^{0,sym/asym}(V)\ [e^2/h]$", legend=[r"$G_{LR}^{0,sym}$", r"$G_{LR}^{0,asym}$", \ r"$G_{LL}^{0,sym}$", r"$G_{LL}^{0,asym}$"], ylim=[-1.1*G_full_absmax, 1.1*G_full_absmax], colors=['C1', "C0", "k", "gray"] )
from math import sqrt import scipy.sparse.linalg as sla from matplotlib import pyplot import kwant syst = kwant.Builder() lat = kwant.lattice.general([(1, 0, 0), (0, 1, 0), (0, 0, 1)]) t = 1.0 R = 10 syst[(lat(x, y, z) for x in range(-R - 1, R + 1) for y in range(-R - 1, R + 1) for z in range(R + 1) if sqrt(x**2 + y**2 + z**2) < R + 0.01)] = 4 * t syst[(lat(x, y, z) for x in range(-2 * R, 2 * R + 1) for y in range(-R, R + 1) for z in range(-R, 0))] = 4 * t syst[lat.neighbors()] = -t syst = syst.finalized() kwant.plot(syst) ham = syst.hamiltonian_submatrix(sparse=True) wf = abs(sla.eigs(ham, sigma=0.2, k=6)[1][:, 0])**2 size = 3 * wf / wf.max() kwant.plot(syst, site_size=size, site_color=(0, 0, 1, 0.05), site_lw=0)
# return 0 <= x < a and 0 <= y < b and 0 <= z < c return x**2 + y**2 < r**2 and 0 <= z < c sys = kwant.Builder() sys[lat.shape(cuboid_shape, (0, 0, 0))] = None sys[lat.neighbors()] = 1 #sys[lat.neighbors(2)] = 110 sys[lat.neighbors(3)] = 1 return sys sys = make_cuboid(r=5, c=5) def family_colors(site): if site.family == a: return 'r' if site.family == b: return 'b' if site.family == c: return 'g' if site.family == d: return 'c' kwant.plot(sys, site_size=0.18, site_lw=0.01, hop_lw=0.05, site_color=family_colors)
lead1_d[kwant.HoppingKind((-1, 1), c,b)] = hop_ras_e3_d lead1_d[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings1_d]] = Hop_Value_d lead1_d[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings2_d]] = Hop_Value_d sys.attach_lead(lead1_d) #============================================================================== def family_colors(site): return 0 if (site.family == a or site.family == c) else 1 def hopping_lw(site1, site2): return 0.04 if site1.family == site2.family else 0.1 def hopping_color(site1,site2): return 'g' if site1.family==site2.family else 'g' kwant.plot(sys,site_color=family_colors,site_lw=0.1, hop_lw=hopping_lw,hop_color=hopping_color,colorbar=False) sys=sys.finalized() #====================== 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()
p.angle) * s_x return 4 * s_0 W = 10 H = kwant.Builder() H[(lat(x, y) for x in range(5 * W) for y in range(W))] = onsite H[lat.neighbors()] = s_0 sym = kwant.TranslationalSymmetry(lat.vec((1, 0))) Hlead = kwant.Builder(sym) Hlead[(lat(0, y) for y in range(W))] = 4 * s_0 Hlead[lat.neighbors()] = s_0 H.attach_lead(Hlead) H.attach_lead(Hlead.reversed()) kwant.plot(H) # In order to visualize the potential, it can be useful to have color maps of it. # In[3]: ps = SimpleNamespace(Exc=2., E=1.2, angle=pi) def V(site): Hd = onsite(site, ps) return (Hd[0, 0] - Hd[1, 1]).real kwant.plotter.map(H, V)
lead = kwant.Builder( kwant.TranslationalSymmetry((0, 0, -a), lat.vec((L[0], 0, 0)), lat.vec((0, L[1], 0)))) lead[(lat(i, j, 0) for i in range(L[0]) for j in range(L[1]))] = 6 * t + e_leads lead[lat.neighbors()] = -t lead = kwant.wraparound.wraparound(lead, keep=0) sys.attach_lead(lead) sys.attach_lead(lead.reversed()) # --------------------------------------------------------------- # if rank == 0: print("Plotting kwant system...") kwant.plot(sys, site_color=potential_at_point, cmap='jet', site_size=0.4, fig_size=(15, 9), file=(out_dir + "kwant.png")) sys = sys.finalized() # ----------------------------------------------------------------------------- # Starting calculation transmission = [] submatrices = [] num_prop = [] for energy in e_range: start_time = time.time() smatrix = kwant.smatrix(sys, energy, [kx_sl, ky_sl])
prim_vecs = tinyarray.array([(a, 0., 0.), (0., a, 0.), (0., 0., a)]) offset = tinyarray.array((-1.2663118961, 0.4114496766, 0.0)) lat2 = kwant.lattice.Monatomic(prim_vecs, offset, norbs=no) syst[lat2(0, 0, N)] = e1 * sigma_0 syst[amorphous_lat(2 * N - 1), lat2(0, 0, N)] = tr * sigma_0 up_lead = kwant.Builder(kwant.TranslationalSymmetry((0, 0, a))) up_lead[lat2(0, 0, N + 1)] = e1 * sigma_0 up_lead[lat2.neighbors()] = t0 * sigma_0 syst.attach_lead(up_lead) system = kwant.plot(syst, site_lw=0.1, site_color=family_color, hop_lw=hopping_lw, fig_size=(20, 15)) trans = True if trans: syst = syst.finalized() energies = [] data = [] for ie in range(-320, 520): energy = ie * 0.001 smatrix = kwant.smatrix(syst, energy=energy) energies.append(energy) data.append(0.5 * smatrix.transmission(1, 0)) fig = pyplot.figure(figsize=(6, 2))
def test(): sys, lead = make_system_two_terminal(Nx =10, Ny = 10) sys1, lead1 = make_system_four_terminal(Nx = 5, Ny = 5) kwant.plot(sys1) kwant.plot(sys)
def test(): sys, lead = make_system_two_terminal(Nx=10, Ny=10) sys1, lead1 = make_system_four_terminal(Nx=5, Ny=5) kwant.plot(sys1) kwant.plot(sys)
return x**2 + y**2 < 20 lat = kwant.lattice.triangular() sys = kwant.Builder() sys[lat.shape(circle, (0, 0))] = 0 sys[lat.neighbors()] = 1 lead_dirs = [lat.vec((-3, 1)), lat.vec((0, -1)), lat.vec((2, -1))] for d in lead_dirs: lead = kwant.Builder(kwant.TranslationalSymmetry(d)) lead[lat.wire((0, 0), 2.1)] = 0 lead[lat.neighbors()] = 1 sys.attach_lead(lead) fig = kwant.plot(sys, show=False) ax = pyplot.gca() pyplot.text(-2, 5.5, 'scattering region', size=15) pyplot.text(-10, -1, 'lead 0', color='red', size=15) pyplot.text(-3, -7.7, 'lead 1', color='red', size=15) pyplot.text(5.5, 0, 'lead 2', color='red', size=15) for dir, offset in zip(lead_dirs, [10.5, 8, 8.6]): dir = dir / math.sqrt(ta.dot(dir, dir)) for i in [0, 0.4, 0.8]: ax.add_artist(Circle(dir * (offset + i), 0.06, fc='k')) pyplot.axis('off') pyplot.xlim((-11, 9)) pyplot.ylim((-8, 6)) fig.tight_layout()
#HIDDEN_BEGIN_xhqc sym_right_lead = kwant.TranslationalSymmetry((a, 0)) right_lead = kwant.Builder(sym_right_lead) for j in xrange(W): right_lead[lat(0, j)] = 4 * t if j > 0: right_lead[lat(0, j), lat(0, j - 1)] = -t right_lead[lat(1, j), lat(0, j)] = -t sys.attach_lead(right_lead) #HIDDEN_END_xhqc # Plot it, to make sure it's OK #HIDDEN_BEGIN_wsgh kwant.plot(sys) #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
def make_system(a=1, t=1, L=10, W=10, srashba=0, barrier=0, lshift=0, lferro=0, theta=0, phi=0, uleftedge=5, uwidth=2, ushift=0, show=False): """Create a tight-binding system on a square lattice. Keyword arguments: a -- Lattice constant (default 1) t -- Hopping amplitude (default 1) L -- Length of scattering region (default 10) W -- Width of scattering region (default 10) srashba -- Rashba strength in scattering region (default 0) lshift -- Net energy shift in left lead (default 0) lferro -- FM strength in left lead (default 0) theta -- FM orientation (default 0) phi -- FM orientation (default 0) uleftedge -- Starting position of upper lead (default 5) uwidth -- Width of upper lead (default 2) """ square = kwant.lattice.square(a) # Define the scattering region shape. def rectangle(pos): x, y = pos return (0 <= x <= L) and (0 <= y <= W) sys = kwant.Builder() # Define the scattering region. sys[square.shape(rectangle, (0, 0))] = 4 * t * s_0 * 0 for j in range(0, W + 1): sys[square(0, j)] = (4 * t * 0 + barrier) * s_0 # Hoppings in the x-direction. sys[kwant.builder.HoppingKind((1, 0), square, square)] = (-t * s_0 - 1j * srashba * s_y) # Hoppings in the y-direction. sys[kwant.builder.HoppingKind((0, 1), square, square)] = (-t * s_0 + 1j * srashba * s_x) # Plot closed system. # kwant.plot(sys) # Define the left and right lead shapes. def lead_shape(pos): x, y = pos return (0 <= y <= W) # Define the left lead. llead = kwant.Builder(kwant.TranslationalSymmetry((-1, 0))) llead[square.shape( lead_shape, (0, 0))] = (4 * t * s_0 * 0 + (lshift) * s_0 - lferro * (sin(theta) * cos(phi) * s_x + sin(theta) * sin(phi) * s_y + cos(theta) * s_z)) llead[kwant.builder.HoppingKind((1, 0), square, square)] = -t * s_0 llead[kwant.builder.HoppingKind((0, 1), square, square)] = -t * s_0 # Define the right lead. rlead = kwant.Builder(kwant.TranslationalSymmetry((1, 0))) rlead[square.shape(lead_shape, (0, 0))] = (4 * t * 0) * s_0 rlead[kwant.builder.HoppingKind((1, 0), square, square)] = -t * s_0 rlead[kwant.builder.HoppingKind((0, 1), square, square)] = -t * s_0 # Define the upper lead. ulead = kwant.Builder(kwant.TranslationalSymmetry((0, 1))) ulead[(square(i, 0) for i in xrange(uleftedge, uleftedge + uwidth))] = (4 * t * 0 + ushift) * s_0 ulead[square.neighbors()] = -t * s_0 # Attach leads to the system sys.attach_lead(llead) sys.attach_lead(rlead) sys.attach_lead(ulead) if show is True: kwant.plot(sys) return sys, [llead, rlead, ulead]
system.attach_lead(left_lead) sym_right_lead = kwant.TranslationalSymmetry((a, 0)) right_lead = kwant.Builder(sym_right_lead) for j in range(W): right_lead[lattice(0, j)] = 4 * t if j > 0: right_lead[lattice(0, j), lattice(0, j - 1)] = -t right_lead[lattice(1, j), lattice(0, j)] = -t system.attach_lead(right_lead) # Visualize the system kwant.plot(system) system = system.finalized() energies = [] data = [] for ie in range(100): energy = ie * 0.01 smatrix = kwant.smatrix(system, energy) energies.append(energy) data.append(smatrix.transmission(1, 0)) plt.plot(energies, data) plt.xlabel('energy [t]')
def _make_syst_jj_2d( m=0.03 * const_m_e, a=5e-9, width=3e-6, electrode_length=3e-6, junction_length=100e-9, mu=None, gap_potential=0, gap_potential_shape=None, disorder=0, gap=None, delta_phi=None, # pure rashba: # # 0 1 # -1 0 # # pure dresselhaus # 0 1 # 1 0 SOI=np.array([[0, 0], [0, 0]]), # | a b | # SOI = | | # | c d | # (σ_x, σ_y) x SOI x (k_x ,k_y)^t = # k_x(a σ_x + c σ_y) + k_y(b σ_x + d σ_y) B=[0, 0, 0], g_factor=-10, debug=False, salt=''): print("making 2d JJ system:\n", locals()) t = const_hbar**2 / (2 * m * a**2) # print("m = %g, a = %g, width = %g, electrode_length = %g, junction_length = %g, t = %g" % (m, a, width, electrode_length, junction_length, t)) W = int(width / a) L = int((2 * electrode_length + junction_length) / a) L_junction = int(junction_length / a) print("L = %d, W = %d, L_junction = %d" % (L, W, L_junction)) lat = kwant.lattice.square(1) syst = kwant.Builder() # On-site def onsite(site): (x, y) = site.pos # p^2 / (2m) - μ + U(r) h0 = 4 * t - mu # variance of h0 is disorder if (disorder != 0): h0 = h0 + disorder * kwant.digest.gauss(site.pos, salt=salt) dphi = delta_phi if x > L / 2: dphi = -dphi start_junction = int((L - L_junction) / 2) pairing = 0 if x < start_junction or x >= start_junction + L_junction: # in electrodes: add pairing term pairing = np.kron( tau_x * np.cos(dphi / 2) - tau_y * np.sin(dphi / 2), gap * sigma_0) else: # in junction if gap_potential_shape == 'cosine_half': h0 = h0 + gap_potential * np.cos(2 * np.pi * (x - L / 2) / (2 * L_junction)) elif gap_potential_shape == 'cosine': h0 = h0 + gap_potential * 1 / 2 * ( 1 + np.cos(2 * np.pi * (x - L / 2) / L_junction)) else: h0 = h0 + gap_potential # mod = (y*a) % junction_island_spacing # if mod < junction_island_width and\ # abs((x-L/2)*a) < junction_island_width/2: # pairing = np.kron(tau_x, gap*sigma_0) # from "a josephson supercurrent diode" paper supplement zeeman = 0.5 * g_factor * const_bohr_magneton * ( B[0] * sigma_x + B[1] * sigma_y + B[2] * sigma_z) return np.kron(tau_z, h0 * sigma_0) + np.kron(tau_0, zeeman) + pairing syst[(lat(x, y) for x in range(L) for y in range(W))] = onsite # Hoppings # Rashba term in hamiltonian: -iα(∂_x σ_y - ∂_y σ_x) = α(k_xσ_y - k_yσ_x) # ∂_x -> 1/(2a) (f_{n+1} - f_{n-1}) # k_x -> -i/(2a)(f_{n+1} - f_{n-1}) # x direction SOI_x = SOI[0, 0] * sigma_x + SOI[1, 0] * sigma_y SOI_y = SOI[0, 1] * sigma_x + SOI[1, 1] * sigma_y syst[kwant.builder.HoppingKind((1, 0), lat, lat)] = \ np.kron(tau_z, -t * sigma_0 -1j/(2*a) * SOI_x) # y direction syst[kwant.builder.HoppingKind((0, 1), lat, lat)] = \ np.kron(tau_z, -t * sigma_0 -1j/(2*a) * SOI_y) # debug functions def onsite_00(site): # onsite electron return np.abs(onsite(site)[0, 0]) def onsite_01(site): return np.abs(onsite(site)[2, 0]) if debug: kwant.plot(syst, site_color=onsite_00) kwant.plot(syst, site_color=onsite_01) return syst.finalized()
from math import sqrt import scipy.sparse.linalg as sla from matplotlib import pyplot import kwant syst = kwant.Builder() lat = kwant.lattice.general([(1,0,0), (0,1,0), (0,0,1)]) t = 1.0 R = 10 syst[(lat(x,y,z) for x in range(-R-1, R+1) for y in range(-R-1, R+1) for z in range(R+1) if sqrt(x**2 + y**2 + z**2) < R + 0.01)] = 4 * t syst[(lat(x,y,z) for x in range(-2*R, 2*R + 1) for y in range(-R, R+1) for z in range(-R, 0))] = 4 * t syst[lat.neighbors()] = -t syst = syst.finalized() kwant.plot(syst) ham = syst.hamiltonian_submatrix(sparse=True) wf = abs(sla.eigs(ham, sigma=0.2, k=6)[1][:,0])**2 size = 3 * wf / wf.max() kwant.plot(syst, site_size=size, site_color=(0,0,1,0.05), site_lw=0)
########### t5 ########### left_lead[sub_d(i, j), sub_a(i, j)] = t5 if j > 0: left_lead[sub_b(i, j), sub_c(i, j - 1)] = t5 ########### t5 ########### syst.attach_lead(left_lead) right_lead = left_lead.reversed() syst.attach_lead(right_lead) # Plot it, to make sure it's OK def family_colors(site): return 'r' if (site.family == sub_a or site.family == sub_b) else 'g' kwant.plot(syst, site_size=0.12, site_color=family_colors) kwant.plotter.sys_leads_sites(syst) # Finalize the system syst = syst.finalized() def plot_wave_function(sys): # Calculate the wave functions in the system. ham_mat = sys.hamiltonian_submatrix(sparse=True) evecs = sla.eigsh(ham_mat, k=10, which='SM')[1] # Plot the probability density of the 10th eigenmode. kwant.plotter.map(sys, np.abs(evecs[:, 9])**2, oversampling=1)
lead[(lat(0))] = 1 lead[lat.neighbors()] = -1 syst.attach_lead(lead) syst.attach_lead(lead.reversed()) return syst def mount_vlead(sys, vlead_interface, norb): """Mounts virtual lead to interfaces provided. :sys: kwant.builder.Builder An unfinalized system to mount leads :vlead_interface: sequence of kwant.builder.Site Interface of lead :norb: integer Number of orbitals in system hamiltonian. """ dim = len(vlead_interface)*norb zero_array = np.zeros((dim, dim), dtype=float) def selfenergy_func(energy, args=()): return zero_array vlead = kwant.builder.SelfEnergyLead(selfenergy_func, vlead_interface) sys.leads.append(vlead) sys=make_system(10) sys=sys.finalized() kwant.plot(sys,fig_size=(5, 10)) s=kwant.smatrix(sys,1.5,check_hermiticity=False).data abs(np.linalg.det(s))