A learned prior over the optical glass manifold for realistic glass selection in lens design.
Project description
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.
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 abbeflow-0.2.0.tar.gz.
File metadata
- Download URL: abbeflow-0.2.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f91968072691d3b877f81732de8713ed51f6ba2f910ebcd2b28e02c9535f6aff
|
|
| MD5 |
f718bb394de78c2c717df8db1ea0a75b
|
|
| BLAKE2b-256 |
b013b405d4d49d216bad4e65597514934fa0bc8c7da3580c17db6beb5e8777fa
|
Provenance
The following attestation bundles were made for abbeflow-0.2.0.tar.gz:
Publisher:
publish.yml on HarrisonKramer/AbbeFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
abbeflow-0.2.0.tar.gz -
Subject digest:
f91968072691d3b877f81732de8713ed51f6ba2f910ebcd2b28e02c9535f6aff - Sigstore transparency entry: 2047496918
- Sigstore integration time:
-
Permalink:
HarrisonKramer/AbbeFlow@92956c81e77c7870a95f3f9b615c5cfe0bd7f62c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/HarrisonKramer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@92956c81e77c7870a95f3f9b615c5cfe0bd7f62c -
Trigger Event:
release
-
Statement type:
File details
Details for the file abbeflow-0.2.0-py3-none-any.whl.
File metadata
- Download URL: abbeflow-0.2.0-py3-none-any.whl
- Upload date:
- Size: 293.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce708da2d9dc134c0a962d5f9e80d6e13642bd02a0d8d5f118b60efdd7891318
|
|
| MD5 |
bc6512e6b538e0fe9ec8a7f54674e545
|
|
| BLAKE2b-256 |
4773386b305e7786573f51dd465cda13b9ba06fe846aa1ef7827cf94ae9f3413
|
Provenance
The following attestation bundles were made for abbeflow-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on HarrisonKramer/AbbeFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
abbeflow-0.2.0-py3-none-any.whl -
Subject digest:
ce708da2d9dc134c0a962d5f9e80d6e13642bd02a0d8d5f118b60efdd7891318 - Sigstore transparency entry: 2047496926
- Sigstore integration time:
-
Permalink:
HarrisonKramer/AbbeFlow@92956c81e77c7870a95f3f9b615c5cfe0bd7f62c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/HarrisonKramer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@92956c81e77c7870a95f3f9b615c5cfe0bd7f62c -
Trigger Event:
release
-
Statement type: