# N-Body Simulation for Photons

For my undergrad optics class I am taking we have to select final projects to work on for second half of the semester. I have spent the last few weeks working on my own project which was a GPU accelerated Barnes-Hunt tree N-Body simulator. I was wondering if I could use a similar idea but for photons. I would put "light sources" in my simulation and emit "photon" particles. I would probably want to simulate billions of these photons. They could bounce off of mirrors and diffract through lenses and be absorbed by a screen.

I am fairly certain this would work well for plain geometric optics, however, I would like to find a way to incorporate the wave properties of light into this simulation so I can form interference and diffraction patterns. I think I can do the interference by having each photon keep track of its phase / path difference as it propagates since the length of the path is easy to track. Then all the photons which strike the same cell on the screen will have their electric fields added together so they interferer with each over. What I am wondering about is what would be a good way to model diffraction? I can't think of a way to generate realistic diffraction patterns given that I am modelling particles and not plane waves. Does anyone know of a method?

I would rather do something a little more physical though than just knowing what a diffraction pattern should look like forcing the rays to conform to that pattern. For instance in my gravitational N-Body sim I only use Newtonian gravity and I can get a galaxy without hard coding it so long as I have the correct initial conditions.

I am also open to other ideas than just random statistical photon ray tracing. I think it would be interesting if I could just straight up model the waves with Maxwell's equations. I looked into doing finite difference analysis but I think you would need a grid cell size on the order of optical wavelength, and for modelling large optical set-ups on the size of meters a 3D grid with nano-meter cells would consume peta-bytes of memory.

• If you want to capture diffraction, then you have to model either the full set of Maxwell's equations, with is much harder than it sounds, or you have to do, at least, a Huygens-Fresnel approximation: en.wikipedia.org/wiki/Huygens%E2%80%93Fresnel_principle. Either way you are going to end up with a much more complex problem than for an n-body problem, so you should look at existing literature on how to implement scalable algorithms, otherwise you aren't going to get beyond trivial sized problems. Feb 24, 2016 at 6:02
• it seems you are trying to do ray tracing. When you're done, you'll be ready for Pixar! Feb 27, 2016 at 21:21