AbbeFlow
AbbeFlow is a differentiable, normalizing-flow-based learned prior over the optical glass catalog manifold. Trained on approximately 1,700 real glasses from major manufacturers (including Schott, Ohara, Hoya, and others), AbbeFlow models the distribution of physical glasses in a 4D Buchdahl dispersion coefficient space. It enables continuous, gradient-based lens optimization while ensuring that glass choices remain on or near the realizable manifold.
For details on the mathematical modeling and formulation, see the Theoretical Background documentation.
Installation
Install AbbeFlow via pip:
pip install abbeflow
Core Optimization Paradigms
AbbeFlow supports two main paradigms for continuous glass optimization:
- Manifold Penalty Mode: Optimize refractive index $n_d$ and Abbe number $V_d$ directly, adding a regularizing penalty based on the negative log-probability under the learned prior to the optical merit function: $$\mathcal{L} = \mathcal{L}{\text{aberration}} - \lambda{\text{glass}} \log p(n_d, V_d)$$
- Latent Space Optimization: Optimize directly in the unconstrained 4D latent space $\mathbf{z} \in \mathbb{R}^4$, mapping back to the physical glass manifold via the decoder $\mathbf{x} = f^{-1}(\mathbf{z})$, which guarantees physically realistic glass parameters.
Quick Start
AbbeFlow provides a pretrained GlassFlow model ready for inference:
from abbeflow import GlassFlow
# Load the pretrained model
gf = GlassFlow.pretrained()
# Compute the log-probability of a glass (manifold prior penalty)
logp = gf.log_prob(nd=1.517, vd=64.2)
print(f"Log probability: {logp.item():.4f}")
# Encode to and decode from the latent space
z = gf.encode(nd=1.517, vd=64.2)
glass = gf.decode(z)
print(f"Decoded glass: nd={glass.nd:.4f}, vd={glass.vd:.2f}")
# Snap to the nearest real catalog glasses
matches = gf.nearest_real(nd=1.517, vd=64.2, k=3)
print("\nNearest catalog glasses:")
for match in matches:
print(f" - {match.manufacturer} {match.name} (Distance: {match.distance:.4f})")
Examples
The following examples are located in the examples/ directory and demonstrate how to integrate AbbeFlow into various workflows:
- optimize_with_manifold_prior.py: A comparison of Penalty Mode and Latent Space Mode on a toy optimization problem.
- sample_glasses.py: Demonstrates sampling novel glass formulations and evaluating full dispersion curves.
- find_real_alternatives.py: Shows how to find the closest real catalog glasses and locate equivalent cross-catalog substitutes.
API Reference
A detailed overview of all modules, classes, and methods is available in the API Reference documentation.
License
AbbeFlow is released under the MIT License.
Metadata
Release files for abbeflow 0.2.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 | |
|---|---|---|---|
| abbeflow-0.2.0.tar.gz | 1.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| abbeflow-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.4 MB
Release files / abbeflow-0.2.0.tar.gz
| Download URL | abbeflow-0.2.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f91968072691d3b877f81732de8713ed51f6ba2f910ebcd2b28e02c9535f6aff
|
|
BLAKE2b-256 checksum How to use checksums |
b013b405d4d49d216bad4e65597514934fa0bc8c7da3580c17db6beb5e8777fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 2, 2026.
Transparency logRelease files / abbeflow-0.2.0-py3-none-any.whl
| Download URL | abbeflow-0.2.0-py3-none-any.whl |
|---|---|
| Size | 293.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce708da2d9dc134c0a962d5f9e80d6e13642bd02a0d8d5f118b60efdd7891318
|
|
BLAKE2b-256 checksum How to use checksums |
4773386b305e7786573f51dd465cda13b9ba06fe846aa1ef7827cf94ae9f3413
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 2, 2026.
Transparency log