Converting second quantized operators to matrix form and back
Project description
Second Quantization
A Python package for seamless conversion between symbolic second-quantized operators and their numerical matrix representations.
Features
- Symbolic to Matrix: Convert fermionic operators (creation/annihilation) to matrix form using Jordan-Wigner transformation
- Matrix to Symbolic: Decompose matrices back into fermionic operator expressions
- Efficient: Supports both dense and sparse matrix representations for large Hilbert spaces
- Flexible: Handle parameterized Hamiltonians with symbolic coefficients
- Fast Parameter Sweeps: Reuse basis operators for different parameter values
Installation
pip install second-quantization
Quick Start
import sympy
from sympy.physics.quantum.fermion import FermionOp
from sympy.physics.quantum import Dagger
from second_quantization import hilbert_space
# Define fermionic operators
c, d = [FermionOp(name) for name in "cd"]
# Create a simple Hamiltonian: t(c†d + d†c) + U c†c d†d
t, U = sympy.symbols("t U", real=True)
H = t * (Dagger(c) * d + Dagger(d) * c) + U * Dagger(c) * c * Dagger(d) * d
# Convert to matrix representation
matrix_dict = hilbert_space.to_matrix(H, operators=[c, d], sparse=False)
# Create a callable function for parameter sweeps
hamiltonian_func = hilbert_space.make_dict_callable(matrix_dict)
# Generate Hamiltonian for specific parameter values
H_matrix = hamiltonian_func(t=1.0, U=2.5)
Documentation
Full documentation with tutorials and API reference is available at: https://qt.pages.quantumtinkerer.group/second_quantization/
Use Cases
- Quantum Many-Body Physics: Study interacting fermion systems
- Quantum Chemistry: Molecular Hamiltonians and electronic structure
- Condensed Matter: Hubbard models, topological systems, quantum dots
- Quantum Computing: Variational quantum algorithms, QAOA
- Education: Learn fermionic second quantization interactively
Core Functions
hilbert_space.to_matrix()
Convert symbolic fermionic expressions to matrix form using Jordan-Wigner transformation.
hilbert_space.make_dict_callable()
Create efficient callable functions from symbolic Hamiltonians for parameter sweeps.
hilbert_space.to_operators()
Decompose matrices back into symbolic fermionic operator expressions.
hilbert_space.basis_operators()
Generate basis for fermionic Hilbert spaces.
Requirements
- Python ≥ 3.11
- NumPy ≥ 2.0
- SciPy ≥ 1.8
- SymPy ≥ 1.13
Contributing
Contributions are welcome! Please see our repository for development setup and contribution guidelines.
License
BSD 3-Clause License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
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 second_quantization-0.1.0.tar.gz.
File metadata
- Download URL: second_quantization-0.1.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbc70cd59aae7e7d6d60665cda8ba23f552c56c8f30784f55498243859601b99
|
|
| MD5 |
0b09ac91f0a187b42c12657bfd5146d4
|
|
| BLAKE2b-256 |
044f7fffbd1efa15fbfaf838422ac2d918ea9708e1173b43deea2608c6674573
|
File details
Details for the file second_quantization-0.1.0-py3-none-any.whl.
File metadata
- Download URL: second_quantization-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9235dbfc789ad259724ef929e59d72bae40dda19bafcbbc6353389da3ad60bd
|
|
| MD5 |
9f08f8b44bf88a7cfd46ec884e30d26a
|
|
| BLAKE2b-256 |
62b05b21331e104bd12edefddf0802841770027c20f1a24696784ba58bd86f9f
|