os-optics
Health Pass
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Community trust — 46 GitHub stars
Code Pass
- Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
OS Optics: MIT-licensed local optical design and simulation in Python. Documentation, getting started and feedback in English and Chinese. Install: pip install os-optics. Tools, cases and agent skills: JunLin615/os-optics-kit.
OS Optics
Open-source Python optical design & simulation engine — built for engineers, parallel optimization, and AI coding agents.
English · 简体中文
Quick Start · Why OS Optics · Gallery · Capabilities · Interop · Toolkit · Roadmap
One engine, two worlds: multi-element imaging lens prescriptions (left) and 160+ optic 3D free-space quantum benches (right).
OS Optics (os-optics) is a deterministic, local-first Python optical design and physical simulation engine released under the MIT License. Design multi-element imaging lenses, catadioptric telescopes, and 100-optic free-space benches; trace 3D rays, propagate Gaussian beams, analyze polarization, interference, PSF/MTF, ghosts, and cavities; and interoperate cleanly with Python diffraction, quantum photonics, and optimization libraries — directly from Python, the CLI, or coding agents such as DeepSeek Harness, Claude Code, Codex, Cursor, and WorkBuddy.
python -m pip install os-optics
| Package / Repo | Where | Role |
|---|---|---|
os-optics |
PyPI | The MIT-licensed optical engine: catalog, physics simulation, structured results & 3D viewer |
os-optics-kit |
PyPI | Community toolkit: 18 reproducible cases, agent skills, parallel sweeps, tolerance, live viewer & plots |
os-optics |
GitHub | This repository: engine source (src/os_optics), tests, documentation & roadmap |
os-optics-kit |
GitHub | Community hub: worked cases, vendor-neutral agent skills, workflows & contributions |
Why OS Optics
Most optical tools force a trade-off between closed, seat-locked commercial GUIs and lightweight scripts that lack real component data or honest validity bounds. OS Optics is engineered from the ground up for reproducible optical design, high parallelism, scientific ecosystem interop, and multi-agent workflows:
- Natively parallel & built for multi-agent swarms — The simulation core is completely stateless, I/O-free, and free of GUI or license-seat locks. Spawn dozens of parallel worker processes, containers, or an agent swarm to explore competing lens topologies and parameter branches concurrently — then merge and compare candidates objectively via canonical JSON outputs, deterministic exit codes, and SHA-256 hashes.
- Seamless interop with Python diffraction, quantum & optimization libraries — Keep the engine core ultra-light while plugging into the wider scientific Python stack through built-in data contracts (
os-optics interop list): hand off transverse beam fields to LightPipes / prysm / POPPY / Diffractio, export lossy linear optical networks with per-path group delays to Perceval / Piquasso / QuTiP, import grcwa / meent metasurface unit-cell models, or drive loops with SciPy / Optuna / SALib. - Deterministic physics with honest validity bounds (
value_basis) — Every number reports whether it is aMODELvalue, a provenLOWER_BOUND/UPPER_BOUND, or anESTIMATEbeyond a model limit. Targets outside model scope are flaggedINDETERMINATE, never silently disguised asPASS. - Real component catalog + custom prescriptions — Sync a versioned, offline-first catalog of 3,000+ real optical components (
OS-OPT-*), or declare custom lenses, even aspheres, freeforms (Zernike / XY polynomial / biconic), crystals, and CSV lens prescriptions in the same engine. Open a sequential prescription as a Project. - Agent-native CLI & in-memory evaluation loops — Every command speaks structured JSON with self-describing schemas (
os-optics capabilities,os-optics schema). Use selective evaluation (os-optics project evaluate/EvaluationSession) to score candidates in memory while reusing compiled optics and catalog data across iterations. - Ultra-light pure Python core — Installs in seconds on Windows, macOS, and Linux (Python 3.11+) with only
numpy,scipy,pydantic, andshapely. No compiler, no license server, no GPU requirement, and no account needed.
| Dimension | Commercial Optical GUIs | Pure Academic Scripts | OS Optics (os-optics) |
|---|---|---|---|
| License & cost | Proprietary, expensive seats | Open source | MIT License, free & local |
| Interface | GUI-first, macro scripting | Python-only | Python API + JSON CLI + Headless/3D Viewer |
| Parallelism & Agent Swarms | Dongle/seat-locked, fragile COM/GUI | Ad-hoc scripts | Stateless core, unlimited workers, native for multi-agent swarms |
| Scientific Ecosystem Interop | Closed binary formats | Manual glue code | Built-in interop contracts: diffraction, quantum, metasurfaces, optimizers |
| Coding Agent readiness | Hard to drive reliably | No standard contract | JSON schemas, deterministic exit codes, vendor-neutral skills (kit) |
| Component library | Fragmented vendor files | Mostly ideal/custom | Versioned offline catalog (3,000+ parts) + custom models |
| Model validity honesty | Often silent extrapolation | Varies | Explicit value_basis, power bounds & model-scope issues |
| Reproducibility | Binary project files | Script-dependent | Canonical JSON Projects + SHA-256 input/result hashes |
Visual Gallery
Each row pairs an optical system design (left) with its physics or tolerance analysis (right), spanning imaging lens prescriptions and 3D free-space quantum benches:
Case 1 — 18 mm f/2 Full-Frame Mirrorless (Design): 14-element / 12-group lens prescription spanning 49.6° half-field with cemented doublets and cover glass. |
Case 1 — Monte Carlo Tolerance Analysis: 128-trial manufacturing MTF@40 lp/mm yield distribution evaluated against the [0.6, 1.0] specification band.
|
Case 2 — 85 mm All-Spherical Portrait Lens (Design): full-frame catalog-glass meridional ray trace from axis to 21.63 mm corner image height. |
Case 2 — Polychromatic Diffraction MTF Benchmark: 10 & 30 lp/mm full-field MTF directly compared against digitized official Canon RF85 F2 data. |
Case 3 — Rb-87 Cold-Atom 3D Quantum Bench (Global Layout): 1.96 m composed workspace routing 160+ optics for MOT, optical tweezers, Rydberg excitation, and readout. |
Case 3 — 3D Alignment & Pointing Tolerance: seeded Monte Carlo mirror-tilt perturbations verifying beam-position stability within ±0.05 mm bounds.
|
Semiconductor RDL high-NA microscopy objective (3D studio glass shading). |
Polychromatic tangential & sagittal diffraction MTF against the diffraction limit. |
Non-sequential reflective folded Schmidt-Cassegrain telescope. |
18 mm f/2 barrel envelope with active alignment stations. |
Quick Start
1. Install
python -m pip install os-optics
os-optics doctor
Or install as an isolated CLI tool with uv: uv tool install os-optics.
2. Run your first optical design in 4 commands
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
This syncs the offline optical catalog, generates a two-lens beam expander, runs deterministic simulation and validation, and opens the interactive 3D optical scene in your browser. Inspect or export results headlessly:
os-optics results describe run
os-optics results targets run
os-optics export arrivals run --format csv --out arrivals.csv
os-optics project verify run
3. Use from Python (including fast candidate evaluation)
from os_optics.local import EvaluationSession, example_project_of_kind, run_optical_project
from os_optics.results import load_run
project = example_project_of_kind("beam_expander")
# Fast in-memory selective evaluation for optimization & parallel agent loops
session = EvaluationSession()
ev = session.evaluate(project, outputs=("readings", "requirements"))
print(ev.requirements())
# Full verified run with saved artifacts and 3D scene
run = run_optical_project(project, output_dir="run-python")
results = load_run("run-python")
print(run.status.value, results.power_budget())
4. Drive it with your Coding Agent (or Agent Swarm)
Paste this into DeepSeek Harness, Claude Code, Codex, Cursor, WorkBuddy, or any agent that can run Python:
Install
os-opticsandos-optics-kitfrom PyPI, runos-optics-kit skills list, and design a 532 nm 3× beam expander using real catalog lenses with spot radius < 50 µm at the target plane. Verify all targets and show me the 3D views.
See AGENT_GUIDE.md for the concise agent entry point.
Capabilities
| Category | What OS Optics computes |
|---|---|
| 3D Ray Tracing & Geometry | Non-sequential 3D tracing through planes, spheres, conics, even aspheres, cylinders, axicons, Zernike / XY-poly / biconic / toroid freeforms, GRIN rods, faceted solids, cubes, prisms, wedges, holes, and lens arrays. |
| Materials, Coatings & Spectra | Dispersion formulas (Sellmeier, Herzberger, power-series, thermo-optic dn/dT, tabulated), angle- & polarization-resolved s/p coatings with phase & group-delay bounds, multi-line and continuous spectra. |
| Gaussian Beams & Polarization | Astigmatic Gaussian q-parameter propagation (waist, beam radius, divergence, Rayleigh range, M²), Jones & Stokes calculus, partial/unpolarized light, uniaxial birefringence, Faraday rotators, SHG slabs. |
| Interference, Power & Safety | Full power ledger with proven upper/lower bounds, two-beam interference (fringe period, visibility, coherence margin), per-surface peak irradiance & pulsed fluence checked against damage ratings. |
| Imaging & Wave Analyses | Diffraction & geometric PSF / MTF, encircled energy, geometric wavefront, 4-bounce interface ghost analysis with remainder bounds, coherent/speckle field propagation, high-NA vector focal fields, linear optical cavities, linear optical network export. |
| Parallelism, Evaluation & Workspaces | Stateless engine for multi-process & multi-agent swarm exploration, project evaluate / EvaluationSession, multi-configuration comparison, modular workspace composition, headless 3D/2D snapshots (--section ALL), and SHA-256 verified runs. |
Scientific Ecosystem & Interop
os-optics stays dependency-light by design and acts as the deterministic hub connecting to specialized Python physics libraries via versioned exports (os-optics interop list):
| Domain | Third-Party Tools | OpenSci Handoff Contract | Status |
|---|---|---|---|
| Optimization & Sensitivity | SciPy, Optuna, SALib, BoTorch |
Stateless EvaluationSession / JSON runs with verified hashes |
Verified example |
| Scalar Diffraction & Wave Optics | LightPipes, prysm, POPPY, Diffractio |
os-optics results handoff (transverse beam state, apertures, field convention) |
Verified example |
| Quantum Photonics & Cold Atoms | Perceval, Piquasso, QuTiP, NetSquid |
os-optics project network (lossy transfer matrix T[out,in] & per-path group delays) |
Verified example |
| Metasurfaces & Nanophotonics | grcwa, meent, torcwa, DFlat, metabox |
TABULATED_THIN_LENS with validated wavelength/angle domain checks |
Verified example |
| Cavities, PICs, Coatings, AO & Lab | Finesse 3, Meep, Tidy3D, gdsfactory, SAX, TorchOptics, Chromatix, tmm, PyMoosh, HCIPy, MCX, PyVISA |
Standard exports & conventions documented in INTEROP.md | Guidance catalog |
os-optics interop list
os-optics interop show quantum-photonics
Ecosystem: os-optics + os-optics-kit
We intentionally keep the engine and the community toolkit in two focused MIT repositories:
os-optics(this repo) — Minimal dependencies (numpy,scipy,pydantic,shapely), strict physical determinism, stateless parallelism, fast CI, and clean Python/CLI APIs.os-optics-kit— Builds onos-opticswith:- 18 engine-reproducible optical cases (Sonnar telephoto, aspheric f/3.5, MWIR 3–5 µm imager, beam expander, polarization control, Hong-Ou-Mandel quantum optics, metasurface interop, flat-top shaping, and more).
- 18 vendor-neutral Agent Skills (
os-optics-kit skills install --dest ...) ready for DeepSeek Harness, Claude Code, Codex, WorkBuddy, and other agent hosts. - Parallel studies & visualization: resumable multi-worker parameter sweeps (
--workers N), sensitivity ranking, Monte Carlo tolerance, live read-only viewer (os-optics-kit view), publication plots, ISO 12233 e-SFR, and slide-ready 3D renders/animations.
python -m pip install os-optics-kit
os-optics-kit cases list
os-optics-kit skills list
Documentation
| Guide | English | 简体中文 |
|---|---|---|
| Project website | opensci-optics.com | opensci-optics.com |
| Agent entry guide | AGENT_GUIDE.md | — |
| Installation and upgrades | Read | 阅读 |
| Your first optical design | Read | 阅读 |
| Catalog and reproducible projects | Read | 阅读 |
| Results, visualization, and export | Read | 阅读 |
| External scientific tools (interop) | INTEROP.md | 外部工具联用 (kit) |
| Engine architecture & module boundaries | ENGINE_ARCHITECTURE.md | — |
| Physics scope & model limits | PHYSICS_SCOPE.md · KNOWN_LIMITATIONS.md | — |
| Complete engine CLI & Python reference | docs/engine/README.md | — |
Contributing & Roadmap
Contributions and discussions are welcome in English or Chinese!
- Questions, ideas & optical design discussions: GitHub Discussions
- Bug reports & feature requests: GitHub Issues
- Pull requests & local test suite: see CONTRIBUTING.md and docs/engine/DEVELOPMENT.md
- Security reports: report privately via the repository's Security tab
Key areas where community issues & PRs are especially welcome:
- Surface & medium extensibility — Modularizing tracer/surface dispatch and adding new optical elements (e.g., DMD / SLM models, diffractive optical elements).
- File format interoperability — Additional prescription records, export formats, and STEP/CAD alignment helpers.
- Optimization & merit-function helpers — Native optimization and multi-agent search workflows built on
EvaluationSession. - Worked optical cases & agent skills — Contribute reproducible designs and skills directly to os-optics-kit (your agent can package a finished design as a PR with
os-optics-kit contrib case).
If OS Optics helps your research, engineering, or agent workflow, please consider starring the repository — it helps more optical engineers and open-source contributors discover the project.
License
This repository — engine source, tests, documentation, and scripts — is licensed under the MIT License (covering os-optics releases from 0.14.0 onward; releases 0.13.0 and earlier on PyPI remain under the licence they were published under). The OpenSci and OS Optics names, as well as the brand logos in assets/, are trademarks excluded from the MIT License (assets/LICENSE, TRADEMARK.md). os-optics-kit is also under the MIT License. Bundled third-party components retain their own licenses (three.js: src/os_optics/viewer/assets/THREE_LICENSE.txt).
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found