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

Ruberhauptmann / quant-met / 13764497520

10 Mar 2025 12:21PM UTC coverage: 86.835% (-0.09%) from 86.922%
13764497520

push

github

web-flow
Fix mistake in chemical potential (#100)

87 of 100 branches covered (87.0%)

Branch coverage included in aggregate %.

3 of 4 new or added lines in 3 files covered. (75.0%)

1 existing line in 1 file now uncovered.

909 of 1047 relevant lines covered (86.82%)

0.87 hits per line

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

21.74
/src/quant_met/cli/dmft.py
1
# SPDX-FileCopyrightText: 2024 Tjark Sievers
2
#
3
# SPDX-License-Identifier: MIT
4

5
"""Functions to run self-consistent calculation for the order parameter."""
6

7
import logging
1✔
8
from pathlib import Path
1✔
9

10
from h5 import HDFArchive
1✔
11
from triqs.gf import Gf, Idx
1✔
12

13
from quant_met.cli._utils import _hamiltonian_factory, _tbl_factory
1✔
14
from quant_met.dmft.dmft_loop import dmft_loop
1✔
15
from quant_met.dmft.utils import get_gloc
1✔
16
from quant_met.parameters import Parameters
1✔
17

18
logger = logging.getLogger(__name__)
1✔
19

20

21
def dmft_scf(parameters: Parameters) -> None:
1✔
22
    """Self-consistent calculation for the order parameter.
23

24
    Parameters
25
    ----------
26
    parameters: Parameters
27
        An instance of Parameters containing control settings, the model,
28
        and k-point specifications for the self-consistency calculation.
29
    """
30
    result_path = Path(parameters.control.outdir)
×
31
    result_path.mkdir(exist_ok=True, parents=True)
×
32

33
    h = _hamiltonian_factory(parameters=parameters.model, classname=parameters.model.name)
×
34
    tbl = _tbl_factory(h=h)
×
35

36
    kmesh = tbl.get_kmesh(n_k=(parameters.k_points.nk1, parameters.k_points.nk2, 1))
×
37

38
    enk = tbl.fourier(kmesh)
×
39
    n_orbitals = tbl.n_orbitals
×
40
    nambu_shape = (2 * n_orbitals, 2 * n_orbitals)
×
41
    h0_nambu_k = Gf(mesh=kmesh, target_shape=nambu_shape)
×
42
    for k in kmesh:
×
43
        h0_nambu_k[k][:n_orbitals, :n_orbitals] = enk(k)
×
44
        h0_nambu_k[k][n_orbitals:, n_orbitals:] = -enk(-k)
×
45

NEW
46
    xmu = -h.hubbard_int_orbital_basis[0] / 2
×
47

48
    solver = dmft_loop(
×
49
        tbl=tbl,
50
        h=h,
51
        h0_nambu_k=h0_nambu_k,
52
        n_bath=parameters.control.n_bath,
53
        n_iw=parameters.control.n_iw,
54
        broadening=parameters.control.broadening,
55
        n_w=parameters.control.n_w,
56
        w_mixing=parameters.control.wmixing,
57
        n_success=parameters.control.n_success,
58
        xmu=xmu,
59
        kmesh=kmesh,
60
        epsilon=parameters.control.conv_treshold,
61
        max_iter=parameters.control.max_iter,
62
    )
63

64
    # Calculate local Green's function on the real axis
65
    s_w = solver.Sigma_w["up"]
×
66
    s_an_w = solver.Sigma_an_w["up_dn"]
×
67
    s_iw = solver.Sigma_iw["up"]
×
68
    s_an_iw = solver.Sigma_an_iw["up_dn"]
×
69
    g_iw, g_an_iw = get_gloc(s_iw, s_an_iw, h0_nambu_k, xmu, parameters.control.broadening, kmesh)
×
70
    g_w, g_an_w = get_gloc(s_w, s_an_w, h0_nambu_k, xmu, parameters.control.broadening, kmesh)
×
71

72
    n_iw0 = int(0.5 * len(s_iw.mesh))
×
73
    iw_0 = s_iw.mesh[n_iw0].value.imag
×
74

75
    gap = s_an_iw[Idx(0)][0, 0].real / (1 - (s_iw[Idx(0)][0, 0].imag / iw_0))
×
76

77
    data_dir = Path("data/DressedGraphene/dmft/sweep_V/")
×
78
    data_dir.mkdir(parents=True, exist_ok=True)
×
79

80
    # Save calculation results
81
    result_file = result_path / f"{parameters.control.prefix}.hdf5"
×
82
    with HDFArchive(f"{result_file}", "w") as ar:
×
83
        ar["s_iw"] = s_iw
×
84
        ar["s_an_iw"] = s_an_iw
×
85
        ar["g_iw"] = g_iw
×
86
        ar["g_an_iw"] = g_an_iw
×
87
        ar["g_w"] = g_w
×
88
        ar["g_an_w"] = g_an_w
×
89
        ar["gap"] = gap
×
90

91
    logger.info("Results saved to %s", result_file)
×
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