tbkit 0.4.2__tar.gz → 0.6.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.0/PKG-INFO +273 -0
- tbkit-0.6.0/README.md +231 -0
- tbkit-0.6.0/pyproject.toml +86 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/__init__.py +13 -1
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/bdg.py +82 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/bridges.py +12 -5
- tbkit-0.6.0/tbkit/continuum.py +273 -0
- tbkit-0.6.0/tbkit/dos.py +238 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/error_handling.py +816 -9
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/exceptional.py +3 -3
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/floquet.py +35 -12
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/graphene.py +48 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/io.py +37 -10
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/kpm.py +5 -2
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/kspace.py +1773 -131
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/lattice.py +8 -5
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/lattices.py +2 -1
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/meanfield.py +9 -9
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/moire.py +8 -5
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/neighbours.py +8 -4
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/optics.py +2 -2
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/orbital.py +40 -17
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/plot.py +41 -44
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/propagation.py +9 -10
- tbkit-0.6.0/tbkit/py.typed +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/slater_koster.py +5 -5
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/system.py +307 -54
- tbkit-0.6.0/tbkit/topology.py +317 -0
- tbkit-0.6.0/tbkit/transport.py +1442 -0
- tbkit-0.6.0/tbkit/values.py +77 -0
- tbkit-0.6.0/tbkit/wannier.py +555 -0
- tbkit-0.6.0/tbkit.egg-info/PKG-INFO +273 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit.egg-info/SOURCES.txt +14 -1
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit.egg-info/requires.txt +5 -0
- tbkit-0.6.0/tests/test_analysis.py +469 -0
- tbkit-0.6.0/tests/test_berry_response.py +240 -0
- tbkit-0.6.0/tests/test_continuum.py +134 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_dos.py +3 -2
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_error_handling.py +142 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_exceptional.py +1 -1
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_green_occupation.py +2 -1
- tbkit-0.6.0/tests/test_invariants.py +316 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_kpm.py +2 -1
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_kspace.py +67 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_moire.py +2 -1
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_optics.py +3 -3
- tbkit-0.6.0/tests/test_periodic.py +254 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_regressions.py +26 -0
- tbkit-0.6.0/tests/test_smatrix.py +289 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_system.py +15 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_transport.py +106 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_transport_response.py +3 -3
- tbkit-0.6.0/tests/test_values.py +316 -0
- tbkit-0.6.0/tests/test_wannier_functions.py +341 -0
- tbkit-0.4.2/PKG-INFO +0 -375
- tbkit-0.4.2/README.md +0 -347
- tbkit-0.4.2/pyproject.toml +0 -47
- tbkit-0.4.2/tbkit/dos.py +0 -98
- tbkit-0.4.2/tbkit/transport.py +0 -717
- tbkit-0.4.2/tbkit.egg-info/PKG-INFO +0 -375
- {tbkit-0.4.2 → tbkit-0.6.0}/LICENSE +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/setup.cfg +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/higher_order.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/occupation.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit/save.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit.egg-info/dependency_links.txt +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tbkit.egg-info/top_level.txt +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_bridges.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_correlations.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_error_handling_structures.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_floquet.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_graphene.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_hall.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_higher_order.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_interactions.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_io.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_large_lattices.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_lattice.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_lattices.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_magnetic.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_neighbours.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_non_hermitian_bands.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_orbitals.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_plot.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_propagation.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_save.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_surface_spectral.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_three_d.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_topology.py +0 -0
- {tbkit-0.4.2 → tbkit-0.6.0}/tests/test_wannier90.py +0 -0
tbkit-0.6.0/PKG-INFO
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tbkit
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: A Python package to build and solve Tight-Binding models.
|
|
5
|
+
Author-email: Charles Poli <cpoli374@gmail.com>
|
|
6
|
+
Maintainer-email: Charles Poli <cpoli374@gmail.com>
|
|
7
|
+
License-Expression: BSD-3-Clause
|
|
8
|
+
Project-URL: Homepage, https://github.com/cpoli/tbkit
|
|
9
|
+
Project-URL: Issues, https://github.com/cpoli/tbkit/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/cpoli/tbkit/blob/master/CHANGELOG.md
|
|
11
|
+
Project-URL: Documentation, https://cpoli.github.io/tbkit/
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: numpy>=1.24
|
|
27
|
+
Requires-Dist: scipy>=1.10
|
|
28
|
+
Requires-Dist: matplotlib>=3.7
|
|
29
|
+
Provides-Extra: continuum
|
|
30
|
+
Requires-Dist: sympy>=1.12; extra == "continuum"
|
|
31
|
+
Provides-Extra: test
|
|
32
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
33
|
+
Requires-Dist: pytest-cov>=4; extra == "test"
|
|
34
|
+
Requires-Dist: pytest-xdist>=3.2; extra == "test"
|
|
35
|
+
Requires-Dist: sympy>=1.12; extra == "test"
|
|
36
|
+
Provides-Extra: docs
|
|
37
|
+
Requires-Dist: sphinx>=7; extra == "docs"
|
|
38
|
+
Requires-Dist: pydata-sphinx-theme>=0.15; extra == "docs"
|
|
39
|
+
Requires-Dist: sphinx-gallery>=0.15; extra == "docs"
|
|
40
|
+
Requires-Dist: sympy>=1.12; extra == "docs"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
# tbkit — a Tight-Binding package
|
|
44
|
+
|
|
45
|
+
| | |
|
|
46
|
+
|:--|:-:|
|
|
47
|
+
| Package | [](https://pypi.org/project/tbkit/) [](https://anaconda.org/conda-forge/tbkit) [](https://pypi.org/project/tbkit/) [](https://zenodo.org/badge/latestdoi/1381398706) |
|
|
48
|
+
| 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
|
+
| Documentation | [](https://cpoli.github.io/tbkit/) |
|
|
50
|
+
| 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
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
**tbkit** is a Python package to build and solve Tight-Binding models, written
|
|
56
|
+
in vectorized NumPy/SciPy. It aims to make the mechanics of Tight-Binding
|
|
57
|
+
models — lattices, hoppings, Hamiltonians, spectra, band structures —
|
|
58
|
+
explicit and easy to inspect, so it works as well for teaching as for
|
|
59
|
+
research prototyping.
|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
For computational physics beyond tight-binding — quantum mechanics,
|
|
64
|
+
classical mechanics, statistical physics, general relativity, and more —
|
|
65
|
+
see [physicskit](https://github.com/cpoli/physicskit), whose
|
|
66
|
+
`physicskit.condensed` subpackage covers tight-binding band theory and
|
|
67
|
+
topology alongside superconductivity.
|
|
68
|
+
|
|
69
|
+
## Examples
|
|
70
|
+
|
|
71
|
+
### Building and solving models
|
|
72
|
+
|
|
73
|
+
Finite lattices, defects, several orbitals per site, real space to k-space and back, k·p models discretized into lattice models, saved models and Wannier90 imports, maximally localized Wannier functions, and solvers for very large lattices.
|
|
74
|
+
|
|
75
|
+

|
|
76
|
+
|
|
77
|
+
### Fields, strain and disorder
|
|
78
|
+
|
|
79
|
+
What happens to a lattice under a magnetic field (Peierls substitution), under strain, and with disorder.
|
|
80
|
+
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
### Band topology
|
|
84
|
+
|
|
85
|
+
Chern numbers, Berry phases, the Z2 invariant (and the four 3D indices), spin and mirror Chern numbers, the Bott index and entanglement spectrum, Weyl points and their chirality, Kitaev's Majorana number, quantum geometry, symmetry classes, higher-order and 3D topological phases.
|
|
86
|
+
|
|
87
|
+

|
|
88
|
+
|
|
89
|
+
### Response and transport
|
|
90
|
+
|
|
91
|
+
Hall conductivities at any Fermi level (with the orbital magnetization, Nernst and thermal Hall responses), Landauer transport between leads, and linear and nonlinear optical response.
|
|
92
|
+
|
|
93
|
+

|
|
94
|
+
|
|
95
|
+
### Flat bands and interactions
|
|
96
|
+
|
|
97
|
+
Flat bands from lattice geometry and from a moiré twist, the Hubbard model in mean field, and superconductivity.
|
|
98
|
+
|
|
99
|
+

|
|
100
|
+
|
|
101
|
+
### Driven and open systems
|
|
102
|
+
|
|
103
|
+
Wavepacket dynamics, periodically driven (Floquet) lattices, and non-Hermitian bands with exceptional points.
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
## Install
|
|
108
|
+
|
|
109
|
+
Requires Python >= 3.10 (tested on 3.10-3.15).
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
pip install tbkit
|
|
113
|
+
# or
|
|
114
|
+
conda install -c conda-forge tbkit
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`tbkit.continuum` (k·p models to tight-binding) also needs sympy:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pip install "tbkit[continuum]"
|
|
121
|
+
# or
|
|
122
|
+
conda install -c conda-forge tbkit sympy
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
or, for an editable install from a clone (e.g. to run the test suite or
|
|
126
|
+
work on tbkit itself):
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
git clone https://github.com/cpoli/tbkit
|
|
130
|
+
cd tbkit
|
|
131
|
+
pip install -e .
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
or, to also install the tools needed to run the test suite:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pip install -e ".[test]"
|
|
138
|
+
pytest tests/
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The test suite has 100% line coverage of the `tbkit` package; see the
|
|
142
|
+
[HTML coverage report](https://cpoli.github.io/tbkit/coverage/).
|
|
143
|
+
|
|
144
|
+
## Quick start
|
|
145
|
+
|
|
146
|
+
Real-space flake, nearest-neighbor square lattice:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from tbkit.lattice import Lattice
|
|
150
|
+
from tbkit.system import System
|
|
151
|
+
|
|
152
|
+
lat = Lattice(unit_cell=[{'tag': 'a', 'r0': (0., 0.)}],
|
|
153
|
+
prim_vec=[(1., 0.), (0., 1.)])
|
|
154
|
+
lat.get_lattice(n1=10, n2=10)
|
|
155
|
+
|
|
156
|
+
sys = System(lat)
|
|
157
|
+
sys.set_hopping([{'n': 1, 't': 1.}])
|
|
158
|
+
sys.get_ham()
|
|
159
|
+
sys.get_eig()
|
|
160
|
+
print(sys.en)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Graphene band structure (reciprocal space):
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
import numpy as np
|
|
167
|
+
from tbkit.lattice import Lattice
|
|
168
|
+
from tbkit.kspace import KSpace, reciprocal_vectors
|
|
169
|
+
|
|
170
|
+
DX, DY = 0.5 * 3 ** 0.5, 0.5
|
|
171
|
+
unit_cell = [{'tag': 'a', 'r0': (0., 0.)}, {'tag': 'b', 'r0': (DX, DY)}]
|
|
172
|
+
prim_vec = [(2 * DX, 0.), (DX, 1.5)]
|
|
173
|
+
lat = Lattice(unit_cell=unit_cell, prim_vec=prim_vec)
|
|
174
|
+
|
|
175
|
+
gra = KSpace(lat)
|
|
176
|
+
gra.set_hopping([{'i': 0, 'j': 1, 'R': (0, 0), 't': 1.},
|
|
177
|
+
{'i': 0, 'j': 1, 'R': (-1, 0), 't': 1.},
|
|
178
|
+
{'i': 0, 'j': 1, 'R': (0, -1), 't': 1.}])
|
|
179
|
+
|
|
180
|
+
b1, b2 = (np.array(v) for v in reciprocal_vectors(prim_vec))
|
|
181
|
+
Gamma, K, M = np.zeros(2), (b1 - b2) / 3, b1 / 2
|
|
182
|
+
gra.k_path([Gamma, K, M, Gamma], nk=60)
|
|
183
|
+
fig = gra.plot_bands(node_labels=[r'$\Gamma$', 'K', 'M', r'$\Gamma$'])
|
|
184
|
+
fig.savefig('graphene_bands.png')
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
A magnetic field is added with `System.set_magnetic_field` (uniform field) or
|
|
188
|
+
`System.set_peierls_phase` (arbitrary vector potential), applied to the
|
|
189
|
+
hoppings *after* `set_hopping`/`set_hopping_manual`:
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
sys.set_hopping_manual(hop_dict)
|
|
193
|
+
sys.set_magnetic_field(alpha=0.01) # flux quanta per unit area
|
|
194
|
+
sys.get_ham()
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
See [`examples/magnetic_field/plot_magnetic_field.py`](examples/magnetic_field/plot_magnetic_field.py) for a full
|
|
198
|
+
worked example (an Aharonov-Bohm ring, reproducing the textbook result that
|
|
199
|
+
the spectrum is periodic in the enclosed flux with period one flux quantum).
|
|
200
|
+
|
|
201
|
+
A Chern number is the Berry curvature of a group of bands, integrated over
|
|
202
|
+
the Brillouin zone:
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
chern = gra.chern_number(bands=[0], nk=40) # ~0 for plain graphene
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
See [`examples/topology/plot_haldane_topology.py`](examples/topology/plot_haldane_topology.py) for the
|
|
209
|
+
Haldane model (the first Chern insulator), reproducing its topological
|
|
210
|
+
phase transition (Chern number 1 -> 0) and Berry-curvature map.
|
|
211
|
+
|
|
212
|
+
A spin-1/2 degree of freedom is added with `KSpace(lat, spin=True)`; onsite
|
|
213
|
+
values and hoppings then also accept 2x2 (Pauli) matrices:
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
from tbkit.kspace import KSpace, PAULI
|
|
217
|
+
|
|
218
|
+
kmele = KSpace(lat, spin=True)
|
|
219
|
+
kmele.set_hopping([{'i': 0, 'j': 0, 'R': (1, 0), 't': 1j*lam*PAULI['z']}]) # intrinsic SOC
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
A ribbon -- periodic in one direction, finite in the other, the standard
|
|
223
|
+
way to see edge states -- is cut out of a periodic model with
|
|
224
|
+
`tbkit.kspace.ribbon`:
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
from tbkit.kspace import ribbon
|
|
228
|
+
|
|
229
|
+
rib = ribbon(lat, list_hop, width=30, direction=1) # 30 unit cells wide
|
|
230
|
+
fig = rib.plot_bands()
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
See [`examples/topology/plot_edge_states.py`](examples/topology/plot_edge_states.py) for the zigzag
|
|
234
|
+
graphene ribbon's zero-energy edge band, and the Kane-Mele ribbon's helical
|
|
235
|
+
edge states crossing a spin-orbit gap.
|
|
236
|
+
|
|
237
|
+
## Documentation
|
|
238
|
+
|
|
239
|
+
Rendered docs (tutorial, API reference, example gallery): https://cpoli.github.io/tbkit/
|
|
240
|
+
|
|
241
|
+
* [`docs/source/tutorial.rst`](docs/source/tutorial.rst) -- a narrative walkthrough of the
|
|
242
|
+
package, from building a lattice through topology, spin-orbit coupling,
|
|
243
|
+
and edge states.
|
|
244
|
+
* [`docs/source/history/`](docs/source/history/) -- a chronology of the breakthroughs
|
|
245
|
+
behind Tight-Binding theory (Bloch's theorem through higher-order topology),
|
|
246
|
+
one page per theme,
|
|
247
|
+
each one linked to the corresponding **tbkit** functionality and example
|
|
248
|
+
above.
|
|
249
|
+
* `docs/source/tbkit.rst` -- the API reference (auto-generated from docstrings).
|
|
250
|
+
* [`ROADMAP.md`](ROADMAP.md) -- what is planned next, and what tbkit
|
|
251
|
+
does not do yet (compared with Kwant and PythTB).
|
|
252
|
+
|
|
253
|
+
Build the HTML docs with `cd docs && make html` (output in `docs/build/html`).
|
|
254
|
+
|
|
255
|
+
## A note on the API
|
|
256
|
+
|
|
257
|
+
Version 0.2 modernized the package to run on current Python/NumPy/SciPy and
|
|
258
|
+
cleaned up the API:
|
|
259
|
+
|
|
260
|
+
* Sublattice tags are plain one-character **strings** (`'a'`) rather than
|
|
261
|
+
byte strings (`b'a'`).
|
|
262
|
+
* Classes are named in `PascalCase` (`Lattice`, `System`, ...) rather than
|
|
263
|
+
lowercase names identical to their module (`lattice.lattice`,
|
|
264
|
+
`system.system`, ...), which used to make `import tbkit.lattice as lattice`
|
|
265
|
+
silently bind the wrong object.
|
|
266
|
+
|
|
267
|
+
For continuity, the pre-0.2 lowercase class names (`lattice`, `system`,
|
|
268
|
+
`plot`, `propagation`, `save`) remain available as aliases of the new
|
|
269
|
+
classes, so `from tbkit.lattice import lattice` still works.
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
BSD 3-Clause, see [LICENSE](LICENSE).
|
tbkit-0.6.0/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# tbkit — a Tight-Binding package
|
|
2
|
+
|
|
3
|
+
| | |
|
|
4
|
+
|:--|:-:|
|
|
5
|
+
| Package | [](https://pypi.org/project/tbkit/) [](https://anaconda.org/conda-forge/tbkit) [](https://pypi.org/project/tbkit/) [](https://zenodo.org/badge/latestdoi/1381398706) |
|
|
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
|
+
| Documentation | [](https://cpoli.github.io/tbkit/) |
|
|
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
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
**tbkit** is a Python package to build and solve Tight-Binding models, written
|
|
14
|
+
in vectorized NumPy/SciPy. It aims to make the mechanics of Tight-Binding
|
|
15
|
+
models — lattices, hoppings, Hamiltonians, spectra, band structures —
|
|
16
|
+
explicit and easy to inspect, so it works as well for teaching as for
|
|
17
|
+
research prototyping.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
For computational physics beyond tight-binding — quantum mechanics,
|
|
22
|
+
classical mechanics, statistical physics, general relativity, and more —
|
|
23
|
+
see [physicskit](https://github.com/cpoli/physicskit), whose
|
|
24
|
+
`physicskit.condensed` subpackage covers tight-binding band theory and
|
|
25
|
+
topology alongside superconductivity.
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
### Building and solving models
|
|
30
|
+
|
|
31
|
+
Finite lattices, defects, several orbitals per site, real space to k-space and back, k·p models discretized into lattice models, saved models and Wannier90 imports, maximally localized Wannier functions, and solvers for very large lattices.
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
### Fields, strain and disorder
|
|
36
|
+
|
|
37
|
+
What happens to a lattice under a magnetic field (Peierls substitution), under strain, and with disorder.
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
### Band topology
|
|
42
|
+
|
|
43
|
+
Chern numbers, Berry phases, the Z2 invariant (and the four 3D indices), spin and mirror Chern numbers, the Bott index and entanglement spectrum, Weyl points and their chirality, Kitaev's Majorana number, quantum geometry, symmetry classes, higher-order and 3D topological phases.
|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
### Response and transport
|
|
48
|
+
|
|
49
|
+
Hall conductivities at any Fermi level (with the orbital magnetization, Nernst and thermal Hall responses), Landauer transport between leads, and linear and nonlinear optical response.
|
|
50
|
+
|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
### Flat bands and interactions
|
|
54
|
+
|
|
55
|
+
Flat bands from lattice geometry and from a moiré twist, the Hubbard model in mean field, and superconductivity.
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
### Driven and open systems
|
|
60
|
+
|
|
61
|
+
Wavepacket dynamics, periodically driven (Floquet) lattices, and non-Hermitian bands with exceptional points.
|
|
62
|
+
|
|
63
|
+

|
|
64
|
+
|
|
65
|
+
## Install
|
|
66
|
+
|
|
67
|
+
Requires Python >= 3.10 (tested on 3.10-3.15).
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install tbkit
|
|
71
|
+
# or
|
|
72
|
+
conda install -c conda-forge tbkit
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`tbkit.continuum` (k·p models to tight-binding) also needs sympy:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install "tbkit[continuum]"
|
|
79
|
+
# or
|
|
80
|
+
conda install -c conda-forge tbkit sympy
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
or, for an editable install from a clone (e.g. to run the test suite or
|
|
84
|
+
work on tbkit itself):
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
git clone https://github.com/cpoli/tbkit
|
|
88
|
+
cd tbkit
|
|
89
|
+
pip install -e .
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
or, to also install the tools needed to run the test suite:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install -e ".[test]"
|
|
96
|
+
pytest tests/
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The test suite has 100% line coverage of the `tbkit` package; see the
|
|
100
|
+
[HTML coverage report](https://cpoli.github.io/tbkit/coverage/).
|
|
101
|
+
|
|
102
|
+
## Quick start
|
|
103
|
+
|
|
104
|
+
Real-space flake, nearest-neighbor square lattice:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from tbkit.lattice import Lattice
|
|
108
|
+
from tbkit.system import System
|
|
109
|
+
|
|
110
|
+
lat = Lattice(unit_cell=[{'tag': 'a', 'r0': (0., 0.)}],
|
|
111
|
+
prim_vec=[(1., 0.), (0., 1.)])
|
|
112
|
+
lat.get_lattice(n1=10, n2=10)
|
|
113
|
+
|
|
114
|
+
sys = System(lat)
|
|
115
|
+
sys.set_hopping([{'n': 1, 't': 1.}])
|
|
116
|
+
sys.get_ham()
|
|
117
|
+
sys.get_eig()
|
|
118
|
+
print(sys.en)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Graphene band structure (reciprocal space):
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
import numpy as np
|
|
125
|
+
from tbkit.lattice import Lattice
|
|
126
|
+
from tbkit.kspace import KSpace, reciprocal_vectors
|
|
127
|
+
|
|
128
|
+
DX, DY = 0.5 * 3 ** 0.5, 0.5
|
|
129
|
+
unit_cell = [{'tag': 'a', 'r0': (0., 0.)}, {'tag': 'b', 'r0': (DX, DY)}]
|
|
130
|
+
prim_vec = [(2 * DX, 0.), (DX, 1.5)]
|
|
131
|
+
lat = Lattice(unit_cell=unit_cell, prim_vec=prim_vec)
|
|
132
|
+
|
|
133
|
+
gra = KSpace(lat)
|
|
134
|
+
gra.set_hopping([{'i': 0, 'j': 1, 'R': (0, 0), 't': 1.},
|
|
135
|
+
{'i': 0, 'j': 1, 'R': (-1, 0), 't': 1.},
|
|
136
|
+
{'i': 0, 'j': 1, 'R': (0, -1), 't': 1.}])
|
|
137
|
+
|
|
138
|
+
b1, b2 = (np.array(v) for v in reciprocal_vectors(prim_vec))
|
|
139
|
+
Gamma, K, M = np.zeros(2), (b1 - b2) / 3, b1 / 2
|
|
140
|
+
gra.k_path([Gamma, K, M, Gamma], nk=60)
|
|
141
|
+
fig = gra.plot_bands(node_labels=[r'$\Gamma$', 'K', 'M', r'$\Gamma$'])
|
|
142
|
+
fig.savefig('graphene_bands.png')
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
A magnetic field is added with `System.set_magnetic_field` (uniform field) or
|
|
146
|
+
`System.set_peierls_phase` (arbitrary vector potential), applied to the
|
|
147
|
+
hoppings *after* `set_hopping`/`set_hopping_manual`:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
sys.set_hopping_manual(hop_dict)
|
|
151
|
+
sys.set_magnetic_field(alpha=0.01) # flux quanta per unit area
|
|
152
|
+
sys.get_ham()
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
See [`examples/magnetic_field/plot_magnetic_field.py`](examples/magnetic_field/plot_magnetic_field.py) for a full
|
|
156
|
+
worked example (an Aharonov-Bohm ring, reproducing the textbook result that
|
|
157
|
+
the spectrum is periodic in the enclosed flux with period one flux quantum).
|
|
158
|
+
|
|
159
|
+
A Chern number is the Berry curvature of a group of bands, integrated over
|
|
160
|
+
the Brillouin zone:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
chern = gra.chern_number(bands=[0], nk=40) # ~0 for plain graphene
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
See [`examples/topology/plot_haldane_topology.py`](examples/topology/plot_haldane_topology.py) for the
|
|
167
|
+
Haldane model (the first Chern insulator), reproducing its topological
|
|
168
|
+
phase transition (Chern number 1 -> 0) and Berry-curvature map.
|
|
169
|
+
|
|
170
|
+
A spin-1/2 degree of freedom is added with `KSpace(lat, spin=True)`; onsite
|
|
171
|
+
values and hoppings then also accept 2x2 (Pauli) matrices:
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
from tbkit.kspace import KSpace, PAULI
|
|
175
|
+
|
|
176
|
+
kmele = KSpace(lat, spin=True)
|
|
177
|
+
kmele.set_hopping([{'i': 0, 'j': 0, 'R': (1, 0), 't': 1j*lam*PAULI['z']}]) # intrinsic SOC
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
A ribbon -- periodic in one direction, finite in the other, the standard
|
|
181
|
+
way to see edge states -- is cut out of a periodic model with
|
|
182
|
+
`tbkit.kspace.ribbon`:
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
from tbkit.kspace import ribbon
|
|
186
|
+
|
|
187
|
+
rib = ribbon(lat, list_hop, width=30, direction=1) # 30 unit cells wide
|
|
188
|
+
fig = rib.plot_bands()
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
See [`examples/topology/plot_edge_states.py`](examples/topology/plot_edge_states.py) for the zigzag
|
|
192
|
+
graphene ribbon's zero-energy edge band, and the Kane-Mele ribbon's helical
|
|
193
|
+
edge states crossing a spin-orbit gap.
|
|
194
|
+
|
|
195
|
+
## Documentation
|
|
196
|
+
|
|
197
|
+
Rendered docs (tutorial, API reference, example gallery): https://cpoli.github.io/tbkit/
|
|
198
|
+
|
|
199
|
+
* [`docs/source/tutorial.rst`](docs/source/tutorial.rst) -- a narrative walkthrough of the
|
|
200
|
+
package, from building a lattice through topology, spin-orbit coupling,
|
|
201
|
+
and edge states.
|
|
202
|
+
* [`docs/source/history/`](docs/source/history/) -- a chronology of the breakthroughs
|
|
203
|
+
behind Tight-Binding theory (Bloch's theorem through higher-order topology),
|
|
204
|
+
one page per theme,
|
|
205
|
+
each one linked to the corresponding **tbkit** functionality and example
|
|
206
|
+
above.
|
|
207
|
+
* `docs/source/tbkit.rst` -- the API reference (auto-generated from docstrings).
|
|
208
|
+
* [`ROADMAP.md`](ROADMAP.md) -- what is planned next, and what tbkit
|
|
209
|
+
does not do yet (compared with Kwant and PythTB).
|
|
210
|
+
|
|
211
|
+
Build the HTML docs with `cd docs && make html` (output in `docs/build/html`).
|
|
212
|
+
|
|
213
|
+
## A note on the API
|
|
214
|
+
|
|
215
|
+
Version 0.2 modernized the package to run on current Python/NumPy/SciPy and
|
|
216
|
+
cleaned up the API:
|
|
217
|
+
|
|
218
|
+
* Sublattice tags are plain one-character **strings** (`'a'`) rather than
|
|
219
|
+
byte strings (`b'a'`).
|
|
220
|
+
* Classes are named in `PascalCase` (`Lattice`, `System`, ...) rather than
|
|
221
|
+
lowercase names identical to their module (`lattice.lattice`,
|
|
222
|
+
`system.system`, ...), which used to make `import tbkit.lattice as lattice`
|
|
223
|
+
silently bind the wrong object.
|
|
224
|
+
|
|
225
|
+
For continuity, the pre-0.2 lowercase class names (`lattice`, `system`,
|
|
226
|
+
`plot`, `propagation`, `save`) remain available as aliases of the new
|
|
227
|
+
classes, so `from tbkit.lattice import lattice` still works.
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
BSD 3-Clause, see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tbkit"
|
|
7
|
+
version = "0.6.0"
|
|
8
|
+
description = "A Python package to build and solve Tight-Binding models."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "BSD-3-Clause"
|
|
11
|
+
authors = [{ name = "Charles Poli", email = "cpoli374@gmail.com" }]
|
|
12
|
+
maintainers = [{ name = "Charles Poli", email = "cpoli374@gmail.com" }]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"numpy>=1.24",
|
|
16
|
+
"scipy>=1.10",
|
|
17
|
+
"matplotlib>=3.7",
|
|
18
|
+
]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Intended Audience :: Education",
|
|
21
|
+
"Intended Audience :: Science/Research",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Programming Language :: Python :: 3.14",
|
|
29
|
+
"Programming Language :: Python :: 3.15",
|
|
30
|
+
"Typing :: Typed",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/cpoli/tbkit"
|
|
35
|
+
Issues = "https://github.com/cpoli/tbkit/issues"
|
|
36
|
+
Changelog = "https://github.com/cpoli/tbkit/blob/master/CHANGELOG.md"
|
|
37
|
+
Documentation = "https://cpoli.github.io/tbkit/"
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
continuum = ["sympy>=1.12"]
|
|
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.15", "sympy>=1.12"]
|
|
43
|
+
|
|
44
|
+
[tool.pytest.ini_options]
|
|
45
|
+
# The suite is warning-free; keep it that way. A warning from tbkit itself is
|
|
46
|
+
# a defect (e.g. complex energies reaching matplotlib), and one from a test is
|
|
47
|
+
# usually the test misusing an API. Add a targeted `ignore::` entry below if a
|
|
48
|
+
# dependency ever emits something genuinely out of our control.
|
|
49
|
+
filterwarnings = ["error"]
|
|
50
|
+
# Run in parallel; worksteal rebalances the few slow Floquet/Hall/KPM tests.
|
|
51
|
+
# Pass -n0 to run a single test without the worker startup cost.
|
|
52
|
+
addopts = "-n auto --dist worksteal"
|
|
53
|
+
|
|
54
|
+
[tool.ruff.lint]
|
|
55
|
+
# Pyflakes and the pycodestyle errors (ruff's classic defaults, named so a
|
|
56
|
+
# ruff upgrade does not change them), minus two that clash with the physics
|
|
57
|
+
# notation: `l` is the angular momentum or a length, and short local lambdas
|
|
58
|
+
# stand for formulas.
|
|
59
|
+
select = ["E4", "E7", "E9", "F"]
|
|
60
|
+
ignore = ["E741", "E731"]
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint.per-file-ignores]
|
|
63
|
+
# Imports grouped by feature, each followed by its `__all__` entry.
|
|
64
|
+
"tbkit/__init__.py" = ["E402", "F401"]
|
|
65
|
+
# `npc = np.char` has to sit between the imports.
|
|
66
|
+
"tbkit/system.py" = ["E402"]
|
|
67
|
+
# Pre-0.2 module built on star imports.
|
|
68
|
+
"tbkit/graphene.py" = ["F403", "F405"]
|
|
69
|
+
|
|
70
|
+
[tool.mypy]
|
|
71
|
+
# No python_version pin: the NumPy >= 2.3 stubs use PEP 695 generics,
|
|
72
|
+
# which mypy resolves wrongly when targeting 3.10 (every bare
|
|
73
|
+
# ``arr.max()`` fails to match). Check against the running interpreter.
|
|
74
|
+
ignore_missing_imports = true
|
|
75
|
+
# The type hints are documentation first: check what is annotated, and
|
|
76
|
+
# skip the bodies of unannotated functions.
|
|
77
|
+
check_untyped_defs = false
|
|
78
|
+
|
|
79
|
+
[tool.setuptools.packages.find]
|
|
80
|
+
include = ["tbkit*"]
|
|
81
|
+
|
|
82
|
+
[tool.setuptools.package-data]
|
|
83
|
+
tbkit = ["py.typed"]
|
|
84
|
+
|
|
85
|
+
[tool.coverage.run]
|
|
86
|
+
source = ["tbkit"]
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
"""tbkit: build and solve Tight-Binding models."""
|
|
8
8
|
|
|
9
|
-
__version__ = "0.
|
|
9
|
+
__version__ = "0.6.0"
|
|
10
10
|
|
|
11
11
|
__all__ = [
|
|
12
12
|
"Lattice", "System", "Plot", "Propagation", "Save", "KSpace",
|
|
@@ -47,3 +47,15 @@ from tbkit.bdg import GapResult, s_wave_gap
|
|
|
47
47
|
__all__ += ["NonCollinearResult", "hubbard_mean_field_noncollinear", "GapResult", "s_wave_gap"]
|
|
48
48
|
from tbkit.transport import RecursiveTransport
|
|
49
49
|
__all__ += ["RecursiveTransport"]
|
|
50
|
+
# Real-space and 3D topological diagnostics
|
|
51
|
+
from tbkit.topology import WeylPoints, find_weyl_points, bott_index
|
|
52
|
+
__all__ += ["WeylPoints", "find_weyl_points", "bott_index"]
|
|
53
|
+
# Analysis and plotting: standard k-paths
|
|
54
|
+
from tbkit.kspace import high_symmetry_path, cubic_path
|
|
55
|
+
__all__ += ["high_symmetry_path", "cubic_path"]
|
|
56
|
+
# Continuum (k.p) models discretized on a grid; sympy is imported on first use
|
|
57
|
+
from tbkit.continuum import discretize, discretize_symbolic
|
|
58
|
+
__all__ += ["discretize", "discretize_symbolic"]
|
|
59
|
+
# Wannier functions: projection and maximal localization
|
|
60
|
+
from tbkit.wannier import WannierFunctions, wannierize
|
|
61
|
+
__all__ += ["WannierFunctions", "wannierize"]
|