Skip to content

Why I built this

I wanted to see light do what the textbooks say it does.

Optics courses are full of statements that are easy to write down and hard to picture: that a lens works because light is slower in glass, that a thin coating can make a reflection disappear, that a lattice of rods can forbid light of one colour from passing while letting another through. Commercial solvers show all of this, but they live behind licences and long setup times. I wanted something you open in a browser tab and play with in the first ten seconds.

PhotonLab started as a small experiment in compiling a Rust FDTD loop to WebAssembly. Version 3 is a rewrite of almost everything: the solver now has a real absorbing boundary, one-way plane waves, both polarizations and metals that behave like metals; the interface was redesigned from scratch; and it measures itself against known answers before every release.

It is not a replacement for a research code. It is two-dimensional, the materials are simple, and the grid is limited by what a browser can do sixty times a second. But within those limits the physics is honest, and I have tried to say clearly in these pages where the limits are.

If you teach with it, find a bug, or build something interesting in it, I would like to hear about it.

— Mehmet Gümüş

PhotonLab is open source under the MIT licence. The code is on GitHub.