qlinks
qlinks is a Python package for building constrained lattice Hamiltonians and studying their Fock-space structure. It is mainly designed for exact diagonalization workflows in quantum link models, quantum dimer models, constrained spin models, and related lattice systems.
Features
- Constraint-aware basis construction
- Sparse Hamiltonian construction with
scipy.sparse - Geometry-aware lattice support for square, triangular, and honeycomb lattices
- Topological / winding-sector workflows where available
- Fock-space graph visualization
- Interference-cage search utilities
- HDF5-oriented workflows for large sweeps
[!NOTE] The current
mainbranch contains the lattice-abstraction refactor formerly developed on theabstract_latticebranch.
Installation
Install from PyPI:
pip install qlinks
Install from source:
poetry install --all-extras
Docker image:
docker pull tanlin2013/qlinks:main
Quick start
The typical workflow is:
- build a lattice model,
- construct the constrained basis and Hamiltonian,
- search for interference cages,
- visualize the cage in real space and in the Hamiltonian graph.
[!WARNING] The exact public API is still evolving, so treat this section as the intended high-level workflow.
1. Build a model and Hamiltonian
from qlinks.models import SquareQDMModel
model = SquareQDMModel(
lx=4,
ly=4,
boundary_condition="periodic",
winding_x=0,
winding_y=0,
coup_kin=1.0,
coup_pot=1.0,
)
build_result = model.build(
basis_solver="dfs",
builder="sparse",
backend="scipy",
sort_basis=True,
on_missing="raise",
)
H = build_result.hamiltonian
K = build_result.kinetic
V = build_result.potential
basis = build_result.basis
H is the full Hamiltonian, K is the kinetic/off-diagonal term, and V is the potential/diagonal term when the model provides one.
2. Run a cage search
from qlinks.caging import CageSearchConfig, CageSearcher
config = CageSearchConfig(
search_type="type1",
type1_kappas=(0,),
tolerance=1e-10,
degenerate_basis_strategy="ipr",
ipr_n_restarts=256,
ipr_candidate_count=128,
ipr_random_seed=1234,
)
searcher = CageSearcher.from_model_build_result(
build_result,
config=config,
)
search_result = searcher.run()
print(search_result.counts_by_signature)
{(0, 4): 12, (0, 6): 9}
A cage result is expected to contain the participating basis-state indices, the restricted eigenvector, and useful metadata such as kinetic/potential quantum numbers when available.
3. Plot basis states in a cage
from qlinks.visualizer import BasisGridVisualizer
signature = (0, 4)
record_index = 0
grid_visualizer = BasisGridVisualizer(
lattice=model.lattice,
layout=model.layout,
periodic_image_mode="positive_patch",
)
grid_visualizer.plot_cage_support(
search_result,
basis_configs=basis.states,
signature=signature,
record_index=record_index,
ncols=4,
show_config_label=False,
)
4. Plot the cage on the Hamiltonian graph
from qlinks.visualizer import HamiltonianGraphVisualizer, HamiltonianGraphStyle
# Lazy indexing by [signature, record_index]
record = search_result[signature, record_index]
graph_visualizer = HamiltonianGraphVisualizer.from_sparse_matrix(
K,
include_self_loops=False,
style=HamiltonianGraphStyle(
cmap="coolwarm",
label_vertices=True,
),
)
graph_visualizer.plot(
backend="igraph-mpl",
color_by="state_amplitude_real",
state_vector=record.full_state,
layout="kk",
)
Testing
Run the test suite:
pytest
Run manual visual tests:
QLINKS_SHOW_PLOTS=1 pytest
Run pre-commit checks:
pre-commit run --all-files
Notes on models
- Square-lattice QLM with staggered background charges is closely related to the square-lattice QDM.
- Honeycomb QLM usually requires nonzero background charges to obtain a nonempty constrained Hilbert space.
- Winding and topological sector labels are geometry-dependent and should be interpreted with the convention used by each model.
Documentation
The documentation is hosted on GitHub Pages:
https://tanlin2013.github.io/qlinks/
[!WARNING] This documentation is currently outdated and unmaintained.
References
-
T.-L. Tan and Y.-P. Huang, Interference-caged quantum many-body scars: the fock space topological localization and interference zeros, arXiv preprint arXiv:2504.07780 (2025).
-
T. Ben-Ami, M. Heyl, and R. Moessner, Many-body cages: disorder-free glassiness from flat bands in fock space, and many-body rabi oscillations, arXiv preprint arXiv:2504.13086 (2025).
-
E. Nicolau, M. Ljubotina, and M. Serbyn, Fragmentation, zero modes, and collective bound states in constrained models, arXiv preprint arXiv:2504.17627 (2025).
-
C. Jonay and F. Pollmann, Localized fock space cages in kinetically constrained models, arXiv preprint arXiv:2504.20987 (2025).
License
© Tan Tao-Lin, 2023-2026. Licensed under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qlinks-1.0.3.tar.gz.
File metadata
- Download URL: qlinks-1.0.3.tar.gz
- Upload date:
- Size: 321.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8aa0dc2c00a35d4bf8ce79644aaeb62b4847c795915be0dce0147ec77b57898
|
|
| MD5 |
379846b1b485aa592dadd1cd65bfa4e4
|
|
| BLAKE2b-256 |
2d4321abcee63823d56e35ffb555c3b860223edc8a4249d1c442665f0c7c60a9
|
Provenance
The following attestation bundles were made for qlinks-1.0.3.tar.gz:
Publisher:
release.yml on tanlin2013/qlinks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qlinks-1.0.3.tar.gz -
Subject digest:
d8aa0dc2c00a35d4bf8ce79644aaeb62b4847c795915be0dce0147ec77b57898 - Sigstore transparency entry: 1947657413
- Sigstore integration time:
-
Permalink:
tanlin2013/qlinks@02c342831a2ae821af33e2babc24c8a7032aedca -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/tanlin2013
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@02c342831a2ae821af33e2babc24c8a7032aedca -
Trigger Event:
push
-
Statement type:
File details
Details for the file qlinks-1.0.3-py3-none-any.whl.
File metadata
- Download URL: qlinks-1.0.3-py3-none-any.whl
- Upload date:
- Size: 383.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1350f0c3fb3f3f1acdacebdbd7d9878c1e2e22cc8b9efef36108f433df6a9eb9
|
|
| MD5 |
1773c455ba4910f81514079eb3e7efb0
|
|
| BLAKE2b-256 |
21dce947fc574246fdccc4b3465c6fe3a145a6ae131bcf4e10a44203fc2fe397
|
Provenance
The following attestation bundles were made for qlinks-1.0.3-py3-none-any.whl:
Publisher:
release.yml on tanlin2013/qlinks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qlinks-1.0.3-py3-none-any.whl -
Subject digest:
1350f0c3fb3f3f1acdacebdbd7d9878c1e2e22cc8b9efef36108f433df6a9eb9 - Sigstore transparency entry: 1947657569
- Sigstore integration time:
-
Permalink:
tanlin2013/qlinks@02c342831a2ae821af33e2babc24c8a7032aedca -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/tanlin2013
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@02c342831a2ae821af33e2babc24c8a7032aedca -
Trigger Event:
push
-
Statement type: