quant-met 0.0.12__tar.gz → 0.0.13__tar.gz

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.
Files changed (35) hide show
  1. {quant_met-0.0.12 → quant_met-0.0.13}/PKG-INFO +3 -2
  2. {quant_met-0.0.12 → quant_met-0.0.13}/README.md +1 -1
  3. {quant_met-0.0.12 → quant_met-0.0.13}/pyproject.toml +5 -8
  4. quant_met-0.0.13/src/quant_met/cli/_utils.py +31 -0
  5. quant_met-0.0.13/src/quant_met/cli/crit_temp.py +55 -0
  6. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/cli/main.py +4 -0
  7. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/cli/scf.py +4 -29
  8. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/__init__.py +3 -0
  9. quant_met-0.0.13/src/quant_met/mean_field/search_crit_temp.py +227 -0
  10. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/self_consistency.py +2 -2
  11. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/parameters/__init__.py +1 -0
  12. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/parameters/hamiltonians.py +13 -24
  13. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/parameters/main.py +16 -4
  14. {quant_met-0.0.12 → quant_met-0.0.13}/LICENSE.txt +0 -0
  15. {quant_met-0.0.12 → quant_met-0.0.13}/LICENSES/MIT.txt +0 -0
  16. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/__init__.py +0 -0
  17. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/cli/__init__.py +0 -0
  18. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/geometry/__init__.py +0 -0
  19. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/geometry/base_lattice.py +0 -0
  20. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/geometry/bz_path.py +0 -0
  21. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/geometry/graphene.py +0 -0
  22. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/geometry/square.py +0 -0
  23. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/_utils.py +0 -0
  24. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/hamiltonians/__init__.py +0 -0
  25. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/hamiltonians/base_hamiltonian.py +0 -0
  26. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/hamiltonians/dressed_graphene.py +0 -0
  27. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/hamiltonians/graphene.py +0 -0
  28. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/hamiltonians/one_band_tight_binding.py +0 -0
  29. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/hamiltonians/three_band_tight_binding.py +0 -0
  30. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/hamiltonians/two_band_tight_binding.py +0 -0
  31. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/quantum_metric.py +0 -0
  32. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/mean_field/superfluid_weight.py +0 -0
  33. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/plotting/__init__.py +0 -0
  34. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/plotting/plotting.py +0 -0
  35. {quant_met-0.0.12 → quant_met-0.0.13}/src/quant_met/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quant-met
3
- Version: 0.0.12
3
+ Version: 0.0.13
4
4
  Summary: Calculate superconductivity in flat-band systems.
5
5
  Home-page: https://quant-met.tjarksievers.de
6
6
  Author: Tjark Sievers
@@ -17,6 +17,7 @@ Requires-Dist: numpydantic (>=1.6.4,<2.0.0)
17
17
  Requires-Dist: pandas (>=2.2.3,<3.0.0)
18
18
  Requires-Dist: pydantic (>=2.9.2,<3.0.0)
19
19
  Requires-Dist: scipy (>=1.14.1,<2.0.0)
20
+ Requires-Dist: tables (>=3.10.1,<4.0.0)
20
21
  Project-URL: Repository, https://github.com/Ruberhauptmann/quant-met
21
22
  Description-Content-Type: text/markdown
22
23
 
@@ -28,7 +29,7 @@ SPDX-License-Identifier: MIT
28
29
 
29
30
  # quant-met
30
31
 
