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

Ruberhauptmann / quant-met / 13794682779

11 Mar 2025 05:43PM UTC coverage: 86.835%. Remained the same
13794682779

Pull #102

github

web-flow
Merge 2603ff93a into 347564a37
Pull Request #102: Fix orbital positions

87 of 100 branches covered (87.0%)

Branch coverage included in aggregate %.

1 of 2 new or added lines in 2 files covered. (50.0%)

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

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 = [(0, 0.5, 0), (0, -0.5, 0), (0, 0.5, 0)]
×
45
    hoppings = {
×
46
        (0, 0): [
47
            [0, h.hopping_gr, h.hopping_x_gr_a],
48
            [h.hopping_gr, 0, 0],
49
            [h.hopping_x_gr_a, 0, 0],
50
        ],
51
        (1, 0): [[0, 0, 0], [h.hopping_gr, 0, 0], [0, 0, 0]],
52
        (-1, 0): [[0, h.hopping_gr, 0], [0, 0, 0], [0, 0, 0]],
53
        (0, 1): [[0, 0, 0], [h.hopping_gr, 0, 0], [0, 0, 0]],
54
        (0, -1): [[0, h.hopping_gr, 0], [0, 0, 0], [0, 0, 0]],
55
    }
56

57
    return TBLattice(
×
58
        units=basis_vectors,
59
        hoppings=hoppings,
60
        orbital_positions=orbital_positions,
61
        orbital_names=["C1", "C2", "X"],
62
    )
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