Skip to main content

Small dense quantum lattice Hamiltonians for exact diagonalization and quantum algorithm prototypes.

Project description

Quantum Lattice Models

PyPI Version Python Versions Tests Docs License Sponsor

Quantum Lattice Models is a lightweight, package-first Python library for constructing, analyzing, plotting, and exporting small lattice Hamiltonians used in physics workflows and quantum algorithm research prototypes.

PyPI: https://pypi.org/project/quantum-lattice-models/

This repository is organized as an installable package first. The real logic lives in src/quantum_lattice_models/; notebooks, scripts, and examples should stay thin and import the public package API. quantum_lattice_models.models remains the compatibility import surface, while implementations are split across focused modules such as spin, tight_binding, hubbard, and topological.

Implemented Models

  • Transverse-field Ising spin chain
  • Longitudinal-field Ising spin chain
  • Next-nearest-neighbor Ising spin chain
  • Anisotropic Heisenberg spin chain
  • XY spin chain
  • XXZ spin chain
  • Frustrated J1-J2 Heisenberg spin chain
  • Two-leg Heisenberg spin ladder
  • Truncated Bose-Hubbard chain
  • Spinful Fermi-Hubbard chain
  • Kitaev-chain Bogoliubov-de Gennes matrix
  • Su-Schrieffer-Heeger single-particle tight-binding model
  • Rice-Mele single-particle chain
  • Generic one-dimensional single-particle tight-binding chain
  • Square-lattice single-particle tight-binding model
  • Harper-Hofstadter square-lattice model
  • Aubry-Andre-Harper quasiperiodic tight-binding chain
  • Haldane honeycomb-lattice model
  • Triangular-lattice single-particle tight-binding model
  • Kagome-lattice single-particle tight-binding model

Spin-chain Hamiltonians are dense qubit-space matrices Tight-binding Hamiltonians are single-particle matrices. This distinction is intentional and explicit.

Why Lattice Models Matter

Small lattice Hamiltonians are useful because they are concrete, inspectable testbeds. They connect physics intuition to numerical linear algebra, and they give quantum algorithm researchers controlled problems for VQE, QPE, QSVT, spectral transforms, quantum walks, and simulation workflows.

This package does not claim quantum advantage. It provides honest small-system tools for exact diagonalization, prototyping, teaching, and notebook-first experiments.

Installation

From a local checkout:

python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

Minimal runtime dependencies are numpy, scipy, and matplotlib.

PennyLane export is optional:

pip install -e ".[pennylane]"

Notebook support is optional:

python -m pip install -e ".[notebooks]"
python -m ipykernel install --user --name quantum-lattice-models --display-name "Quantum Lattice Models"

Quickstart

from quantum_lattice_models.models import transverse_field_ising
from quantum_lattice_models.spectra import ground_energy, spectral_gap

H = transverse_field_ising(n_sites=4, j=1.0, h=0.5, periodic=False)

print(H.shape)
print(ground_energy(H))
print(spectral_gap(H))
from quantum_lattice_models.models import ssh_model, ssh_edge_state_localizations
from quantum_lattice_models.spectra import eigensystem

H = ssh_model(n_cells=8, t1=0.5, t2=1.0, periodic=False)
values, vectors = eigensystem(H)
weights = ssh_edge_state_localizations(vectors, n_cells=8, edge_cells=2)

Repository Structure

src/quantum_lattice_models/  Package source
tests/                       Pytest test suite
examples/                    Command-line examples that save plots
notebooks/                   Thin-client exploratory notebooks
README.md                    Project overview
CHANGELOG.md                 Release notes
USAGE.md                     API examples
THEORY.md                    Model and method notes
RESULTS.md                   Generated results

Key package modules:

spin.py                      Dense spin-chain and ladder builders
tight_binding.py             Single-particle tight-binding builders
hubbard.py                   Bose-Hubbard and Fermi-Hubbard builders
topological.py               Haldane, Hofstadter, and Kitaev builders
geometry.py                  Coordinate helpers for plotting
registry.py                  Structured model metadata
cli.py                       quantum-lattice command-line entry point
models.py                    Backwards-compatible re-export layer

Notebooks as Thin Clients

Notebooks should import from quantum_lattice_models rather than defining their own model logic. A notebook can choose parameters, run spectra, plot results, and tell a story. The package should remain the source of truth.

Current notebooks:

  • notebooks/ising_spin_chains.ipynb
  • notebooks/ssh_rice_mele_comparison.ipynb
  • notebooks/hofstadter_flux_sweep.ipynb
  • notebooks/hubbard_exact_diagonalization.ipynb
  • notebooks/haldane_kagome_lattices.ipynb
  • notebooks/model_registry_and_cli.ipynb
  • notebooks/kitaev_bdg_symmetry.ipynb
  • notebooks/heisenberg_ladder_spectrum.ipynb
  • notebooks/sparse_dense_scaling.ipynb
  • notebooks/cli_plot_walkthrough.ipynb

Development

Use the virtual environment for examples, notebooks, tests, and packaging commands. The standard local checks are:

make format
make lint
make test

The Makefile runs Black one file at a time to avoid multi-file formatter stalls observed in some Codespace environments.

Limitations / Truth Contract

  • Dense spin-chain matrices scale as 2**n_sites by 2**n_sites.
  • These tools are for small systems, education, exact diagonalization, and research prototypes.
  • SSH, Rice-Mele, square, Harper-Hofstadter, Haldane, triangular, kagome, and generic tight-binding builders return single-particle matrices, not many-body Fock-space Hamiltonians.
  • The Bose-Hubbard builder uses a truncated local occupation basis.
  • The Fermi-Hubbard builder uses a dense occupation-number basis with explicit fermionic signs.
  • The Kitaev-chain builder returns a Bogoliubov-de Gennes matrix, not a many-body Hamiltonian.
  • Sparse builders are available for selected tight-binding and Hubbard chains, but exact diagonalization remains a small-system workflow.
  • PennyLane is optional and only used when explicitly installed.
  • The project is a backend for experiments, not a benchmark suite proving speedup or quantum advantage.

Support development

If this repository is useful for research, learning, or experimentation, you can support continued development via GitHub Sponsors:

https://github.com/sponsors/SidRichardsQuantum

Sponsorship helps support ongoing work on open-source implementations of quantum algorithms, including improvements to documentation, reproducible workflows, and example notebooks.

Support helps maintain and expand practical tooling for variational quantum methods, quantum simulation workflows, and related experimentation.

Citation

Sid Richards (2026)

Unified Variational and Phase-Estimation Quantum Simulation Suite

Author

Sid Richards

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quantum_lattice_models-0.1.1.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantum_lattice_models-0.1.1-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file quantum_lattice_models-0.1.1.tar.gz.

File metadata

  • Download URL: quantum_lattice_models-0.1.1.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for quantum_lattice_models-0.1.1.tar.gz
Algorithm Hash digest
SHA256 950b8fc03ee5b047e0c3d225d4df88136869d93b8d3d00ad7722e08304323e44
MD5 3de73fd6aa50237d31756db39eb31872
BLAKE2b-256 3d1194563546a58b0d3ddac3d22f12443a8b1888fe91ea52e696e364fbd774ad

See more details on using hashes here.

File details

Details for the file quantum_lattice_models-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for quantum_lattice_models-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6dc396564d1c9f095aa5bb7689f32acba4d5b812baef39f3e20f79a63ce3a6e9
MD5 300f073d50c41d152843ebceccf41d8f
BLAKE2b-256 02d8a05c75bba68e0463dba47fd6b50af69a9291ff20877fd8f55523dae271f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page