Skip to content

Commit 02e74dc

Browse files
committed
feat: Add Gauss-Laguerre and Hankel backends for exchange kernels, form factor calculations, and related tests/examples.
0 parents  commit 02e74dc

29 files changed

Lines changed: 1125 additions & 0 deletions

.coverage

52 KB
Binary file not shown.

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"python-envs.defaultEnvManager": "ms-python.python:conda",
3+
"python-envs.defaultPackageManager": "ms-python.python:conda",
4+
"python-envs.pythonProjects": []
5+
}

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Tobias Wolf
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# quantumhall_matrixelements
2+
3+
Landau-level plane-wave form factors and exchange kernels for quantum Hall systems.
4+
5+
This library factors out the continuum matrix-element kernels used in Hartree–Fock and
6+
related calculations into a small, reusable package. It provides:
7+
8+
- Analytic Landau-level plane-wave form factors $F_{n',n}(\mathbf{q})$.
9+
- Exchange kernels $X_{n_1 m_1 n_2 m_2}(\mathbf{G})$ computed via:
10+
- Generalized Gauss–Laguerre quadrature (`gausslag` backend).
11+
- Hankel-transform based integration (`hankel` backend).
12+
- Symmetry diagnostics for verifying kernel implementations on a given G-grid.
13+
14+
## Mathematical Definitions
15+
16+
### Plane-Wave Form Factors
17+
18+
The form factors are the matrix elements of the plane-wave operator $e^{i \mathbf{q} \cdot \mathbf{R}}$ in the Landau level basis $|n\rangle$:
19+
20+
$$ F_{n',n}(\mathbf{q}) = \langle n' | e^{i \mathbf{q} \cdot \mathbf{R}} | n \rangle $$
21+
22+
Analytically, these are given by:
23+
24+
$$ F_{n',n}(\mathbf{q}) = i^{|n-n'|} e^{i(n-n')\theta_\mathbf{q}} \sqrt{\frac{n_<!}{n_>!}} \left( \frac{|\mathbf{q}|\ell_B}{\sqrt{2}} \right)^{|n-n'|} L_{n_<}^{|n-n'|}\left( \frac{|\mathbf{q}|^2\ell_B^2}{2} \right) e^{-|\mathbf{q}|^2\ell_B^2/4} $$
25+
26+
where $n_< = \min(n, n')$, $n_> = \max(n, n')$, and $L_n^\alpha$ are the generalized Laguerre polynomials, and $\ell_B$ is the magnetic length.
27+
28+
### Exchange Kernels
29+
30+
The exchange kernels $X_{n_1 m_1 n_2 m_2}(\mathbf{G})$ are defined as the Fourier transform of the interaction potential weighted by the form factors:
31+
32+
$$ X_{n_1 m_1 n_2 m_2}(\mathbf{G}) = \int \frac{d^2 q}{(2\pi)^2} V(q) F_{n_1, m_1}(\mathbf{q}) F_{m_2, n_2}(-\mathbf{q}) e^{-i \mathbf{q} \cdot \mathbf{G} \ell_B^2} $$
33+
34+
where $V(q)$ is the interaction potential. For the Coulomb interaction, $V(q) = \frac{2\pi e^2}{\epsilon q}$.
35+
36+
### Units and Interaction Strength
37+
38+
The package performs calculations in dimensionless units where lengths are scaled by $\ell_B$. The interaction strength is parameterized by a dimensionless prefactor $\kappa$.
39+
40+
- **Coulomb Interaction**: The code assumes a potential of the form $V(q) = \kappa \frac{2\pi \ell_B}{q \ell_B}$ (in effective dimensionless form).
41+
- If you set `kappa = 1.0`, the resulting exchange kernels will be in units of the **Coulomb energy scale** $E_C = e^2 / (\epsilon \ell_B)$.
42+
- If you want the results in units of the cyclotron energy $\hbar \omega_c$, you should set $\kappa = E_C / (\hbar \omega_c) = (e^2/\epsilon \ell_B) / (\hbar \omega_c)$.
43+
44+
- **General Potential**: For a general $V(q)$, the function `V_of_q` should return values in your desired energy units. The integration measure $d^2q/(2\pi)^2$ introduces a factor of $1/\ell_B^2$, so ensure your potential scaling is consistent.
45+
46+
## Installation
47+
48+
From a local checkout:
49+
50+
```bash
51+
pip install -e .[dev]
52+
```
53+
54+
## Basic usage
55+
56+
```python
57+
import numpy as np
58+
from quantumhall_matrixelements import (
59+
get_form_factors,
60+
get_exchange_kernels,
61+
)
62+
63+
# Simple G set: G0=(0,0), G+=(1,0), G-=(-1,0)
64+
Gs_dimless = np.array([0.0, 1.0, 1.0])
65+
thetas = np.array([0.0, 0.0, np.pi])
66+
nmax = 2
67+
68+
F = get_form_factors(Gs_dimless, thetas, nmax) # shape (nG, nmax, nmax)
69+
X = get_exchange_kernels(Gs_dimless, thetas, nmax) # default 'gausslag' backend
70+
71+
print("F shape:", F.shape)
72+
print("X shape:", X.shape)
73+
```
74+
75+
For more detailed examples, see the tests under `tests/`.
76+
77+
## Development
78+
79+
- Run tests and coverage:
80+
81+
```bash
82+
pytest
83+
```
84+
85+
- Lint and type-check:
86+
87+
```bash
88+
ruff check .
89+
mypy .
90+
```
91+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""Compare Gauss–Laguerre and Hankel exchange-kernel backends.
2+
3+
For a small |G|ℓ_B grid and nmax=2, this script computes the exchange
4+
kernels using both the Gauss–Laguerre and Hankel backends and plots the
5+
relative difference of a representative diagonal element X_{0000}(G).
6+
"""
7+
from __future__ import annotations
8+
9+
import numpy as np
10+
import matplotlib.pyplot as plt
11+
12+
from quantumhall_matrixelements import get_exchange_kernels
13+
14+
15+
def main() -> None:
16+
nmax = 2
17+
q = np.linspace(0.2, 3.0, 60)
18+
theta = np.zeros_like(q)
19+
20+
X_gl = get_exchange_kernels(q, theta, nmax, method="gausslag")
21+
X_hk = get_exchange_kernels(q, theta, nmax, method="hankel")
22+
23+
# Focus on X_{0000}(G) as a simple representative component
24+
X_gl_diag = X_gl[:, 0, 0, 0, 0]
25+
X_hk_diag = X_hk[:, 0, 0, 0, 0]
26+
27+
abs_diff = np.abs(X_gl_diag - X_hk_diag)
28+
denom = np.maximum(np.abs(X_gl_diag), np.abs(X_hk_diag))
29+
rel_diff = np.where(denom > 0, abs_diff / denom, 0.0)
30+
31+
fig, ax = plt.subplots()
32+
ax.plot(q, rel_diff, marker="o", linestyle="-")
33+
ax.set_xlabel(r"$|G| \ell_B$")
34+
ax.set_ylabel(r"relative difference")
35+
ax.set_title(r"Relative difference of $X_{0000}(G)$: Gauss–Laguerre vs Hankel")
36+
ax.grid(True, alpha=0.3)
37+
fig.tight_layout()
38+
plt.show()
39+
40+
41+
if __name__ == "__main__":
42+
main()
43+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""Exchange kernel diagonal elements X_{nnnn}(G) vs |G|ℓ_B.
2+
3+
This example computes selected diagonal components of the exchange kernel
4+
using the Gauss–Laguerre backend and plots their real parts as a function
5+
of |G|ℓ_B.
6+
"""
7+
from __future__ import annotations
8+
9+
import numpy as np
10+
import matplotlib.pyplot as plt
11+
12+
from quantumhall_matrixelements import get_exchange_kernels
13+
14+
15+
def main() -> None:
16+
nmax = 3
17+
# Avoid G=0 to dodge the Coulomb singularity; start from small q
18+
q = np.linspace(0.2, 4.0, 80)
19+
theta = np.zeros_like(q)
20+
21+
X = get_exchange_kernels(q, theta, nmax, method="gausslag")
22+
23+
fig, ax = plt.subplots()
24+
for n in range(nmax):
25+
vals = X[:, n, n, n, n]
26+
ax.plot(q, vals.real, label=fr"$\mathrm{{Re}}\,X_{{{n}{n}{n}{n}}}(G)$")
27+
28+
for n in range(1,nmax):
29+
vals = X[:, n, n-1, n-1, n]
30+
ax.plot(q, vals.real, label=fr"$\mathrm{{Re}}\,X_{{{n}{n-1}{n-1}{n}}}(G)$")
31+
32+
ax.set_xlabel(r"$|G| \ell_B$")
33+
ax.set_ylabel(r"$\mathrm{Re}\,X_{nnnn}(G)$ (κ=1)")
34+
ax.set_title("Diagonal exchange kernels (Gauss–Laguerre backend)")
35+
ax.legend()
36+
ax.grid(True, alpha=0.3)
37+
fig.tight_layout()
38+
plt.show()
39+
40+
41+
if __name__ == "__main__":
42+
main()
43+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Radial Landau-level form factors F_{n',n}(q) vs qℓ_B.
2+
3+
This example plots the lowest diagonal LL form factors as a function of
4+
dimensionless momentum qℓ_B, illustrating the Gaussian envelope and
5+
Laguerre oscillations.
6+
"""
7+
from __future__ import annotations
8+
9+
import numpy as np
10+
import matplotlib.pyplot as plt
11+
12+
from quantumhall_matrixelements import get_form_factors
13+
14+
15+
def main() -> None:
16+
# Dimensionless |G|ℓ_B grid
17+
q = np.linspace(0.0, 5.0, 400)
18+
theta = np.zeros_like(q)
19+
nmax = 3
20+
21+
F = get_form_factors(q, theta, nmax) # shape (nq, nmax, nmax)
22+
23+
fig, ax = plt.subplots()
24+
for n in range(nmax):
25+
ax.plot(q, F[:, n, n].real, label=fr"$\mathrm{{Re}}\,F_{{{n}{n}}}(q)$")
26+
27+
ax.set_xlabel(r"$q \ell_B$")
28+
ax.set_ylabel(r"$\mathrm{Re}\,F_{nn}(q)$")
29+
ax.set_title("Diagonal Landau-level form factors")
30+
ax.legend()
31+
ax.grid(True, alpha=0.3)
32+
fig.tight_layout()
33+
plt.show()
34+
35+
36+
if __name__ == "__main__":
37+
main()
38+

pyproject.toml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[build-system]
2+
requires = ["setuptools>=69", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "quantumhall_matrixelements"
7+
version = "0.1.0"
8+
description = "Landau-level plane-wave form factors and exchange kernels for quantum Hall systems."
9+
readme = "README.md"
10+
authors = [
11+
{ name = "Tobias Wolf", email = "public@wolft.xyz" }
12+
]
13+
license = { text = "MIT" }
14+
requires-python = ">=3.10"
15+
keywords = ["quantum Hall", "matrix elements", "form factors", "exchange kernels", "Landau levels"]
16+
classifiers = [
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
"License :: OSI Approved :: MIT License",
22+
"Intended Audience :: Science/Research",
23+
"Topic :: Scientific/Engineering :: Physics"
24+
]
25+
dependencies = [
26+
"numpy>=1.26",
27+
"scipy>=1.11",
28+
"hankel>=1.2"
29+
]
30+
31+
[project.optional-dependencies]
32+
dev = [
33+
"pytest>=8.0",
34+
"pytest-cov>=5.0",
35+
"ruff>=0.5.0",
36+
"mypy>=1.10",
37+
"build",
38+
"twine"
39+
]
40+
41+
[project.urls]
42+
Homepage = "https://github.com/wolft/quantumhall_matrixelements"
43+
Issues = "https://github.com/wolft/quantumhall_matrixelements/issues"
44+
45+
[tool.setuptools.packages.find]
46+
where = ["src"]
47+
48+
[tool.ruff]
49+
line-length = 100
50+
select = ["E", "F", "I", "B", "UP", "SIM", "NPY", "PERF"]
51+
ignore = ["E203"]
52+
53+
[tool.ruff.isort]
54+
known-first-party = ["quantumhall_matrixelements"]
55+
56+
[tool.pytest.ini_options]
57+
minversion = "8.0"
58+
addopts = "-ra -q --cov=quantumhall_matrixelements --cov-report=term-missing"
59+
testpaths = ["tests"]
60+
61+
[tool.mypy]
62+
python_version = "3.10"
63+
strict = true
64+
ignore_missing_imports = true
65+
66+
[tool.coverage.run]
67+
branch = true
68+
source = ["quantumhall_matrixelements"]
69+

0 commit comments

Comments
 (0)