quant-met 0.0.9__py3-none-any.whl → 0.0.11__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 +36 -5
- quant_met/geometry/__init__.py +1 -1
- quant_met/mean_field/__init__.py +3 -5
- quant_met/mean_field/hamiltonians/__init__.py +4 -2
- quant_met/mean_field/hamiltonians/base_hamiltonian.py +171 -78
- quant_met/mean_field/hamiltonians/dressed_graphene.py +4 -36
- quant_met/mean_field/hamiltonians/graphene.py +4 -36
- quant_met/mean_field/hamiltonians/one_band_tight_binding.py +6 -38
- quant_met/mean_field/hamiltonians/three_band_tight_binding.py +5 -37
- quant_met/mean_field/hamiltonians/two_band_tight_binding.py +5 -37
- quant_met/mean_field/quantum_metric.py +22 -62
- quant_met/mean_field/self_consistency.py +60 -6
- quant_met/mean_field/superfluid_weight.py +6 -6
- quant_met/parameters/__init__.py +19 -7
- quant_met/parameters/hamiltonians.py +49 -4
- quant_met/parameters/main.py +35 -3
- quant_met/plotting/__init__.py +0 -3
- quant_met/plotting/plotting.py +0 -34
- {quant_met-0.0.9.dist-info → quant_met-0.0.11.dist-info}/METADATA +5 -41
- quant_met-0.0.11.dist-info/RECORD +33 -0
- quant_met-0.0.9.dist-info/RECORD +0 -33
- {quant_met-0.0.9.dist-info → quant_met-0.0.11.dist-info}/LICENSE.txt +0 -0
- {quant_met-0.0.9.dist-info → quant_met-0.0.11.dist-info}/LICENSES/MIT.txt +0 -0
- {quant_met-0.0.9.dist-info → quant_met-0.0.11.dist-info}/WHEEL +0 -0
- {quant_met-0.0.9.dist-info → quant_met-0.0.11.dist-info}/entry_points.txt +0 -0
@@ -28,30 +28,14 @@ class DressedGraphene(BaseHamiltonian[DressedGrapheneParameters]):
|
|
28
28
|
if parameters.delta is not None:
|
29
29
|
self.delta_orbital_basis = np.astype(parameters.delta, np.complex64)
|
30
30
|
|
31
|
-
def setup_lattice(self, parameters: DressedGrapheneParameters) -> BaseLattice:
|
32
|
-
"""Set up lattice based on parameters."""
|
31
|
+
def setup_lattice(self, parameters: DressedGrapheneParameters) -> BaseLattice: # noqa: D102
|
33
32
|
return GrapheneLattice(lattice_constant=parameters.lattice_constant)
|
34
33
|
|
35
34
|
@classmethod
|
36
|
-
def get_parameters_model(cls) -> type[DressedGrapheneParameters]:
|
37
|
-
"""Return the specific parameters model for the subclass."""
|
35
|
+
def get_parameters_model(cls) -> type[DressedGrapheneParameters]: # noqa: D102
|
38
36
|
return DressedGrapheneParameters
|
39
37
|
|
40
|
-
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]:
|
41
|
-
"""
|
42
|
-
Return the normal state Hamiltonian in orbital basis.
|
43
|
-
|
44
|
-
Parameters
|
45
|
-
----------
|
46
|
-
k : :class:`numpy.ndarray`
|
47
|
-
List of k points.
|
48
|
-
|
49
|
-
Returns
|
50
|
-
-------
|
51
|
-
:class:`numpy.ndarray`
|
52
|
-
Hamiltonian in matrix form.
|
53
|
-
|
54
|
-
"""
|
38
|
+
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]: # noqa: D102
|
55
39
|
assert _check_valid_array(k)
|
56
40
|
|
57
41
|
t_gr = self.hopping_gr
|
@@ -88,25 +72,9 @@ class DressedGraphene(BaseHamiltonian[DressedGrapheneParameters]):
|
|
88
72
|
|
89
73
|
return h.squeeze()
|
90
74
|
|
91
|
-
def hamiltonian_derivative(
|
75
|
+
def hamiltonian_derivative( # noqa: D102
|
92
76
|
self, k: npt.NDArray[np.float64], direction: str
|
93
77
|
) -> npt.NDArray[np.complex64]:
|
94
|
-
"""
|
95
|
-
Deriative of the Hamiltonian.
|
96
|
-
|
97
|
-
Parameters
|
98
|
-
----------
|
99
|
-
k: :class:`numpy.ndarray`
|
100
|
-
List of k points.
|
101
|
-
direction: str
|
102
|
-
Direction for derivative, either 'x' oder 'y'.
|
103
|
-
|
104
|
-
Returns
|
105
|
-
-------
|
106
|
-
:class:`numpy.ndarray`
|
107
|
-
Derivative of Hamiltonian.
|
108
|
-
|
109
|
-
"""
|
110
78
|
assert _check_valid_array(k)
|
111
79
|
assert direction in ["x", "y"]
|
112
80
|
|
@@ -27,30 +27,14 @@ class Graphene(BaseHamiltonian[GrapheneParameters]):
|
|
27
27
|
if parameters.delta is not None:
|
28
28
|
self.delta_orbital_basis = np.astype(parameters.delta, np.complex64)
|
29
29
|
|
30
|
-
def setup_lattice(self, parameters: GrapheneParameters) -> GrapheneLattice:
|
31
|
-
"""Set up lattice based on parameters."""
|
30
|
+
def setup_lattice(self, parameters: GrapheneParameters) -> GrapheneLattice: # noqa: D102
|
32
31
|
return GrapheneLattice(lattice_constant=parameters.lattice_constant)
|
33
32
|
|
34
33
|
@classmethod
|
35
|
-
def get_parameters_model(cls) -> type[GrapheneParameters]:
|
36
|
-
"""Return the specific parameters model for the subclass."""
|
34
|
+
def get_parameters_model(cls) -> type[GrapheneParameters]: # noqa: D102
|
37
35
|
return GrapheneParameters
|
38
36
|
|
39
|
-
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]:
|
40
|
-
"""
|
41
|
-
Return the normal state Hamiltonian in orbital basis.
|
42
|
-
|
43
|
-
Parameters
|
44
|
-
----------
|
45
|
-
k : :class:`numpy.ndarray`
|
46
|
-
List of k points.
|
47
|
-
|
48
|
-
Returns
|
49
|
-
-------
|
50
|
-
:class:`numpy.ndarray`
|
51
|
-
Hamiltonian in matrix form.
|
52
|
-
|
53
|
-
"""
|
37
|
+
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]: # noqa: D102
|
54
38
|
assert _check_valid_array(k)
|
55
39
|
hopping = self.hopping
|
56
40
|
lattice_constant = self.lattice.lattice_constant
|
@@ -72,25 +56,9 @@ class Graphene(BaseHamiltonian[GrapheneParameters]):
|
|
72
56
|
|
73
57
|
return h.squeeze()
|
74
58
|
|
75
|
-
def hamiltonian_derivative(
|
59
|
+
def hamiltonian_derivative( # noqa: D102
|
76
60
|
self, k: npt.NDArray[np.float64], direction: str
|
77
61
|
) -> npt.NDArray[np.complex64]:
|
78
|
-
"""
|
79
|
-
Deriative of the Hamiltonian.
|
80
|
-
|
81
|
-
Parameters
|
82
|
-
----------
|
83
|
-
k: :class:`numpy.ndarray`
|
84
|
-
List of k points.
|
85
|
-
direction: str
|
86
|
-
Direction for derivative, either 'x' oder 'y'.
|
87
|
-
|
88
|
-
Returns
|
89
|
-
-------
|
90
|
-
:class:`numpy.ndarray`
|
91
|
-
Derivative of Hamiltonian.
|
92
|
-
|
93
|
-
"""
|
94
62
|
assert _check_valid_array(k)
|
95
63
|
assert direction in ["x", "y"]
|
96
64
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
|
5
|
-
"""Provides the implementation for
|
5
|
+
"""Provides the implementation for a one band tight binding model."""
|
6
6
|
|
7
7
|
import numpy as np
|
8
8
|
import numpy.typing as npt
|
@@ -15,7 +15,7 @@ from .base_hamiltonian import BaseHamiltonian
|
|
15
15
|
|
16
16
|
|
17
17
|
class OneBand(BaseHamiltonian[OneBandParameters]):
|
18
|
-
"""Hamiltonian for
|
18
|
+
"""Hamiltonian for one band tight binding model."""
|
19
19
|
|
20
20
|
def __init__(self, parameters: OneBandParameters) -> None:
|
21
21
|
super().__init__(parameters)
|
@@ -24,30 +24,14 @@ class OneBand(BaseHamiltonian[OneBandParameters]):
|
|
24
24
|
if parameters.delta is not None:
|
25
25
|
self.delta_orbital_basis = np.astype(parameters.delta, np.complex64)
|
26
26
|
|
27
|
-
def setup_lattice(self, parameters: OneBandParameters) -> SquareLattice:
|
28
|
-
"""Set up lattice based on parameters."""
|
27
|
+
def setup_lattice(self, parameters: OneBandParameters) -> SquareLattice: # noqa: D102
|
29
28
|
return SquareLattice(lattice_constant=parameters.lattice_constant)
|
30
29
|
|
31
30
|
@classmethod
|
32
|
-
def get_parameters_model(cls) -> type[OneBandParameters]:
|
33
|
-
"""Return the specific parameters model for the subclass."""
|
31
|
+
def get_parameters_model(cls) -> type[OneBandParameters]: # noqa: D102
|
34
32
|
return OneBandParameters
|
35
33
|
|
36
|
-
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]:
|
37
|
-
"""
|
38
|
-
Return the normal state Hamiltonian in orbital basis.
|
39
|
-
|
40
|
-
Parameters
|
41
|
-
----------
|
42
|
-
k : :class:`numpy.ndarray`
|
43
|
-
List of k points.
|
44
|
-
|
45
|
-
Returns
|
46
|
-
-------
|
47
|
-
:class:`numpy.ndarray`
|
48
|
-
Hamiltonian in matrix form.
|
49
|
-
|
50
|
-
"""
|
34
|
+
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]: # noqa: D102
|
51
35
|
assert _check_valid_array(k)
|
52
36
|
hopping = self.hopping
|
53
37
|
lattice_constant = self.lattice.lattice_constant
|
@@ -64,25 +48,9 @@ class OneBand(BaseHamiltonian[OneBandParameters]):
|
|
64
48
|
|
65
49
|
return h
|
66
50
|
|
67
|
-
def hamiltonian_derivative(
|
51
|
+
def hamiltonian_derivative( # noqa: D102
|
68
52
|
self, k: npt.NDArray[np.float64], direction: str
|
69
53
|
) -> npt.NDArray[np.complex64]:
|
70
|
-
"""
|
71
|
-
Deriative of the Hamiltonian.
|
72
|
-
|
73
|
-
Parameters
|
74
|
-
----------
|
75
|
-
k: :class:`numpy.ndarray`
|
76
|
-
List of k points.
|
77
|
-
direction: str
|
78
|
-
Direction for derivative, either 'x' oder 'y'.
|
79
|
-
|
80
|
-
Returns
|
81
|
-
-------
|
82
|
-
:class:`numpy.ndarray`
|
83
|
-
Derivative of Hamiltonian.
|
84
|
-
|
85
|
-
"""
|
86
54
|
assert _check_valid_array(k)
|
87
55
|
assert direction in ["x", "y"]
|
88
56
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
|
5
|
-
"""Provides the implementation for
|
5
|
+
"""Provides the implementation for a three band tight binding model."""
|
6
6
|
|
7
7
|
import numpy as np
|
8
8
|
import numpy.typing as npt
|
@@ -24,30 +24,14 @@ class ThreeBand(BaseHamiltonian[ThreeBandParameters]):
|
|
24
24
|
if parameters.delta is not None:
|
25
25
|
self.delta_orbital_basis = np.astype(parameters.delta, np.complex64)
|
26
26
|
|
27
|
-
def setup_lattice(self, parameters: ThreeBandParameters) -> SquareLattice:
|
28
|
-
"""Set up lattice based on parameters."""
|
27
|
+
def setup_lattice(self, parameters: ThreeBandParameters) -> SquareLattice: # noqa: D102
|
29
28
|
return SquareLattice(lattice_constant=parameters.lattice_constant)
|
30
29
|
|
31
30
|
@classmethod
|
32
|
-
def get_parameters_model(cls) -> type[ThreeBandParameters]:
|
33
|
-
"""Return the specific parameters model for the subclass."""
|
31
|
+
def get_parameters_model(cls) -> type[ThreeBandParameters]: # noqa: D102
|
34
32
|
return ThreeBandParameters
|
35
33
|
|
36
|
-
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]:
|
37
|
-
"""
|
38
|
-
Return the normal state Hamiltonian in orbital basis.
|
39
|
-
|
40
|
-
Parameters
|
41
|
-
----------
|
42
|
-
k : :class:`numpy.ndarray`
|
43
|
-
List of k points.
|
44
|
-
|
45
|
-
Returns
|
46
|
-
-------
|
47
|
-
:class:`numpy.ndarray`
|
48
|
-
Hamiltonian in matrix form.
|
49
|
-
|
50
|
-
"""
|
34
|
+
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]: # noqa: D102
|
51
35
|
assert _check_valid_array(k)
|
52
36
|
hopping = self.hopping
|
53
37
|
lattice_constant = self.lattice.lattice_constant
|
@@ -75,25 +59,9 @@ class ThreeBand(BaseHamiltonian[ThreeBandParameters]):
|
|
75
59
|
|
76
60
|
return h.squeeze()
|
77
61
|
|
78
|
-
def hamiltonian_derivative(
|
62
|
+
def hamiltonian_derivative( # noqa: D102
|
79
63
|
self, k: npt.NDArray[np.float64], direction: str
|
80
64
|
) -> npt.NDArray[np.complex64]:
|
81
|
-
"""
|
82
|
-
Deriative of the Hamiltonian.
|
83
|
-
|
84
|
-
Parameters
|
85
|
-
----------
|
86
|
-
k: :class:`numpy.ndarray`
|
87
|
-
List of k points.
|
88
|
-
direction: str
|
89
|
-
Direction for derivative, either 'x' oder 'y'.
|
90
|
-
|
91
|
-
Returns
|
92
|
-
-------
|
93
|
-
:class:`numpy.ndarray`
|
94
|
-
Derivative of Hamiltonian.
|
95
|
-
|
96
|
-
"""
|
97
65
|
assert _check_valid_array(k)
|
98
66
|
assert direction in ["x", "y"]
|
99
67
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
|
5
|
-
"""Provides the implementation for
|
5
|
+
"""Provides the implementation for a two band tight binding model."""
|
6
6
|
|
7
7
|
import numpy as np
|
8
8
|
import numpy.typing as npt
|
@@ -24,30 +24,14 @@ class TwoBand(BaseHamiltonian[TwoBandParameters]):
|
|
24
24
|
if parameters.delta is not None:
|
25
25
|
self.delta_orbital_basis = np.astype(parameters.delta, np.complex64)
|
26
26
|
|
27
|
-
def setup_lattice(self, parameters: TwoBandParameters) -> SquareLattice:
|
28
|
-
"""Set up lattice based on parameters."""
|
27
|
+
def setup_lattice(self, parameters: TwoBandParameters) -> SquareLattice: # noqa: D102
|
29
28
|
return SquareLattice(lattice_constant=parameters.lattice_constant)
|
30
29
|
|
31
30
|
@classmethod
|
32
|
-
def get_parameters_model(cls) -> type[TwoBandParameters]:
|
33
|
-
"""Return the specific parameters model for the subclass."""
|
31
|
+
def get_parameters_model(cls) -> type[TwoBandParameters]: # noqa: D102
|
34
32
|
return TwoBandParameters
|
35
33
|
|
36
|
-
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]:
|
37
|
-
"""
|
38
|
-
Return the normal state Hamiltonian in orbital basis.
|
39
|
-
|
40
|
-
Parameters
|
41
|
-
----------
|
42
|
-
k : :class:`numpy.ndarray`
|
43
|
-
List of k points.
|
44
|
-
|
45
|
-
Returns
|
46
|
-
-------
|
47
|
-
:class:`numpy.ndarray`
|
48
|
-
Hamiltonian in matrix form.
|
49
|
-
|
50
|
-
"""
|
34
|
+
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]: # noqa: D102
|
51
35
|
assert _check_valid_array(k)
|
52
36
|
hopping = self.hopping
|
53
37
|
lattice_constant = self.lattice.lattice_constant
|
@@ -68,25 +52,9 @@ class TwoBand(BaseHamiltonian[TwoBandParameters]):
|
|
68
52
|
|
69
53
|
return h.squeeze()
|
70
54
|
|
71
|
-
def hamiltonian_derivative(
|
55
|
+
def hamiltonian_derivative( # noqa: D102
|
72
56
|
self, k: npt.NDArray[np.float64], direction: str
|
73
57
|
) -> npt.NDArray[np.complex64]:
|
74
|
-
"""
|
75
|
-
Deriative of the Hamiltonian.
|
76
|
-
|
77
|
-
Parameters
|
78
|
-
----------
|
79
|
-
k: :class:`numpy.ndarray`
|
80
|
-
List of k points.
|
81
|
-
direction: str
|
82
|
-
Direction for derivative, either 'x' oder 'y'.
|
83
|
-
|
84
|
-
Returns
|
85
|
-
-------
|
86
|
-
:class:`numpy.ndarray`
|
87
|
-
Derivative of Hamiltonian.
|
88
|
-
|
89
|
-
"""
|
90
58
|
assert _check_valid_array(k)
|
91
59
|
assert direction in ["x", "y"]
|
92
60
|
|
@@ -12,36 +12,45 @@ from quant_met.parameters import GenericParameters
|
|
12
12
|
|
13
13
|
|
14
14
|
def quantum_metric(
|
15
|
-
h: BaseHamiltonian[GenericParameters],
|
15
|
+
h: BaseHamiltonian[GenericParameters], k: npt.NDArray[np.float64], bands: list[int]
|
16
16
|
) -> npt.NDArray[np.float64]:
|
17
|
-
"""Calculate the quantum metric
|
17
|
+
"""Calculate the quantum metric (geometric tensor) for specified bands.
|
18
|
+
|
19
|
+
This function computes the quantum geometric tensor associated with
|
20
|
+
the specified bands of a given Hamiltonian over a grid of k-points.
|
21
|
+
The output is a 2x2 matrix representing the quantum metric.
|
18
22
|
|
19
23
|
Parameters
|
20
24
|
----------
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
h : BaseHamiltonian
|
26
|
+
Hamiltonian object used to compute Bloch states and their derivatives.
|
27
|
+
k : numpy.ndarray
|
28
|
+
Array of k points in the Brillouin zone.
|
29
|
+
bands : list of int
|
30
|
+
Indices of the bands for which the quantum metric is to be calculated.
|
26
31
|
|
27
32
|
Returns
|
28
33
|
-------
|
29
34
|
:class:`numpy.ndarray`
|
30
|
-
|
35
|
+
A 2x2 matrix representing the quantum metric.
|
31
36
|
|
37
|
+
Raises
|
38
|
+
------
|
39
|
+
ValueError
|
40
|
+
If `bands` contains invalid indices or `k_grid` is empty.
|
32
41
|
"""
|
33
|
-
energies, bloch = h.diagonalize_nonint(
|
42
|
+
energies, bloch = h.diagonalize_nonint(k)
|
34
43
|
|
35
|
-
number_k_points = len(
|
44
|
+
number_k_points = len(k)
|
36
45
|
|
37
46
|
quantum_geom_tensor = np.zeros(shape=(2, 2), dtype=np.complex64)
|
38
47
|
|
39
48
|
for band in bands:
|
40
49
|
for i, direction_1 in enumerate(["x", "y"]):
|
41
|
-
h_derivative_direction_1 = h.hamiltonian_derivative(k=
|
50
|
+
h_derivative_direction_1 = h.hamiltonian_derivative(k=k, direction=direction_1)
|
42
51
|
for j, direction_2 in enumerate(["x", "y"]):
|
43
|
-
h_derivative_direction_2 = h.hamiltonian_derivative(k=
|
44
|
-
for k_index in range(len(
|
52
|
+
h_derivative_direction_2 = h.hamiltonian_derivative(k=k, direction=direction_2)
|
53
|
+
for k_index in range(len(k)):
|
45
54
|
for n in [i for i in range(h.number_of_bands) if i != band]:
|
46
55
|
quantum_geom_tensor[i, j] += (
|
47
56
|
(
|
@@ -58,52 +67,3 @@ def quantum_metric(
|
|
58
67
|
)
|
59
68
|
|
60
69
|
return np.real(quantum_geom_tensor) / number_k_points
|
61
|
-
|
62
|
-
|
63
|
-
def quantum_metric_bdg(
|
64
|
-
h: BaseHamiltonian[GenericParameters], k_grid: npt.NDArray[np.float64], bands: list[int]
|
65
|
-
) -> npt.NDArray[np.float64]:
|
66
|
-
"""Calculate the quantum metric in the BdG state.
|
67
|
-
|
68
|
-
Parameters
|
69
|
-
----------
|
70
|
-
bands
|
71
|
-
h : :class:`~quant_met.BaseHamiltonian`
|
72
|
-
Hamiltonian object.
|
73
|
-
k_grid : :class:`numpy.ndarray`
|
74
|
-
List of k points.
|
75
|
-
|
76
|
-
Returns
|
77
|
-
-------
|
78
|
-
:class:`numpy.ndarray`
|
79
|
-
Quantum metric in the normal state.
|
80
|
-
|
81
|
-
"""
|
82
|
-
energies, bdg_functions = h.diagonalize_bdg(k_grid)
|
83
|
-
|
84
|
-
number_k_points = len(k_grid)
|
85
|
-
|
86
|
-
quantum_geom_tensor = np.zeros(shape=(2, 2), dtype=np.complex64)
|
87
|
-
|
88
|
-
for band in bands:
|
89
|
-
for i, direction_1 in enumerate(["x", "y"]):
|
90
|
-
h_derivative_dir_1 = h.bdg_hamiltonian_derivative(k=k_grid, direction=direction_1)
|
91
|
-
for j, direction_2 in enumerate(["x", "y"]):
|
92
|
-
h_derivative_dir_2 = h.bdg_hamiltonian_derivative(k=k_grid, direction=direction_2)
|
93
|
-
for k_index in range(len(k_grid)):
|
94
|
-
for n in [i for i in range(2 * h.number_of_bands) if i != band]:
|
95
|
-
quantum_geom_tensor[i, j] += (
|
96
|
-
(
|
97
|
-
bdg_functions[k_index][:, band].conjugate()
|
98
|
-
@ h_derivative_dir_1[k_index]
|
99
|
-
@ bdg_functions[k_index][:, n]
|
100
|
-
)
|
101
|
-
* (
|
102
|
-
bdg_functions[k_index][:, n].conjugate()
|
103
|
-
@ h_derivative_dir_2[k_index]
|
104
|
-
@ bdg_functions[k_index][:, band]
|
105
|
-
)
|
106
|
-
/ (energies[k_index][band] - energies[k_index][n]) ** 2
|
107
|
-
)
|
108
|
-
|
109
|
-
return np.real(quantum_geom_tensor) / number_k_points
|
@@ -4,37 +4,91 @@
|
|
4
4
|
|
5
5
|
"""Self-consistency loop."""
|
6
6
|
|
7
|
+
import logging
|
8
|
+
import sys
|
9
|
+
|
7
10
|
import numpy as np
|
8
11
|
import numpy.typing as npt
|
9
12
|
|
10
13
|
from quant_met.mean_field.hamiltonians.base_hamiltonian import BaseHamiltonian
|
11
14
|
from quant_met.parameters import GenericParameters
|
12
15
|
|
16
|
+
logger = logging.getLogger(__name__)
|
17
|
+
|
13
18
|
|
14
19
|
def self_consistency_loop(
|
15
20
|
h: BaseHamiltonian[GenericParameters],
|
16
21
|
k_space_grid: npt.NDArray[np.float64],
|
17
22
|
epsilon: float,
|
23
|
+
max_iter: int = 1000,
|
18
24
|
) -> BaseHamiltonian[GenericParameters]:
|
19
|
-
"""Self-
|
25
|
+
"""Self-consistently solves the gap equation for a given Hamiltonian.
|
26
|
+
|
27
|
+
This function performs a self-consistency loop to solve the gap equation
|
28
|
+
for a Hamiltonian `h`.
|
29
|
+
The gaps in the orbital basis are iteratively updated until the change is within
|
30
|
+
a specified tolerance `epsilon`.
|
20
31
|
|
21
32
|
Parameters
|
22
33
|
----------
|
23
|
-
|
24
|
-
|
25
|
-
|
34
|
+
h : :class:`BaseHamiltonian<quant_met.mean_field.hamiltonians.BaseHamiltonian>`
|
35
|
+
The Hamiltonian object with the parameters for the calculation.
|
36
|
+
|
37
|
+
k_space_grid : :class:`numpy.ndarray`
|
38
|
+
A grid of points in the Brillouin zone at which the gap equation is evaluated.
|
39
|
+
See
|
40
|
+
|
41
|
+
epsilon : float
|
42
|
+
The convergence criterion. The loop will terminate when the change
|
43
|
+
in the delta orbital basis is less than this value.
|
44
|
+
|
45
|
+
max_iter : int
|
46
|
+
Maximal number of iterations, default 300.
|
47
|
+
|
48
|
+
Returns
|
49
|
+
-------
|
50
|
+
:class:`quant_met.mean_field.BaseHamiltonian`
|
51
|
+
The updated Hamiltonian object with the new gaps.
|
52
|
+
|
53
|
+
Notes
|
54
|
+
-----
|
55
|
+
The function initializes the gaps with random complex numbers before entering the
|
56
|
+
self-consistency loop.
|
57
|
+
The mixing parameter is set to 0.2, which controls how much of the new gaps is taken
|
58
|
+
relative to the previous value in each iteration.
|
26
59
|
"""
|
60
|
+
logger.info("Starting self-consistency loop.")
|
61
|
+
|
27
62
|
rng = np.random.default_rng()
|
28
63
|
delta_init = np.zeros(shape=h.delta_orbital_basis.shape, dtype=np.complex64)
|
29
64
|
delta_init += (0.2 * rng.random(size=h.delta_orbital_basis.shape) - 1) + 1.0j * (
|
30
65
|
0.2 * rng.random(size=h.delta_orbital_basis.shape) - 1
|
31
66
|
)
|
32
67
|
h.delta_orbital_basis = delta_init
|
68
|
+
logger.debug("Initial gaps set to: %s", h.delta_orbital_basis)
|
33
69
|
|
70
|
+
iteration_count = 0
|
34
71
|
while True:
|
72
|
+
iteration_count += 1
|
73
|
+
if iteration_count > max_iter:
|
74
|
+
sys.exit("Maximum number of iterations reached.")
|
75
|
+
|
76
|
+
logger.debug("Iteration %d: Computing new gaps.", iteration_count)
|
77
|
+
|
35
78
|
new_gap = h.gap_equation(k=k_space_grid)
|
36
|
-
|
79
|
+
|
80
|
+
if not np.allclose(h.delta_orbital_basis, 0):
|
81
|
+
delta_change = np.abs(h.delta_orbital_basis - new_gap) / np.abs(h.delta_orbital_basis)
|
82
|
+
else:
|
83
|
+
delta_change = np.abs(h.delta_orbital_basis - new_gap)
|
84
|
+
logger.debug("New gaps computed: %s", new_gap)
|
85
|
+
|
86
|
+
if (delta_change < epsilon).all():
|
37
87
|
h.delta_orbital_basis = new_gap
|
88
|
+
logger.info("Convergence achieved after %d iterations.", iteration_count)
|
38
89
|
return h
|
39
|
-
|
90
|
+
|
91
|
+
mixing_greed = 0.2
|
40
92
|
h.delta_orbital_basis = mixing_greed * new_gap + (1 - mixing_greed) * h.delta_orbital_basis
|
93
|
+
logger.debug("Updated gaps: %s", h.delta_orbital_basis)
|
94
|
+
logger.debug("Change in gaps: %s", delta_change)
|
@@ -13,7 +13,7 @@ from quant_met.parameters import GenericParameters
|
|
13
13
|
|
14
14
|
def superfluid_weight(
|
15
15
|
h: BaseHamiltonian[GenericParameters],
|
16
|
-
|
16
|
+
k: npt.NDArray[np.float64],
|
17
17
|
) -> tuple[npt.NDArray[np.complex64], npt.NDArray[np.complex64]]:
|
18
18
|
"""Calculate the superfluid weight.
|
19
19
|
|
@@ -21,7 +21,7 @@ def superfluid_weight(
|
|
21
21
|
----------
|
22
22
|
h : :class:`~quant_met.mean_field.Hamiltonian`
|
23
23
|
Hamiltonian.
|
24
|
-
|
24
|
+
k : :class:`numpy.ndarray`
|
25
25
|
List of k points.
|
26
26
|
|
27
27
|
Returns
|
@@ -37,10 +37,10 @@ def superfluid_weight(
|
|
37
37
|
|
38
38
|
for i, direction_1 in enumerate(["x", "y"]):
|
39
39
|
for j, direction_2 in enumerate(["x", "y"]):
|
40
|
-
for
|
41
|
-
c_mnpq = _c_factor(h,
|
42
|
-
j_up = _current_operator(h, direction_1,
|
43
|
-
j_down = _current_operator(h, direction_2, -
|
40
|
+
for k_point in k:
|
41
|
+
c_mnpq = _c_factor(h, k_point)
|
42
|
+
j_up = _current_operator(h, direction_1, k_point)
|
43
|
+
j_down = _current_operator(h, direction_2, -k_point)
|
44
44
|
for m in range(h.number_of_bands):
|
45
45
|
for n in range(h.number_of_bands):
|
46
46
|
for p in range(h.number_of_bands):
|
quant_met/parameters/__init__.py
CHANGED
@@ -3,30 +3,42 @@
|
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
|
5
5
|
"""
|
6
|
-
|
7
|
-
|
6
|
+
Parameter Classes
|
7
|
+
=================
|
8
|
+
|
9
|
+
Main class holding all the parameters for the calculation.
|
10
|
+
|
11
|
+
Classes holding the configuration for the Hamiltonians.
|
12
|
+
|
13
|
+
.. autosummary::
|
14
|
+
:toctree: generated/parameters/hamiltonians
|
15
|
+
|
16
|
+
hamiltonians
|
8
17
|
|
9
18
|
.. autosummary::
|
10
19
|
:toctree: generated/parameters/
|
11
20
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Parameters
|
21
|
+
Parameters # noqa
|
22
|
+
Control # noqa
|
23
|
+
KPoints # noqa
|
16
24
|
""" # noqa: D205, D400
|
17
25
|
|
18
26
|
from .hamiltonians import (
|
19
27
|
DressedGrapheneParameters,
|
20
28
|
GenericParameters,
|
21
29
|
GrapheneParameters,
|
30
|
+
HamiltonianParameters,
|
22
31
|
OneBandParameters,
|
23
32
|
ThreeBandParameters,
|
24
33
|
TwoBandParameters,
|
25
34
|
)
|
26
|
-
from .main import Parameters
|
35
|
+
from .main import Control, KPoints, Parameters
|
27
36
|
|
28
37
|
__all__ = [
|
29
38
|
"Parameters",
|
39
|
+
"Control",
|
40
|
+
"KPoints",
|
41
|
+
"HamiltonianParameters",
|
30
42
|
"DressedGrapheneParameters",
|
31
43
|
"GrapheneParameters",
|
32
44
|
"OneBandParameters",
|