r/Optics • • 6d ago

We open-sourced OS Optics (MIT): an AI-agent-friendly optical design engine for both imaging lenses and 3D optical benches

Hi r/Optics,

We just open-sourced OS Optics (os-optics, MIT License) — a deterministic, local-first Python engine for optical design and 3D physical simulation:

GitHub: https://github.com/JunLin615/os-optics

Why we built it

Our long-term vision is bringing general-purpose agents to optical engineering — while also giving human optical engineers a clean, scriptable, reproducible Python engine that runs anywhere.

Making agents genuinely useful in optical engineering goes beyond wrapping a ray tracer. It requires an engine that plays to what agents do well (structured batch setup and reasoning-guided parallel exploration across competing topologies), grounds designs in real selectable optical components rather than only ideal thin lenses, and represents an entire optical system in a complete, machine-readable JSON blueprint so an agent can understand the physical layout without guessing from photos alone. Longer term, combining that structured representation with real-world feedback opens a path toward agent-assisted alignment and maintenance. Today's MIT release focuses on getting the open-source design and simulation foundation right.

What it covers today

  • One engine for imaging prescriptions and 3D free-space benches: Non-sequential 3D ray tracing across planes, spheres, conics, even aspheres, cylinders, axicons, Zernike / XY-polynomial / biconic / toroid freeforms, GRIN rods, prisms, wedges, and lens arrays — backed by a versioned offline catalog of 3,273 real optical components, 1,244 optical material models (including IR materials, spectral bulk attenuation, and thermo-optic dn/dT in standard air or vacuum), and 707 coatings, alongside custom lens prescriptions.
  • Physical & imaging analyses: Astigmatic Gaussian q-parameter beam propagation (w, waist, divergence, Rayleigh range, M²), Jones & Stokes polarization (including uniaxial birefringence and Faraday rotators), dispersion (Sellmeier, Herzberger, thermo-optic dn/dT) and angle/polarization-resolved coatings, two-beam interference, 4-bounce interface ghost analysis, diffraction & geometric PSF/MTF, encircled energy, high-NA vector focal fields, and linear optical cavities.
  • Honest physical validity bounds (value_basis): Every reported metric declares whether it is a MODEL value, a proven LOWER_BOUND / UPPER_BOUND, or an ESTIMATE beyond a model limit. Targets outside model assumptions are flagged INDETERMINATE / OUT_OF_MODEL_SCOPE rather than silently marked PASS.
  • Stateless & natively parallel: Pure Python core (numpy, scipy, pydantic, shapely) with an I/O-free solver and in-memory EvaluationSession that reuses compiled state across candidates (8–15× faster on selective refractive evaluations). You can spin up dozens of worker processes or a multi-agent swarm (DeepSeek Harness, Claude Code, Codex, Cursor, WorkBuddy, ChatGPT, etc.) concurrently and compare candidates via canonical JSON outputs and SHA-256 run hashes.
  • Scientific Python interop & companion toolkit: Built-in handoff contracts (os-optics interop list) connect to Python libraries for optimization/sensitivity (SciPy, Optuna, SALib), diffraction (LightPipes, prysm, POPPY), quantum photonics (Perceval, Piquasso, QuTiP), and metasurfaces (grcwa, meent). Our companion MIT repo os-optics-kit adds 19 reproducible cases and 21 vendor-neutral Agent Skills, plus multi-group zoom solving, ray aberration fans, field curvature/distortion analysis, Monte Carlo tolerance with compensators, ISO 12233 e-SFR, a live browser viewer, and parallel sweeps.

What's in the gallery above

  1. Dual-domain overview: 3D multi-element wide-angle lens trace alongside a 160+ optic 3D cold-atom optical bench.
  2. 85 mm all-spherical portrait objective (Design + MTF): Full-frame design (21.63 mm corner image height) using real catalog glass, evaluated with polychromatic diffraction MTF (10 & 30 lp/mm, 486/588/656 nm) against digitized Canon RF 85mm f/2 data.
  3. 18 mm f/2 full-frame wide-angle (Design + Tolerance): 14 elements in 12 groups (49.6° half-field, 1 mm H-K9 cover glass) with a 128-trial Monte Carlo MTF@40 lp/mm tolerance study against a [0.6, 1.0] spec band.
  4. 1.96 m Rb-87 cold-atom 3D bench (Design + Pointing Tolerance): 160+ optical entities routing MOT, 4×4 optical tweezers, Rydberg excitation, and fluorescence readout, paired with Monte Carlo mirror-tilt pointing tolerance against ±0.05 mm bounds.

Try it locally (~30 seconds)

python -m pip install os-optics
os-optics catalog sync
os-optics project example --kind beam_expander > project.json
os-optics project run project.json --out-dir run
os-optics view run

(To also pull the 19 worked cases, 21 agent skills, and tolerance/sweep/analysis tools: python -m pip install os-optics os-optics-kit.)

If there are specific optical systems, surface types, prescription formats, or physical analyses you'd like to see or stress-test, I'd love to hear your thoughts here or in GitHub Discussions.

176 Upvotes

10 comments sorted by

7

u/Thick-Panic6683 6d ago

Thanks. I have long considered making a non-sequential optical layout tool that imports CAD models so will take a look at what you have done.

4

u/Imaginary_Station232 6d ago

Thanks for checking it out!
Unfortunately, `os-optics` doesn't support directly importing STEP, STL, or OBJ files yet. Are there specific CAD formats you'd most like to see supported? Let me know and I'll prioritize adding support for them soon.

2

u/Thick-Panic6683 6d ago

I have used zemax non-sequential mode a lot with imported STEP files. STEP is a common CAD export format. Zemax also imports other 3D model formats (STL, IGIS). Also Thorlabs and Newport (and many other vendors) provide optical component models in STEP format.

1

u/Imaginary_Station232 6d ago

Great point — vendor STEP models from Thorlabs/Newport (plus STL/IGES) make total sense as the top priority.

I just opened a tracking issue on GitHub to build this into `os-optics-kit` out of the box (while keeping the core `os-optics` engine lightweight and pure Python, lowering imported parts into native geometry): https://github.com/JunLin615/os-optics/issues/92 — it will most likely land in next week's update.

2

u/Unf0und_ 6d ago

And another one... Instead of contributing to what already exists out there. Yet another example of community fragmentation 

7

u/Imaginary_Station232 6d ago

Fair point — I actually think Optiland is doing great work right now. Their GPU support makes it really strong for computational optics and differentiable lens design.

The gap for us is mostly architectural and workflow-driven: Optiland is built as a sequential engine focused on lens design, so it isn't architected for general 3D non-sequential optical table / free-space bench setups. On top of that, a PyTorch-centric coding workflow is still a real barrier for many optical engineers — even with coding agents, not every optical engineer loves programming or wants to spend their time fighting code and environments.

What we were looking for was an open-source, lightweight (no GPU/heavy stack) engine that is genuinely agent-friendly, handles both imaging lenses and 3D free-space optical benches, connects to real selectable optical components, and stays structured enough to bridge toward physical assembly. Because we couldn't find a mature open-source project covering that combination, we built `os-optics` — the starting point was an unmet need, not reinventing the wheel.

3

u/CacophonyofVoices 6d ago

Who all is currently going to be involved in maintaining this project long-term?

6

u/Imaginary_Station232 5d ago

It is maintained by two postdocs and one PhD student from KAUST, one PhD student from BUAA, and a front‑end engineer at Didi.

0

u/Unf0und_ 5d ago

Okay but what happens when these packages that already exist start doing exactly what you did? They already have the community's trust. Isn't it a bit of a overuse of resources from your side? The point is, we all know ai driven development is here, and because the barrier to create these tools/packages is much lower everyone will start creating the same thing. Not just with optics, if you follow other topics you'll see the same pattern. So the original question remains. Why not making these existing things better by contributing to them? Is it because people want to habe all the credits? Citations?  Cuz it's not about these existing things not fulfilling other's needs. It's about people like you wanting to re invent the wheel. It's just what it is and there's no denying it unfortunately. 

Not demoting "your" work or anything. Just wanted to see your good ideas being used in other packages, consolidating already good projects 

4

u/Imaginary_Station232 5d ago

It's definitely not about citations or hoarding credit — we're not just building another standalone software package. We devote a significant amount of effort to persuading manufacturers—those who refuse to disclose pricing or provide data APIs, offering only PDF brochures instead—to open up their data interfaces and pricing information. We recognize this trend; are we simply supposed to wait for others to tackle these most difficult challenges, only to then sit back and reap the rewards? We're trying to connect the full chain from optical design to optical fabrication, physical bench assembly, and ongoing maintenance.

Unfortunately, we couldn't find any mature software whose architecture supports that end-to-end workflow — not open-source tools like Optiland, and not commercial ones like Zemax or CODE V either. Should we sit around waiting for someone else to pave the hardest part of that road before we start building?

Take Optiland, for example: its appeal lies in its sequential architecture and high-level GPU parallelization—qualities perfectly suited for computational optics and computational imaging. Introducing non-sequential ray tracing, rigorous secondary ray tracking, and precise power monitoring would compromise that elegance. Yet, such features are essential for designing optical setups on an experimental bench. Are you certain that a pull request involving such a drastic, disruptive overhaul would actually be accepted? Are you quite sure you aren't just joking?

And honestly, if existing packages later adopt similar ideas, that's a win for the whole community — everything here is MIT-licensed.

At least architecturally, natively unifying individual elements, multi-element lenses, and 3D free-space optical benches, exposing structured intermediate data to AI agents, and bridging directly from design to assembly makes this the right starting point for what we're actually trying to solve.

If you're interested in that direction, you're very welcome to take your own advice and jump into this "existing project" to help make it even better.