A test-driven tensor network playground for finite-size DMRG and MPS/MPO algorithms
Project description
quantum-simulation-lab
A small, test-driven tensor network playground focused on finite-size DMRG and MPS/MPO algorithms for 1D quantum lattice models. Designed for clarity and correctness first, with a strict pytest workflow and cross-checks against iTensor.
Features
- Core tensor network primitives
Tensor,Index,MPS,MPO,TruncationPolicy, and utility routines for expectation values and environments.
- Hamiltonian builders
- Transverse-field Ising model (TFIM).
- XXZ Heisenberg model (via
heisenberg_mpoand XX wrappers). - Random field models in X and Z, ZZ+Z examples.
- Finite-size 2-site DMRG
- Mixed-canonical MPS, left/right environments, and two-site effective Hamiltonians.
- Incremental environment updates and correct gauge fixing per sweep direction.
- Tested on TFIM, Heisenberg, random Z-field, random X-field, and ZZ+Z models.
- Examples and tests
- Example scripts under
examples/with convergence CSVs and plots. - 300+ pytest tests, including dense-reference checks and regression tests for DMRG.
- Example scripts under
Planned (not in v1):
- TEBD and iTEBD (v2).
- Fermionic and higher-spin local Hilbert spaces.
- 2D geometries via 1D mappings and swap gates (v3).
Installation
From source:
git clone https://github.com/szmbthydmnk/quantum-simulation-lab.git
cd quantum-simulation-lab
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install --upgrade pip
pip install -e .
This installs quantum-simulation-lab in editable mode along with its core dependencies (numpy, scipy, pytest, matplotlib).[cite:215]
Quickstart: ground state of TFIM with DMRG
import numpy as np
from tensor_network_library.core.env import Environment
from tensor_network_library.core.mps import MPS
from tensor_network_library.core.policy import TruncationPolicy
from tensor_network_library.core.utils import expectation_value_env
from tensor_network_library.algorithms.dmrg import finite_dmrg, DMRGConfig
from tensor_network_library.hamiltonian.models import tfim_mpo
# System parameters
L = 10
J = 1.0
g = 1.0
# Build environment and Hamiltonian
env = Environment.qubit_chain(L=L, chi_max=32)
mpo = tfim_mpo(L=L, J=J, g=g)
# Initial random MPS
rng = np.random.default_rng(0)
psi = rng.standard_normal(2**L) + 1j * rng.standard_normal(2**L)
psi /= np.linalg.norm(psi)
mps0 = MPS.from_statevector(psi, physical_dims=2, normalize=True)
# DMRG configuration
trunc = TruncationPolicy(max_bond_dim=32)
config = DMRGConfig(max_sweeps=10, energy_tol=1e-10, verbose=True)
result = finite_dmrg(env, mpo, mps0, config)
E0 = result.energies[-1]
print(f"Ground-state energy: {E0:.12f}")
See examples/ for more complete scripts (e.g. random field models and convergence plots).
Running tests and linting
Run the full test suite:
pytest
The GitHub Actions CI runs pytest on each push and pull request targeting main and keeps the “Lines of code” badge below up to date.[cite:209][cite:210]
Roadmap
High-level plan:
- v1 – Finite-size DMRG:
- Robust 2-site DMRG for qubit and spin-1/2 bosonic chains.
- Canonical forms, incremental environments, dense-reference tests, and iTensor cross-checks.
- v2 – TEBD / iTEBD:
- Real and imaginary time evolution on finite and infinite chains.
- Fermionic and higher-spin site types.
- v3 – 2D via 1D mappings:
- Support 2D geometries mapped to 1D chains via swap networks and long-range MPOs.
See ROADMAP.md and DIARY.md for more detailed development notes.[cite:202]
Lines of code
Last updated automatically by CI:
5112
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
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 quantum_simulation_lab-0.1.0.tar.gz.
File metadata
- Download URL: quantum_simulation_lab-0.1.0.tar.gz
- Upload date:
- Size: 284.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b6f21fefca684d4606f0840c1ca6cb4ed897a6bd21945d55e99f8a93b97e217
|
|
| MD5 |
cc54100761d3c36c468623d600562907
|
|
| BLAKE2b-256 |
b25f7ed00f59b1d19f6c2e380e09db7b3215260118685f2e61b1190cd37305bf
|
Provenance
The following attestation bundles were made for quantum_simulation_lab-0.1.0.tar.gz:
Publisher:
publish.yml on szmbthydmnk/quantum-simulation-lab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quantum_simulation_lab-0.1.0.tar.gz -
Subject digest:
1b6f21fefca684d4606f0840c1ca6cb4ed897a6bd21945d55e99f8a93b97e217 - Sigstore transparency entry: 1203539270
- Sigstore integration time:
-
Permalink:
szmbthydmnk/quantum-simulation-lab@9ca2fb96ae066d26638f0f2de7f54518cee48428 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/szmbthydmnk
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9ca2fb96ae066d26638f0f2de7f54518cee48428 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quantum_simulation_lab-0.1.0-py3-none-any.whl.
File metadata
- Download URL: quantum_simulation_lab-0.1.0-py3-none-any.whl
- Upload date:
- Size: 44.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3122db0d01b154d111581a80b89d7dbcf61509f19b84411f9a47cf227e302eaf
|
|
| MD5 |
79c7ba266cfcc70858e172194f8a7c75
|
|
| BLAKE2b-256 |
c3b4c81cf02f071e989e7056131dacb9ac3dc681c52800cd2e6cc139529e178d
|
Provenance
The following attestation bundles were made for quantum_simulation_lab-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on szmbthydmnk/quantum-simulation-lab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quantum_simulation_lab-0.1.0-py3-none-any.whl -
Subject digest:
3122db0d01b154d111581a80b89d7dbcf61509f19b84411f9a47cf227e302eaf - Sigstore transparency entry: 1203539277
- Sigstore integration time:
-
Permalink:
szmbthydmnk/quantum-simulation-lab@9ca2fb96ae066d26638f0f2de7f54518cee48428 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/szmbthydmnk
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9ca2fb96ae066d26638f0f2de7f54518cee48428 -
Trigger Event:
push
-
Statement type: