def ase_et(self, scatter_hamil): # Set up options if we want to call ASE with special cases if self.input.dict['orthonormal_overlap'] != 'False': scatter_hamil['s'] = None scatter_hamil['s1'] = None scatter_hamil['s2'] = None # initialize the calculator ETran = TCalc(h=scatter_hamil['h'], h1=scatter_hamil['h1'], h2=scatter_hamil['h2'], s=scatter_hamil['s'], s1=scatter_hamil['s1'], s2=scatter_hamil['s2']) # Disable reading in the off diagonal matrices if (self.input.dict['exclude_coupling'] == 'False'): ETran.set(hc1=scatter_hamil['hc1'], hc2=scatter_hamil['hc2'], sc1=scatter_hamil['sc1'], sc2=scatter_hamil['sc2']) # either calculate the electron transport at the Fermi level or a # range of values relative to the Fermi level if (self.input.dict['energy_levels_ET'] is None): temp_form = [(0.0)] ETran.set(energies=[(0.0)]) else: temp_form = self.input.dict['energy_levels_ET'] ETran.set( energies=np.arange(temp_form[0], temp_form[1], temp_form[2])) # ase has some warnings that we can't do anything about, # so suppress the warnings with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=FutureWarning) T = ETran.get_transmission() # print results if (self.input.dict['energy_levels_ET'] is not None): j = 0 for i in np.arange(temp_form[0], temp_form[1], temp_form[2]): printx("Energy = {0:.3f} Transmission = {1}".format(i, T[j]), self.file) j += 1 self.print_conductance(T, temp_form[2], temp_form[0], temp_form[1]) else: printx("Energy = 0.0 Transmission = {0}".format(T[0]), self.file) printx("\n", self.file) return
def test_transport_calculator(): H_lead = np.zeros([4, 4]) # On-site energies are zero for i in range(4): H_lead[i, i] = 0.0 # Nearest neighbor hopping is -1.0 for i in range(3): H_lead[i, i + 1] = -1.0 H_lead[i + 1, i] = -1.0 # Next-nearest neighbor hopping is 0.2 for i in range(2): H_lead[i, i + 2] = 0.2 H_lead[i + 2, i] = 0.2 H_scat = np.zeros([6, 6]) # Principal layers on either side of S H_scat[:2, :2] = H_lead[:2, :2] H_scat[-2:, -2:] = H_lead[:2, :2] # Scattering region H_scat[2, 2] = 0.0 H_scat[3, 3] = 0.0 H_scat[2, 3] = -0.8 H_scat[3, 2] = -0.8 # External coupling H_scat[1, 2] = 0.2 H_scat[2, 1] = 0.2 H_scat[3, 4] = 0.2 H_scat[4, 3] = 0.2 energies = np.arange(-3, 3, 0.02) tcalc = TransportCalculator(h=H_scat, h1=H_lead, eta=0.02, energies=energies) T = tcalc.get_transmission() tcalc.set(pdos=[2, 3]) pdos = tcalc.get_pdos() tcalc.set(dos=True) dos = tcalc.get_dos() write('T.dat', tcalc.energies, T) write('pdos0.dat', tcalc.energies, pdos[0]) write('pdos1.dat', tcalc.energies, pdos[1]) #subdiagonalize h_rot, s_rot, eps, u = tcalc.subdiagonalize_bfs([2, 3], apply=True) T_rot = tcalc.get_transmission() dos_rot = tcalc.get_dos() pdos_rot = tcalc.get_pdos() write('T_rot.dat', tcalc.energies, T_rot) write('pdos0_rot.dat', tcalc.energies, pdos_rot[0]) write('pdos1_rot.dat', tcalc.energies, pdos_rot[1]) print('Subspace eigenvalues:', eps) assert sum(abs(eps - (-0.8, 0.8))) < 2.0e-15, 'Subdiagonalization. error' print('Max deviation of T after the rotation:', np.abs(T - T_rot).max()) assert max(abs(T - T_rot)) < 2.0e-15, 'Subdiagonalization. error' #remove coupling h_cut, s_cut = tcalc.cutcoupling_bfs([2], apply=True) T_cut = tcalc.get_transmission() dos_cut = tcalc.get_dos() pdos_cut = tcalc.get_pdos() write('T_cut.dat', tcalc.energies, T_cut) write('pdos0_cut.dat', tcalc.energies, pdos_cut[0]) write('pdos1_cut.dat', tcalc.energies, pdos_cut[1])
H_scat[2, 2] = 0.0 H_scat[3, 3] = 0.0 H_scat[2, 3] = -0.8 H_scat[3, 2] = -0.8 # External coupling H_scat[1, 2] = 0.2 H_scat[2, 1] = 0.2 H_scat[3, 4] = 0.2 H_scat[4, 3] = 0.2 energies = np.arange(-3, 3, 0.02) tcalc = TransportCalculator(h=H_scat, h1=H_lead, eta=0.02, energies=energies) T = tcalc.get_transmission() tcalc.set(pdos=[2, 3]) pdos = tcalc.get_pdos() tcalc.set(dos=True) dos = tcalc.get_dos() write('T.dat', tcalc.energies, T) write('pdos0.dat', tcalc.energies, pdos[0]) write('pdos1.dat', tcalc.energies, pdos[1]) #subdiagonalize h_rot, s_rot, eps, u = tcalc.subdiagonalize_bfs([2, 3], apply=True) T_rot = tcalc.get_transmission() dos_rot = tcalc.get_dos() pdos_rot = tcalc.get_pdos()
# coupling to the leads - nearest neighbor only H_scat[1, 2] = H_scat[2, 1] = H_scat[3, 4] = H_scat[4, 3] = 0.2 tcalc = TransportCalculator( h=H_scat, # Scattering Hamiltonian h1=H_lead, # Lead 1 (left) h2=H_lead, # Lead 2 (right) energies=np.arange(-3, 3, 0.02)) T_e = tcalc.get_transmission() pylab.plot(tcalc.energies, T_e) pylab.title('Transmission function') pylab.show() tcalc.set(pdos=[2, 3]) pdos_ne = tcalc.get_pdos() pylab.plot(tcalc.energies, pdos_ne[0], ':') pylab.plot(tcalc.energies, pdos_ne[1], '--') pylab.title('Projected density of states') pylab.show() h_rot, s_rot, eps_n, vec_nn = tcalc.subdiagonalize_bfs([2, 3]) tcalc.set(h=h_rot, s=s_rot) # Set the rotated matrices for n in range(2): print("eigenvalue, eigenvector:", eps_n[n], ',', vec_nn[:, n]) pdos_rot_ne = tcalc.get_pdos() pylab.plot(tcalc.energies, pdos_rot_ne[0], ':') pylab.plot(tcalc.energies, pdos_rot_ne[1], '--') pylab.title('Projected density of states (rotated)')
# Uncomment this line if going back to gpawtransport again # h, s = h[pl:-pl, pl:-pl], s[pl:-pl, pl:-pl] h1, s1 = pickle.load(open('lead1_hs.pickle', 'rb')) h2, s2 = pickle.load(open('lead2_hs.pickle', 'rb')) tcalc = TransportCalculator( h=h, h1=h1, h2=h2, # hamiltonian matrices s=s, s1=s1, s2=s2, # overlap matrices align_bf=1) # align the Fermi levels # Calculate the conductance (the energy zero corresponds to the Fermi level) tcalc.set(energies=[0.0]) G = tcalc.get_transmission()[0] print('Conductance: %.2f 2e^2/h' % G) # Determine the basis functions of the two Hydrogen atoms and subdiagonalize Pt_N = 5 # Number of Pt atoms on each side in the scattering region Pt_nbf = 15 # number of bf per Pt atom (basis=szp) H_nbf = 4 # number of bf per H atom (basis=szp) bf_H1 = Pt_nbf * Pt_N bfs = range(bf_H1, bf_H1 + 2 * H_nbf) h_rot, s_rot, eps_n, vec_jn = tcalc.subdiagonalize_bfs(bfs) for n in range(len(eps_n)): print("bf %i corresponds to the eigenvalue %.2f eV" % (bfs[n], eps_n[n])) # Switch to the rotated basis set tcalc.set(h=h_rot, s=s_rot)
H_scat[2:4, 2:4] = [[0.0, -0.8], [-0.8, 0.0]] # coupling to the leads - nearest neighbor only H_scat[1, 2] = H_scat[2, 1] = H_scat[3, 4] = H_scat[4, 3] = 0.2 tcalc = TransportCalculator(h=H_scat, # Scattering Hamiltonian h1=H_lead, # Lead 1 (left) h2=H_lead, # Lead 2 (right) energies=np.arange(-3, 3, 0.02)) T_e = tcalc.get_transmission() pylab.plot(tcalc.energies, T_e) pylab.title('Transmission function') pylab.show() tcalc.set(pdos=[2, 3]) pdos_ne = tcalc.get_pdos() pylab.plot(tcalc.energies, pdos_ne[0], ':') pylab.plot(tcalc.energies, pdos_ne[1], '--') pylab.title('Projected density of states') pylab.show() h_rot, s_rot, eps_n, vec_nn = tcalc.subdiagonalize_bfs([2, 3]) tcalc.set(h=h_rot, s=s_rot) # Set the rotated matrices for n in range(2): print("eigenvalue, eigenvector:", eps_n[n], ',', vec_nn[:, n]) pdos_rot_ne = tcalc.get_pdos() pylab.plot(tcalc.energies, pdos_rot_ne[0], ':') pylab.plot(tcalc.energies, pdos_rot_ne[1], '--') pylab.title('Projected density of states (rotated)')
H_scat[3,2] = -0.8 # External coupling H_scat[1,2] = 0.2 H_scat[2,1] = 0.2 H_scat[3,4] = 0.2 H_scat[4,3] = 0.2 energies = np.arange(-3,3,0.02) tcalc = TransportCalculator(h=H_scat, h1=H_lead, h2=H_lead, energies=energies) T = tcalc.get_transmission() tcalc.set(pdos=[2, 3]) pdos = tcalc.get_pdos() tcalc.set(dos=True) dos = tcalc.get_dos() write('T.dat',tcalc.energies,T) write('pdos0.dat', tcalc.energies,pdos[0]) write('pdos1.dat', tcalc.energies,pdos[1]) #subdiagonalize h_rot, s_rot, eps, u = tcalc.subdiagonalize_bfs([2, 3]) tcalc.set(h=h_rot,s=s_rot) T_rot = tcalc.get_transmission() dos_rot = tcalc.get_dos() pdos_rot = tcalc.get_pdos()
H_scat[3,2] = -0.8 # External coupling H_scat[1,2] = 0.2 H_scat[2,1] = 0.2 H_scat[3,4] = 0.2 H_scat[4,3] = 0.2 energies = np.arange(-3,3,0.02) tcalc = TransportCalculator(h=H_scat, h1=H_lead, eta=0.02, energies=energies) T = tcalc.get_transmission() tcalc.set(pdos=[2, 3]) pdos = tcalc.get_pdos() tcalc.set(dos=True) dos = tcalc.get_dos() write('T.dat',tcalc.energies,T) write('pdos0.dat', tcalc.energies,pdos[0]) write('pdos1.dat', tcalc.energies,pdos[1]) #subdiagonalize h_rot, s_rot, eps, u = tcalc.subdiagonalize_bfs([2, 3], apply=True) T_rot = tcalc.get_transmission() dos_rot = tcalc.get_dos() pdos_rot = tcalc.get_pdos()
# Uncomment this line if going back to gpawtransport again # pl = 4 * 9 # 9 is the number of bf per Pt atom (basis=szp), see below # Read in the hamiltonians h, s = pickle.load(file('scat_hs.pickle')) # Uncomment this line if going back to gpawtransport again # h, s = h[pl:-pl, pl:-pl], s[pl:-pl, pl:-pl] h1, s1 = pickle.load(file('lead1_hs.pickle')) h2, s2 = pickle.load(file('lead2_hs.pickle')) tcalc = TransportCalculator(h=h, h1=h1, h2=h2, # hamiltonian matrices s=s, s1=s1, s2=s2, # overlap matrices align_bf=1) # align the Fermi levels # Calculate the conductance (the energy zero corresponds to the Fermi level) tcalc.set(energies=[0.0]) G = tcalc.get_transmission()[0] print('Conductance: %.2f 2e^2/h' % G) # Determine the basis functions of the two Hydrogen atoms and subdiagonalize Pt_N = 5 # Number of Pt atoms on each side in the scattering region Pt_nbf = 9 # number of bf per Pt atom (basis=szp) H_nbf = 4 # number of bf per H atom (basis=szp) bf_H1 = Pt_nbf * Pt_N bfs = range(bf_H1, bf_H1 + 2 * H_nbf) h_rot, s_rot, eps_n, vec_jn = tcalc.subdiagonalize_bfs(bfs) for n in range(len(eps_n)): print("bf %i corresponds to the eigenvalue %.2f eV" % (bfs[n], eps_n[n])) # Switch to the rotated basis set tcalc.set(h=h_rot, s=s_rot)