from pytriqs.utility.comparison_tests import * # for the imaginary GFs beta = 40 n_tau = 5001 H = np.array([[0, 0.1j], [-0.1j, 0]]) # construct the atomic GF by hand: # G_tau = inverse_fourier( (iOmega - H)^(-1) ) G_iw = GfImFreq(beta=beta, indices=[0, 1]) G_iw << iOmega_n - H G_iw.invert() G_tau = GfImTime(beta=beta, indices=[0, 1], n_points=n_tau) G_tau.set_from_inverse_fourier(G_iw) # construct the Hamiltonian as operator H_op = Operator() for i in range(H.shape[0]): for j in range(H.shape[1]): H_op += H[i, j] * c_dag('ud', i) * c('ud', j) # initialize the atomic diagonalization AD = AtomDiag(H_op, [('ud', 0), ('ud', 1)]) # atomic G(tau) from solver G_at = atomic_gf(AD, beta, {'ud': [0, 1]}, n_tau) assert_gfs_are_close(G_at['ud'], G_tau)
[ 0.0-0.1j ,-0.2+0.j , 0.1+0.j , 0.5+0.j ], [ 0.5+0.j , 0.1+0.j , 0.0+0.j , 0.0+0.j ], [ 0.1+0.j , 0.5+0.j , 0.0+0.j , 0.0+0.j ]] H_matrix = np.array(H_matrix) # fops for the AtomDiag solver fops = [] for i in range(H_matrix.shape[0]): fops.append(('ud',i)) H = Operator() for i in range(H_matrix.shape[0]): for j in range(H_matrix.shape[1]): H += H_matrix[i,j] * c_dag('ud',i)*c('ud',j) # interaction term between the 1st and 2nd orbital H+=3*n('ud',0)*n('ud',1) S = AtomDiag(H,fops) G_tau = atomic_gf(S,beta=10,indices_list={'ud':range(4)},n_tau=41) with HDFArchive('atomdiag_ed.out.h5','w') as ar: ar['G_tau']=G_tau from pytriqs.utility.h5diff import h5diff # the reference solution was checked against an external ED result h5diff('atomdiag_ed.ref.h5','atomdiag_ed.out.h5')
# the single-particle Hamiltonian of the problem H_matrix = [[-0.2 + 0.j, 0.0 + 0.1j, 0.5 + 0.j, 0.1 + 0.j], [0.0 - 0.1j, -0.2 + 0.j, 0.1 + 0.j, 0.5 + 0.j], [0.5 + 0.j, 0.1 + 0.j, 0.0 + 0.j, 0.0 + 0.j], [0.1 + 0.j, 0.5 + 0.j, 0.0 + 0.j, 0.0 + 0.j]] H_matrix = np.array(H_matrix) # fops for the AtomDiag solver fops = [] for i in range(H_matrix.shape[0]): fops.append(('ud', i)) H = Operator() for i in range(H_matrix.shape[0]): for j in range(H_matrix.shape[1]): H += H_matrix[i, j] * c_dag('ud', i) * c('ud', j) # interaction term between the 1st and 2nd orbital H += 3 * n('ud', 0) * n('ud', 1) S = AtomDiag(H, fops) G_tau = atomic_gf(S, beta=10, indices_list={'ud': range(4)}, n_tau=41) with HDFArchive('atomdiag_ed.out.h5', 'w') as ar: ar['G_tau'] = G_tau from pytriqs.utility.h5diff import h5diff # the reference solution was checked against an external ED result h5diff('atomdiag_ed.ref.h5', 'atomdiag_ed.out.h5')
# for the imaginary GFs beta = 40 n_tau = 5001 H = np.array([[0,0.1j],[-0.1j,0]]) # construct the atomic GF by hand: # G_tau = inverse_fourier( (iOmega - H)^(-1) ) G_iw = GfImFreq(beta=beta,indices=[0,1]) G_iw << iOmega_n - H G_iw.invert() G_tau = GfImTime(beta=beta,indices=[0,1],n_points=n_tau) G_tau.set_from_inverse_fourier(G_iw) # construct the Hamiltonian as operator H_op = Operator() for i in range(H.shape[0]): for j in range(H.shape[1]): H_op += H[i,j] * c_dag('ud',i)*c('ud',j) # initialize the atomic diagonalization AD = AtomDiag(H_op,[('ud',0),('ud',1)]) # atomic G(tau) from solver G_at = atomic_gf(AD,beta,{'ud':[0,1]},n_tau) assert_gfs_are_close(G_at['ud'],G_tau)