quant-met 0.0.8__py3-none-any.whl → 0.0.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quant_met/cli/__init__.py +2 -5
- quant_met/cli/main.py +30 -3
- quant_met/cli/scf.py +40 -10
- quant_met/geometry/__init__.py +1 -1
- quant_met/geometry/base_lattice.py +18 -4
- quant_met/geometry/graphene.py +10 -2
- quant_met/geometry/square.py +11 -3
- quant_met/mean_field/__init__.py +3 -5
- quant_met/mean_field/_utils.py +0 -11
- quant_met/mean_field/hamiltonians/__init__.py +7 -8
- quant_met/mean_field/hamiltonians/base_hamiltonian.py +202 -176
- quant_met/mean_field/hamiltonians/dressed_graphene.py +21 -108
- quant_met/mean_field/hamiltonians/graphene.py +14 -93
- quant_met/mean_field/hamiltonians/one_band_tight_binding.py +17 -97
- quant_met/mean_field/hamiltonians/three_band_tight_binding.py +84 -0
- quant_met/mean_field/hamiltonians/two_band_tight_binding.py +75 -0
- quant_met/mean_field/quantum_metric.py +18 -57
- quant_met/mean_field/self_consistency.py +54 -20
- quant_met/mean_field/superfluid_weight.py +6 -3
- quant_met/parameters/__init__.py +28 -5
- quant_met/parameters/hamiltonians.py +146 -16
- quant_met/parameters/main.py +35 -6
- quant_met/plotting/__init__.py +0 -3
- quant_met/plotting/plotting.py +0 -34
- {quant_met-0.0.8.dist-info → quant_met-0.0.10.dist-info}/METADATA +1 -1
- quant_met-0.0.10.dist-info/RECORD +33 -0
- quant_met-0.0.8.dist-info/RECORD +0 -31
- {quant_met-0.0.8.dist-info → quant_met-0.0.10.dist-info}/LICENSE.txt +0 -0
- {quant_met-0.0.8.dist-info → quant_met-0.0.10.dist-info}/LICENSES/MIT.txt +0 -0
- {quant_met-0.0.8.dist-info → quant_met-0.0.10.dist-info}/WHEEL +0 -0
- {quant_met-0.0.8.dist-info → quant_met-0.0.10.dist-info}/entry_points.txt +0 -0
quant_met/cli/__init__.py
CHANGED
@@ -3,11 +3,8 @@
|
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
|
5
5
|
"""
|
6
|
-
Command-Line-Interface
|
7
|
-
|
8
|
-
|
9
|
-
Functions
|
10
|
-
---------
|
6
|
+
Command-Line-Interface
|
7
|
+
======================
|
11
8
|
|
12
9
|
.. autosummary::
|
13
10
|
:toctree: generated/
|
quant_met/cli/main.py
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
"""Command line interface."""
|
6
6
|
|
7
|
+
import logging
|
7
8
|
import sys
|
8
9
|
from typing import TextIO
|
9
10
|
|
@@ -14,21 +15,47 @@ from quant_met.parameters import Parameters
|
|
14
15
|
|
15
16
|
from .scf import scf
|
16
17
|
|
18
|
+
logger = logging.getLogger(__name__)
|
19
|
+
|
17
20
|
|
18
21
|
@click.command()
|
19
22
|
@click.argument("input-file", type=click.File("r"))
|
20
|
-
|
23
|
+
@click.option("--debug", is_flag=True, help="Enable debug logging.")
|
24
|
+
def cli(input_file: TextIO, *, debug: bool) -> None:
|
21
25
|
"""Command line interface for quant-met.
|
22
26
|
|
23
27
|
Parameters
|
24
28
|
----------
|
25
|
-
input_file
|
29
|
+
input_file: TextIO
|
30
|
+
A file object containing YAML formatted parameters for the simulation.
|
31
|
+
debug : bool
|
32
|
+
If set, enables debug logging instead of the default info logging.
|
33
|
+
|
34
|
+
This command reads the parameters from the specified file and runs the
|
35
|
+
desired calculation based on the provided parameters.
|
26
36
|
"""
|
37
|
+
if debug:
|
38
|
+
logging.basicConfig(
|
39
|
+
level=logging.DEBUG,
|
40
|
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
41
|
+
stream=sys.stdout,
|
42
|
+
)
|
43
|
+
logger.setLevel(logging.DEBUG)
|
44
|
+
logger.info("Debug logging is enabled.")
|
45
|
+
else:
|
46
|
+
logging.basicConfig(
|
47
|
+
level=logging.INFO,
|
48
|
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
49
|
+
stream=sys.stdout,
|
50
|
+
)
|
51
|
+
|
27
52
|
params = Parameters(**yaml.safe_load(input_file))
|
53
|
+
logger.info("Loaded parameters successfully.")
|
28
54
|
|
29
55
|
match params.control.calculation:
|
30
56
|
case "scf":
|
57
|
+
logger.info("Starting SCF calculation.")
|
31
58
|
scf(params)
|
32
59
|
case _:
|
33
|
-
|
60
|
+
logger.error("Calculation %s not found.", params.control.calculation)
|
34
61
|
sys.exit(1)
|
quant_met/cli/scf.py
CHANGED
@@ -4,39 +4,69 @@
|
|
4
4
|
|
5
5
|
"""Functions to run self-consistent calculation for the order parameter."""
|
6
6
|
|
7
|
+
import logging
|
7
8
|
from pathlib import Path
|
8
9
|
|
9
|
-
import numpy as np
|
10
|
-
from pydantic import BaseModel
|
11
|
-
|
12
10
|
from quant_met import mean_field
|
13
11
|
from quant_met.mean_field.hamiltonians import BaseHamiltonian
|
14
12
|
from quant_met.parameters import Parameters
|
13
|
+
from quant_met.parameters.hamiltonians import HamiltonianParameters
|
14
|
+
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
15
17
|
|
18
|
+
def _hamiltonian_factory(
|
19
|
+
classname: str, parameters: HamiltonianParameters
|
20
|
+
) -> BaseHamiltonian[HamiltonianParameters]:
|
21
|
+
"""Create a Hamiltonian by its class name.
|
16
22
|
|
17
|
-
|
18
|
-
|
23
|
+
Parameters
|
24
|
+
----------
|
25
|
+
classname: str
|
26
|
+
The name of the Hamiltonian class to instantiate.
|
27
|
+
parameters: HamiltonianParameters
|
28
|
+
An instance of HamiltonianParameters containing all necessary
|
29
|
+
configuration for the specific Hamiltonian.
|
30
|
+
|
31
|
+
Returns
|
32
|
+
-------
|
33
|
+
BaseHamiltonian[HamiltonianParameters]
|
34
|
+
An instance of the specified Hamiltonian class.
|
35
|
+
"""
|
19
36
|
from quant_met.mean_field import hamiltonians
|
20
37
|
|
21
38
|
cls = getattr(hamiltonians, classname)
|
22
|
-
h: BaseHamiltonian = cls(parameters)
|
39
|
+
h: BaseHamiltonian[HamiltonianParameters] = cls(parameters)
|
23
40
|
return h
|
24
41
|
|
25
42
|
|
26
43
|
def scf(parameters: Parameters) -> None:
|
27
|
-
"""Self-consistent calculation for the order parameter.
|
44
|
+
"""Self-consistent calculation for the order parameter.
|
45
|
+
|
46
|
+
Parameters
|
47
|
+
----------
|
48
|
+
parameters: Parameters
|
49
|
+
An instance of Parameters containing control settings, the model,
|
50
|
+
and k-point specifications for the self-consistency calculation.
|
51
|
+
"""
|
28
52
|
result_path = Path(parameters.control.outdir)
|
29
53
|
result_path.mkdir(exist_ok=True, parents=True)
|
54
|
+
|
55
|
+
logger.info("Initializing Hamiltonian factory.")
|
30
56
|
h = _hamiltonian_factory(parameters=parameters.model, classname=parameters.model.name)
|
57
|
+
|
58
|
+
logger.info("Starting self-consistency loop.")
|
31
59
|
solved_h = mean_field.self_consistency_loop(
|
32
60
|
h=h,
|
33
61
|
k_space_grid=h.lattice.generate_bz_grid(
|
34
62
|
ncols=parameters.k_points.nk1, nrows=parameters.k_points.nk2
|
35
63
|
),
|
36
|
-
beta=np.float64(parameters.control.beta),
|
37
64
|
epsilon=parameters.control.conv_treshold,
|
38
|
-
q=parameters.control.q,
|
39
65
|
)
|
40
|
-
|
66
|
+
|
67
|
+
logger.info("Self-consistency loop completed successfully.")
|
68
|
+
logger.debug("Obtained delta values: %s", solved_h.delta_orbital_basis)
|
69
|
+
|
41
70
|
result_file = result_path / f"{parameters.control.prefix}.hdf5"
|
42
71
|
solved_h.save(filename=result_file)
|
72
|
+
logger.info("Results saved to %s", result_file)
|
quant_met/geometry/__init__.py
CHANGED
@@ -19,19 +19,29 @@ class BaseLattice(ABC):
|
|
19
19
|
|
20
20
|
@property
|
21
21
|
@abstractmethod
|
22
|
-
def lattice_constant(self) ->
|
22
|
+
def lattice_constant(self) -> float: # pragma: no cover
|
23
23
|
"""Lattice constant."""
|
24
24
|
raise NotImplementedError
|
25
25
|
|
26
26
|
@property
|
27
27
|
@abstractmethod
|
28
|
-
def bz_corners(self) -> npt.NDArray[np.float64]:
|
28
|
+
def bz_corners(self) -> npt.NDArray[np.float64]: # pragma: no cover
|
29
29
|
"""Corners of the BZ."""
|
30
30
|
raise NotImplementedError
|
31
31
|
|
32
32
|
@property
|
33
33
|
@abstractmethod
|
34
|
-
def
|
34
|
+
def reciprocal_basis(
|
35
|
+
self,
|
36
|
+
) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]: # pragma: no cover
|
37
|
+
"""Reciprocal basis vectors."""
|
38
|
+
raise NotImplementedError
|
39
|
+
|
40
|
+
@property
|
41
|
+
@abstractmethod
|
42
|
+
def high_symmetry_points(
|
43
|
+
self,
|
44
|
+
) -> tuple[tuple[npt.NDArray[np.float64], str], ...]: # pragma: no cover
|
35
45
|
"""Tuple of high symmetry points and names."""
|
36
46
|
raise NotImplementedError
|
37
47
|
|
@@ -52,7 +62,11 @@ class BaseLattice(ABC):
|
|
52
62
|
|
53
63
|
"""
|
54
64
|
return generate_uniform_grid(
|
55
|
-
ncols,
|
65
|
+
ncols,
|
66
|
+
nrows,
|
67
|
+
self.reciprocal_basis[0],
|
68
|
+
self.reciprocal_basis[1],
|
69
|
+
origin=np.array([0, 0]),
|
56
70
|
)
|
57
71
|
|
58
72
|
def generate_high_symmetry_path(
|
quant_met/geometry/graphene.py
CHANGED
@@ -13,7 +13,7 @@ from .base_lattice import BaseLattice
|
|
13
13
|
class GrapheneLattice(BaseLattice):
|
14
14
|
"""Lattice geometry for Graphene."""
|
15
15
|
|
16
|
-
def __init__(self, lattice_constant:
|
16
|
+
def __init__(self, lattice_constant: float) -> None:
|
17
17
|
self._lattice_constant = lattice_constant
|
18
18
|
self._bz_corners = (
|
19
19
|
4
|
@@ -25,15 +25,23 @@ class GrapheneLattice(BaseLattice):
|
|
25
25
|
self.M = np.pi / self.lattice_constant * np.array([1, 1 / np.sqrt(3)])
|
26
26
|
self.K = 4 * np.pi / (3 * self.lattice_constant) * np.array([1, 0])
|
27
27
|
self._high_symmetry_points = ((self.M, "M"), (self.Gamma, r"\Gamma"), (self.K, "K"))
|
28
|
+
self._reciprocal_basis = (
|
29
|
+
2 * np.pi / self.lattice_constant * np.array([1, 1 / np.sqrt(3)]),
|
30
|
+
2 * np.pi / self.lattice_constant * np.array([1, -1 / np.sqrt(3)]),
|
31
|
+
)
|
28
32
|
|
29
33
|
@property
|
30
|
-
def lattice_constant(self) ->
|
34
|
+
def lattice_constant(self) -> float: # noqa: D102
|
31
35
|
return self._lattice_constant
|
32
36
|
|
33
37
|
@property
|
34
38
|
def bz_corners(self) -> npt.NDArray[np.float64]: # noqa: D102
|
35
39
|
return self._bz_corners
|
36
40
|
|
41
|
+
@property
|
42
|
+
def reciprocal_basis(self) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]: # noqa: D102
|
43
|
+
return self._reciprocal_basis
|
44
|
+
|
37
45
|
@property
|
38
46
|
def high_symmetry_points(self) -> tuple[tuple[npt.NDArray[np.float64], str], ...]: # noqa: D102
|
39
47
|
return self._high_symmetry_points
|
quant_met/geometry/square.py
CHANGED
@@ -13,26 +13,34 @@ from .base_lattice import BaseLattice
|
|
13
13
|
class SquareLattice(BaseLattice):
|
14
14
|
"""Lattice geometry for Square Lattice."""
|
15
15
|
|
16
|
-
def __init__(self, lattice_constant:
|
16
|
+
def __init__(self, lattice_constant: float) -> None:
|
17
17
|
self._lattice_constant = lattice_constant
|
18
18
|
self._bz_corners = (
|
19
19
|
np.pi
|
20
20
|
/ lattice_constant
|
21
21
|
* np.array([np.array([1, 1]), np.array([-1, 1]), np.array([1, -1]), np.array([-1, -1])])
|
22
22
|
)
|
23
|
+
self._reciprocal_basis = (
|
24
|
+
2 * np.pi / self.lattice_constant * np.array([1, 0]),
|
25
|
+
2 * np.pi / self.lattice_constant * np.array([0, 1]),
|
26
|
+
)
|
23
27
|
self.Gamma = np.array([0, 0])
|
24
28
|
self.M = np.pi / lattice_constant * np.array([1, 1])
|
25
29
|
self.X = np.pi / lattice_constant * np.array([1, 0])
|
26
30
|
self._high_symmetry_points = ((self.Gamma, r"\Gamma"), (self.M, "M"))
|
27
31
|
|
28
32
|
@property
|
29
|
-
def lattice_constant(self) ->
|
33
|
+
def lattice_constant(self) -> float: # noqa: D102
|
30
34
|
return self._lattice_constant
|
31
35
|
|
32
36
|
@property
|
33
|
-
def bz_corners(self) -> npt.NDArray[np.float64]: # noqa: D102
|
37
|
+
def bz_corners(self) -> npt.NDArray[np.float64]: # noqa: D102 # pragma: no cover
|
34
38
|
return self._bz_corners
|
35
39
|
|
40
|
+
@property
|
41
|
+
def reciprocal_basis(self) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]: # noqa: D102
|
42
|
+
return self._reciprocal_basis
|
43
|
+
|
36
44
|
@property
|
37
45
|
def high_symmetry_points(self) -> tuple[tuple[npt.NDArray[np.float64], str], ...]: # noqa: D102
|
38
46
|
return self._high_symmetry_points
|
quant_met/mean_field/__init__.py
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
|
5
5
|
"""
|
6
|
-
Mean field
|
7
|
-
|
6
|
+
Mean field
|
7
|
+
==========
|
8
8
|
|
9
9
|
Submodules
|
10
10
|
----------
|
@@ -23,20 +23,18 @@ Functions
|
|
23
23
|
|
24
24
|
superfluid_weight
|
25
25
|
quantum_metric
|
26
|
-
quantum_metric_bdg
|
27
26
|
self_consistency_loop
|
28
27
|
""" # noqa: D205, D400
|
29
28
|
|
30
29
|
from quant_met.mean_field import hamiltonians
|
31
30
|
|
32
|
-
from .quantum_metric import quantum_metric
|
31
|
+
from .quantum_metric import quantum_metric
|
33
32
|
from .self_consistency import self_consistency_loop
|
34
33
|
from .superfluid_weight import superfluid_weight
|
35
34
|
|
36
35
|
__all__ = [
|
37
36
|
"superfluid_weight",
|
38
37
|
"quantum_metric",
|
39
|
-
"quantum_metric_bdg",
|
40
38
|
"self_consistency_loop",
|
41
39
|
"hamiltonians",
|
42
40
|
]
|
quant_met/mean_field/_utils.py
CHANGED
@@ -14,14 +14,3 @@ def _check_valid_array(array_in: npt.NDArray[Any]) -> bool:
|
|
14
14
|
raise ValueError(msg)
|
15
15
|
|
16
16
|
return True
|
17
|
-
|
18
|
-
|
19
|
-
def _validate_float(float_in: float, parameter_name: str) -> float:
|
20
|
-
if np.isinf(float_in):
|
21
|
-
msg = f"{parameter_name} must not be Infinity"
|
22
|
-
raise ValueError(msg)
|
23
|
-
if np.isnan(float_in):
|
24
|
-
msg = f"{parameter_name} must not be NaN"
|
25
|
-
raise ValueError(msg)
|
26
|
-
|
27
|
-
return float_in
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
|
5
5
|
"""
|
6
|
-
|
7
|
-
|
6
|
+
hamiltonians
|
7
|
+
============
|
8
8
|
|
9
9
|
Base
|
10
10
|
|
@@ -19,16 +19,15 @@ Base
|
|
19
19
|
Graphene
|
20
20
|
DressedGraphene
|
21
21
|
OneBand
|
22
|
+
TwoBand
|
23
|
+
ThreeBand
|
22
24
|
""" # noqa: D205, D400
|
23
25
|
|
24
26
|
from .base_hamiltonian import BaseHamiltonian
|
25
27
|
from .dressed_graphene import DressedGraphene
|
26
28
|
from .graphene import Graphene
|
27
29
|
from .one_band_tight_binding import OneBand
|
30
|
+
from .three_band_tight_binding import ThreeBand
|
31
|
+
from .two_band_tight_binding import TwoBand
|
28
32
|
|
29
|
-
__all__ = [
|
30
|
-
"BaseHamiltonian",
|
31
|
-
"Graphene",
|
32
|
-
"DressedGraphene",
|
33
|
-
"OneBand",
|
34
|
-
]
|
33
|
+
__all__ = ["BaseHamiltonian", "Graphene", "DressedGraphene", "OneBand", "TwoBand", "ThreeBand"]
|