FluxOptics.jl: A Differentiable Wave Optics Framework for Inverse Design in Julia
FluxOptics.jl: A Differentiable Wave Optics Framework for Inverse Design in Julia - Published in JOSS (2026)
Science Score: 87.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 1 DOI reference(s) in JOSS metadata -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Repository
A Julia package for inverse problems in optics with differentiable forward models.
Basic Info
- Host: GitHub
- Owner: anscoil
- License: mit
- Language: Julia
- Default Branch: main
- Size: 66 MB
Statistics
- Stars: 9
- Watchers: 0
- Forks: 0
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
FluxOptics.jl
Differentiable optical propagation and inverse design in Julia
FluxOptics.jl enables gradient-based optimization of optical systems through fully differentiable wave propagation. It allows you to design diffractive optical elements, optimize beam shaping, reconstruct optical fields, and characterize photonic structures.
✨ Key Features
- 🌊 Wave propagation: Angular Spectrum, Rayleigh-Sommerfeld, Beam Propagation Method
- 🎯 Inverse design: End-to-end optimization of phase masks, DOEs, and refractive index profiles
- 🔧 Proximal optimization: FISTA, TV regularization, ISTA sparsity, custom constraints
- 📊 Multi-wavelength & multimode: Polychromatic propagation and mode coupling
- 🚀 GPU accelerated: Seamless CUDA support
- 🧩 Composable architecture: Intuitive piping syntax for complex optical systems
Applications
FluxOptics.jl is designed for: - Inverse design: Diffractive optical elements, metasurfaces, beam shaping - Optical characterization: Phase retrieval, tomographic reconstruction, waveguide/fiber analysis - Laser physics: Cavity eigenmode analysis, mode selection, resonator design - Photonics: Fiber coupling, multimode decomposition, GRIN media simulation
📦 Installation
julia
using Pkg
Pkg.add("FluxOptics")
Minimum Julia version: 1.11
Required for optimization workflows
To run gradient-based optimization, you need:
Automatic differentiation:
julia
Pkg.add("Zygote") # Used in all examples and tutorials
Optimization algorithms :
FluxOptics.jl reexports Descent from Optimisers.jl and provides Fista (Nesterov-accelerated proximal gradient). Install Optimisers.jl for additional algorithms:
julia
Pkg.add("Optimisers") # For additional optimizers (Adam, Momentum, etc.)
Optional: Visualization
For plotting capabilities:
julia
Pkg.add("CairoMakie") # for visualize()
Pkg.add("GLMakie") # for visualize_slider()
🚀 Quick Start
Design diffractive optical elements that split a Gaussian beam into two equal outputs:
```julia using FluxOptics, Zygote
Uncomment to use more FFTW threads
using FFTW
FFTW.setnumthreads(6)
using CUDA # Uncomment to use CUDA
Setup: 512×512 grid, 1 μm pitch, 1.064 μm wavelength
ns = (512, 512) ds = (1.0, 1.0) λ = 1.064 x, y = spatial_vectors(ns, ds)
Source and target fields
u0 = ScalarField(Gaussian(30.0)(x, y), ds, λ) target = ScalarField(Gaussian(30.0)(x, y, Shift2D(-60, 0)), ds, λ) + ScalarField(Gaussian(30.0)(x, y, Shift2D(60, 0)), ds, λ)
Uncomment if you are using CUDA
u0 = cu(u0)
target = cu(target)
normalizepower!(u0) normalizepower!(target)
Optical system: source → propagation → DOE → propagation → DOE → propagation
doe1 = Phase(u0, zeros(size(u0)); trainable=true, buffered=true) doe2 = Phase(u0, zeros(size(u0)); trainable=true, buffered=true) prop1 = RSProp(u0, 1500.0) prop2 = RSProp(u0, 2000.0) system = ScalarSource(u0) |> prop1 |> doe1 |> prop2 |> doe2 |> prop1
Optimize
loss(system) = sum(abs2, abs2.(system().out.electric - target.electric)) opt = FluxOptics.setup(Fista(4e3), system)
Lower the number of iterations for a quick test on cpu
for i in 1:1000 l, ∇ = Zygote.withgradient(loss, system) FluxOptics.update!(opt, system, ∇[1]) end
Result: 99.25% coupling efficiency
output = system().out coupling_efficiency(output, target) ```
📖 Tutorials
Six comprehensive tutorials:
| Tutorial | Description | |----------|-------------| | Fox-Li Cavity | Eigenmode analysis in semi-degenerate laser resonators | | Field Retrieval | Reconstruct amplitude and phase from intensity-only data | | Multi-Wavelength | Independent RGB beam control with cascaded DOEs | | Waveguide Tomography | Refractive index reconstruction from angle-resolved intensity | | Multimode Shaping | Shape 105 modes into square/ring targets with TV regularization | | Mode Sorting | Transform 45 Gaussian beams into Hermite-Gaussian modes (8-plane system) |
⚡ Performance
FluxOptics.jl is benchmarked against JaxOptics, WaveOpticsPropagation.jl, and TorchOptics on Angular Spectrum propagation (512×512, up to 1386 modes, NVIDIA RTX 4070):
| Library | GPU speedup vs FluxOptics | |---------|--------------------------| | FluxOptics | 1× (baseline) | | JaxOptics | 0.8× | | WaveOpticsPropagation.jl | 0.6× | | TorchOptics | 0.002× |
FluxOptics also handles ~1.5× more modes than JaxOptics before running out of GPU memory.
Note: these benchmarks measure Angular Spectrum propagation performance in isolation. On full optimization loops, the gap may narrow: TorchOptics showed as little as 13× slowdown on a 3-plane monomode conversion task. For FFT and tensor-dominated problems, XLA-based frameworks like JAX may even slightly outperform Julia due to whole-graph compilation, and for such cases, JaxOptics may well be sufficient. FluxOptics is expected to show stronger advantages on more complex optical components where manual optimization and Julia's flexibility become decisive.
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines on: - Reporting bugs and requesting features - Sharing use cases and examples - Submitting code contributions
📝 Citation
If you use FluxOptics.jl in your research, please cite:
bibtex
@software{fluxoptics2025,
author = {Barré, Nicolas},
title = {FluxOptics.jl: Differentiable Optical Simulations in Julia},
year = {2025},
url = {https://github.com/anscoil/FluxOptics.jl}
}
📄 License
MIT License - see LICENSE file for details.
🙏 Acknowledgments
Built on the Julia ecosystem: - Zygote.jl / ChainRulesCore.jl for automatic differentiation - Optimisers.jl for optimization algorithms - CUDA.jl for GPU acceleration
Owner
- Name: Nicolas Barré
- Login: anscoil
- Kind: user
- Location: Rennes (FRANCE)
- Repositories: 2
- Profile: https://github.com/anscoil
JOSS Publication
FluxOptics.jl: A Differentiable Wave Optics Framework for Inverse Design in Julia
Tags
optics inverse design automatic differentiation beam propagation diffractive optics computational opticsGitHub Events
Total
- Delete event: 3
- Pull request event: 5
- Watch event: 3
- Issue comment event: 1
- Push event: 38
- Commit comment event: 2
Last Year
- Delete event: 3
- Pull request event: 5
- Watch event: 3
- Issue comment event: 1
- Push event: 38
- Commit comment event: 2
Issues and Pull Requests
Last synced: 10 days ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- julia 2 total
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
juliahub.com: FluxOptics
A Julia package for inverse problems in optics with differentiable forward models.
- Documentation: https://docs.juliahub.com/General/FluxOptics/stable/
- License: MIT
-
Latest release: 0.1.0
published 5 months ago
