Qiskit Hamiltonian Simulation
Time evolution e^(-i t H / hbar) under potentials V(x) and kinetic energies T(p), given as qiu-signals signals, built on the phase circuits of qiu-quantum-computing.
Installation
pip install qiu-hamiltonian-simulation
Position and momentum domain
A potential acts diagonally on the position amplitudes. A kinetic energy acts diagonally on the momentum amplitudes, the orthonormal DFT numpy.fft.fft(psi, norm="ortho"), which is Qiskit's inverse QFT (time_independent.fourier). The momentum-domain evolutions thus apply the inverse QFT, the phase and the QFT, in this order.
The momentum signal must live on a Fourier domain axis (e.g. MomentumAxis or AngularWavenumberAxis) in the FFT ordering, whose sample k is the momentum of the Fourier basis state |k>. Other orderings, and signals on axes of the wrong domain, are rejected.
Evolutions
time_independent.direct, exact for quadratic signals f, i.e. e^(i f):
PositionDomainEvolutionQuadratic(f)forfon a position axis.MomentumDomainEvolutionQuadratic(f, fourier_method)forfon a momentum axis.
For the evolution under V or T over the time t, pass f = (-t / hbar) * V; scaling a QuadraticSignal keeps it quadratic.
time_independent.sample_based, for arbitrary real signals of one sign, sampled or algebraic:
PotentialEvolutionSampleBased(V, t, hbar, max_delta, state_preparation_method)KineticEvolutionSampleBased(T, t, hbar, max_delta, state_preparation_method, fourier_method)
Both apply e^(-i t V / hbar) or e^(-i t T / hbar) with the sample-based phase propagator, sliced into phases of at most max_delta, and expose its num_of_cycles.
All synthesis methods default to GATE, leaving the synthesis to Qiskit when transpiling; see the caveat on the state preparation in qiu-quantum-computing.
Usage
import numpy as np
from qiu_signals.algebraic_signal import QuadraticSignal
from qiu_signals.integer_axis import IndexOrdering
from qiu_signals.physical_axis import MomentumAxis, PositionAxis
from qiskit.quantum_info import Statevector
from qiu_hamiltonian_simulation.time_independent.direct import (
MomentumDomainEvolutionQuadratic,
)
x_axis = PositionAxis(size=16, delta_x=0.5, ordering=IndexOrdering.CENTERED)
p_axis = MomentumAxis.from_position_axis(x_axis, hbar=1.0) # FFT ordering
# free evolution of a particle of mass 1 over the time t = 0.2
t, mass = 0.2, 1.0
kinetic = QuadraticSignal(p_axis, alpha=1 / (2 * mass))
evolution = MomentumDomainEvolutionQuadratic((-t / 1.0) * kinetic)
psi = Statevector(
np.exp(-(x_axis.values**2)) / np.linalg.norm(np.exp(-(x_axis.values**2)))
)
out = psi.evolve(evolution)
expected = np.fft.ifft(
np.exp(-1j * t * kinetic.data) * np.fft.fft(psi.data, norm="ortho"), norm="ortho"
)
assert np.allclose(out.data, expected)
Examples
examples/free_space_double_slit.py: The paraxial diffraction of a double slit over 1 km, with the direct propagator on 10 qubits, checked against NumPy's FFT.
Documentation
The documentation, with the API reference from the docstrings, is built from docs/ with MkDocs and published at https://blackwild.github.io/qiu/qiu-hamiltonian-simulation/. To serve it locally, from the repository root:
uv run mkdocs serve -f packages/qiu-hamiltonian-simulation/mkdocs.yml
Tests
From the repository root:
uv run pytest packages/qiu-hamiltonian-simulation
Release files for qiu-hamiltonian-simulation 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qiu_hamiltonian_simulation-0.1.0.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qiu_hamiltonian_simulation-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.7 kB
Release files / qiu_hamiltonian_simulation-0.1.0.tar.gz
| Download URL | qiu_hamiltonian_simulation-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83c64d4fa289a57a01ba38575d252931a683e446ba39fa56c5326007259b27c3
|
|
BLAKE2b-256 checksum How to use checksums |
fe38bb89f75ed58c5f83fc2023e6e7d8ed3f388d89b7bd21d2aa5d564b31bc45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / qiu_hamiltonian_simulation-0.1.0-py3-none-any.whl
| Download URL | qiu_hamiltonian_simulation-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
000d6ded4667e961521163c2ab38032c4576c238b54d996e7d806c254284e2dc
|
|
BLAKE2b-256 checksum How to use checksums |
7fe17503aa47a91f79e5161b21839633ccced3c91838d0998c45c6696dddce87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|