• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Ruberhauptmann / quant-met / 13719580150

07 Mar 2025 11:18AM UTC coverage: 86.979% (-13.0%) from 100.0%
13719580150

Pull #93

github

web-flow
Merge d738954ea into 17b683f9d
Pull Request #93: Add DMFT

87 of 100 branches covered (87.0%)

Branch coverage included in aggregate %.

43 of 180 new or added lines in 7 files covered. (23.89%)

915 of 1052 relevant lines covered (86.98%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.64
/src/quant_met/dmft/utils.py
1
# SPDX-FileCopyrightText: 2025 Tjark Sievers
2
#
3
# SPDX-License-Identifier: MIT
4

5
"""Utility functions used in DMFT."""
6

7
import numpy as np
1✔
8
import numpy.typing as npt
1✔
9
from triqs.gf import Gf, MeshBrZone, MeshImFreq, MeshProduct, conjugate, dyson, inverse, iOmega_n
1✔
10

11

12
def get_gloc(
1✔
13
    s: Gf,
14
    s_an: Gf,
15
    h0_nambu_k: Gf,
16
    xmu: npt.NDArray[np.complex128],
17
    broadening: float,
18
    kmesh: MeshBrZone,
19
) -> tuple[Gf, Gf]:
20
    """Compute local GF from bare lattice Hamiltonian and self-energy.
21

22
    Parameters
23
    ----------
24
    s
25
    s_an
26
    h0_nambu_k
27

28
    Returns
29
    -------
30
    tuple[Gf, Gf]
31

32
    """
NEW
33
    z = Gf(mesh=s.mesh, target_shape=h0_nambu_k.target_shape)
×
NEW
34
    n_orbitals = z.target_shape[0] // 2
×
NEW
35
    if isinstance(s.mesh, MeshImFreq):
×
NEW
36
        z[:n_orbitals, :n_orbitals] << iOmega_n + xmu - s
×
NEW
37
        z[:n_orbitals, n_orbitals:] << -s_an
×
NEW
38
        z[n_orbitals:, :n_orbitals] << -s_an
×
NEW
39
        z[n_orbitals:, n_orbitals:] << iOmega_n - xmu + conjugate(s)
×
40
    else:
NEW
41
        z[:n_orbitals, n_orbitals:] << -s_an
×
NEW
42
        z[n_orbitals:, :n_orbitals] << -s_an
×
NEW
43
        for w in z.mesh:
×
NEW
44
            z[w][:n_orbitals, :n_orbitals] = (w + 1j * broadening + xmu) * np.eye(n_orbitals) - s[w]
×
NEW
45
            z[w][n_orbitals:, n_orbitals:] = (w + 1j * broadening - xmu) * np.eye(
×
46
                n_orbitals
47
            ) + conjugate(s(-w))
48

NEW
49
    g_k = Gf(mesh=MeshProduct(kmesh, z.mesh), target_shape=h0_nambu_k.target_shape)
×
NEW
50
    for k in kmesh:
×
NEW
51
        g_k[k, :] << inverse(z - h0_nambu_k[k])
×
52

NEW
53
    g_loc_nambu = sum(g_k[k, :] for k in kmesh) / len(kmesh)
×
54

NEW
55
    g_loc = s.copy()
×
NEW
56
    g_loc_an = s_an.copy()
×
NEW
57
    g_loc[:] = g_loc_nambu[:n_orbitals, :n_orbitals]
×
NEW
58
    g_loc_an[:] = g_loc_nambu[:n_orbitals, n_orbitals:]
×
NEW
59
    return g_loc, g_loc_an
×
60

61

62
def _dmft_weiss_field(g_iw: Gf, g_an_iw: Gf, s_iw: Gf, s_an_iw: Gf) -> tuple[Gf, Gf]:
1✔
63
    """Compute Weiss field from local GF and self-energy.
64

65
    Parameters
66
    ----------
67
    g_iw
68
    g_an_iw
69
    s_iw
70
    s_an_iw
71

72
    Returns
73
    -------
74
    tuple[Gf, Gf]
75

76
    """
NEW
77
    n_orbitals = g_iw.target_shape[0]
×
NEW
78
    nambu_shape = (2 * n_orbitals, 2 * n_orbitals)
×
NEW
79
    g_nambu_iw = Gf(mesh=g_iw.mesh, target_shape=nambu_shape)
×
NEW
80
    s_nambu_iw = Gf(mesh=s_iw.mesh, target_shape=nambu_shape)
×
81

NEW
82
    g_nambu_iw[:n_orbitals, :n_orbitals] = g_iw
×
NEW
83
    g_nambu_iw[:n_orbitals, n_orbitals:] = g_an_iw
×
NEW
84
    g_nambu_iw[n_orbitals:, :n_orbitals] = g_an_iw
×
NEW
85
    g_nambu_iw[n_orbitals:, n_orbitals:] = -conjugate(g_iw)
×
86

NEW
87
    s_nambu_iw[:n_orbitals, :n_orbitals] = s_iw
×
NEW
88
    s_nambu_iw[:n_orbitals, n_orbitals:] = s_an_iw
×
NEW
89
    s_nambu_iw[n_orbitals:, :n_orbitals] = s_an_iw
×
NEW
90
    s_nambu_iw[n_orbitals:, n_orbitals:] = -conjugate(s_iw)
×
91

NEW
92
    g0_nambu_iw = dyson(G_iw=g_nambu_iw, Sigma_iw=s_nambu_iw)
×
93

NEW
94
    g0_iw = g_iw.copy()
×
NEW
95
    g0_an_iw = g_an_iw.copy()
×
NEW
96
    g0_iw[:] = g0_nambu_iw[:n_orbitals, :n_orbitals]
×
NEW
97
    g0_an_iw[:] = g0_nambu_iw[:n_orbitals, n_orbitals:]
×
NEW
98
    return g0_iw, g0_an_iw
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc