quant-met 0.0.1__tar.gz → 0.0.3__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.
- quant_met-0.0.3/LICENSES/MIT.txt +9 -0
- {quant_met-0.0.1 → quant_met-0.0.3}/PKG-INFO +26 -14
- {quant_met-0.0.1 → quant_met-0.0.3}/README.md +19 -5
- quant_met-0.0.3/pyproject.toml +74 -0
- quant_met-0.0.3/src/quant_met/__init__.py +5 -0
- quant_met-0.0.3/src/quant_met/mean_field/__init__.py +60 -0
- quant_met-0.0.3/src/quant_met/mean_field/_utils.py +27 -0
- quant_met-0.0.3/src/quant_met/mean_field/base_hamiltonian.py +296 -0
- quant_met-0.0.3/src/quant_met/mean_field/eg_x.py +120 -0
- quant_met-0.0.3/src/quant_met/mean_field/free_energy.py +130 -0
- quant_met-0.0.3/src/quant_met/mean_field/graphene.py +97 -0
- quant_met-0.0.3/src/quant_met/mean_field/quantum_metric.py +59 -0
- quant_met-0.0.3/src/quant_met/mean_field/superfluid_weight.py +146 -0
- quant_met-0.0.3/src/quant_met/plotting/__init__.py +28 -0
- quant_met-0.0.3/src/quant_met/plotting/plotting.py +230 -0
- quant_met-0.0.3/src/quant_met/utils.py +71 -0
- quant_met-0.0.1/pyproject.toml +0 -35
- quant_met-0.0.1/src/quant_met/__about__.py +0 -4
- quant_met-0.0.1/src/quant_met/__init__.py +0 -3
- quant_met-0.0.1/src/quant_met/bcs/__init__.py +0 -0
- quant_met-0.0.1/src/quant_met/bcs/find_fixpoint.py +0 -65
- quant_met-0.0.1/src/quant_met/bcs/gap_equation.py +0 -43
- quant_met-0.0.1/src/quant_met/cli.py +0 -16
- quant_met-0.0.1/src/quant_met/configuration.py +0 -53
- quant_met-0.0.1/src/quant_met/hamiltonians.py +0 -174
- quant_met-0.0.1/src/quant_met/plotting/__init__.py +0 -2
- quant_met-0.0.1/src/quant_met/plotting/_plotting.py +0 -180
- {quant_met-0.0.1 → quant_met-0.0.3}/LICENSE.txt +0 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024-present Tjark <tsievers@physnet.uni-hamburg.de>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,38 +1,52 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: quant-met
|
3
|
-
Version: 0.0.
|
4
|
-
Summary:
|
3
|
+
Version: 0.0.3
|
4
|
+
Summary: Calculate superconductivity in flat-band systems.
|
5
5
|
Author: Tjark Sievers
|
6
6
|
Author-email: tsievers@physnet.uni-hamburg.de
|
7
|
-
Requires-Python: >=3.
|
7
|
+
Requires-Python: >=3.11,<4.0
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: Programming Language :: Python :: 3.10
|
10
9
|
Classifier: Programming Language :: Python :: 3.11
|
11
10
|
Classifier: Programming Language :: Python :: 3.12
|
12
|
-
Requires-Dist:
|
13
|
-
Requires-Dist: matplotlib (>=3.
|
14
|
-
Requires-Dist: numpy (>=
|
11
|
+
Requires-Dist: h5py (>=3.11.0,<4.0.0)
|
12
|
+
Requires-Dist: matplotlib (>=3.9.1,<4.0.0)
|
13
|
+
Requires-Dist: numpy (>=2.0.0,<3.0.0)
|
15
14
|
Requires-Dist: pandas (>=2.2.2,<3.0.0)
|
16
|
-
Requires-Dist: scipy (>=1.
|
17
|
-
Requires-Dist: sympy (>=1.12,<2.0)
|
15
|
+
Requires-Dist: scipy (>=1.14.0,<2.0.0)
|
18
16
|
Description-Content-Type: text/markdown
|
19
17
|
|
18
|
+
<!--
|
19
|
+
SPDX-FileCopyrightText: 2024 Tjark Sievers
|
20
|
+
|
21
|
+
SPDX-License-Identifier: MIT
|
22
|
+
-->
|
23
|
+
|
20
24
|
# quant-met
|
21
25
|
|
22
26
|
[](https://github.com/Ruberhauptmann/quant-met/actions/workflows/test.yml)
|
23
27
|
[](https://coveralls.io/github/Ruberhauptmann/quant-met?branch=main)
|
28
|
+
[](https://pypi.org/project/quant-met/)
|
29
|
+
[](https://pypi.org/project/quant-met/)
|
30
|
+
|
31
|
+
This is a python package to treat superconductivity in flat-band systems.
|
24
32
|
|
25
33
|
* Documentation: [quant-met.readthedocs.io](https://quant-met.readthedocs.io/en/latest/)
|
26
34
|
|
27
35
|
## Installation
|
28
36
|
|
29
37
|
The package can be installed via
|
38
|
+
```shell
|
39
|
+
pip install quant-met
|
40
|
+
```
|
30
41
|
|
31
42
|
## Usage
|
32
43
|
|
44
|
+
For usage examples see [documentation](https://quant-met.readthedocs.io/en/latest/examples.html).
|
45
|
+
|
33
46
|
## Contributing
|
34
47
|
|
35
|
-
|
48
|
+
This is a personal project, very geared to the work I did in my master's thesis.
|
49
|
+
If someone is using this and experiencing bugs or want the software extended, feel free to open an issue!
|
36
50
|
|
37
51
|
### Developing
|
38
52
|
|
@@ -49,13 +63,11 @@ Set up the development environment:
|
|
49
63
|
* run `make environment`
|
50
64
|
* now activate the conda environment `conda activate quant-met-dev`
|
51
65
|
|
52
|
-
Now you can create a separate branch to work on the project.
|
53
|
-
|
54
66
|
You can manually run tests using for example `tox -e py312` (for running against python 3.12).
|
55
|
-
After pushing your branch, all tests will also be run via
|
67
|
+
After pushing your branch, all tests will also be run via Github Actions.
|
56
68
|
|
57
69
|
Using `pre-commit`, automatic linting and formatting is done before every commit, which may cause the first commit to fail.
|
58
70
|
A second try should then succeed.
|
59
71
|
|
60
|
-
After you are done working on an issue and all tests are running successful, you can add a new piece of changelog via `scriv create` and make a
|
72
|
+
After you are done working on an issue and all tests are running successful, you can add a new piece of changelog via `scriv create` and make a pull request.
|
61
73
|
|
@@ -1,19 +1,35 @@
|
|
1
|
+
<!--
|
2
|
+
SPDX-FileCopyrightText: 2024 Tjark Sievers
|
3
|
+
|
4
|
+
SPDX-License-Identifier: MIT
|
5
|
+
-->
|
6
|
+
|
1
7
|
# quant-met
|
2
8
|
|
3
9
|
[](https://github.com/Ruberhauptmann/quant-met/actions/workflows/test.yml)
|
4
10
|
[](https://coveralls.io/github/Ruberhauptmann/quant-met?branch=main)
|
11
|
+
[](https://pypi.org/project/quant-met/)
|
12
|
+
[](https://pypi.org/project/quant-met/)
|
13
|
+
|
14
|
+
This is a python package to treat superconductivity in flat-band systems.
|
5
15
|
|
6
16
|
* Documentation: [quant-met.readthedocs.io](https://quant-met.readthedocs.io/en/latest/)
|
7
17
|
|
8
18
|
## Installation
|
9
19
|
|
10
20
|
The package can be installed via
|
21
|
+
```shell
|
22
|
+
pip install quant-met
|
23
|
+
```
|
11
24
|
|
12
25
|
## Usage
|
13
26
|
|
27
|
+
For usage examples see [documentation](https://quant-met.readthedocs.io/en/latest/examples.html).
|
28
|
+
|
14
29
|
## Contributing
|
15
30
|
|
16
|
-
|
31
|
+
This is a personal project, very geared to the work I did in my master's thesis.
|
32
|
+
If someone is using this and experiencing bugs or want the software extended, feel free to open an issue!
|
17
33
|
|
18
34
|
### Developing
|
19
35
|
|
@@ -30,12 +46,10 @@ Set up the development environment:
|
|
30
46
|
* run `make environment`
|
31
47
|
* now activate the conda environment `conda activate quant-met-dev`
|
32
48
|
|
33
|
-
Now you can create a separate branch to work on the project.
|
34
|
-
|
35
49
|
You can manually run tests using for example `tox -e py312` (for running against python 3.12).
|
36
|
-
After pushing your branch, all tests will also be run via
|
50
|
+
After pushing your branch, all tests will also be run via Github Actions.
|
37
51
|
|
38
52
|
Using `pre-commit`, automatic linting and formatting is done before every commit, which may cause the first commit to fail.
|
39
53
|
A second try should then succeed.
|
40
54
|
|
41
|
-
After you are done working on an issue and all tests are running successful, you can add a new piece of changelog via `scriv create` and make a
|
55
|
+
After you are done working on an issue and all tests are running successful, you can add a new piece of changelog via `scriv create` and make a pull request.
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# SPDX-FileCopyrightText: 2024 Tjark Sievers
|
2
|
+
#
|
3
|
+
# SPDX-License-Identifier: MIT
|
4
|
+
|
5
|
+
[project]
|
6
|
+
name = "quant-met"
|
7
|
+
requires-python = ">=3.11"
|
8
|
+
|
9
|
+
[tool.poetry]
|
10
|
+
name = "quant-met"
|
11
|
+
version = "0.0.3"
|
12
|
+
description = "Calculate superconductivity in flat-band systems."
|
13
|
+
authors = ["Tjark Sievers <tsievers@physnet.uni-hamburg.de>"]
|
14
|
+
readme = "README.md"
|
15
|
+
|
16
|
+
[tool.poetry.dependencies]
|
17
|
+
python = "^3.11"
|
18
|
+
numpy = "^2.0.0"
|
19
|
+
scipy = "^1.14.0"
|
20
|
+
matplotlib = "^3.9.1"
|
21
|
+
pandas = "^2.2.2"
|
22
|
+
h5py = "^3.11.0"
|
23
|
+
|
24
|
+
[tool.poetry.group.dev.dependencies]
|
25
|
+
pre-commit = "^3.7.0"
|
26
|
+
scriv = "^1.5.1"
|
27
|
+
jupyter = "^1.0.0"
|
28
|
+
ipympl = "^0.9.4"
|
29
|
+
sphinx = "^7.3.7"
|
30
|
+
myst-parser = "^3.0.1"
|
31
|
+
nbsphinx = "^0.9.4"
|
32
|
+
sphinx-gallery = "^0.16.0"
|
33
|
+
pydata-sphinx-theme = "^0.15.4"
|
34
|
+
sphinx-design = "^0.6.0"
|
35
|
+
tox = "^4.15.0"
|
36
|
+
mypy = "^1.10.0"
|
37
|
+
pytest = "^8.2.1"
|
38
|
+
pytest-cov = "^5.0.0"
|
39
|
+
hypothesis = {extras = ["numpy"], version = "^6.103.0"}
|
40
|
+
pytest-regressions = "^2.5.0"
|
41
|
+
numpydoc = "^1.7.0"
|
42
|
+
ruff = "^0.5.0"
|
43
|
+
|
44
|
+
[build-system]
|
45
|
+
requires = ["poetry-core"]
|
46
|
+
build-backend = "poetry.core.masonry.api"
|
47
|
+
|
48
|
+
# Config for ruff
|
49
|
+
[tool.ruff]
|
50
|
+
line-length = 100
|
51
|
+
force-exclude = true
|
52
|
+
extend-exclude = ["tests", "docs/source/conf.py"]
|
53
|
+
|
54
|
+
[tool.ruff.lint]
|
55
|
+
#select = []
|
56
|
+
#select = ["D", "E", "F", "I", "W"]
|
57
|
+
select = ["ALL"]
|
58
|
+
ignore = [
|
59
|
+
"D203", # one-blank-line-before-class
|
60
|
+
"D212", # multi-line-summary-first-line
|
61
|
+
"COM812",
|
62
|
+
"ISC001",
|
63
|
+
"Q000",
|
64
|
+
"Q003",
|
65
|
+
"S101", # This checks against using assert
|
66
|
+
"PLR0913", # This checks against using more than 5 function arguments
|
67
|
+
]
|
68
|
+
|
69
|
+
|
70
|
+
[tool.ruff.lint.pydocstyle]
|
71
|
+
convention = "numpy"
|
72
|
+
|
73
|
+
#[format]
|
74
|
+
#docstring-code-format = true
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# SPDX-FileCopyrightText: 2024 Tjark Sievers
|
2
|
+
#
|
3
|
+
# SPDX-License-Identifier: MIT
|
4
|
+
|
5
|
+
"""
|
6
|
+
Mean field treatment (:mod:`quant_met.mean_field`)
|
7
|
+
==================================================
|
8
|
+
|
9
|
+
Hamiltonians
|
10
|
+
------------
|
11
|
+
|
12
|
+
Base
|
13
|
+
|
14
|
+
.. autosummary::
|
15
|
+
:toctree: generated/
|
16
|
+
|
17
|
+
BaseHamiltonian
|
18
|
+
|
19
|
+
.. autosummary::
|
20
|
+
:toctree: generated/
|
21
|
+
|
22
|
+
GrapheneHamiltonian
|
23
|
+
EGXHamiltonian
|
24
|
+
|
25
|
+
|
26
|
+
Functions
|
27
|
+
---------
|
28
|
+
|
29
|
+
.. autosummary::
|
30
|
+
:toctree: generated/
|
31
|
+
|
32
|
+
superfluid_weight
|
33
|
+
quantum_metric
|
34
|
+
free_energy
|
35
|
+
free_energy_uniform_pairing
|
36
|
+
""" # noqa: D205, D400
|
37
|
+
|
38
|
+
from .base_hamiltonian import BaseHamiltonian
|
39
|
+
from .eg_x import EGXHamiltonian
|
40
|
+
from .free_energy import (
|
41
|
+
free_energy,
|
42
|
+
free_energy_complex_gap,
|
43
|
+
free_energy_real_gap,
|
44
|
+
free_energy_uniform_pairing,
|
45
|
+
)
|
46
|
+
from .graphene import GrapheneHamiltonian
|
47
|
+
from .quantum_metric import quantum_metric
|
48
|
+
from .superfluid_weight import superfluid_weight
|
49
|
+
|
50
|
+
__all__ = [
|
51
|
+
"superfluid_weight",
|
52
|
+
"quantum_metric",
|
53
|
+
"free_energy",
|
54
|
+
"free_energy_complex_gap",
|
55
|
+
"free_energy_real_gap",
|
56
|
+
"free_energy_uniform_pairing",
|
57
|
+
"BaseHamiltonian",
|
58
|
+
"GrapheneHamiltonian",
|
59
|
+
"EGXHamiltonian",
|
60
|
+
]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# SPDX-FileCopyrightText: 2024 Tjark Sievers
|
2
|
+
#
|
3
|
+
# SPDX-License-Identifier: MIT
|
4
|
+
|
5
|
+
from typing import Any
|
6
|
+
|
7
|
+
import numpy as np
|
8
|
+
import numpy.typing as npt
|
9
|
+
|
10
|
+
|
11
|
+
def _check_valid_array(array_in: npt.NDArray[Any]) -> bool:
|
12
|
+
if np.isnan(array_in).any() or np.isinf(array_in).any():
|
13
|
+
msg = "k is NaN or Infinity"
|
14
|
+
raise ValueError(msg)
|
15
|
+
|
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
|
@@ -0,0 +1,296 @@
|
|
1
|
+
# SPDX-FileCopyrightText: 2024 Tjark Sievers
|
2
|
+
#
|
3
|
+
# SPDX-License-Identifier: MIT
|
4
|
+
|
5
|
+
"""Provides the base class for Hamiltonians."""
|
6
|
+
|
7
|
+
import pathlib
|
8
|
+
from abc import ABC, abstractmethod
|
9
|
+
|
10
|
+
import h5py
|
11
|
+
import numpy as np
|
12
|
+
import numpy.typing as npt
|
13
|
+
import pandas as pd
|
14
|
+
|
15
|
+
from ._utils import _check_valid_array
|
16
|
+
|
17
|
+
|
18
|
+
class BaseHamiltonian(ABC):
|
19
|
+
"""Base class for Hamiltonians."""
|
20
|
+
|
21
|
+
@property
|
22
|
+
@abstractmethod
|
23
|
+
def number_of_bands(self) -> int:
|
24
|
+
"""Number of bands in the model."""
|
25
|
+
raise NotImplementedError
|
26
|
+
|
27
|
+
@property
|
28
|
+
def coloumb_orbital_basis(self) -> npt.NDArray[np.float64]:
|
29
|
+
"""
|
30
|
+
Coloumb interaction split up in orbitals.
|
31
|
+
|
32
|
+
Returns
|
33
|
+
-------
|
34
|
+
:class:`numpy.ndarray`
|
35
|
+
|
36
|
+
"""
|
37
|
+
raise NotImplementedError
|
38
|
+
|
39
|
+
@property
|
40
|
+
def delta_orbital_basis(self) -> npt.NDArray[np.complex64]:
|
41
|
+
"""
|
42
|
+
Order parameter in orbital basis.
|
43
|
+
|
44
|
+
Returns
|
45
|
+
-------
|
46
|
+
:class:`numpy.ndarray`
|
47
|
+
|
48
|
+
"""
|
49
|
+
raise NotImplementedError
|
50
|
+
|
51
|
+
@delta_orbital_basis.setter
|
52
|
+
@abstractmethod
|
53
|
+
def delta_orbital_basis(self, new_delta: npt.NDArray[np.complex64]) -> None:
|
54
|
+
raise NotImplementedError
|
55
|
+
|
56
|
+
@abstractmethod
|
57
|
+
def _hamiltonian_one_point(self, k_point: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]:
|
58
|
+
raise NotImplementedError
|
59
|
+
|
60
|
+
@abstractmethod
|
61
|
+
def _hamiltonian_derivative_one_point(
|
62
|
+
self, k_point: npt.NDArray[np.float64], directions: str
|
63
|
+
) -> npt.NDArray[np.complex64]:
|
64
|
+
raise NotImplementedError
|
65
|
+
|
66
|
+
def _bdg_hamiltonian_one_point(
|
67
|
+
self, k_point: npt.NDArray[np.float64]
|
68
|
+
) -> npt.NDArray[np.complex64]:
|
69
|
+
delta_matrix: npt.NDArray[np.complex64] = np.zeros(
|
70
|
+
shape=(self.number_of_bands, self.number_of_bands), dtype=np.complex64
|
71
|
+
)
|
72
|
+
np.fill_diagonal(delta_matrix, self.delta_orbital_basis)
|
73
|
+
|
74
|
+
return np.block(
|
75
|
+
[
|
76
|
+
[self.hamiltonian(k_point), delta_matrix],
|
77
|
+
[np.conjugate(delta_matrix), -np.conjugate(self.hamiltonian(-k_point))],
|
78
|
+
]
|
79
|
+
)
|
80
|
+
|
81
|
+
def save(self, filename: pathlib.Path) -> None:
|
82
|
+
"""
|
83
|
+
Save the Hamiltonian as a HDF5 file.
|
84
|
+
|
85
|
+
Parameters
|
86
|
+
----------
|
87
|
+
filename : :class:`pathlib.Path`
|
88
|
+
Filename to save the Hamiltonian to, should end in .hdf5
|
89
|
+
|
90
|
+
"""
|
91
|
+
with h5py.File(f"{filename}", "a") as f:
|
92
|
+
f.create_dataset("delta", data=self.delta_orbital_basis)
|
93
|
+
for key, value in vars(self).items():
|
94
|
+
if not key.startswith("_"):
|
95
|
+
f.attrs[key] = value
|
96
|
+
|
97
|
+
@classmethod
|
98
|
+
def from_file(cls, filename: pathlib.Path) -> "BaseHamiltonian":
|
99
|
+
"""
|
100
|
+
Initialise a Hamiltonian from a HDF5 file.
|
101
|
+
|
102
|
+
Parameters
|
103
|
+
----------
|
104
|
+
filename : :class:`pathlib.Path`
|
105
|
+
File to load the Hamiltonian from.
|
106
|
+
|
107
|
+
"""
|
108
|
+
with h5py.File(f"{filename}", "r") as f:
|
109
|
+
config_dict = dict(f.attrs.items())
|
110
|
+
config_dict["delta"] = f["delta"][()]
|
111
|
+
|
112
|
+
return cls(**config_dict)
|
113
|
+
|
114
|
+
def bdg_hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]:
|
115
|
+
"""
|
116
|
+
Bogoliuobov de Genne Hamiltonian.
|
117
|
+
|
118
|
+
Parameters
|
119
|
+
----------
|
120
|
+
k : :class:`numpy.ndarray`
|
121
|
+
List of k points.
|
122
|
+
|
123
|
+
Returns
|
124
|
+
-------
|
125
|
+
:class:`numpy.ndarray`
|
126
|
+
BdG Hamiltonian.
|
127
|
+
|
128
|
+
"""
|
129
|
+
if np.isnan(k).any() or np.isinf(k).any():
|
130
|
+
msg = "k is NaN or Infinity"
|
131
|
+
raise ValueError(msg)
|
132
|
+
if k.ndim == 1:
|
133
|
+
h = self._bdg_hamiltonian_one_point(k)
|
134
|
+
else:
|
135
|
+
h = np.array([self._bdg_hamiltonian_one_point(k) for k in k])
|
136
|
+
return h
|
137
|
+
|
138
|
+
def hamiltonian(self, k: npt.NDArray[np.float64]) -> npt.NDArray[np.complex64]:
|
139
|
+
"""
|
140
|
+
Return the normal state Hamiltonian in orbital basis.
|
141
|
+
|
142
|
+
Parameters
|
143
|
+
----------
|
144
|
+
k : :class:`numpy.ndarray`
|
145
|
+
List of k points.
|
146
|
+
|
147
|
+
Returns
|
148
|
+
-------
|
149
|
+
:class:`numpy.ndarray`
|
150
|
+
Hamiltonian in matrix form.
|
151
|
+
|
152
|
+
"""
|
153
|
+
assert _check_valid_array(k)
|
154
|
+
if k.ndim == 1:
|
155
|
+
h = self._hamiltonian_one_point(k)
|
156
|
+
else:
|
157
|
+
h = np.array([self._hamiltonian_one_point(k) for k in k])
|
158
|
+
return h
|
159
|
+
|
160
|
+
def hamiltonian_derivative(
|
161
|
+
self, k: npt.NDArray[np.float64], direction: str
|
162
|
+
) -> npt.NDArray[np.complex64]:
|
163
|
+
"""
|
164
|
+
Deriative of the Hamiltonian.
|
165
|
+
|
166
|
+
Parameters
|
167
|
+
----------
|
168
|
+
k: :class:`numpy.ndarray`
|
169
|
+
List of k points.
|
170
|
+
direction: str
|
171
|
+
Direction for derivative, either 'x' oder 'y'.
|
172
|
+
|
173
|
+
Returns
|
174
|
+
-------
|
175
|
+
:class:`numpy.ndarray`
|
176
|
+
Derivative of Hamiltonian.
|
177
|
+
|
178
|
+
"""
|
179
|
+
assert _check_valid_array(k)
|
180
|
+
if k.ndim == 1:
|
181
|
+
h = self._hamiltonian_derivative_one_point(k, direction)
|
182
|
+
else:
|
183
|
+
h = np.array([self._hamiltonian_derivative_one_point(k, direction) for k in k])
|
184
|
+
return h
|
185
|
+
|
186
|
+
def diagonalize_nonint(
|
187
|
+
self, k: npt.NDArray[np.float64]
|
188
|
+
) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]:
|
189
|
+
"""
|
190
|
+
Diagonalize the normal state Hamiltonian.
|
191
|
+
|
192
|
+
Parameters
|
193
|
+
----------
|
194
|
+
k : :class:`numpy.ndarray`
|
195
|
+
List of k points.
|
196
|
+
|
197
|
+
Returns
|
198
|
+
-------
|
199
|
+
:class:`numpy.ndarray`
|
200
|
+
Eigenvalues of the normal state Hamiltonian.
|
201
|
+
:class:`numpy.ndarray`
|
202
|
+
Diagonalising matrix of the normal state Hamiltonian.
|
203
|
+
|
204
|
+
"""
|
205
|
+
k_point_matrix = self.hamiltonian(k)
|
206
|
+
|
207
|
+
if k.ndim == 1:
|
208
|
+
band_energies, bloch_wavefunctions = np.linalg.eigh(k_point_matrix)
|
209
|
+
else:
|
210
|
+
bloch_wavefunctions = np.zeros(
|
211
|
+
(len(k), self.number_of_bands, self.number_of_bands),
|
212
|
+
dtype=complex,
|
213
|
+
)
|
214
|
+
band_energies = np.zeros((len(k), self.number_of_bands))
|
215
|
+
|
216
|
+
for i in range(len(k)):
|
217
|
+
band_energies[i], bloch_wavefunctions[i] = np.linalg.eigh(k_point_matrix[i])
|
218
|
+
|
219
|
+
return band_energies, bloch_wavefunctions
|
220
|
+
|
221
|
+
def diagonalize_bdg(
|
222
|
+
self, k: npt.NDArray[np.float64]
|
223
|
+
) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.complex64]]:
|
224
|
+
"""
|
225
|
+
Diagonalize the BdG Hamiltonian.
|
226
|
+
|
227
|
+
Parameters
|
228
|
+
----------
|
229
|
+
k : :class:`numpy.ndarray`
|
230
|
+
List of k points.
|
231
|
+
|
232
|
+
Returns
|
233
|
+
-------
|
234
|
+
:class:`numpy.ndarray`
|
235
|
+
Eigenvalues of the BdG Hamiltonian.
|
236
|
+
:class:`numpy.ndarray`
|
237
|
+
Diagonalising matrix of the BdG Hamiltonian.
|
238
|
+
|
239
|
+
"""
|
240
|
+
bdg_matrix = self.bdg_hamiltonian(k)
|
241
|
+
|
242
|
+
if k.ndim == 1:
|
243
|
+
bdg_energies, bdg_wavefunctions = np.linalg.eigh(bdg_matrix)
|
244
|
+
else:
|
245
|
+
bdg_wavefunctions = np.zeros(
|
246
|
+
(len(k), 2 * self.number_of_bands, 2 * self.number_of_bands),
|
247
|
+
dtype=np.complex64,
|
248
|
+
)
|
249
|
+
bdg_energies = np.zeros((len(k), 2 * self.number_of_bands))
|
250
|
+
|
251
|
+
for i in range(len(k)):
|
252
|
+
bdg_energies[i], bdg_wavefunctions[i] = np.linalg.eigh(bdg_matrix[i])
|
253
|
+
|
254
|
+
return bdg_energies, bdg_wavefunctions
|
255
|
+
|
256
|
+
def calculate_bandstructure(
|
257
|
+
self,
|
258
|
+
k: npt.NDArray[np.float64],
|
259
|
+
overlaps: tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]] | None = None,
|
260
|
+
) -> pd.DataFrame:
|
261
|
+
"""
|
262
|
+
Calculate the band structure.
|
263
|
+
|
264
|
+
Parameters
|
265
|
+
----------
|
266
|
+
k : :class:`numpy.ndarray`
|
267
|
+
List of k points.
|
268
|
+
overlaps : tuple(:class:`numpy.ndarray`, :class:`numpy.ndarray`), optional
|
269
|
+
Overlaps.
|
270
|
+
|
271
|
+
Returns
|
272
|
+
-------
|
273
|
+
`pandas.DataFrame`
|
274
|
+
Band structure.
|
275
|
+
|
276
|
+
"""
|
277
|
+
k_point_matrix = self.hamiltonian(k)
|
278
|
+
|
279
|
+
results = pd.DataFrame(
|
280
|
+
index=range(len(k)),
|
281
|
+
dtype=float,
|
282
|
+
)
|
283
|
+
|
284
|
+
for i in range(len(k)):
|
285
|
+
energies, eigenvectors = np.linalg.eigh(k_point_matrix[i])
|
286
|
+
|
287
|
+
for band_index in range(self.number_of_bands):
|
288
|
+
results.loc[i, f"band_{band_index}"] = energies[band_index]
|
289
|
+
|
290
|
+
if overlaps is not None:
|
291
|
+
results.loc[i, f"wx_{band_index}"] = (
|
292
|
+
np.abs(np.dot(eigenvectors[:, band_index], overlaps[0])) ** 2
|
293
|
+
- np.abs(np.dot(eigenvectors[:, band_index], overlaps[1])) ** 2
|
294
|
+
)
|
295
|
+
|
296
|
+
return results
|