示例#1
0
文件: calc_pyed.py 项目: TRIQS/tprf
def make_calc(beta=2.0, h_field=0.0):
    
    # ------------------------------------------------------------------
    # -- Hubbard atom with two bath sites, Hamiltonian

    p = ParameterCollection(
        beta = beta,
        h_field = h_field,
        U = 5.0,
        ntau = 40,
        niw = 15,
        )

    p.mu = 0.5*p.U
    
    # ------------------------------------------------------------------

    print('--> Solving SIAM with parameters')
    print(p)
    
    # ------------------------------------------------------------------

    up, do = 'up', 'dn'
    docc = c_dag(up,0) * c(up,0) * c_dag(do,0) * c(do,0)
    mA = c_dag(up,0) * c(up,0) - c_dag(do,0) * c(do,0)
    nA = c_dag(up,0) * c(up,0) + c_dag(do,0) * c(do,0)

    p.H = -p.mu * nA + p.U * docc + p.h_field * mA
    
    # ------------------------------------------------------------------

    fundamental_operators = [c(up,0), c(do,0)]
    
    ed = TriqsExactDiagonalization(p.H, fundamental_operators, p.beta)

    g_tau = GfImTime(beta=beta, statistic='Fermion', n_points=40, indices=[0])
    g_iw = GfImFreq(beta=beta, statistic='Fermion', n_points=10, indices=[0])

    p.G_tau = BlockGf(name_list=[up,do], block_list=[g_tau]*2, make_copies=True)
    p.G_iw = BlockGf(name_list=[up,do], block_list=[g_iw]*2, make_copies=True)
    
    ed.set_g2_tau(p.G_tau[up], c(up,0), c_dag(up,0))
    ed.set_g2_tau(p.G_tau[do], c(do,0), c_dag(do,0))

    ed.set_g2_iwn(p.G_iw[up], c(up,0), c_dag(up,0))
    ed.set_g2_iwn(p.G_iw[do], c(do,0), c_dag(do,0))

    p.magnetization = ed.get_expectation_value(0.5 * mA)
    p.magnetization2 = ed.get_expectation_value(0.25 * mA * mA)
    
    # ------------------------------------------------------------------
    # -- Store to hdf5
    
    filename = 'data_pyed_h_field_%4.4f.h5' % h_field
    with HDFArchive(filename,'w') as res:
        res['p'] = p
示例#2
0
    def test_sumk_discrete(self):
        tbl_w90 = TB_from_wannier90(seed='wannier_TB_test',
                                    path='./',
                                    extend_to_spin=False)

        SK = SumkDiscreteFromLattice(lattice=tbl_w90, n_points=10)
        Sigma_proto = GfImFreq(
            mesh=MeshImFreq(beta=40, S='Fermion', n_max=1025),
            target_shape=[tbl_w90.n_orbitals, tbl_w90.n_orbitals])
        Sigma_iw = BlockGf(name_list=['up', 'down'],
                           block_list=[Sigma_proto, Sigma_proto],
                           make_copies=True)

        # Sumk only accepts Sigma of MeshImFreq
        Gloc = SK(Sigma=Sigma_iw, mu=12.3461)
        # check if density is close to 1, not to strict since nkpts is relatively small
        assert abs(Gloc.total_density().real - 1.0) < 1e-2
示例#3
0
    # -- Exact diagonalization

    fundamental_operators = [
        c(up,0), c(do,0), c(up,1), c(do,1), c(up,2), c(do,2)]

    ed = TriqsExactDiagonalization(H, fundamental_operators, beta)

    # ------------------------------------------------------------------
    # -- Single-particle Green's functions

    g_tau = GfImTime(name=r'$g$', beta=beta,
                     statistic='Fermion', n_points=50,
                     target_shape=(1,1))

    g_iwn = GfImFreq(name='$g$', beta=beta,
                     statistic='Fermion', n_points=10,
                     target_shape=(1,1))

    ed.set_g2_tau(g_tau[0,0], c(up,0), c_dag(up,0))
    ed.set_g2_iwn(g_iwn[0,0], c(up,0), c_dag(up,0))

    # ------------------------------------------------------------------
    # -- Two particle Green's functions

    ntau = 20
    imtime = MeshImTime(beta, 'Fermion', ntau)
    prodmesh = MeshProduct(imtime, imtime, imtime)

    g40_tau = Gf(name='g40_tau', mesh=prodmesh, target_shape=[1, 1, 1, 1])
    g4_tau = Gf(name='g4_tau', mesh=prodmesh, target_shape=[1, 1, 1, 1])
示例#4
0
from triqs.gf 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 triqs.plot.mpl_interface import oplot, plt

oplot(g, '-o', x_window=(0, 10))
plt.ylim(-2, 1)
示例#5
0
# Import the Green's functions
from triqs.gf 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 triqs.plot.mpl_interface import oplot
oplot(g, '-o', x_window=(0, 10))
示例#6
0
文件: gf_bcast.py 项目: DerWeh/triqs
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You may obtain a copy of the License at
#     https:#www.gnu.org/licenses/gpl-3.0.txt
#
# Authors: Olivier Parcollet, Nils Wentzell

# Import the Green's functions
from triqs.gf 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 triqs.utility.mpi as mpi

mpi.bcast(g)

#Block

from triqs.gf 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)
示例#7
0
文件: fit_test.py 项目: DerWeh/triqs
from triqs.plot.mpl_interface import oplot
from triqs.gf 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 triqs.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))
示例#8
0
def test_cf_G_tau_and_G_iw_nonint(verbose=False):

    beta = 3.22
    eps = 1.234

    niw = 64
    ntau = 2 * niw + 1

    H = eps * c_dag(0, 0) * c(0, 0)

    fundamental_operators = [c(0, 0)]

    ed = TriqsExactDiagonalization(H, fundamental_operators, beta)

    # ------------------------------------------------------------------
    # -- Single-particle Green's functions

    G_tau = GfImTime(beta=beta,
                     statistic='Fermion',
                     n_points=ntau,
                     target_shape=(1, 1))
    G_iw = GfImFreq(beta=beta,
                    statistic='Fermion',
                    n_points=niw,
                    target_shape=(1, 1))

    G_iw << inverse(iOmega_n - eps)
    G_tau << Fourier(G_iw)

    G_tau_ed = GfImTime(beta=beta,
                        statistic='Fermion',
                        n_points=ntau,
                        target_shape=(1, 1))
    G_iw_ed = GfImFreq(beta=beta,
                       statistic='Fermion',
                       n_points=niw,
                       target_shape=(1, 1))

    ed.set_g2_tau(G_tau_ed[0, 0], c(0, 0), c_dag(0, 0))
    ed.set_g2_iwn(G_iw_ed[0, 0], c(0, 0), c_dag(0, 0))

    # ------------------------------------------------------------------
    # -- Compare gfs

    from triqs.utility.comparison_tests import assert_gfs_are_close

    assert_gfs_are_close(G_tau, G_tau_ed)
    assert_gfs_are_close(G_iw, G_iw_ed)

    # ------------------------------------------------------------------
    # -- Plotting

    if verbose:
        from triqs.plot.mpl_interface import oplot, plt
        subp = [3, 1, 1]
        plt.subplot(*subp)
        subp[-1] += 1
        oplot(G_tau.real)
        oplot(G_tau_ed.real)

        plt.subplot(*subp)
        subp[-1] += 1
        diff = G_tau - G_tau_ed
        oplot(diff.real)
        oplot(diff.imag)

        plt.subplot(*subp)
        subp[-1] += 1
        oplot(G_iw)
        oplot(G_iw_ed)

        plt.show()