def initialize(self, energies, bias=0): """ energies: list of energies for which the transmission function should be evaluated. bias. Will precalculate the surface greenfunctions of the tip and surface. """ self.bias = bias self.energies = energies nenergies = len(energies) pl1, pl2 = self.pl1, self.pl2 nbf1, nbf2 = len(self.h1), len(self.h2) #periodic part of the tip hs1_dii = self.h10[:pl1, :pl1], self.s10[:pl1, :pl1] hs1_dij = self.h10[:pl1, pl1:2 * pl1], self.s10[:pl1, pl1:2 * pl1] #coupling betwen per. and non. per part of the tip h1_im = np.zeros((pl1, nbf1), complex) s1_im = np.zeros((pl1, nbf1), complex) h1_im[:pl1, :pl1], s1_im[:pl1, :pl1] = hs1_dij hs1_dim = [h1_im, s1_im] #periodic part the surface hs2_dii = self.h20[:pl2, :pl2], self.s20[:pl2, :pl2] hs2_dij = self.h20[pl2:2 * pl2, :pl2], self.s20[pl2:2 * pl2, :pl2] #coupling betwen per. and non. per part of the surface h2_im = np.zeros((pl2, nbf2), complex) s2_im = np.zeros((pl2, nbf2), complex) h2_im[-pl2:, -pl2:], s2_im[-pl2:, -pl2:] = hs2_dij hs2_dim = [h2_im, s2_im] #tip and surface greenfunction self.selfenergy1 = LeadSelfEnergy(hs1_dii, hs1_dij, hs1_dim, self.eta1) self.selfenergy2 = LeadSelfEnergy(hs2_dii, hs2_dij, hs2_dim, self.eta2) self.greenfunction1 = GreenFunction( self.h1 - self.bias * self.w * self.s1, self.s1, [self.selfenergy1], self.eta1) self.greenfunction2 = GreenFunction( self.h2 - self.bias * (self.w - 1) * self.s2, self.s2, [self.selfenergy2], self.eta2) #Shift the bands due to the bias. bias_shift1 = -bias * self.w bias_shift2 = -bias * (self.w - 1) self.selfenergy1.set_bias(bias_shift1) self.selfenergy2.set_bias(bias_shift2) #tip and surface greenfunction matrices. nbf1_small = nbf1 #XXX Change this for efficiency in the future nbf2_small = nbf2 #XXX -||- coupling_list1 = range(nbf1_small) # XXX -||- coupling_list2 = range(nbf2_small) # XXX -||- self.gft1_emm = np.zeros((nenergies, nbf1_small, nbf1_small), complex) self.gft2_emm = np.zeros((nenergies, nbf2_small, nbf2_small), complex) for e, energy in enumerate(self.energies): if self.log != None: # and world.rank == 0: T = time.localtime() self.log.write(' %d:%02d:%02d, ' % (T[3], T[4], T[5]) + '%d, %d, %02f\n' % (world.rank, e, energy)) gft1_mm = self.greenfunction1.retarded(energy)[coupling_list1] gft1_mm = np.take(gft1_mm, coupling_list1, axis=1) gft2_mm = self.greenfunction2.retarded(energy)[coupling_list2] gft2_mm = np.take(gft2_mm, coupling_list2, axis=1) self.gft1_emm[e] = gft1_mm self.gft2_emm[e] = gft2_mm if self.log != None and world.rank == 0: self.log.flush()
def initialize(self): if self.initialized: return print('# Initializing calculator...', file=self.log) p = self.input_parameters if p['s'] is None: p['s'] = np.identity(len(p['h'])) identical_leads = False if p['h2'] is None: p['h2'] = p['h1'] # Lead2 is idendical to lead1 identical_leads = True if p['s1'] is None: p['s1'] = np.identity(len(p['h1'])) if identical_leads: p['s2'] = p['s1'] else: if p['s2'] is None: p['s2'] = np.identity(len(p['h2'])) h_mm = p['h'] s_mm = p['s'] pl1 = len(p['h1']) // 2 pl2 = len(p['h2']) // 2 h1_ii = p['h1'][:pl1, :pl1] h1_ij = p['h1'][:pl1, pl1:2 * pl1] s1_ii = p['s1'][:pl1, :pl1] s1_ij = p['s1'][:pl1, pl1:2 * pl1] h2_ii = p['h2'][:pl2, :pl2] h2_ij = p['h2'][pl2: 2 * pl2, :pl2] s2_ii = p['s2'][:pl2, :pl2] s2_ij = p['s2'][pl2: 2 * pl2, :pl2] if p['hc1'] is None: nbf = len(h_mm) h1_im = np.zeros((pl1, nbf), complex) s1_im = np.zeros((pl1, nbf), complex) h1_im[:pl1, :pl1] = h1_ij s1_im[:pl1, :pl1] = s1_ij p['hc1'] = h1_im p['sc1'] = s1_im else: h1_im = p['hc1'] if p['sc1'] is not None: s1_im = p['sc1'] else: s1_im = np.zeros(h1_im.shape, complex) p['sc1'] = s1_im if p['hc2'] is None: h2_im = np.zeros((pl2, nbf), complex) s2_im = np.zeros((pl2, nbf), complex) h2_im[-pl2:, -pl2:] = h2_ij s2_im[-pl2:, -pl2:] = s2_ij p['hc2'] = h2_im p['sc2'] = s2_im else: h2_im = p['hc2'] if p['sc2'] is not None: s2_im = p['sc2'] else: s2_im = np.zeros(h2_im.shape, complex) p['sc2'] = s2_im align_bf = p['align_bf'] if align_bf is not None: diff = ((h_mm[align_bf, align_bf] - h1_ii[align_bf, align_bf]) / s_mm[align_bf, align_bf]) print('# Aligning scat. H to left lead H. diff=', diff, file=self.log) h_mm -= diff * s_mm # Setup lead self-energies # All infinitesimals must be > 0 assert np.all(np.array((p['eta'], p['eta1'], p['eta2'])) > 0.0) self.selfenergies = [LeadSelfEnergy((h1_ii, s1_ii), (h1_ij, s1_ij), (h1_im, s1_im), p['eta1']), LeadSelfEnergy((h2_ii, s2_ii), (h2_ij, s2_ij), (h2_im, s2_im), p['eta2'])] box = p['box'] if box is not None: print('Using box probe!') self.selfenergies.append( BoxProbe(eta=box[0], a=box[1], b=box[2], energies=box[3], S=s_mm, T=0.3)) # setup scattering green function self.greenfunction = GreenFunction(selfenergies=self.selfenergies, H=h_mm, S=s_mm, eta=p['eta']) self.initialized = True