コード例 #1
0
ファイル: tconvergence.py プロジェクト: MHarland/ClusterDMFT
 def run_StandardDeviation(self):
     block1 = GfImFreq(beta = 10, indices = range(2), n_points = 2)
     block1.data[2,:,:] = np.array([[0,0],[0,0]])
     block1.data[3,:,:] = np.array([[0,0],[0,0]])
     block2 = GfImFreq(beta = 10, indices = range(2), n_points = 2)
     block2.data[2,:,:] = np.array([[0,1],[2,3]])
     block2.data[3,:,:] = np.array([[4,5],[6,complex(7,8)]])
     g1 = BlockGf(name_list = ["up", "dn"], block_list = [block1, block2])
     g2 = BlockGf(name_list = ["up", "dn"], block_list = [block2, block1])
     stddev = StandardDeviation([g1, g2])
     stddev.calc_quantity([2,4])
     self.assertEqual(stddev.data_g["up"].data[3,1,1], complex(3.5, 4))
コード例 #2
0
ファイル: tconvergence.py プロジェクト: MHarland/ClusterDMFT
 def run_Distance(self):
     block1 = GfImFreq(beta = 10, indices = range(2), n_points = 2)
     block1.data[2,:,:] = np.array([[0,0],[0,0]])
     block1.data[3,:,:] = np.array([[0,0],[0,0]])
     block2 = GfImFreq(beta = 10, indices = range(2), n_points = 2)
     block2.data[2,:,:] = np.array([[0,1],[2,3]])
     block2.data[3,:,:] = np.array([[4,5],[6,complex(7,8)]])
     g1 = BlockGf(name_list = ["up", "dn"], block_list = [block1, block2])
     g2 = BlockGf(name_list = ["up", "dn"], block_list = [block2, block1])
     dist = Distance([g1, g2])
     dist.calc_quantity([2,4])
     for blockname, block in dist.data_g:
         if blockname == "dn":
             self.assertEqual(block.data[3,1,1], complex(-7, -8))
コード例 #3
0
ファイル: tconvergence.py プロジェクト: MHarland/ClusterDMFT
 def run_ConvergenceAnalysis(self):
     block1 = GfImFreq(beta = 10, indices = range(2), n_points = 2)
     block1.data[2,:,:] = np.array([[0,0],[0,0]])
     block1.data[3,:,:] = np.array([[0,0],[0,0]])
     block2 = GfImFreq(beta = 10, indices = range(2), n_points = 2)
     block2.data[2,:,:] = np.array([[0,1],[2,3]])
     block2.data[3,:,:] = np.array([[4,5],[6,complex(7,8)]])
     g1 = BlockGf(name_list = ["up", "dn"], block_list = [block1, block2])
     g2 = BlockGf(name_list = ["up", "dn"], block_list = [block2, block1])
     analysis = ConvergenceAnalysis(f_list = [g1, g2])
     analysis.calc_standard_deviations()
     g_dict = analysis.integrated_standard_deviations[1]
     for blockname, block in g_dict.items():
         if blockname == "up":
             self.assertEqual(block[1,1], complex(2.5, 2))
     analysis.calc_distances()
     dist_list = analysis.integrated_distances
     for g_dict in dist_list:
         for blockname, block in g_dict.items():
             if blockname == "up":
                 self.assertEqual(block[0,1], 3)
コード例 #4
0
ファイル: pade.py プロジェクト: dhirschm/triqs
L = 10      # Number of Matsubara frequencies used in the Pade approximation
eta = 0.01  # Imaginary frequency shift

## Test Green's functions ##

# Two Lorentzians
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
コード例 #5
0
###############################################################################
# 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)
コード例 #6
0
ファイル: tut_ex2.py プロジェクト: TRIQS/TRIQS.github.io
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)




コード例 #7
0
ファイル: gf_bcast.py プロジェクト: aherrmann/triqs1.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
コード例 #8
0
ファイル: green_imfreq.py プロジェクト: TRIQS/TRIQS.github.io
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)
コード例 #9
0
ファイル: example.py プロジェクト: TRIQS/TRIQS.github.io
# 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))
コード例 #10
0
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
コード例 #11
0
ファイル: fit_test.py プロジェクト: JaksaVucicevic/triqs
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) )
    
コード例 #12
0
ファイル: fit_test.py プロジェクト: TRIQS/TRIQS.github.io
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))
コード例 #13
0
# 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))

コード例 #14
0
    (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)
コード例 #15
0
ファイル: ex_Hilbert.py プロジェクト: EBRUDU1/triqs
from pytriqs.lattice.tight_binding import *
from pytriqs.dos import HilbertTransform
from pytriqs.gf.local import GfImFreq

# Define a DOS (here on a square lattice)
BL = BravaisLattice(Units = [(1,0,0) , (0,1,0) ], orbital_positions= {"" :  (0,0,0)} ) 
t   = -1.00                # First neighbour Hopping
tp  =  0.0*t               # Second neighbour Hopping
hop= {  (1,0)  :  [[ t]],       
        (-1,0) :  [[ t]],     
        (0,1)  :  [[ t]],
        (0,-1) :  [[ t]],
        (1,1)  :  [[ tp]],
        (-1,-1):  [[ tp]],
        (1,-1) :  [[ tp]],
        (-1,1) :  [[ tp]]}

TB = TightBinding (BL, hop)
d = dos(TB, n_kpts= 500, n_eps = 101, name = 'dos')[0]

#define a Hilbert transform
H = HilbertTransform(d)

#fill a Green function
G = GfImFreq(indices = ['up','down'], beta = 20)
Sigma0 = GfImFreq(indices = ['up','down'], beta = 20); Sigma0.zero()
G <<= H(Sigma = Sigma0,mu=0.)