31
- [![Test](https://github.com/Ruberhauptmann/quant-met/actions/workflows/test.yml/badge.svg)](https://github.com/Ruberhauptmann/quant-met/actions/workflows/test.yml)
32
+ [![Test](https://github.com/Ruberhauptmann/quant-met/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/Ruberhauptmann/quant-met/actions/workflows/unit_tests.yml)
32
33
  [![Coverage Status](https://coveralls.io/repos/github/Ruberhauptmann/quant-met/badge.svg?branch=main)](https://coveralls.io/github/Ruberhauptmann/quant-met?branch=main)
33
34
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/quant-met)](https://pypi.org/project/quant-met/)
34
35
  [![PyPI - Version](https://img.shields.io/pypi/v/quant-met)](https://pypi.org/project/quant-met/)
@@ -6,7 +6,7 @@ SPDX-License-Identifier: MIT
6
6
 
7
7
  # quant-met
8
8
 
9
- [![Test](https://github.com/Ruberhauptmann/quant-met/actions/workflows/test.yml/badge.svg)](https://github.com/Ruberhauptmann/quant-met/actions/workflows/test.yml)
9
+ [![Test](https://github.com/Ruberhauptmann/quant-met/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/Ruberhauptmann/quant-met/actions/workflows/unit_tests.yml)
10
10
  [![Coverage Status](https://coveralls.io/repos/github/Ruberhauptmann/quant-met/badge.svg?branch=main)](https://coveralls.io/github/Ruberhauptmann/quant-met?branch=main)
11
11
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/quant-met)](https://pypi.org/project/quant-met/)
12
12
  [![PyPI - Version](https://img.shields.io/pypi/v/quant-met)](https://pypi.org/project/quant-met/)
@@ -8,7 +8,7 @@ requires-python = ">=3.11,<3.13"
8
8
 
9
9
  [tool.poetry]
10
10
  name = "quant-met"
11
- version = "0.0.12"
11
+ version = "0.0.13"
12
12
  description = "Calculate superconductivity in flat-band systems."
13
13
  authors = ["Tjark Sievers <tsievers@physnet.uni-hamburg.de>"]
14
14
  homepage = "https://quant-met.tjarksievers.de"
@@ -28,6 +28,7 @@ h5py = "^3.12.1"
28
28
  pydantic = "^2.9.2"
29
29
  click = "^8.1.7"
30
30
  numpydantic = "^1.6.4"
31
+ tables = "^3.10.1"
31
32
 
32
33
  [tool.poetry.group.dev.dependencies]
33
34
  pre-commit = "^3.7.0"
@@ -49,6 +50,9 @@ pytest-regressions = "^2.5.0"
49
50
  numpydoc = "^1.7.0"
50
51
  ruff = "^0.5.0"
51
52
  types-pyyaml = "^6.0.12.20240917"
53
+ autodoc-pydantic = "^2.2.0"
54
+ pytest-integration = "^0.2.3"
55
+ pytest-mock = "^3.14.0"
52
56
 
53
57
  [build-system]
54
58
  requires = ["poetry-core"]
@@ -58,12 +62,9 @@ build-backend = "poetry.core.masonry.api"
58
62
  [tool.ruff]
59
63
  line-length = 100
60
64
  force-exclude = true
61
- #extend-exclude = ["tests", "docs/source/conf.py"]
62
65
  extend-exclude = ["docs/source/conf.py"]
63
66
 
64
67
  [tool.ruff.lint]
65
- #select = []
66
- #select = ["D", "E", "F", "I", "W"]
67
68
  select = ["ALL"]
68
69
  ignore = [
69
70
  "D203", # one-blank-line-before-class
@@ -78,9 +79,5 @@ ignore = [
78
79
  "T201", # Warn about print statements
79
80
  ]
80
81
 
81
-
82
82
  [tool.ruff.lint.pydocstyle]
83
83
  convention = "numpy"
84
-
85
- #[format]
86
- #docstring-code-format = true
@@ -0,0 +1,31 @@
1
+ # SPDX-FileCopyrightText: 2024 Tjark Sievers
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ from quant_met.mean_field.hamiltonians import BaseHamiltonian
6
+ from quant_met.parameters import HamiltonianParameters
7
+
8
+
9
+ def _hamiltonian_factory(
10
+ classname: str, parameters: HamiltonianParameters
11
+ ) -> BaseHamiltonian[HamiltonianParameters]:
12
+ """Create a Hamiltonian by its class name.
13
+
14
+ Parameters
15
+ ----------
16
+ classname: str
17
+ The name of the Hamiltonian class to instantiate.
18
+ parameters: HamiltonianParameters
19
+ An instance of HamiltonianParameters containing all necessary
20
+ configuration for the specific Hamiltonian.
21
+
22
+ Returns
23
+ -------
24
+ BaseHamiltonian[HamiltonianParameters]
25
+ An instance of the specified Hamiltonian class.
26
+ """
27
+ from quant_met.mean_field import hamiltonians
28
+
29
+ cls = getattr(hamiltonians, classname)
30
+ h: BaseHamiltonian[HamiltonianParameters] = cls(parameters)
31
+ return h
@@ -0,0 +1,55 @@
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
8
+ from pathlib import Path
9
+
10
+ import h5py
11
+
12
+ from quant_met import mean_field
13
+ from quant_met.parameters import Parameters
14
+
15
+ from ._utils import _hamiltonian_factory
16
+
17
+ logger = logging.getLogger(__name__)
18
+
19
+
20
+ def crit_temp(parameters: Parameters) -> None:
21
+ """Self-consistent calculation for the order parameter.
22
+
23
+ Parameters
24
+ ----------
25
+ parameters: Parameters
26
+ An instance of Parameters containing control settings, the model,
27
+ and k-point specifications for the T_C calculation.
28
+ """
29
+ result_path = Path(parameters.control.outdir)
30
+ result_path.mkdir(exist_ok=True, parents=True)
31
+
32
+ h = _hamiltonian_factory(parameters=parameters.model, classname=parameters.model.name)
33
+
34
+ delta_vs_temp, critical_temperatures, fit_fig = mean_field.search_crit_temp(
35
+ h=h,
36
+ k_space_grid=h.lattice.generate_bz_grid(
37
+ ncols=parameters.k_points.nk1, nrows=parameters.k_points.nk2
38
+ ),
39
+ epsilon=parameters.control.conv_treshold,
40
+ max_iter=parameters.control.max_iter,
41
+ n_temp_points=parameters.control.n_temp_points,
42
+ )
43
+
44
+ logger.info("Search for T_C completed successfully.")
45
+ logger.info("Obtained T_Cs: %s", critical_temperatures)
46
+
47
+ fit_fig.savefig(result_path / f"{parameters.control.prefix}_T_C_fit.pdf", bbox_inches="tight")
48
+
49
+ result_file = result_path / f"{parameters.control.prefix}.hdf5"
50
+ delta_vs_temp.to_hdf(result_file, key="delta_vs_temp")
51
+ with h5py.File(result_file, mode="a") as file:
52
+ for orbital, crit_temp_orbital in enumerate(critical_temperatures):
53
+ file.attrs[f"T_C_{orbital}"] = crit_temp_orbital
54
+
55
+ logger.info("Results saved to %s", result_file)
@@ -13,6 +13,7 @@ import yaml
13
13
 
14
14
  from quant_met.parameters import Parameters
15
15
 
16
+ from .crit_temp import crit_temp
16
17
  from .scf import scf
17
18
 
18
19
  logger = logging.getLogger(__name__)
@@ -56,6 +57,9 @@ def cli(input_file: TextIO, *, debug: bool) -> None:
56
57
  case "scf":
57
58
  logger.info("Starting SCF calculation.")
58
59
  scf(params)
60
+ case "crit-temp":
61
+ logger.info("Starting T_C calculation.")
62
+ crit_temp(params)
59
63
  case _:
60
64
  logger.error("Calculation %s not found.", params.control.calculation)
61
65
  sys.exit(1)
@@ -8,35 +8,11 @@ import logging
8
8
  from pathlib import Path
9
9
 
10
10
  from quant_met import mean_field
11
- from quant_met.mean_field.hamiltonians import BaseHamiltonian
12
- from quant_met.parameters import HamiltonianParameters, Parameters
11
+ from quant_met.parameters import Parameters
13
12
 
14
- logger = logging.getLogger(__name__)
15
-
16
-
17
- def _hamiltonian_factory(
18
- classname: str, parameters: HamiltonianParameters
19
- ) -> BaseHamiltonian[HamiltonianParameters]:
20
- """Create a Hamiltonian by its class name.
13
+ from ._utils import _hamiltonian_factory
21
14
 
22
- Parameters
23
- ----------
24
- classname: str
25
- The name of the Hamiltonian class to instantiate.
26
- parameters: HamiltonianParameters
27
- An instance of HamiltonianParameters containing all necessary
28
- configuration for the specific Hamiltonian.
29
-
30
- Returns
31
- -------
32
- BaseHamiltonian[HamiltonianParameters]
33
- An instance of the specified Hamiltonian class.
34
- """
35
- from quant_met.mean_field import hamiltonians
36
-
37
- cls = getattr(hamiltonians, classname)
38
- h: BaseHamiltonian[HamiltonianParameters] = cls(parameters)
39
- return h
15
+ logger = logging.getLogger(__name__)
40
16
 
41
17
 
42
18
  def scf(parameters: Parameters) -> None:
@@ -51,16 +27,15 @@ def scf(parameters: Parameters) -> None:
51
27
  result_path = Path(parameters.control.outdir)
52
28
  result_path.mkdir(exist_ok=True, parents=True)
53
29
 
54
- logger.info("Initializing Hamiltonian factory.")
55
30
  h = _hamiltonian_factory(parameters=parameters.model, classname=parameters.model.name)
56
31
 
57
- logger.info("Starting self-consistency loop.")
58
32
  solved_h = mean_field.self_consistency_loop(
59
33
  h=h,
60
34
  k_space_grid=h.lattice.generate_bz_grid(
61
35
  ncols=parameters.k_points.nk1, nrows=parameters.k_points.nk2
62
36
  ),
63
37
  epsilon=parameters.control.conv_treshold,
38
+ max_iter=parameters.control.max_iter,
64
39
  )
65
40
 
66
41
  logger.info("Self-consistency loop completed successfully.")
@@ -24,11 +24,13 @@ Functions
24
24
  superfluid_weight
25
25
  quantum_metric
26
26
  self_consistency_loop
27
+ search_crit_temp
27
28
  """ # noqa: D205, D400
28
29
 
29
30
  from quant_met.mean_field import hamiltonians
30
31
 
31
32
  from .quantum_metric import quantum_metric
33
+ from .search_crit_temp import search_crit_temp
32
34
  from .self_consistency import self_consistency_loop
33
35
  from .superfluid_weight import superfluid_weight
34
36
 
@@ -36,5 +38,6 @@ __all__ = [
36
38
  "superfluid_weight",
37
39
  "quantum_metric",
38
40
  "self_consistency_loop",
41
+ "search_crit_temp",
39
42
  "hamiltonians",
40
43
  ]
@@ -0,0 +1,227 @@
1
+ # SPDX-FileCopyrightText: 2024 Tjark Sievers
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ """Function to run search for critical temperature."""
6
+
7
+ import logging
8
+ from functools import partial
9
+ from multiprocessing import Pool
10
+ from typing import Any
11
+
12
+ import matplotlib.figure
13
+ import matplotlib.pyplot as plt
14
+ import numpy as np
15
+ import numpy.typing as npt
16
+ import pandas as pd
17
+ from scipy import stats
18
+
19
+ from quant_met import plotting
20
+ from quant_met.parameters import GenericParameters
21
+
22
+ from .hamiltonians import BaseHamiltonian
23
+ from .self_consistency import self_consistency_loop
24
+
25
+ logger = logging.getLogger(__name__)
26
+
27
+
28
+ def _get_bounds(
29
+ temp: float,
30
+ gap_for_temp_partial: partial[dict[str, Any] | None],
31
+ zero_temperature_gap: npt.NDArray[np.complex64],
32
+ ) -> tuple[list[dict[str, Any]], float, float]: # pragma: no cover
33
+ delta_vs_temp_list = []
34
+ zero_gap_temp = nonzero_gap_temp = temp
35
+ found_zero_gap = False
36
+ found_nonzero_gap = False
37
+ iterations = 0
38
+ while (found_zero_gap and found_nonzero_gap) is False and iterations < 100:
39
+ logger.info("Trying temperature: %s", temp)
40
+ data_dict = gap_for_temp_partial(temp)
41
+ if data_dict is not None:
42
+ delta_vs_temp_list.append(data_dict)
43
+ gap = np.array([data_dict[key] for key in data_dict if key.startswith("delta")])
44
+ if np.allclose(gap, 0):
45
+ zero_gap_temp = temp
46
+ temp = 0.5 * temp
47
+ logger.info("Found temperature with zero gap.")
48
+ found_zero_gap = True
49
+ elif np.allclose(gap, zero_temperature_gap):
50
+ nonzero_gap_temp = temp
51
+ temp = 2 * temp
52
+ logger.info("Found temperature with nonzero gap.")
53
+ found_nonzero_gap = True
54
+ else:
55
+ temp = 0.5 * temp
56
+ else:
57
+ temp = 0.5 * temp
58
+ iterations += 1
59
+ return delta_vs_temp_list, zero_gap_temp, nonzero_gap_temp
60
+
61
+
62
+ def _fit_for_crit_temp(
63
+ delta_vs_temp: pd.DataFrame, orbital: int
64
+ ) -> tuple[pd.DataFrame | None, pd.DataFrame, float | None, float | None]: # pragma: no cover
65
+ filtered_results = delta_vs_temp.iloc[
66
+ np.where(
67
+ np.invert(
68
+ np.logical_or(
69
+ np.isclose(
70
+ np.abs(delta_vs_temp[f"delta_{orbital}"]) ** 2,
71
+ 0,
72
+ atol=1000 * (np.abs(delta_vs_temp[f"delta_{orbital}"]) ** 2).min(),
73
+ rtol=1e-3,
74
+ ),
75
+ np.isclose(
76
+ np.abs(delta_vs_temp[f"delta_{orbital}"]) ** 2,
77
+ (np.abs(delta_vs_temp[f"delta_{orbital}"]) ** 2).max(),
78
+ rtol=1e-3,
79
+ ),
80
+ )
81
+ )
82
+ )
83
+ ]
84
+
85
+ err = []
86
+ if len(filtered_results) <= 4:
87
+ return None, filtered_results, None, None
88
+
89
+ lengths = range(4, len(filtered_results))
90
+
91
+ for length in lengths:
92
+ range_results = filtered_results.iloc[-length:]
93
+ linreg = stats.linregress(
94
+ range_results["T"], np.abs(range_results[f"delta_{orbital}"]) ** 2
95
+ )
96
+ err.append(linreg.stderr)
97
+
98
+ min_length = lengths[np.argmin(np.array(err))]
99
+ range_results = filtered_results.iloc[-min_length:]
100
+ linreg = stats.linregress(range_results["T"], np.abs(range_results[f"delta_{orbital}"]) ** 2)
101
+
102
+ return range_results, filtered_results, linreg.intercept, linreg.slope
103
+
104
+
105
+ def _gap_for_temp(
106
+ temp: float,
107
+ h: BaseHamiltonian[GenericParameters],
108
+ k_space_grid: npt.NDArray[np.float64],
109
+ epsilon: float,
110
+ max_iter: int = 1000,
111
+ ) -> dict[str, Any] | None: # pragma: no cover
112
+ beta = np.inf if temp == 0 else 1 / temp
113
+ h.beta = beta
114
+ try:
115
+ solved_h = self_consistency_loop(h, k_space_grid, epsilon, max_iter)
116
+ except RuntimeError:
117
+ logger.exception("Did not converge.")
118
+ return None
119
+ else:
120
+ data_dict = {
121
+ "T": temp,
122
+ }
123
+ zero_temperature_gap = solved_h.delta_orbital_basis
124
+ data_dict.update(
125
+ {
126
+ f"delta_{orbital}": zero_temperature_gap[orbital]
127
+ for orbital in range(len(zero_temperature_gap))
128
+ }
129
+ )
130
+ return data_dict
131
+
132
+
133
+ def search_crit_temp(
134
+ h: BaseHamiltonian[GenericParameters],
135
+ k_space_grid: npt.NDArray[np.float64],
136
+ epsilon: float,
137
+ max_iter: int,
138
+ n_temp_points: int,
139
+ ) -> tuple[pd.DataFrame, list[float], matplotlib.figure.Figure]: # pragma: no cover
140
+ """Search for critical temperature."""
141
+ logger.info("Start search for bounds for T_C")
142
+ temp = 1 / h.beta if not np.isinf(h.beta) else 0.25 * h.hubbard_int_orbital_basis[0]
143
+
144
+ delta_vs_temp_list = []
145
+ critical_temp_list = []
146
+
147
+ gap_for_temp_partial = partial(
148
+ _gap_for_temp, h=h, k_space_grid=k_space_grid, epsilon=epsilon, max_iter=max_iter
149
+ )
150
+
151
+ data_dict = gap_for_temp_partial(0)
152
+ assert data_dict is not None
153
+
154
+ logger.info("Calculating zero temperature gap")
155
+ zero_temperature_gap = np.array(
156
+ [data_dict[key] for key in data_dict if key.startswith("delta")]
157
+ )
158
+ delta_vs_temp_list.append(data_dict)
159
+
160
+ delta_vs_temp_list_tmp, zero_gap_temp, nonzero_gap_temp = _get_bounds(
161
+ temp, gap_for_temp_partial, zero_temperature_gap
162
+ )
163
+ delta_vs_temp_list.extend(delta_vs_temp_list_tmp)
164
+ logger.info("Temperature bounds: %s to %s", nonzero_gap_temp, zero_gap_temp)
165
+
166
+ temperature_list = np.concatenate(
167
+ [
168
+ np.linspace(
169
+ 0.8 * nonzero_gap_temp,
170
+ nonzero_gap_temp,
171
+ num=int(0.05 * n_temp_points),
172
+ endpoint=False,
173
+ ),
174
+ np.linspace(
175
+ nonzero_gap_temp, zero_gap_temp, num=int(0.9 * n_temp_points), endpoint=False
176
+ ),
177
+ np.linspace(
178
+ zero_gap_temp, 1.2 * zero_gap_temp, num=int(0.05 * n_temp_points), endpoint=True
179
+ ),
180
+ ]
181
+ )
182
+
183
+ with Pool() as p:
184
+ delta_vs_temp_list.extend(p.map(gap_for_temp_partial, temperature_list)) # type: ignore[arg-type]
185
+ delta_vs_temp_list = [x for x in delta_vs_temp_list if x is not None]
186
+
187
+ delta_vs_temp = pd.DataFrame(delta_vs_temp_list).sort_values(by=["T"]).reset_index(drop=True)
188
+
189
+ fit_fig, fit_axs = plt.subplots(
190
+ nrows=1, ncols=h.number_of_bands, figsize=(h.number_of_bands * 6, 6)
191
+ )
192
+
193
+ for orbital in range(h.number_of_bands):
194
+ fit_range, filtered_range, intercept, slope = _fit_for_crit_temp(delta_vs_temp, orbital)
195
+
196
+ ax = fit_axs if h.number_of_bands == 1 else fit_axs[orbital]
197
+
198
+ if fit_range is not None and intercept is not None and slope is not None:
199
+ critical_temp = -intercept / slope
200
+ critical_temp_list.append(critical_temp)
201
+
202
+ ax.plot(
203
+ filtered_range["T"],
204
+ intercept + slope * filtered_range["T"],
205
+ "r--",
206
+ alpha=0.3,
207
+ )
208
+ ax.plot(
209
+ fit_range["T"],
210
+ intercept + slope * fit_range["T"],
211
+ "r-",
212
+ )
213
+ ax.axvline(x=critical_temp, linestyle="--", color="gray")
214
+ else:
215
+ critical_temp = 0
216
+ critical_temp_list.append(critical_temp)
217
+
218
+ ax.plot(
219
+ delta_vs_temp["T"],
220
+ np.abs(delta_vs_temp[f"delta_{orbital}"]) ** 2,
221
+ "--x",
222
+ color=f"C{orbital}",
223
+ )
224
+ ax = plotting.format_plot(ax)
225
+ ax.set_ylabel(r"$\vert\Delta\vert^2\ [t^2]$")
226
+
227
+ return delta_vs_temp, critical_temp_list, fit_fig
@@ -5,7 +5,6 @@
5
5
  """Self-consistency loop."""
6
6
 
7
7
  import logging
8
- import sys
9
8
 
10
9
  import numpy as np
11
10
  import numpy.typing as npt
@@ -71,7 +70,8 @@ def self_consistency_loop(
71
70
  while True:
72
71
  iteration_count += 1
73
72
  if iteration_count > max_iter:
74
- sys.exit("Maximum number of iterations reached.")
73
+ msg = "Maximum number of iterations reached."
74
+ raise RuntimeError(msg)
75
75
 
76
76
  logger.debug("Iteration %d: Computing new gaps.", iteration_count)
77
77
 
@@ -17,6 +17,7 @@ Classes holding the configuration for the Hamiltonians.
17
17
 
18
18
  .. autosummary::
19
19
  :toctree: generated/parameters/
20
+ :template: autosummary/pydantic.rst
20
21
 
21
22
  Parameters # noqa
22
23
  Control # noqa
@@ -3,19 +3,20 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
 
5
5
  """
6
- Hamiltonian Parameter Classes
7
- =============================
6
+ hamiltonians
7
+ ============
8
8
 
9
9
  Classes holding the configuration for the Hamiltonians.
10
10
 
11
11
  .. autosummary::
12
- :toctree: generated/parameters/
12
+ :toctree:
13
+ :template: autosummary/pydantic.rst
13
14
 
14
15
  HamiltonianParameters
15
16
  DressedGrapheneParameters
16
17
  GrapheneParameters
17
18
  OneBandParameters
18
- TwobandParameters
19
+ TwoBandParameters
19
20
  ThreeBandParameters
20
21
  """ # noqa: D205, D400
21
22
 
@@ -49,28 +50,16 @@ def validate_float(value: float, info: ValidationInfo) -> float:
49
50
 
50
51
 
51
52
  class HamiltonianParameters(BaseModel):
52
- """Base class for Hamiltonian parameters.
53
-
54
- Attributes
55
- ----------
56
- name : str
57
- The name of the Hamiltonian model (e.g., "Graphene", "DressedGraphene").
58
- beta : float
59
- The inverse temperature; default is set to infinity.
60
- q : :class:`numpy.ndarray` | None
61
- An optional numpy array representing the momentum of Cooper pairs.
62
- hubbard_int_orbital_basis : :class:`numpy.ndarray`
63
- A numpy array representing the Hubbard interactions in the orbital basis.
64
- """
53
+ """Base class for Hamiltonian parameters."""
65
54
 
66
55
  name: str
67
- beta: float = Field(default=np.inf, description="Inverse temperature")
68
- q: NDArray[Shape["2"], int | float] | None = Field(
69
- default=None, description="Momentum of Cooper pairs"
70
- )
71
- hubbard_int_orbital_basis: NDArray = Field(
72
- ..., description="Hubbard interaction in orbital basis"
73
- )
56
+ """The name of the Hamiltonian model (e.g., "Graphene", "DressedGraphene")."""
57
+ hubbard_int_orbital_basis: NDArray
58
+ """A numpy array representing the Hubbard interactions in the orbital basis."""
59
+ beta: float = np.inf
60
+ """The inverse temperature; default is set to infinity."""
61
+ q: NDArray[Shape["2"], float] | None = None
62
+ """An optional numpy array representing the momentum of Cooper pairs."""
74
63
 
75
64
 
76
65
  class DressedGrapheneParameters(HamiltonianParameters):
@@ -8,7 +8,13 @@ import pathlib
8
8
 
9
9
  from pydantic import BaseModel, Field
10
10
 
11
- from .hamiltonians import DressedGrapheneParameters, GrapheneParameters, OneBandParameters
11
+ from .hamiltonians import (
12
+ DressedGrapheneParameters,
13
+ GrapheneParameters,
14
+ OneBandParameters,
15
+ ThreeBandParameters,
16
+ TwoBandParameters,
17
+ )
12
18
 
13
19
 
14
20
  class Control(BaseModel):
@@ -31,6 +37,8 @@ class Control(BaseModel):
31
37
  prefix: str
32
38
  outdir: pathlib.Path
33
39
  conv_treshold: float
40
+ max_iter: int = 1000
41
+ n_temp_points: int = 50
34
42
 
35
43
 
36
44
  class KPoints(BaseModel):
@@ -63,7 +71,11 @@ class Parameters(BaseModel):
63
71
  """
64
72
 
65
73
  control: Control
66
- model: DressedGrapheneParameters | GrapheneParameters | OneBandParameters = Field(
67
- ..., discriminator="name"
68
- )
74
+ model: (
75
+ DressedGrapheneParameters
76
+ | GrapheneParameters
77
+ | OneBandParameters
78
+ | TwoBandParameters
79
+ | ThreeBandParameters
80
+ ) = Field(..., discriminator="name")
69
81
  k_points: KPoints
File without changes
File without changes