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

Ruberhauptmann / quant-met / 13840136129

13 Mar 2025 04:50PM UTC coverage: 82.713% (-4.1%) from 86.824%
13840136129

Pull #104

github

web-flow
Merge 170f405cf into 2a2a1a05f
Pull Request #104: Fix TBLattice and DMFT convergence script

86 of 106 branches covered (81.13%)

Branch coverage included in aggregate %.

7 of 100 new or added lines in 4 files covered. (7.0%)

1 existing line in 1 file now uncovered.

914 of 1103 relevant lines covered (82.86%)

0.83 hits per line

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

22.45
/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 mpi4py import MPI
1✔
12
from triqs.gf import Gf
1✔
13

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

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

21

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

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

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

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

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

NEW
47
    ust = 0
×
NEW
48
    jh = 0
×
NEW
49
    xmu = (
×
50
        h.hubbard_int_orbital_basis[0] / 2
51
        + (tbl.n_orbitals - 1) * ust / 2
52
        + (tbl.n_orbitals - 1) * (ust - jh) / 2
53
    )
54

55
    solver = dmft_loop(
×
56
        tbl=tbl,
57
        h=h,
58
        h0_nambu_k=h0_nambu_k,
59
        n_bath=parameters.control.n_bath,
60
        n_iw=parameters.control.n_iw,
61
        broadening=parameters.control.broadening,
62
        n_w=parameters.control.n_w,
63
        w_mixing=parameters.control.wmixing,
64
        n_success=parameters.control.n_success,
65
        xmu=xmu,
66
        kmesh=kmesh,
67
        epsilon=parameters.control.conv_treshold,
68
        max_iter=parameters.control.max_iter,
69
    )
70

71
    # Calculate local Green's function on the real axis
72
    s_w = solver.Sigma_w["up"]
×
73
    s_an_w = solver.Sigma_an_w["up_dn"]
×
74
    s_iw = solver.Sigma_iw["up"]
×
75
    s_an_iw = solver.Sigma_an_iw["up_dn"]
×
76
    g_iw, g_an_iw = get_gloc(s_iw, s_an_iw, h0_nambu_k, xmu, parameters.control.broadening, kmesh)
×
77
    g_w, g_an_w = get_gloc(s_w, s_an_w, h0_nambu_k, xmu, parameters.control.broadening, kmesh)
×
78

NEW
79
    comm = MPI.COMM_WORLD
×
NEW
80
    rank = comm.Get_rank()
×
81

NEW
82
    if rank == 0:
×
NEW
83
        data_dir = Path("data/DressedGraphene/dmft/sweep_V/")
×
NEW
84
        data_dir.mkdir(parents=True, exist_ok=True)
×
85

86
        # Save calculation results
NEW
87
        result_file = result_path / f"{parameters.control.prefix}.hdf5"
×
NEW
88
        with HDFArchive(f"{result_file}", "w") as ar:
×
NEW
89
            ar["s_iw"] = s_iw
×
NEW
90
            ar["s_an_iw"] = s_an_iw
×
NEW
91
            ar["g_iw"] = g_iw
×
NEW
92
            ar["g_an_iw"] = g_an_iw
×
NEW
93
            ar["g_w"] = g_w
×
NEW
94
            ar["g_an_w"] = g_an_w
×
95

NEW
96
        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