Introduction
A continuation from yesterday’s post, we extend the FDTD simulation to 2D and model the double slit experiment.
Results
(Some image artifacts are due to the GIF compression).
As you can see, a single electron creates a wave interface pattern on the other side of the double slits.
Notes
- The animation was very slow on CPU, but I was able to speed it up by creating a GPU kernel (function) (code).
- It took some massaging https://gpu.rocks/#/, but it was worth it.
- Easy “step” is sent to the GPU to calculate, and probably sped up the simulation by 5-10x
- I didn’t realize just how paralell a GPU is.
- I made a mistake and thought it would be better to just use complex numbers instead of splitting the schrodinger equation into two equations (one for real and imaginary).
- But the GPU kernel requires very specific input for the shader, so I had to convert back to arrays of numbers and now custom types
- I’m not sure I’m modeling an electron correctly. It’s a 2D gaussian envelope of a cos/sin in only the x direction. I think that’s correct but I need to look it up
- Chrome debugging tools are great for profiling an application. Specially the line-by-line profiling and heap analyzer
Future
- I bet there’s faster ways to run this algorithm, I’m going to skim through the computation books and see if maybe there’s some better linear algebra algorithms to speed it up or maybe shortcuts
- It could be fun to make some more interesting potentials such as dirac combs, or even a hydrogen atom, or graphene
- Long term I want to start modeling the dirac equation and introduce more and more fields till I get QED/QCD together