MRMENDEZ
← back to projects
optical compiler / 2026

Diffract

A hologram compiler and local workbench for phase masks, optical simulation, and fabrication-ready exports.

working research toolPythonReactPhotonicsSimulation
Diffract project overview

What it compiles

Diffract takes a grayscale target or a generated pattern and produces a quantized phase mask for a spatial light modulator. It also simulates the reconstruction, tracks convergence, reports optical efficiency, scans axial intensity, and exports a transmissive surface-relief height map.

The output bundle is meant to be reproducible. It contains images, NumPy arrays, convergence data, metadata, and SHA-256 checksums rather than one attractive preview with no record of how it was made.

Optical models

The compiler supports two deliberately limited setups. The Fourier-lens model places the SLM in the front focal plane of an ideal thin lens and uses a centered unitary FFT. The free-space model uses equal-pitch scalar propagation with a band-limited angular spectrum transfer function.

The optimizer supports Gerchberg-Saxton and mixed-region amplitude freedom. MRAF constrains the requested signal region and lets the surrounding noise region move, which is often more useful than forcing the whole plane to match.

The workbench

A local Python server and React client provide a lab-style interface. Iteration metrics stream into the page while the last successful run remains available for comparison. The workbench exposes source shape, wavelength, pixel pitch, propagation setup, solver settings, phase quantization, measured phase LUTs, and export controls.

Completed runs expose the phase mask, physical reconstruction, convergence history, propagation surface, phase-plate relief, STL, and a reproducible ZIP bundle.

What it does not claim

The simulation assumes coherent monochromatic scalar light, ideal pixels, known source amplitude, and no unknown aberration. It does not replace camera-in-the-loop calibration, polarization alignment, zero-order control, or a full electromagnetic solver. A high simulated fidelity score is not a guarantee that the same mask will work on an uncalibrated optical bench.