from pytriqs.archive import HDFArchive from pytriqs.gf.local import GfImFreq # Define a Green function G = GfImFreq ( indices = [1], beta = 10, n_points = 1000) # Opens the file myfile.h5, in read/write mode R = HDFArchive('myfile.h5', 'w') # Store the object G under the name 'g1' and mu R['g1'] = G R['mu'] = 1.29 del R # closing the files (optional : file is closed when the R reference is deleted)
############################################################################### # High temperature seeds # ---------------------- hot_beta = np.round(1 / np.arange(1 / 25, .2, 1.44e-3), 3) gfsiw = [] wnli = [] for beta in hot_beta: freq = 2 * int(beta * 3) wnh = gf.matsubara_freq(beta, freq, 1 - freq) wnli.append(wnh) print(beta) gfsiw.append(hilbert_trans(1j * wnh, w, differential_weight(w), Aw, 0)) plt.plot(wnh, gfsiw[-1].imag, 'o:') plt.plot(wnh, gfsiw[-1].real, 'o:') # triqs blocks gfarr = GfImFreq(indices=[0], beta=beta, n_points=int(beta * 3)) G_iw = BlockGf(name_list=['asym_dw', 'asym_up', 'sym_dw', 'sym_up'], block_list=(gfarr, gfarr, gfarr, gfarr), make_copies=True) dlat.gf_sym_2_triqs_blockgf(gfsiw[-1], G_iw, u_int, tp) with HDFArchive('DIMER_PM_met_B{}_tp0.3.h5'.format(beta), 'a') as dest: dest['/U{}/it000/G_iw'.format(u_int)] = G_iw # block_names = ['sym_up', 'sym_dw', 'asym_up', 'asym_dw'] # gref = np.squeeze([G_iw[name].data for name in block_names]) # plt.plot(wnh, gref.T.real) # plt.plot(wnh, gref.T.imag)
from pytriqs.gf.local import GfImFreq, SemiCircular g = GfImFreq(indices=['eg1', 'eg2'], beta=50, n_points=1000, name="egBlock") g['eg1', 'eg1'] = SemiCircular(half_bandwidth=1) g['eg2', 'eg2'] = SemiCircular(half_bandwidth=2) from pytriqs.plot.mpl_interface import oplot, plt oplot(g, '-o', x_window=(0, 10)) plt.ylim(-2, 1)
# Import the Green's functions from pytriqs.gf.local import GfImFreq, iOmega_n, inverse # Create the Matsubara-frequency Green's function and initialize it g = GfImFreq(indices=[1], beta=50, n_points=1000, name="imp") g <<= inverse(iOmega_n + 0.5) import pytriqs.utility.mpi as mpi mpi.bcast(g) #Block from pytriqs.gf.local import * g1 = GfImFreq(indices=['eg1', 'eg2'], beta=50, n_points=1000, name="egBlock") g2 = GfImFreq(indices=['t2g1', 't2g2', 't2g3'], beta=50, n_points=1000, name="t2gBlock") G = BlockGf(name_list=('eg', 't2g'), block_list=(g1, g2), make_copies=False) mpi.bcast(G) #imtime from pytriqs.gf.local import * # A Green's function on the Matsubara axis set to a semicircular gw = GfImFreq(indices=[1], beta=50) gw <<= SemiCircular(half_bandwidth=1) # Create an imaginary-time Green's function and plot it
# Import the Green's functions from pytriqs.gf.local import GfImFreq, iOmega_n, inverse # Create the Matsubara-frequency Green's function and initialize it g = GfImFreq(indices=[1], beta=50, n_points=1000, name="$G_\mathrm{imp}$") g << inverse(iOmega_n + 0.5) from pytriqs.plot.mpl_interface import oplot oplot(g, '-o', x_window=(0, 10))
def GLorentz(z): return 0.7 / (z - 2.6 + 0.3 * 1j) + 0.3 / (z + 3.4 + 0.1 * 1j) # Semicircle def GSC(z): return 2.0 * (z + sqrt(1 - z**2) * (log(1 - z) - log(-1 + z)) / pi) # A superposition of GLorentz(z) and GSC(z) with equal weights def G(z): return 0.5 * GLorentz(z) + 0.5 * GSC(z) # Matsubara GF gm = GfImFreq(indices=[0], beta=beta, name="gm") gm << Function(G) gm.tail.zero() gm.tail[1] = array([[1.0]]) # Analytic continuation of gm g_pade = GfReFreq(indices=[0], window=(-5.995, 5.995), n_points=1200, name="g_pade") g_pade.set_from_pade(gm, n_points=L, freq_offset=eta) from pytriqs.archive import HDFArchive R = HDFArchive('pade.output.h5', 'w') R['g_pade'] = g_pade
from pytriqs.plot.mpl_interface import oplot from pytriqs.gf.local import GfImFreq, Omega, inverse g = GfImFreq(indices=[0], beta=300, n_points=1000, name="g") g <<= inverse(Omega + 0.5) # the data we want to fit... # The green function for omega \in [0,0.2] X, Y = g.x_data_view(x_window=(0, 0.2), flatten_y=True) from pytriqs.fit import Fit, linear, quadratic fitl = Fit(X, Y.imag, linear) fitq = Fit(X, Y.imag, quadratic) oplot(g, '-o', x_window=(0, 5)) oplot(fitl, '-x', x_window=(0, 0.5)) oplot(fitq, '-x', x_window=(0, 1)) # a bit more complex, we want to fit with a one fermion level .... # Cf the definition of linear and quadratic in the lib one_fermion_level = lambda X, a, b: 1 / (a * X * 1j + b ), r"${1}/(%f x + %f)$", (1, 1) fit1 = Fit(X, Y, one_fermion_level) oplot(fit1, '-x', x_window=(0, 3))
# Import the Green's functions from pytriqs.gf.local import GfImFreq, iOmega_n, inverse # Create the Matsubara-frequency Green's function and initialize it g = GfImFreq(indices = [1], beta = 50, n_points = 1000, name = "imp") g <<= inverse( iOmega_n + 0.5 ) from pytriqs.plot.mpl_interface import oplot oplot(g, '-o', x_window = (0,10))
(0, -1): [[t]], (1, 1): [[tp]], (-1, -1): [[tp]], (1, -1): [[tp]], (-1, 1): [[tp]] } L = TBLattice(units=[(1, 0, 0), (0, 1, 0)], hopping=hop) SL = TBSuperLattice(tb_lattice=L, super_lattice_units=[(2, 0), (0, 2)]) # SumK function that will perform the sum over the BZ SK = SumkDiscreteFromLattice(lattice=SL, n_points=8, method="Riemann") # Defines G and Sigma with a block structure compatible with the SumK function G = BlockGf(name_block_generator=[(s, GfImFreq(indices=SK.GFBlocIndices, mesh=S.G.mesh)) for s in ['up', 'down']], make_copies=False) Sigma = G.copy() # Init Sigma for n, B in S.Sigma: B <<= 2.0 S.symm_to_real(gf_in=S.Sigma, gf_out=Sigma) # Embedding # Computes sum over BZ and returns density dens = (SK(mu=Chemical_potential, Sigma=Sigma, field=None, result=G).total_density() / 4) mpi.report("Total density = %.3f" % dens)