Skip to main content

EDinPy

CI Docs Python License

EDinPy is a Python package for exact diagonalization of finite quantum many-body systems in Fock space. Its central aim is to keep numerical calculations close to the second-quantized algebra used to define the physics.

Fermionic and bosonic calculations can define labeled modes, construct finite particle-number sectors, write Hamiltonians and observables from literal creation-annihilation algebra or standard helper functions, solve finite eigensystems, and evaluate observables with basis-aware states. Sparse matrices and matrix-free execution are available when the represented Hilbert space grows beyond dense linear algebra.

EDinPy is suited to finite-cluster studies, interacting few-body and lattice problems, checks of analytical limits, teaching, and benchmarks for approximate many-body methods. Practical system size remains controlled by the growth of the many-body Hilbert space.

Documentation: quantumartificer.github.io/edinpy

Installation

Install EDinPy from source:

git clone https://github.com/QuantumArtificer/edinpy.git
cd edinpy
python -m pip install -e .

Optional Numba execution is available with

python -m pip install -e ".[numba]"

For development, install the test, documentation, and release tools as well:

python -m pip install -e ".[test,docs,dev]"

EDinPy requires Python 3.10 or newer, NumPy, and SciPy.

A first calculation

The half-filled two-site Hubbard model is small enough to inspect directly and already contains hopping, local interactions, correlated eigenstates, and spin physics:

$$ H=-t\sum_\sigma\left(c_{0\sigma}^\dagger c_{1\sigma}+c_{1\sigma}^\dagger c_{0\sigma}\right) +U\sum_i n_{i\uparrow}n_{i\downarrow}. $$

from edinpy import fermion as edf

L = 2
UP, DOWN = 0, 1
t = 1.0
U = 4.0

site = edf.DoF(L, name="site")
spin = edf.DoF(2, name="spin", labels=("up", "down"))
modes = edf.FermionModes(site, spin)
sector = edf.NParticleSector(modes, N=2).build()

c = edf.set_notation(edf.Annihilation, modes)
cd = edf.set_notation(edf.Creation, modes)
n = edf.set_notation(edf.Number, modes)

H = 0
for sigma in (UP, DOWN):
    hop = cd(0, sigma) * c(1, sigma)
    H += -t * (hop + hop.dag)

for i in range(L):
    H += U * n(i, UP) * n(i, DOWN)

hamiltonian = edf.Hamiltonian(H, sector)
energies, _ = hamiltonian.eigsolve(k=None)
psi0 = hamiltonian.eigenstate(0)

D = sum(
    (n(i, UP) * n(i, DOWN) for i in range(L)),
    start=0,
)

print(energies)
print(psi0.dag * D * psi0)
[-0.82842712  0.          0.          0.          4.          4.82842712]
0.1464466094067262

The operator expression remains readable throughout the calculation, and the same literal algebra is available for custom observables. Standard constructors such as Hopping, Hubbard, and HeisenbergExchange provide compact forms for common physical terms.

Fermions and bosons

The two particle statistics are exposed through separate namespaces:

from edinpy import fermion as edf
from edinpy import boson as edb

Fermionic modes obey the occupation constraint $n_i\in{0,1}$ and canonical anticommutation relations. Bosonic modes admit multiple occupation and obey canonical commutation relations. Both interfaces use the same broad workflow from mode definition and sector construction through diagonalization and observable evaluation.

Core workflow

  1. Define the one-particle labels with DoF and FermionModes or BosonModes.
  2. Build the fixed-particle-number sector with NParticleSector, adding symmetry constraints for separately conserved mode populations when appropriate.
  3. Construct Hamiltonians and observables from primitive operators, literal sums and products, or standard helper functions.
  4. Use Hamiltonian to obtain sparse or matrix-free numerical action and solve the required eigenpairs.
  5. Recover basis-aware states and evaluate expectation values or custom correlation functions directly from the operator algebra.

Performance depends on basis dimension, operator structure, sparsity, requested eigenpairs, and hardware. Reproducible benchmark entry points are listed in benchmarks/README.md.

Documentation

Executable examples are split between examples/fermion/ and examples/boson/.

Testing and development

Run the test suite with

python -m pytest

Build the documentation with warnings treated as errors:

python -m sphinx -W --keep-going -b html docs/source docs/_build/html

Release and contribution notes are in the development documentation.

Citation and provenance

If EDinPy contributes to published work, cite the archived software release used in the calculation. CITATION.cff contains the package citation metadata. PROVENANCE.md records algorithmic sources and numerical-library references used by the implementation.

Scientific references used in the documentation are collected on the references page.

License

EDinPy is distributed under the MIT License.

Metadata

Release files for edinpy 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for edinpy 0.3.0
File Size Uploaded
edinpy-0.3.0.tar.gz 96.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for edinpy 0.3.0
File Interpreter ABI Platform
edinpy-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 199.9 kB

Release files / edinpy-0.3.0.tar.gz

Download URL edinpy-0.3.0.tar.gz
Size 96.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0ebd906a275da01cfcc0ca838494d890ea51e5663c92e9af5ee6bbe23030338c
BLAKE2b-256 checksum
How to use checksums
03f5369bff0f179a75946442df030a501af535ec83b65300ecc896b1e86d6c05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / edinpy-0.3.0-py3-none-any.whl

Download URL edinpy-0.3.0-py3-none-any.whl
Size 103.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5373735fbf7185559641f44bde912d40ee89b8a045f7e98d410463b9ab53086b
BLAKE2b-256 checksum
How to use checksums
3225b3b161e5c8ca7033af21353c77ce6f5501b4f3c3e8dd0aad4d265ac887ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page