PETAL2D
PETAL2D (Polar Expansion Toolkit for Atomic Orbitals and Localized Fields in 2D) decomposes localized two-dimensional real or complex scalar fields into polar angular harmonics while retaining their radial structure.
For a field written as
$$ f(r,\theta)=\sum_{m\in\mathbb Z}\rho_m(r)e^{im\theta}, $$
PETAL2D computes the radial profiles $\rho_m(r)$ and their polar-area-weighted powers
$$ P_m=\int_0^{r_{\max}} |\rho_m(r)|^2 r,dr. $$
The angular channels can then be ranked by power and used to construct controlled reconstructions. PETAL2D also reports the radial extent of retained channels, angular sampling limits, domain coverage, and reconstruction errors.
Installation
Install a development checkout with
git clone https://github.com/QuantumArtificer/petal2d.git
cd petal2d
python -m pip install -e .
For tests and documentation:
python -m pip install -e ".[test,docs]"
PETAL2D requires Python 3.10 or newer, NumPy 1.23 or newer, SciPy 1.9 or newer, and Matplotlib 3.6 or newer.
Quick start
import numpy as np
from petal2d import PolarDecomposition
x = np.linspace(-6.0, 6.0, 161)
y = np.linspace(-6.0, 6.0, 161)
def px(x, y):
return x * np.exp(-0.5 * (x**2 + y**2))
dec = PolarDecomposition(
px,
x,
y,
Nr=160,
Ntheta=256,
recon_err_tol=1e-8,
)
print(dec.selected_pairs)
print(dec.m_sorted.tolist())
print(f"{dec.domain_consistency:.8f}")
print(f"{dec.recon_error_measured:.6g}")
[(1, -1)]
[1, -1]
1.00000003
2.70394e-14
The real $p_x$-like field contains equal $m=+1$ and $m=-1$ components. PETAL2D keeps the conjugate pair together so that the adaptive reconstruction remains real.
The complete script is available in examples/px_orbital.py.
Inputs and outputs
PETAL2D accepts either an analytic callable or a two-dimensional array sampled on a uniform Cartesian grid.
The main decomposition provides:
- the complete discrete angular spectrum
- retained harmonics selected by a requested reconstruction error
- radial profiles $\rho_m(r)$
- angular power fractions
- measured and Parseval-predicted reconstruction errors
- conjugate-pair selection for real fields
domain_consistencyfor the analyzed polar disk- angular Nyquist information
- radial power-support and amplitude-support radii
cutoff_radiusas the stricter radial-extent diagnostic
Reconstruction can use the retained spectrum, the complete spectrum, or an explicit set of angular harmonics.
Applications
PETAL2D is intended for localized 2D fields whose angular structure is meaningful about a chosen center. Examples include:
- planar atomic and molecular orbitals
- Wannier and other localized crystal orbitals
- defect, impurity, and bound-state wavefunctions
- localized moiré states around high-symmetry regions
- complex order parameters and vortex states
- charge, probability, and scalar spin-density anisotropy
- excitonic relative-coordinate wavefunctions
- localized photonic, phononic, acoustic, and PDE eigenmodes
- angular descriptors of localized simulation or image data
For a complex wavefunction, the harmonic index $m$ labels the planar $L_z/\hbar$ sector about the chosen origin. For a density such as $|\psi|^2$, the same decomposition describes angular morphology and does not recover the phase removed by taking the modulus square.
PETAL2D is not a replacement for a Cartesian FFT, a three-dimensional spherical-harmonic expansion, a vector or tensor harmonic decomposition, or a crystallographic point-group analysis.
Documentation
The documentation is available at quantumartificer.github.io/petal2d.
Build the documentation locally with
python -m sphinx -W --keep-going -b html docs/source docs/_build/html
Validation and tests
Run the test suite with
python -m pytest -q
The numerical validation suite covers interpolation accuracy, radial convergence, angular sampling and aliasing, real-field Nyquist behavior, and adaptive truncation. The benchmark suite records runtime and peak-memory measurements separately from the validation studies.
Run the full validation and benchmark workflow with
./tools/run_full_validation_and_benchmarks.sh
See validation/README.md and benchmarks/README.md for the individual studies.
Citation
Citation metadata are provided in CITATION.cff. A versioned DOI will be added with the first archived release.
Contributing
See CONTRIBUTING.md and the development guide.
License
PETAL2D is distributed under the MIT License. See LICENSE.
Alex Santacruz, 2DQMAT Research @ IF-UNAM
Metadata
Release files for petal2d 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 | Provenance | |
|---|---|---|---|---|
| petal2d-0.1.0.tar.gz | 2.1 MB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| petal2d-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.1 MB
Release files / petal2d-0.1.0.tar.gz
| Download URL | petal2d-0.1.0.tar.gz |
|---|---|
| Size | 2.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d2b075e6588afa2a61eb8bae7227a8a7554ddd1257150765846b7b519825870
|
|
BLAKE2b-256 checksum How to use checksums |
28fcb9d5638e5dab606064f62a3c6ee62e0b379e2422a0ca8efb4252a23a9b18
|
| 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 Sep 11, 2026.
Transparency logRelease files / petal2d-0.1.0-py3-none-any.whl
| Download URL | petal2d-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
862f1b9d5304a43bb2c1d08b2fe194cb5089c9797cb55593bcb6118e7db34460
|
|
BLAKE2b-256 checksum How to use checksums |
e2ff209118c933c9cb455cc17e0dc0de416d9de7afc232811e7d3bafc8117e4d
|
| 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 Sep 11, 2026.
Transparency logSecurity for petal2d 0.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for petal2d-0.1.0.tar.gz
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 Sep 11, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.