def main(): if myrank == 0: time0 = time.time() if myrank == 0: print(' ') print('nprocs = ', nprocs) assert not os.path.exists(savedir + 'Sigma') and not os.path.exists( savedir + 'Gloc'), 'Cannot overwrite existing data' volume = Nkx * Nky k2p, k2i, i2k = init_k2p_k2i_i2k(Nkx, Nky, nprocs, myrank) kpp = np.count_nonzero(k2p == myrank) integrator = integration.integrator(6, nt, beta, ntau) def H(kx, ky, t): return -2.0 * np.cos(kx) * np.ones([norb, norb]) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) UksR, UksI, eks, fks, Rs, Ht = init_Uks(H, dt_fine, *constants, version='higher order') print('Done initializing Us') SigmaM = matsubara(0, 0, 0, 0) SigmaM.load(savedir, 'SigmaM') # Solve real axis part xo #--------------------------------------------------------- D = compute_D0R(norb, omega, nt, tmax, ntau, beta, +1) print('Done initializing D') Sigma0 = langreth(norb, nt, tmax, ntau, beta, -1) Sigma = langreth(norb, nt, tmax, ntau, beta, -1) iter_selfconsistency = 4 change = 0.0 for i in range(iter_selfconsistency): print('iteration : %d' % i) Sigma0.copy(Sigma) Gloc = langreth(norb, nt, tmax, ntau, beta, -1) for ik in range(kpp): ik1, ik2 = i2k[ik] G0M = compute_G0M(ik1, ik2, UksI, eks, fks, Rs, *constants) G0 = compute_G0R(ik1, ik2, UksR, UksI, eks, fks, Rs, *constants) if i == 0: G = G0 else: G = langreth(norb, nt, tmax, ntau, beta, -1) integrator.dyson_langreth(G0M, SigmaM, G0, Sigma, G) Gloc.add(G) Sigma = langreth(norb, nt, tmax, ntau, beta, -1) if nprocs == 1: Sigma.copy(Gloc) else: comm.Allreduce(Gloc.L, Sigma.L, op=MPI.SUM) comm.Allreduce(Gloc.R, Sigma.R, op=MPI.SUM) comm.Allreduce(Gloc.RI, Sigma.RI, op=MPI.SUM) comm.Allreduce(Gloc.deltaR, Sigma.deltaR, op=MPI.SUM) Sigma.multiply(D) Sigma.scale(1j * g2 / volume) print('Done computing Sigma') print('sigma size') print(np.mean(np.abs(Sigma.R))) print(np.mean(np.abs(Sigma.RI))) print(np.mean(np.abs(Sigma.L))) change = max([np.mean(abs(Sigma0.R-Sigma.R)), \ np.mean(abs(Sigma0.L-Sigma.L)), \ np.mean(abs(Sigma0.RI-Sigma.RI)), \ np.mean(abs(Sigma0.deltaR-Sigma.deltaR))]) print('change = %1.3e' % change) Sigma.save(savedir, 'Sigma') Gloc.save(savedir, 'Gloc') saveparams(savedir) if 'MPI' in sys.modules: MPI.Finalize()
def main(): if myrank==0: time0 = time.time() print(' ') print('nprocs = ',nprocs) Nkx = 1 Nky = 1 k2p, k2i, i2k = init_k2p_k2i_i2k(Nkx, Nky, nprocs, myrank) kpp = np.count_nonzero(k2p==myrank) beta = 10.0 ARPES = False pump = 0 g2 = None omega = None tmax = 1.0 #dt_fine = 0.001 dt_fine = 0.001 order = 6 ntau = 800 #nts = [10, 50, 100, 500] nts = [100] diffs = {} diffs['nts'] = nts diffs['U'] = [] diffs['M'] = [] diffs['IR'] = [] diffs['R'] = [] diffs['L'] = [] delta = 0.3 omega = 0.2 V = 0.5 norb = 2 def H(kx, ky, t): #Bx = 2.0*V*np.cos(2.0*omega*t) #By = 2.0*V*np.sin(2.0*omega*t) #Bz = 2.0*delta #return 0.5*np.array([[Bz, Bx-1j*By], [Bx+1j*By, -Bz]], dtype=complex) return np.array([[delta, V*np.exp(-2.0*1j*omega*t)], [V*np.exp(+2.0*1j*omega*t), -delta]], dtype=complex) def compute_time_dependent_G0(H, myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump): # check how much slower this is than computing G0 using U(t,t') norb = np.shape(H(0,0,0))[0] def H0(kx, ky, t): return np.zeros([norb,norb]) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) UksR, UksI, eks, fks, Rs, Ht = init_Uks(H0, dt_fine, *constants, version='higher order') G0M_ref = compute_G0M(0, 0, UksI, eks, fks, Rs, *constants) G0_ref = compute_G0R(0, 0, UksR, UksI, eks, fks, Rs, *constants) dt = 1.0*tmax/(nt-1) G0M = compute_G00M(0, 0, *constants) G0 = compute_G00R(0, 0, *constants) print('test G00') differences(G0_ref, G0) ''' G00M = compute_G00M(0, 0, *constants) G00 = compute_G00R(0, 0, G0M, *constants) print('shpae G0M', np.shape(G0M.M)) print('shape G00M', np.shape(G00M.M)) #for (i,j) in product(range(norb), repeat=2): # plt(np.linspace(0,beta,ntau), [G0M.M[:,i,j].imag, G00M.M[:,i,j].imag], 'G00M %d %d'%(i,j)) # plt(np.linspace(0,beta,ntau), [G0M.M[:,i,j].real, G00M.M[:,i,j].real], 'G00M %d %d'%(i,j)) print('diffs') print(dist(G0M.M, G00M.M)) print(dist(G0.R, G00.R)) print(dist(G0.L, G00.L)) print(dist(G0.IR, G00.IR)) exit() ''' GM = matsubara(beta, ntau, norb, -1) SigmaM = matsubara(beta, ntau, norb, -1) SigmaM.deltaM = H(0, 0, 0) integrator.dyson_matsubara(G0M, SigmaM, GM) # check if SigmaM is the same as before G = langreth(norb, nt, tmax, ntau, beta, -1) Sigma = langreth(norb, nt, tmax, ntau, beta, -1) for it in range(nt): Sigma.deltaR[it] = H(0, 0, it*dt) integrator.dyson_langreth(G0M, SigmaM, G0, Sigma, G) return GM, G for nt in nts: constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) integrator = integration.integrator(6, nt, beta, ntau) #--------------------------------------------------------- # compute U(t,t') exactly and the corresponding G0 #Uexact = np.array([expm(-1j*H(0,0,0)*t) for t in ts]) ts = np.linspace(0, tmax, nt) _, UksI, eks, fks, Rs, _ = init_Uks(H, dt_fine, *constants) Omega = sqrt((delta-omega)**2 + V**2) Uexact = np.zeros([1, nt, norb, norb], dtype=np.complex128) Uexact[0, :, 0, 0] = np.exp(-1j*omega*ts)*(np.cos(Omega*ts) - 1j*(delta-omega)/Omega*np.sin(Omega*ts)) Uexact[0, :, 0, 1] = -1j*V/Omega*np.exp(-1j*omega*ts)*np.sin(Omega*ts) Uexact[0, :, 1, 0] = -1j*V/Omega*np.exp(1j*omega*ts)*np.sin(Omega*ts) Uexact[0, :, 1, 1] = np.exp(1j*omega*ts)*(np.cos(Omega*ts) + 1j*(delta-omega)/Omega*np.sin(Omega*ts)) print('check unitary ') p = np.einsum('tba,tbc->tac', np.conj(Uexact[0,:]), Uexact[0,:]) print(dist(p, np.einsum('t,ab->tab', np.ones(nt), np.diag(np.ones(norb))))) GMexact = compute_G0M(0, 0, UksI, eks, fks, Rs, *constants) Gexact = compute_G0R(0, 0, Uexact, UksI, eks, fks, Rs, *constants) #--------------------------------------------------------- # compute G0 computed with U(t,t') via integration UksR, UksI, eks, fks, Rs, _ = init_Uks(H, dt_fine, *constants, version='higher order') G0M = compute_G0M(0, 0, UksI, eks, fks, Rs, *constants) G0 = compute_G0R(0, 0, UksR, UksI, eks, fks, Rs, *constants) # test for U(t,t') d = dist(Uexact, UksR) print('diff Uexact UksR', d) print("done computing G0 using U(t,t')") diffs['U'].append(d) #--------------------------------------------------------- # compute non-interacting G for the norb x norb problem # we compute this by solving Dyson's equation with the time-dependent hamiltonian as the selfenergy GdysonM, Gdyson = compute_time_dependent_G0(H, *constants) print('done computing G0 via Dyson equation') ''' ts = np.linspace(0,tmax,nt) Uexact = np.array([expm(-1j*H(0,0,0)*t) for t in ts]) print('diff Uexact UksR', dist(Uexact, UksR[0])) for (i,j) in product(range(2), repeat=2): plt(ts, [UksR[0,:,i,j].real, Uexact[:,i,j].real], 'real part %d %d'%(i,j)) plt(ts, [UksR[0,:,i,j].imag, Uexact[:,i,j].imag], 'imag part %d %d'%(i,j)) exit() ''' #for (i,j) in product(range(norb), repeat=2): # plt(np.linspace(0, beta, ntau), [G0.M[:,i,j].imag, GdysonM.M[:,i,j].imag], 'G0M') ''' for (i,j) in product(range(norb), repeat=2): im([Gexact.L[:,i,:,j].real, G0.L[:,i,:,j].real, Gdyson.L[:,i,:,j].real], [0,tmax,0,tmax], 'G0 real L %d %d'%(i,j)) im([Gexact.L[:,i,:,j].imag, G0.L[:,i,:,j].imag, Gdyson.L[:,i,:,j].imag], [0,tmax,0,tmax], 'G0 imag L %d %d'%(i,j)) ''' print('differences between G0 and Gexact') differences(G0, Gexact) print('differences between Gdyson and Gexact') differences(Gdyson, Gexact) ''' for (i,j) in product(range(norb), repeat=2): print('i j %d %d'%(i,j)) im([G0.R[:,i,:,j].imag, Gexact.R[:,i,:,j].imag], [0,tmax,0,tmax], 'R imag') im([G0.R[:,i,:,j].real, Gexact.R[:,i,:,j].real], [0,tmax,0,tmax], 'R real') ''' plt_diffs(diffs) if 'MPI' in sys.modules: MPI.Finalize()
def main(): if myrank == 0: time0 = time.time() print(' ') print('nprocs = ', nprocs) Nkx = 1 Nky = 1 k2p, k2i, i2k = init_k2p_k2i_i2k(Nkx, Nky, nprocs, myrank) kpp = np.count_nonzero(k2p == myrank) beta = 2.0 ARPES = False pump = 0 g2 = None omega = None tmax = 5.0 dim_embedding = 2 order = 6 ntau = 200 #nts = [400,800,1000] #nts = [10, 50, 100, 500] #nts = [50, 100, 500] #nts = [50, 100, 500] nts = [10, 50, 100, 500] diffs = {} diffs['nts'] = nts diffs['M'] = [] diffs['RI'] = [] diffs['R'] = [] diffs['L'] = [] # random H np.random.seed(1) norb = 4 Hmat = 0.1 * np.random.randn(norb, norb) + 0.1 * 1j * np.random.randn( norb, norb) Hmat += np.conj(Hmat).T Tmat = 0.1 * np.random.randn(norb, norb) + 0.1 * 1j * np.random.randn( norb, norb) Tmat += np.conj(Tmat).T # example H ''' norb = 3 e0 = -0.2 e1 = -0.1 e2 = 0.2 lamb1 = 1.0 lamb2 = 1.2 Hmat = np.array([[e0, lamb1, lamb2], [np.conj(lamb1), e1, 0], [np.conj(lamb2), 0, e2]], dtype=complex) ''' print('\nH : ') print(Hmat) print('') #def f(t): return np.cos(0.01*t) def f(t): return 1.0 for nt in nts: dt_fine = 0.1 * tmax / (nt - 1) #--------------------------------------------------------- # compute non-interacting G for the norb x norb problem norb = np.shape(Hmat)[0] def H(kx, ky, t): return Hmat + Tmat * np.cos(0.2 * t) #return np.array([[e0, lamb1, lamb2], # [np.conj(lamb1), e1, 0], # [np.conj(lamb2), 0, e2]], # dtype=complex) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) UksR, UksI, eks, fks, Rs, Ht = init_Uks(H, dt_fine, *constants, version='higher order') GexactM = compute_G0M(0, 0, UksI, eks, fks, Rs, *constants) Gexact = compute_G0R(0, 0, UksR, UksI, eks, fks, Rs, *constants) #------------------------------------------------------ # compute Sigma_embedding # Sigma = sum_{i,j} H0i(t) Gij(t,t') Hj0(t') norb = np.shape(Hmat)[0] - dim_embedding SigmaM = matsubara(beta, ntau, norb, -1) def H(kx, ky, t): return Hmat[dim_embedding:, dim_embedding:] + Tmat[ dim_embedding:, dim_embedding:] * np.cos(0.2 * t) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) UksR, UksI, eks, fks, Rs, _ = init_Uks(H, dt_fine, *constants, version='higher order') SM = compute_G0M(0, 0, UksI, eks, fks, Rs, *constants) SM.M = np.einsum('hi,mij,jk->mhk', Ht[0, 0, :dim_embedding, dim_embedding:], SM.M, Ht[0, 0, dim_embedding:, :dim_embedding]) #taus = np.linspace(0, beta, ntau) #plt(taus, [SM.M[:,0,0].real, SM.M[:,0,0].imag], 'SM') #exit() S = compute_G0R(0, 0, UksR, UksI, eks, fks, Rs, *constants) S.R = np.einsum('mhi,minj,njk->mhnk', Ht[0, :, :dim_embedding, dim_embedding:], S.R, Ht[0, :, dim_embedding:, :dim_embedding]) S.L = np.einsum('mhi,minj,njk->mhnk', Ht[0, :, :dim_embedding, dim_embedding:], S.L, Ht[0, :, dim_embedding:, :dim_embedding]) S.RI = np.einsum('mhi,minj,jk->mhnk', Ht[0, :, :dim_embedding, dim_embedding:], S.RI, Ht[0, 0, dim_embedding:, :dim_embedding]) #dt = 1.0*tmax/(nt-1) #ts = np.linspace(0, tmax, nt) SigmaM = matsubara(beta, ntau, dim_embedding, -1) SigmaM.M = SM.M Sigma = langreth(norb, nt, tmax, ntau, beta, -1) Sigma.L = S.L Sigma.R = S.R Sigma.RI = S.RI #------------------------------------------------------ # solve the embedding problem norb = dim_embedding def H(kx, ky, t): return Hmat[:dim_embedding, : dim_embedding] + Tmat[:dim_embedding, : dim_embedding] * np.cos(0.2 * t) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) #Ht = init_Ht(H, *constants) UksR, UksI, eks, fks, Rs, _ = init_Uks(H, dt_fine, *constants, version='higher order') G0M = compute_G0M(0, 0, UksI, eks, fks, Rs, *constants) G0 = compute_G0R(0, 0, UksR, UksI, eks, fks, Rs, *constants) integrator = integration.integrator(6, nt, beta, ntau) GM = matsubara(beta, ntau, norb, -1) integrator.dyson_matsubara(G0M, SigmaM, GM) print('differences Matsubara') diff = np.mean(abs(GM.M - GexactM.M[:, :dim_embedding, :dim_embedding])) print('diff = %1.3e' % diff) G = langreth(norb, nt, tmax, ntau, beta, -1) integrator.dyson_langreth(G0M, SigmaM, G0, Sigma, G) #------------------------------------------------------ # compute differences diff = np.mean(abs(GM.M - GexactM.M[:, :dim_embedding, :dim_embedding])) print('diff = %1.3e' % diff) diffs['M'].append(diff) diff = np.mean( abs(G.R - Gexact.R[:, :dim_embedding, :, :dim_embedding])) print('diff langreth R = %1.3e' % diff) diffs['R'].append(diff) diff = np.mean( abs(G.RI - Gexact.RI[:, :dim_embedding, :, :dim_embedding])) print('diff langreth RI = %1.3e' % diff) diffs['RI'].append(diff) diff = np.mean( abs(G.L - Gexact.L[:, :dim_embedding, :, :dim_embedding])) print('diff langreth L = %1.3e' % diff) diffs['L'].append(diff) #------------------------------------------------------ plt_diffs(diffs) if 'MPI' in sys.modules: MPI.Finalize()
def main(): if myrank == 0: time0 = time.time() print(' ') print('nprocs = ', nprocs) Nkx = 1 Nky = 1 k2p, k2i, i2k = init_k2p_k2i_i2k(Nkx, Nky, nprocs, myrank) kpp = np.count_nonzero(k2p == myrank) beta = 10.0 ARPES = False pump = 0 g2 = None omega = None tmax = 10.0 dt_fine = 0.01 #dt_fine = 10.0 order = 6 ntau = 800 nts = [10, 50, 100, 500] diffs = {} diffs['nts'] = nts diffs['U'] = [] diffs['U_higher_order'] = [] delta = 0.3 omega = 0.2 V = 0.5 norb = 2 def H(kx, ky, t): #Bx = 2.0*V*np.cos(2.0*omega*t) #By = 2.0*V*np.sin(2.0*omega*t) #Bz = 2.0*delta #return 0.5*np.array([[Bz, Bx-1j*By], [Bx+1j*By, -Bz]], dtype=complex) return np.array([[delta, V * np.exp(-2.0 * 1j * omega * t)], [V * np.exp(+2.0 * 1j * omega * t), -delta]], dtype=complex) def compute_time_dependent_G0(H, myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump): # check how much slower this is than computing G0 using U(t,t') dt = 1.0 * tmax / (nt - 1) G0M = compute_G00M(0, 0, *constants) GM = matsubara(beta, ntau, norb, -1) SigmaM = matsubara(beta, ntau, norb, -1) SigmaM.deltaM = H(0, 0, 0) integrator.dyson_matsubara(G0M, SigmaM, GM) # check if SigmaM is the same as before G = langreth(nt, tmax, GM) Sigma = langreth(nt, tmax, SigmaM) for it in range(nt): Sigma.deltaR[it] = H(0, 0, it * dt) integrator.dyson_langreth(G0, Sigma, G) return GM, G for nt in nts: constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) integrator = integration.integrator(6, nt, beta, ntau) #--------------------------------------------------------- # compute U(t,t') exactly and the corresponding G0 ts = np.linspace(0, tmax, nt) UksR, UksI, eks, fks, Rs, _ = init_Uks(H, dt_fine, *constants) Omega = sqrt((delta - omega)**2 + V**2) Uexact = np.zeros([1, nt, norb, norb], dtype=np.complex128) Uexact[0, :, 0, 0] = np.exp( -1j * omega * ts) * (np.cos(Omega * ts) - 1j * (delta - omega) / Omega * np.sin(Omega * ts)) Uexact[0, :, 0, 1] = -1j * V / Omega * np.exp( -1j * omega * ts) * np.sin(Omega * ts) Uexact[0, :, 1, 0] = -1j * V / Omega * np.exp( 1j * omega * ts) * np.sin(Omega * ts) Uexact[0, :, 1, 1] = np.exp( 1j * omega * ts) * (np.cos(Omega * ts) + 1j * (delta - omega) / Omega * np.sin(Omega * ts)) print('check unitary ') p = np.einsum('tba,tbc->tac', np.conj(Uexact[0, :]), Uexact[0, :]) print( dist(p, np.einsum('t,ab->tab', np.ones(nt), np.diag(np.ones(norb))))) #--------------------------------------------------------- # compute G0 computed with U(t,t') via integration UksR, UksI, eks, fks, Rs, _ = init_Uks(H, dt_fine, *constants, version='regular') # test for U(t,t') d = dist(Uexact, UksR) print('diff Uexact UksR', d) print("done computing U regular") diffs['U'].append(d) #--------------------------------------------------------- # compute G0 computed with U(t,t') via higher-order integration UksR, UksI, eks, fks, Rs, _ = init_Uks(H, dt_fine, *constants, version='higher order') # test for U(t,t') d = dist(Uexact, UksR) print('diff Uexact UksR', d) print("done computing U higher order") diffs['U_higher_order'].append(d) plt_diffs(diffs) if diffs['U'][-1] > 1e-5: print('\nFAILED TEST') print('U above desired accuracy') exit() if diffs['U_higher_order'][-1] > 1e-12: print('\nFAILED TEST') print('U_higher_order above desired accuracy') exit() if 'MPI' in sys.modules: MPI.Finalize()
def main(): if myrank == 0: time0 = time.time() if myrank == 0: print(' ') print('nprocs = ', nprocs) if not os.path.exists(savedir): os.mkdir(savedir) assert not os.path.exists(savedir + 'SigmaM') and not os.path.exists( savedir + 'GlocM'), 'Cannot overwrite existing data' volume = Nkx * Nky k2p, k2i, i2k = init_k2p_k2i_i2k(Nkx, Nky, nprocs, myrank) kpp = np.count_nonzero(k2p == myrank) integrator = integration.integrator(6, nt, beta, ntau) def H(kx, ky): return -2.0 * np.cos(kx) * np.ones([norb, norb]) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) UksI, eks, fks, Rs = init_UksM(H, dt_fine, *constants, version='higher order') print('Done initializing Us') # Solve Matsubara problem #--------------------------------------------------------- DM = compute_D0M(omega, beta, ntau, norb) SigmaM = matsubara(beta, ntau, norb, -1) iter_selfconsistency = 8 change = 0.0 for i in range(iter_selfconsistency): print('iteration : %d' % i) SigmaM0 = SigmaM.M.copy() GlocM = matsubara(beta, ntau, norb, -1) for ik in range(kpp): ik1, ik2 = i2k[ik] G0M = compute_G0M(ik1, ik2, UksI, eks, fks, Rs, *constants) if i == 0: GM = G0M else: GM = matsubara(beta, ntau, norb, -1) integrator.dyson_matsubara(G0M, SigmaM, GM) GlocM.add(GM) SigmaM = matsubara(beta, ntau, norb, -1) if nprocs == 1: SigmaM.M = GlocM.M else: comm.Allreduce(GlocM.M, SigmaM.M, op=MPI.SUM) SigmaM.multiply(DM) SigmaM.scale(1j * g2 / volume) print('Done computing SigmaM') change = np.mean(abs(SigmaM0 - SigmaM.M)) print('change = %1.3e' % change) print('Done computing GlocM') SigmaM.save(savedir, 'SigmaM') GlocM.save(savedir, 'GlocM') saveparams(savedir) if 'MPI' in sys.modules: MPI.Finalize()
def main(): beta = 2.0 ARPES = False pump = 0 g2 = None omega = None tmax = 1.0 nt = 10 e1 = -0.1 e2 = 0.1 lamb = 1.0 diffs_vs_ntau = [] ntaus = [200] for ntau in ntaus: #--------------------------------------------------------- # compute non-interacting G for the 2x2 problem (exact solution) norb = 2 def H(kx, ky): return np.array([[e1, lamb], [np.conj(lamb), e2]], dtype=complex) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) UksR, UksI, eks, fks, Rs = init_Uks(H, *constants) G2x2 = compute_G0M(0, 0, UksR, UksI, eks, fks, Rs, *constants) #------------------------------------------------------ # compute Sigma_embedding # Sigma = |lambda|^2 * g22(t,t') norb = 1 def H(kx, ky): return e2*np.ones([1,1]) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) UksR, UksI, eks, fks, Rs = init_Uks(H, *constants) Sigma = compute_G0M(0, 0, UksR, UksI, eks, fks, Rs, *constants) Sigma.scale(lamb*np.conj(lamb)) # solve the embedding problem norb = 1 def H(kx, ky): return e1*np.ones([1,1]) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) UksR, UksI, eks, fks, Rs = init_Uks(H, *constants) G0 = compute_G0M(0, 0, UksR, UksI, eks, fks, Rs, *constants) G = matsubara(beta, ntau, norb, -1) integrator = integration.integrator(6, nt, beta, ntau, norb) integrator.dyson_matsubara(G0, Sigma, G) #plt(linspace(0,beta,ntau), [G.M[:,0].imag, G2x2M[:,0,0].imag], 'Gsol and G2x2') print('diff = %1.3e'%np.amax(abs(G.M[:,0,0]-G2x2.M[:,0,0]))) #------------------------------------------------------ #np.save(savedir+'diffs', diffs_vs_deltat) #np.save(savedir+'dts', dts) if 'MPI' in sys.modules: MPI.Finalize()
def main(): if myrank == 0: time0 = time.time() if myrank == 0: print(' ') print('nprocs = ', nprocs) Nkx = 1 Nky = 1 k2p, k2i, i2k = init_k2p_k2i_i2k(Nkx, Nky, nprocs, myrank) kpp = np.count_nonzero(k2p == myrank) beta = 10.0 ARPES = False pump = 0 g2 = None omega = None tmax = 10.0 dt_fine = 0.01 e1 = -0.1 e2 = 0.1 lamb = 1.0 ntau = 400 order = 6 nts = [10, 50, 100, 500] #nts = [100] diffs = {} diffs['nts'] = nts diffs['RxR'] = [] diffs['MxIR'] = [] diffs['MxM'] = [] #diffs['MxM_new'] = [] diffs['RIxIR'] = [] diffs['IRxA'] = [] diffs['LxA'] = [] diffs['RxL'] = [] diffs['RIxM'] = [] diffs['RxRI'] = [] for nt in nts: ntau = nt print('nt = %d' % nt) # compute Sigma_embedding # Sigma = |lambda|^2 * g22(t,t') norb = 1 def H(kx, ky, t): return e2 * np.ones([1, 1]) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) UksR, UksI, eks, fks, Rs, _ = init_Uks(H, dt_fine, *constants, version='higher order') SigmaM = compute_G0M(0, 0, UksI, eks, fks, Rs, *constants) SigmaM.scale(lamb * np.conj(lamb)) Sigma = compute_G0R(0, 0, UksR, UksI, eks, fks, Rs, *constants) Sigma.scale(lamb * np.conj(lamb)) norb = 1 def H(kx, ky, t): return e1 * np.ones([1, 1]) constants = (myrank, Nkx, Nky, ARPES, kpp, k2p, k2i, tmax, nt, beta, ntau, norb, pump) UksR, UksI, eks, fks, Rs, _ = init_Uks(H, dt_fine, *constants, version='higher order') G0M = compute_G0M(0, 0, UksI, eks, fks, Rs, *constants) G0 = compute_G0R(0, 0, UksR, UksI, eks, fks, Rs, *constants) integrator = integration.integrator(order, nt, beta, ntau) for p in diffs: if p == 'nts': continue print(p) #print(getattr(p+'_test')) diff_mean = eval( p + '_test(integrator, G0M, SigmaM, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau)' ) diffs[p].append(diff_mean) continue diff_mean = MxM_test(integrator, G0M, SigmaM, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) diffs['MxM'].append(diff_mean) diff_mean = RIxM_test(integrator, G0M, SigmaM, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) diffs['RIxM'].append(diff_mean) #diff_mean = MxM_new_test(integrator, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) #diffs['MxM_new'].append(diff_mean) diff_mean = MxIR_test(integrator, G0M, SigmaM, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) diffs['MxIR'].append(diff_mean) diff_mean = RxR_test(integrator, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) diffs['RxR'].append(diff_mean) diff_mean = RIxIR_test(integrator, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) diffs['RIxIR'].append(diff_mean) diff_mean = IRxA_test(integrator, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) diffs['IRxA'].append(diff_mean) diff_mean = LxA_test(integrator, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) diffs['LxA'].append(diff_mean) diff_mean = RxL_test(integrator, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) diffs['RxL'].append(diff_mean) diff_mean = RxRI_test(integrator, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) diffs['RxRI'].append(diff_mean) #diff_mean = MxM_test2(integrator, G0, Sigma, e1, e2, lamb, tmax, nt, beta, ntau) #diffs['RIxM'].append(diff_mean) if len(nts) > 1: #np.save(savedir+'diffs.npy', diffs) #np.save(savedir+'nts.npy', nts) #log_nts = np.log(array(nts)) #log_diffs = np.log(np.array(diffs)) #plt(log_nts, [log_diffs], 'diffs') #slope = (log_diffs[-1]-log_diffs[0])/(log_nts[-1]-log_nts[0]) #print('slope = %1.3f'%slope) plt_diffs(diffs)