• 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

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

5
import numpy as np
1✔
6
from triqs.lattice.tight_binding import TBLattice
1✔
7

8
from quant_met.mean_field.hamiltonians import BaseHamiltonian
1✔
9
from quant_met.parameters import GenericParameters, HamiltonianParameters
1✔
10

11

12
def _hamiltonian_factory(
1✔
13
    classname: str, parameters: HamiltonianParameters
14
) -> BaseHamiltonian[HamiltonianParameters]:
15
    """Create a Hamiltonian by its class name.
16

17
    Parameters
18
    ----------
19
    classname: str
20
        The name of the Hamiltonian class to instantiate.
21
    parameters: HamiltonianParameters
22
        An instance of HamiltonianParameters containing all necessary
23
        configuration for the specific Hamiltonian.
24

25
    Returns
26
    -------
27
    BaseHamiltonian[HamiltonianParameters]
28
        An instance of the specified Hamiltonian class.
29
    """
30
    from quant_met.mean_field import hamiltonians
1✔
31

32
    cls = getattr(hamiltonians, classname)
1✔
33
    h: BaseHamiltonian[HamiltonianParameters] = cls(parameters)
1✔
34
    return h
1✔
35

36

37
def _tbl_factory(h: BaseHamiltonian[GenericParameters]) -> TBLattice:
1✔
38
    lattice_constant = np.sqrt(3)
×
39

40
    basis_vectors = [
×
41
        0.5 * lattice_constant * np.array([1, np.sqrt(3), 0]),
42
        0.5 * lattice_constant * np.array([1, -np.sqrt(3), 0]),
43
    ]
NEW
44
    orbital_positions = [
×
45
        (0.5 * (np.sqrt(3) - 1), 0, 0),
46
        (0.5 * (np.sqrt(3) + 1), 0, 0),
47
        (0.5 * (np.sqrt(3) - 1), 0, 0),
48
    ]
UNCOV
49
    hoppings = {
×
50
        (0, 0): [
51
            [0, h.hopping_gr, h.hopping_x_gr_a],
52
            [h.hopping_gr, 0, 0],
53
            [h.hopping_x_gr_a, 0, 0],
54
        ],
55
        (1, 0): [[0, 0, 0], [h.hopping_gr, 0, 0], [0, 0, 0]],
56
        (-1, 0): [[0, h.hopping_gr, 0], [0, 0, 0], [0, 0, 0]],
57
        (0, 1): [[0, h.hopping_gr, 0], [0, 0, 0], [0, 0, 0]],
58
        (0, -1): [[0, 0, 0], [h.hopping_gr, 0, 0], [0, 0, 0]],
59
    }
60

61
    return TBLattice(
×
62
        units=basis_vectors,
63
        hoppings=hoppings,
64
        orbital_positions=orbital_positions,
65
        orbital_names=["A", "B", "X"],
66
    )
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