tbkit 0.6.1__tar.gz → 0.7.0__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.
- {tbkit-0.6.1/tbkit.egg-info → tbkit-0.7.0}/PKG-INFO +8 -5
- {tbkit-0.6.1 → tbkit-0.7.0}/README.md +3 -3
- {tbkit-0.6.1 → tbkit-0.7.0}/pyproject.toml +2 -2
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/__init__.py +1 -1
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/bdg.py +198 -41
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/bridges.py +50 -24
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/continuum.py +31 -15
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/dos.py +30 -12
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/error_handling.py +1328 -398
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/exceptional.py +142 -65
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/floquet.py +195 -84
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/graphene.py +58 -21
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/higher_order.py +90 -48
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/io.py +82 -40
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/kpm.py +119 -64
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/kspace.py +1167 -489
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/lattice.py +101 -43
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/lattices.py +30 -6
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/meanfield.py +80 -40
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/moire.py +120 -59
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/neighbours.py +44 -21
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/occupation.py +20 -11
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/optics.py +96 -53
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/orbital.py +84 -32
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/plot.py +229 -116
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/propagation.py +91 -39
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/save.py +32 -14
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/slater_koster.py +28 -16
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/system.py +235 -92
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/topology.py +49 -23
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/transport.py +523 -251
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/values.py +13 -6
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/wannier.py +78 -33
- {tbkit-0.6.1 → tbkit-0.7.0/tbkit.egg-info}/PKG-INFO +8 -5
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit.egg-info/requires.txt +4 -1
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_error_handling.py +12 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_error_handling_structures.py +4 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_floquet.py +14 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_interactions.py +58 -1
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_kspace.py +61 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_smatrix.py +69 -1
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_surface_spectral.py +18 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_topology.py +109 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_transport_response.py +45 -6
- {tbkit-0.6.1 → tbkit-0.7.0}/LICENSE +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/setup.cfg +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit/py.typed +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit.egg-info/SOURCES.txt +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit.egg-info/dependency_links.txt +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tbkit.egg-info/top_level.txt +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_analysis.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_berry_response.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_bridges.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_continuum.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_correlations.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_dos.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_exceptional.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_graphene.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_green_occupation.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_hall.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_higher_order.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_invariants.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_io.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_kpm.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_large_lattices.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_lattice.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_lattices.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_magnetic.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_moire.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_neighbours.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_non_hermitian_bands.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_optics.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_orbitals.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_periodic.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_plot.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_propagation.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_regressions.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_save.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_system.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_three_d.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_transport.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_values.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_wannier90.py +0 -0
- {tbkit-0.6.1 → tbkit-0.7.0}/tests/test_wannier_functions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tbkit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: A Python package to build and solve Tight-Binding models.
|
|
5
5
|
Author-email: Charles Poli <cpoli374@gmail.com>
|
|
6
6
|
Maintainer-email: Charles Poli <cpoli374@gmail.com>
|
|
@@ -36,19 +36,22 @@ Requires-Dist: sympy>=1.12; extra == "test"
|
|
|
36
36
|
Provides-Extra: docs
|
|
37
37
|
Requires-Dist: sphinx>=7; extra == "docs"
|
|
38
38
|
Requires-Dist: pydata-sphinx-theme>=0.15; extra == "docs"
|
|
39
|
-
Requires-Dist: sphinx-gallery>=0.
|
|
39
|
+
Requires-Dist: sphinx-gallery>=0.17; extra == "docs"
|
|
40
|
+
Requires-Dist: joblib>=1.3; extra == "docs"
|
|
40
41
|
Requires-Dist: sympy>=1.12; extra == "docs"
|
|
42
|
+
Requires-Dist: sphinx-sitemap>=2.6; extra == "docs"
|
|
43
|
+
Requires-Dist: sphinxext-opengraph>=0.9; extra == "docs"
|
|
41
44
|
Dynamic: license-file
|
|
42
45
|
|
|
43
46
|
# tbkit — a Tight-Binding package
|
|
44
47
|
|
|
45
48
|
| | |
|
|
46
49
|
|:--|:-:|
|
|
47
|
-
| Package | [](https://pypi.org/project/tbkit/) [](https://anaconda.org/conda-forge/tbkit) [](https://pypi.org/project/tbkit/) [](https://pypi.org/project/tbkit/) [](https://anaconda.org/conda-forge/tbkit) [](https://pypi.org/project/tbkit/) [](https://doi.org/10.5281/zenodo.23755191) |
|
|
51
|
+
| Quality | [](https://github.com/cpoli/tbkit/blob/master/LICENSE) [](https://github.com/cpoli/tbkit/actions/workflows/ci.yml) [](https://codecov.io/gh/cpoli/tbkit) |
|
|
49
52
|
| Documentation | [](https://cpoli.github.io/tbkit/) |
|
|
50
53
|
| Downloads | [](https://pepy.tech/project/tbkit) [](https://pepy.tech/project/tbkit) |
|
|
51
|
-
| Community | [](https://github.com/cpoli/tbkit) [](https://github.com/cpoli/tbkit) [](https://github.com/cpoli/tbkit/graphs/contributors) [](https://github.com/cpoli/tbkit/commits/master) |
|
|
52
55
|
|
|
53
56
|

|
|
54
57
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
| | |
|
|
4
4
|
|:--|:-:|
|
|
5
|
-
| Package | [](https://pypi.org/project/tbkit/) [](https://anaconda.org/conda-forge/tbkit) [](https://pypi.org/project/tbkit/) [](https://pypi.org/project/tbkit/) [](https://anaconda.org/conda-forge/tbkit) [](https://pypi.org/project/tbkit/) [](https://doi.org/10.5281/zenodo.23755191) |
|
|
6
|
+
| Quality | [](https://github.com/cpoli/tbkit/blob/master/LICENSE) [](https://github.com/cpoli/tbkit/actions/workflows/ci.yml) [](https://codecov.io/gh/cpoli/tbkit) |
|
|
7
7
|
| Documentation | [](https://cpoli.github.io/tbkit/) |
|
|
8
8
|
| Downloads | [](https://pepy.tech/project/tbkit) [](https://pepy.tech/project/tbkit) |
|
|
9
|
-
| Community | [](https://github.com/cpoli/tbkit) [](https://github.com/cpoli/tbkit) [](https://github.com/cpoli/tbkit/graphs/contributors) [](https://github.com/cpoli/tbkit/commits/master) |
|
|
10
10
|
|
|
11
11
|

|
|
12
12
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tbkit"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.7.0"
|
|
8
8
|
description = "A Python package to build and solve Tight-Binding models."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "BSD-3-Clause"
|
|
@@ -39,7 +39,7 @@ Documentation = "https://cpoli.github.io/tbkit/"
|
|
|
39
39
|
[project.optional-dependencies]
|
|
40
40
|
continuum = ["sympy>=1.12"]
|
|
41
41
|
test = ["pytest>=7", "pytest-cov>=4", "pytest-xdist>=3.2", "sympy>=1.12"]
|
|
42
|
-
docs = ["sphinx>=7", "pydata-sphinx-theme>=0.15", "sphinx-gallery>=0.
|
|
42
|
+
docs = ["sphinx>=7", "pydata-sphinx-theme>=0.15", "sphinx-gallery>=0.17", "joblib>=1.3", "sympy>=1.12", "sphinx-sitemap>=2.6", "sphinxext-opengraph>=0.9"]
|
|
43
43
|
|
|
44
44
|
[tool.pytest.ini_options]
|
|
45
45
|
# The suite is warning-free; keep it that way. A warning from tbkit itself is
|
|
@@ -30,13 +30,18 @@ def bdg_ham(ham, pairing, mu: float = 0.) -> sparse.csr_matrix:
|
|
|
30
30
|
r'''
|
|
31
31
|
Get the real-space BdG Hamiltonian (see the module docstring).
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
ham : Square Hermitian matrix, shape (N, N) (e.g. *System.ham*)
|
|
36
|
+
pairing
|
|
37
|
+
Square antisymmetric matrix, shape (N, N): :math:`\Delta`
|
|
35
38
|
(see *pairing_bonds*, *pairing_s_wave*).
|
|
36
|
-
|
|
39
|
+
mu : Real number, default 0
|
|
40
|
+
Chemical potential.
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
Returns
|
|
43
|
+
-------
|
|
44
|
+
ham_bdg : Sparse CSR matrix, shape (2N, 2N)
|
|
40
45
|
'''
|
|
41
46
|
h = sparse.csr_matrix(ham, dtype='c16')
|
|
42
47
|
delta = sparse.csr_matrix(pairing, dtype='c16')
|
|
@@ -56,11 +61,15 @@ def pairing_bonds(sys, delta: complex) -> sparse.csr_matrix:
|
|
|
56
61
|
them: angle in :math:`[0, 180)`). On a chain it is Kitaev's
|
|
57
62
|
:math:`\Delta\,c^\dagger_jc^\dagger_{j+1}`.
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
Parameters
|
|
65
|
+
----------
|
|
66
|
+
sys : **System** instance, with hoppings
|
|
67
|
+
delta : Complex number
|
|
68
|
+
:math:`\Delta`.
|
|
61
69
|
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
Returns
|
|
71
|
+
-------
|
|
72
|
+
pairing : Sparse CSR matrix, shape (sites, sites)
|
|
64
73
|
'''
|
|
65
74
|
error_handling.empty_hop(sys.hop)
|
|
66
75
|
error_handling.number(delta, 'delta')
|
|
@@ -78,11 +87,16 @@ def pairing_s_wave(n_sites: int, delta: complex) -> sparse.csr_matrix:
|
|
|
78
87
|
for a spinful model with rows ordered site by site, spin up then down
|
|
79
88
|
(as *KSpace* with ``spin=True`` and *OrbitalSystem* with one orbital).
|
|
80
89
|
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
Parameters
|
|
91
|
+
----------
|
|
92
|
+
n_sites : Positive integer
|
|
93
|
+
Number of sites.
|
|
94
|
+
delta : Complex number
|
|
95
|
+
:math:`\Delta`.
|
|
83
96
|
|
|
84
|
-
|
|
85
|
-
|
|
97
|
+
Returns
|
|
98
|
+
-------
|
|
99
|
+
pairing : Sparse CSR matrix, shape (2 n_sites, 2 n_sites)
|
|
86
100
|
'''
|
|
87
101
|
error_handling.positive_int(n_sites, 'n_sites')
|
|
88
102
|
error_handling.number(delta, 'delta')
|
|
@@ -105,15 +119,22 @@ def bdg_kspace(ks, pairing: list[dict], mu: float = 0.):
|
|
|
105
119
|
same positions). Each pairing :math:`\Delta\,c^\dagger_{i,\mathbf{0}}c^\dagger_{j,\mathbf{R}} + h.c.`
|
|
106
120
|
enters antisymmetrized, :math:`\Delta_{ij}(\mathbf{R}) = -\Delta_{ji}(-\mathbf{R})`.
|
|
107
121
|
|
|
108
|
-
|
|
109
|
-
|
|
122
|
+
Parameters
|
|
123
|
+
----------
|
|
124
|
+
ks : **KSpace** instance (Hermitian, orthogonal basis)
|
|
125
|
+
pairing
|
|
126
|
+
List of dictionaries with keys ('i', 'j', 'R', 'delta'):
|
|
110
127
|
orbital indices of *ks* (``0 ... norb-1``; with ``spin=True``,
|
|
111
128
|
``2*site + spin``), lattice vector, amplitude.
|
|
112
|
-
|
|
129
|
+
mu : Real number, default 0
|
|
130
|
+
Chemical potential.
|
|
113
131
|
|
|
114
|
-
|
|
115
|
-
|
|
132
|
+
Returns
|
|
133
|
+
-------
|
|
134
|
+
ks_bdg : **KSpace** instance, 2 norb orbitals
|
|
116
135
|
|
|
136
|
+
Examples
|
|
137
|
+
--------
|
|
117
138
|
Example usage::
|
|
118
139
|
|
|
119
140
|
# Kitaev chain: E(k) = +-sqrt((2t cos k - mu)^2 + 4 Delta^2 sin^2 k)
|
|
@@ -154,10 +175,14 @@ def particle_hole(n: int) -> NDArray[np.float64]:
|
|
|
154
175
|
orbitals: pass it to *KSpace.symmetry_error* (``antiunitary=True``,
|
|
155
176
|
``anti=True``) or *KSpace.tenfold_class* (``particle_hole=``).
|
|
156
177
|
|
|
157
|
-
|
|
178
|
+
Parameters
|
|
179
|
+
----------
|
|
180
|
+
n : Positive integer
|
|
181
|
+
Number of particle orbitals.
|
|
158
182
|
|
|
159
|
-
|
|
160
|
-
|
|
183
|
+
Returns
|
|
184
|
+
-------
|
|
185
|
+
tau_x : Real ndarray, shape (2n, 2n)
|
|
161
186
|
'''
|
|
162
187
|
error_handling.positive_int(n, 'n')
|
|
163
188
|
return np.kron(np.array([[0., 1.], [1., 0.]]), np.eye(n))
|
|
@@ -171,10 +196,13 @@ def pfaffian(a) -> complex:
|
|
|
171
196
|
(2012)). For a 2x2 block :math:`\begin{pmatrix}0 & a\\ -a & 0\end{pmatrix}`
|
|
172
197
|
it is :math:`a`; it is 0 for an odd dimension.
|
|
173
198
|
|
|
174
|
-
|
|
199
|
+
Parameters
|
|
200
|
+
----------
|
|
201
|
+
a : Square antisymmetric matrix, shape (n, n)
|
|
175
202
|
|
|
176
|
-
|
|
177
|
-
|
|
203
|
+
Returns
|
|
204
|
+
-------
|
|
205
|
+
pf : Complex number (a float for a real matrix)
|
|
178
206
|
'''
|
|
179
207
|
real = not np.iscomplexobj(a)
|
|
180
208
|
a = np.array(a, dtype='c16')
|
|
@@ -224,11 +252,15 @@ def majorana_number(ks) -> int:
|
|
|
224
252
|
B 82, 184525 (2010)). The invariant changes only where the gap closes
|
|
225
253
|
at one of the :math:`\Gamma_i`.
|
|
226
254
|
|
|
227
|
-
|
|
255
|
+
Parameters
|
|
256
|
+
----------
|
|
257
|
+
ks
|
|
258
|
+
**KSpace** instance of a BdG model, 2n orbitals: n particles
|
|
228
259
|
then their n holes (see *bdg_kspace*).
|
|
229
260
|
|
|
230
|
-
|
|
231
|
-
|
|
261
|
+
Returns
|
|
262
|
+
-------
|
|
263
|
+
m : Integer, -1 (topological) or +1 (trivial)
|
|
232
264
|
'''
|
|
233
265
|
from tbkit.kspace import KSpace
|
|
234
266
|
error_handling.kspace(ks, KSpace)
|
|
@@ -249,12 +281,18 @@ class GapResult():
|
|
|
249
281
|
r'''
|
|
250
282
|
Self-consistent s-wave pairing of *s_wave_gap*.
|
|
251
283
|
|
|
252
|
-
|
|
253
|
-
|
|
284
|
+
Attributes
|
|
285
|
+
----------
|
|
286
|
+
delta : Complex ndarray
|
|
287
|
+
Gap :math:`\Delta_i` on every site.
|
|
288
|
+
energies : Real ndarray, shape (2N,)
|
|
289
|
+
Spectrum of the reduced BdG
|
|
254
290
|
Hamiltonian (symmetric, :math:`\pm E_n`).
|
|
255
|
-
|
|
291
|
+
states : Complex ndarray, shape (2N, 2N)
|
|
292
|
+
Its eigenvectors
|
|
256
293
|
:math:`(u_n, v_n)` (columns).
|
|
257
|
-
|
|
294
|
+
iterations : Integer
|
|
295
|
+
Number of iterations.
|
|
258
296
|
'''
|
|
259
297
|
|
|
260
298
|
def __init__(self, delta, energies, states, iterations) -> None:
|
|
@@ -305,19 +343,26 @@ def s_wave_gap(
|
|
|
305
343
|
:math:`T_c` the iteration slows down (the linearized map has an
|
|
306
344
|
eigenvalue close to 1): raise *max_iter* there.
|
|
307
345
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
346
|
+
Parameters
|
|
347
|
+
----------
|
|
348
|
+
ham : Square Hermitian matrix, (N, N), spin independent (e.g. *System.ham*)
|
|
349
|
+
V : Positive real, or array of N non-negative reals
|
|
350
|
+
Attraction.
|
|
351
|
+
mu : Real number, default 0
|
|
352
|
+
Chemical potential.
|
|
353
|
+
temperature : Positive real or zero, default 0
|
|
354
|
+
delta0 : Number, or array of N numbers, default 0.1
|
|
313
355
|
Initial gap.
|
|
314
|
-
|
|
315
|
-
|
|
356
|
+
mixing : Real in (0, 1]
|
|
357
|
+
Default value 1 (plain iteration).
|
|
358
|
+
tol : Positive real, default 1e-8
|
|
359
|
+
Convergence threshold
|
|
316
360
|
on the largest change of :math:`\Delta_i`.
|
|
317
|
-
|
|
361
|
+
max_iter : Positive integer, default 10000
|
|
318
362
|
|
|
319
|
-
|
|
320
|
-
|
|
363
|
+
Returns
|
|
364
|
+
-------
|
|
365
|
+
result : :class:`GapResult`
|
|
321
366
|
'''
|
|
322
367
|
h = ham.toarray() if hasattr(ham, 'toarray') else np.asarray(ham)
|
|
323
368
|
error_handling.square_matrix(h, 'ham')
|
|
@@ -350,3 +395,115 @@ def s_wave_gap(
|
|
|
350
395
|
else:
|
|
351
396
|
error_handling.converged(False, 's_wave_gap')
|
|
352
397
|
return GapResult(new, en, vec, it)
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
def superfluid_weight(
|
|
401
|
+
ks, delta: complex | NDArray, mu: float = 0., nk: int | tuple[int, ...] = 60,
|
|
402
|
+
temperature: float = 0., dq: float = 1e-3,
|
|
403
|
+
) -> NDArray[np.float64]:
|
|
404
|
+
r'''
|
|
405
|
+
Get the superfluid weight of an s-wave superconductor,
|
|
406
|
+
:math:`D_{\mu\nu} = \partial^2\Omega/\partial A_\mu\partial A_\nu` at
|
|
407
|
+
:math:`\mathbf{A} = 0` (:math:`\hbar = e = 1`): the curvature of the
|
|
408
|
+
grand potential per unit volume in a uniform vector potential, which
|
|
409
|
+
gives the supercurrent :math:`j_\mu = -D_{\mu\nu}A_\nu` (London). *ks* is
|
|
410
|
+
the spin-up model; the spin-down electrons are its time-reversed
|
|
411
|
+
partners, :math:`h_\downarrow(\mathbf{k}) = h(-\mathbf{k})^*`, so the
|
|
412
|
+
Kramers pairs :math:`(\mathbf{k}\uparrow, -\mathbf{k}\downarrow)` pair
|
|
413
|
+
even when *ks* is a Chern band (for real hoppings, the spin-independent
|
|
414
|
+
model). In the Nambu basis
|
|
415
|
+
:math:`(c_{\mathbf{k}\uparrow}, c^\dagger_{-\mathbf{k}\downarrow})`,
|
|
416
|
+
|
|
417
|
+
.. math::
|
|
418
|
+
|
|
419
|
+
H_{\mathbf{A}}(\mathbf{k}) = \begin{pmatrix} h_{\mathbf{A}}(\mathbf{k})-\mu & \Delta \\
|
|
420
|
+
\Delta^* & -[h_{-\mathbf{A}}(\mathbf{k})-\mu]\end{pmatrix}\, ,\qquad
|
|
421
|
+
\Omega(\mathbf{A}) = \frac{1}{N_kV}\sum_{\mathbf{k}}\Big[\mathrm{Tr}\,
|
|
422
|
+
[h_{-\mathbf{A}}(\mathbf{k})-\mu] - T\sum_n\ln\big(1 + e^{-E_n/T}\big)\Big]\, ,
|
|
423
|
+
|
|
424
|
+
with :math:`h_{\mathbf{A}}` the Peierls Hamiltonian of
|
|
425
|
+
*get_ham_peierls* (phases on the bond vectors, orbital positions
|
|
426
|
+
included), :math:`\Delta = \mathrm{diag}(\Delta_i)` the onsite pairing,
|
|
427
|
+
:math:`E_n` the eigenvalues and :math:`V` the cell volume.
|
|
428
|
+
:math:`\Delta` is held fixed (not re-solved in the field), which is
|
|
429
|
+
exact when symmetry fixes it, e.g. uniform pairing. The derivatives are
|
|
430
|
+
central differences in :math:`\mathbf{A}`.
|
|
431
|
+
|
|
432
|
+
For a dispersive band it is the conventional :math:`n/m`. For an
|
|
433
|
+
isolated flat band at filling :math:`\nu`, with uniform :math:`\Delta`
|
|
434
|
+
small compared to the band gaps, there is no dispersion, and
|
|
435
|
+
:math:`D` is purely geometric (Peotta and Törmä, Nat. Commun. 6, 8944
|
|
436
|
+
(2015)),
|
|
437
|
+
|
|
438
|
+
.. math::
|
|
439
|
+
|
|
440
|
+
D_{\mu\nu} = 8\Delta\sqrt{\nu(1-\nu)}\int\frac{d^d\mathbf{k}}{(2\pi)^d}\,g_{\mu\nu}(\mathbf{k})
|
|
441
|
+
\, ,\qquad \mathrm{Tr}\,D \ge \frac{4\Delta}{\pi}\sqrt{\nu(1-\nu)}\,|C|\ \ (2D)\, ,
|
|
442
|
+
|
|
443
|
+
with :math:`g` the quantum metric of the band (see
|
|
444
|
+
*KSpace.quantum_geometric_tensor*) and :math:`C` its Chern number.
|
|
445
|
+
|
|
446
|
+
Parameters
|
|
447
|
+
----------
|
|
448
|
+
ks : **KSpace** instance (Hermitian, orthogonal basis, spinless)
|
|
449
|
+
Spin-up model.
|
|
450
|
+
delta : Number, or array of norb numbers
|
|
451
|
+
Onsite pairing :math:`\Delta_i`.
|
|
452
|
+
mu : Real number, default 0
|
|
453
|
+
Chemical potential.
|
|
454
|
+
nk : Positive integer, or tuple of *dim* positive integers, default 60
|
|
455
|
+
k-mesh (see *mesh_grid*).
|
|
456
|
+
temperature : Positive real or zero, default 0
|
|
457
|
+
dq : Positive real, default 1e-3
|
|
458
|
+
Finite-difference step in :math:`\mathbf{A}`.
|
|
459
|
+
|
|
460
|
+
Returns
|
|
461
|
+
-------
|
|
462
|
+
D : Real ndarray, shape (dim, dim), in the k coordinates of *get_ham*
|
|
463
|
+
|
|
464
|
+
Examples
|
|
465
|
+
--------
|
|
466
|
+
Example usage::
|
|
467
|
+
|
|
468
|
+
# BCS chain: D = (1/2 pi) int dk 2t cos k (1 - xi/E)
|
|
469
|
+
chain = KSpace(lattices.chain())
|
|
470
|
+
chain.set_hopping([{'i': 0, 'j': 0, 'R': (1,), 't': -1.}])
|
|
471
|
+
d = superfluid_weight(chain, 0.2, mu=-0.5)
|
|
472
|
+
'''
|
|
473
|
+
from tbkit.kspace import KSpace
|
|
474
|
+
error_handling.kspace(ks, KSpace)
|
|
475
|
+
error_handling.hermitian_kspace(ks.is_hermitian(), ks._overlap_hop)
|
|
476
|
+
error_handling.spin_up_model(ks.spin)
|
|
477
|
+
error_handling.pairing_amplitudes(delta, ks.norb, 'delta')
|
|
478
|
+
error_handling.real_number(mu, 'mu')
|
|
479
|
+
error_handling.nk(nk, ks.dim)
|
|
480
|
+
error_handling.positive_real_zero(temperature, 'temperature')
|
|
481
|
+
error_handling.positive_real(dq, 'dq')
|
|
482
|
+
n, dim = ks.norb, ks.dim
|
|
483
|
+
k_cart = ks.mesh_grid(nk)[1] @ ks.k_basis.T
|
|
484
|
+
diag = np.arange(n)
|
|
485
|
+
pair = np.broadcast_to(np.asarray(delta, dtype='c16'), (n,))
|
|
486
|
+
volume = (2 * np.pi) ** dim / abs(np.linalg.det(ks.rec_vec_k))
|
|
487
|
+
|
|
488
|
+
def omega(q):
|
|
489
|
+
A = ks.k_basis @ q
|
|
490
|
+
hole = ks._bloch_ham(k_cart, A=-A) - mu * np.eye(n)
|
|
491
|
+
big = np.zeros((len(k_cart), 2 * n, 2 * n), 'c16')
|
|
492
|
+
big[:, :n, :n] = ks._bloch_ham(k_cart, A=A) - mu * np.eye(n)
|
|
493
|
+
big[:, n:, n:] = -hole
|
|
494
|
+
big[:, diag, diag + n] = pair
|
|
495
|
+
big[:, diag + n, diag] = pair.conj()
|
|
496
|
+
en = np.linalg.eigvalsh(big)
|
|
497
|
+
free = (-temperature * np.logaddexp(0., -en / temperature) if temperature > 0
|
|
498
|
+
else np.minimum(en, 0.))
|
|
499
|
+
return (np.trace(hole, axis1=1, axis2=2).real.sum() + free.sum()) / (len(k_cart) * volume)
|
|
500
|
+
|
|
501
|
+
step = dq * np.eye(dim)
|
|
502
|
+
w0 = omega(np.zeros(dim))
|
|
503
|
+
d = np.zeros((dim, dim))
|
|
504
|
+
for a in range(dim):
|
|
505
|
+
d[a, a] = (omega(step[a]) - 2 * w0 + omega(-step[a])) / dq ** 2
|
|
506
|
+
for b in range(a):
|
|
507
|
+
d[a, b] = d[b, a] = (omega(step[a] + step[b]) - omega(step[a] - step[b])
|
|
508
|
+
- omega(step[b] - step[a]) + omega(-step[a] - step[b])) / (4 * dq ** 2)
|
|
509
|
+
return d
|
|
@@ -45,12 +45,18 @@ def cell_orbitals(lat: Lattice) -> tuple[NDArray[np.int64], NDArray[np.int64]]:
|
|
|
45
45
|
:math:`\boldsymbol\tau_{o_s} + \sum_k n_{s,k}\mathbf{a}_k`, with the tag
|
|
46
46
|
of orbital :math:`o_s` (within ``ATOL``).
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
Parameters
|
|
49
|
+
----------
|
|
50
|
+
lat
|
|
51
|
+
**Lattice** instance, after *get_lattice* (sites may have
|
|
49
52
|
been removed, but not moved).
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
Returns
|
|
55
|
+
-------
|
|
56
|
+
cells : Integer ndarray, shape (sites, dim)
|
|
57
|
+
:math:`n_{s,k}`.
|
|
58
|
+
orbitals : Integer ndarray, shape (sites,)
|
|
59
|
+
:math:`o_s`.
|
|
54
60
|
'''
|
|
55
61
|
error_handling.lat(lat)
|
|
56
62
|
error_handling.empty_coor(lat.coor)
|
|
@@ -90,19 +96,27 @@ def kspace_from_system(sys: System, periodic: bool | None = None, tol: float = 1
|
|
|
90
96
|
element is kept, with ``hermitian=False``. Onsite energies are taken
|
|
91
97
|
orbital by orbital.
|
|
92
98
|
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
Parameters
|
|
100
|
+
----------
|
|
101
|
+
sys : **System** instance with its hoppings set (one orbital per site)
|
|
102
|
+
periodic : Boolean
|
|
103
|
+
Default value None: True if *sys* has
|
|
95
104
|
periodic boundaries along some primitive vector (``System(lat,
|
|
96
105
|
periodic=...)``, or *finite_system* with ``periodic=True``). The
|
|
97
106
|
System is a torus of the *lat.n1* x *lat.n2* (x *lat.n3*) cells of
|
|
98
107
|
*get_lattice*.
|
|
99
|
-
|
|
108
|
+
tol : Positive real number, default 1e-9
|
|
109
|
+
Largest allowed
|
|
100
110
|
difference between equivalent matrix elements.
|
|
101
111
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
Returns
|
|
113
|
+
-------
|
|
114
|
+
ks
|
|
115
|
+
**KSpace** instance (spinless), on a new **Lattice**
|
|
116
|
+
with the *unit_cell* and *prim_vec* of *sys.lat*.
|
|
105
117
|
|
|
118
|
+
Examples
|
|
119
|
+
--------
|
|
106
120
|
Example usage::
|
|
107
121
|
|
|
108
122
|
lat = lattices.honeycomb()
|
|
@@ -170,17 +184,23 @@ def finite_model(
|
|
|
170
184
|
and tag of every row. Spinful models are supported (the two spin
|
|
171
185
|
components of a site share its position).
|
|
172
186
|
|
|
173
|
-
|
|
174
|
-
|
|
187
|
+
Parameters
|
|
188
|
+
----------
|
|
189
|
+
ks : **KSpace** instance
|
|
190
|
+
n_cells : Positive integer, or tuple of *dim* positive integers
|
|
175
191
|
Number of unit cells along each primitive vector.
|
|
176
|
-
|
|
192
|
+
periodic : Boolean, default False
|
|
193
|
+
Periodic boundaries (a torus).
|
|
177
194
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
195
|
+
Returns
|
|
196
|
+
-------
|
|
197
|
+
ham : Complex CSR matrix, shape (N*norb, N*norb)
|
|
198
|
+
positions : Real ndarray, shape (N*norb, space_dim)
|
|
199
|
+
Row
|
|
200
|
+
:math:`c\,\mathrm{norb}+o` sits at :math:`\boldsymbol\tau_o + \sum_k n_k\mathbf{a}_k`
|
|
201
|
+
(cell *c* has :math:`c = n_1 + N_1 n_2 + N_1N_2 n_3`).
|
|
202
|
+
tags : String ndarray, shape (N*norb,)
|
|
203
|
+
Sublattice tags.
|
|
184
204
|
'''
|
|
185
205
|
error_handling.kspace(ks, KSpace)
|
|
186
206
|
error_handling.nk(n_cells, ks.dim)
|
|
@@ -210,13 +230,19 @@ def finite_system(ks: KSpace, n_cells: int | tuple[int, ...], periodic: bool = F
|
|
|
210
230
|
(``sys.periodic``), so that further *set_hopping* calls, *Plot* and
|
|
211
231
|
*get_bott_index* treat it as a torus.
|
|
212
232
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
233
|
+
Parameters
|
|
234
|
+
----------
|
|
235
|
+
ks : **KSpace** instance, with ``spin=False``
|
|
236
|
+
n_cells : Positive integer, or tuple of *dim* positive integers
|
|
237
|
+
periodic : Boolean, default False
|
|
238
|
+
Periodic boundaries (a torus).
|
|
216
239
|
|
|
217
|
-
|
|
218
|
-
|
|
240
|
+
Returns
|
|
241
|
+
-------
|
|
242
|
+
sys : **System** instance, with its hoppings set
|
|
219
243
|
|
|
244
|
+
Examples
|
|
245
|
+
--------
|
|
220
246
|
Example usage::
|
|
221
247
|
|
|
222
248
|
sys = finite_system(gra, (30, 30), periodic=True)
|
|
@@ -149,21 +149,29 @@ def discretize_symbolic(hamiltonian, dim: int | None = None) -> dict:
|
|
|
149
149
|
the grid spacing *a* and the parameters of the Hamiltonian (see the
|
|
150
150
|
module docstring for the scheme).
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
Parameters
|
|
153
|
+
----------
|
|
154
|
+
hamiltonian
|
|
155
|
+
sympy expression or Matrix, or a string, in the
|
|
153
156
|
momenta ``k_x``, ``k_y``, ``k_z``: a polynomial in them with
|
|
154
157
|
constant coefficients. Any other symbol is a parameter, taken real
|
|
155
158
|
(the symbols ``x``, ``y``, ``z`` and ``a`` are not allowed). A
|
|
156
159
|
string may use the Pauli matrices ``sigma_0``, ``sigma_x``,
|
|
157
160
|
``sigma_y``, ``sigma_z`` and ``kron`` (Kronecker product); ``I``
|
|
158
161
|
is the imaginary unit.
|
|
159
|
-
|
|
162
|
+
dim : 1, 2 or 3
|
|
163
|
+
Default value None: the last axis whose momentum
|
|
160
164
|
appears (1 if none).
|
|
161
165
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
+
Returns
|
|
167
|
+
-------
|
|
168
|
+
hoppings : Dictionary
|
|
169
|
+
key: tuple of *dim* integers
|
|
170
|
+
:math:`\mathbf{R}`, val: sympy Matrix :math:`T(\mathbf{R})`, in
|
|
171
|
+
the symbol ``a`` and those of *hamiltonian*.
|
|
166
172
|
|
|
173
|
+
Examples
|
|
174
|
+
--------
|
|
167
175
|
Example usage::
|
|
168
176
|
|
|
169
177
|
discretize_symbolic('k_x**2')
|
|
@@ -211,21 +219,29 @@ def discretize(hamiltonian, a: float = 1., dim: int | None = None,
|
|
|
211
219
|
otherwise every matrix element is stored, with ``hermitian=False``.
|
|
212
220
|
Constant onsite terms are in *ks.onsite*.
|
|
213
221
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
Parameters
|
|
223
|
+
----------
|
|
224
|
+
hamiltonian : sympy expression or Matrix, or a string (see *discretize_symbolic*)
|
|
225
|
+
a
|
|
226
|
+
Real number, at least :math:`\sqrt{0.1}\approx 0.316` (the
|
|
217
227
|
shortest primitive vector of a **Lattice**). Default value 1. Grid
|
|
218
228
|
spacing: to refine the grid, measure lengths in a smaller unit.
|
|
219
|
-
|
|
229
|
+
dim : 1, 2 or 3
|
|
230
|
+
Default value None: the last axis whose momentum
|
|
220
231
|
appears (1 if none).
|
|
221
|
-
|
|
232
|
+
tags : String or list of one-character strings
|
|
233
|
+
Default value
|
|
222
234
|
None: 'a', 'b', 'c', ... Tag of each orbital.
|
|
223
235
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
236
|
+
Returns
|
|
237
|
+
-------
|
|
238
|
+
ks : **KSpace** instance (spinless, *norb* orbitals)
|
|
239
|
+
Its
|
|
240
|
+
lattice has *prim_vec* :math:`a\hat{\mathbf{x}}, a\hat{\mathbf{y}},
|
|
241
|
+
(a\hat{\mathbf{z}})`.
|
|
228
242
|
|
|
243
|
+
Examples
|
|
244
|
+
--------
|
|
229
245
|
Example usage::
|
|
230
246
|
|
|
231
247
|
# the BHZ model of HgTe quantum wells, one spin block
|