Capstone
Project
Over the course of my college experience, my education followed two major paths. While my formal education is a degree in physics, my long term goal for college was to learn to code. After opportunities to take classes, get research, and work an internship with a leading tech company, ASML, I am satisfied with the programming skills I have acquired along the way.
My capstone project is an attempt to bring both sides of my education, Physics and programming, into a single product. The physics that I was most interested in throughout undergrad never had easy ways to visualize the phenomena. My capstone project is building a virtual environment where one can easily observe the typically non-observable events happening without having to understand the math.
The project required an understanding of the physical phenomenon I was visualizing as well as the programming knowledge to translate these interactions into code. On top of this, I also had to program the setup of the environment and controls so the user can explore the environment. For this project, I taught myself the Unity game engine as well as the language C# to code all the necessary features in.
Virtual Physics Simulator
Background and Initial Exploration
The physics I want to simulate and visualize are Quantum Mechanical interactions that occur at the subatomic level. The physics of these systems can best be understood as the interactions of waves under different conditions. The medium I chose to represent these is a grid of points that represent a two dimensional space where the waves will interact. Each position within the grid is a position in the field and the height of the dot at a given point can be understood as the value of a specific quantity at that region. This quantity can be variety of values we are trying to observe depending on the system. As a majority of analysis in Quantum Mechanical systems is finding how likely a particle is in a given position or state, the most typical quantity we will observe in these scenarios are the probabilities (this quantity will be explicitly stated for each scenario).

2D Grid and Math Function Response
The first major challenge was representation of the space that these interactions will occur in. The grid is designed as a two dimensional array with each spot containing a Unity Sphere Game Object. At every instance that the system updates, each sphere's position is supplied into a given multidimensional mathematical function which determines the specific output value. In the first testing instance, I worked with simple two dimensional sine functions to ensure the spheres within the grid were properly responding to supplied functions. The two dimensional sine function which evolves with time can be seen below.
2D Particle-in-a-box Scenario
Typically, the first scenario one is introduced to in Quantum Mechanics is the the particle-in-a-box setup. This situation uses the idea of a given subatomic particle being trapped inside a region of space which has impenetrable barriers on all sides. In the 2D case, we can think of the particle being fenced in this region left to wander around. When you account for those impassible barriers (known as potentials), we can then derive the wave equation for the particle. This wave equation behaves very similar to standing waves you may be familiar with seeing on guitars and other stringed instruments. The standing waves given by this wave function do not change with time (hence they are "standing" waves). The wave function for a two dimensional particle-in-a-box particle looks like the following.

Note how the standing wave function looks very similar to the two dimensional sine wave. This is because the underlying wave structure of both systems are just simple sine waves! In this case, we see four peaks (high and low) because the particle's energy levels for both the x and y dimension are set to two. If we were to raise the energy level in either dimension, we would see the corresponding number of peaks as energy levels within the wave function in that dimension. This is a direct influence of energy on the wave function of a particle.
Now, we have a wave function, but what does it mean? The easiest way to make sense of this wave function (and probably what you think of when you hear Quantum Mechanics) is actually to multiply it by itself. Doing this, you get the the particle's probability distribution. For a second, let's return to the idea of the particle wandering around a fenced in region. A consequence of how Quantum Mechanical systems work is that we cannot actually observe this particle wandering, but only certain snapshots. Imagine that this particle fenced in is an animal and the lights to its cage are turned off. To find out were are able to turn on the lights for a split second and take a picture of the cage to see where it is.
In this scenario, the probability function we just derived can tell us where in the cage we expect to find the animal in the picture. While the lights are off, it could be anywhere, but once they turn on we'll find it somewhere in the cage. If we were to take enough of these pictures flicking on and off the lights, the distribution of the position of the animal in the cage will perfectly follow our probability function.
Let's observed the two dimensional particle-in-a-box probability function. We see that the structure is actually the exact same as the wave function, except all the peaks are positive.

For this probability function, the higher the dot on the grid lies in the z-direction, the more probable it is the particle will be found in that spot. If this were the example of the animal in the cage, the animal would be found at around the position of the four purple peaks most of the time while being found around the edges and center of the square very rarely. Using this introduction into the way to understand the wave functions and probability distributions, we will dive in to more exciting examples!
2D Quantum Harmonic Oscillator
Another typical scenario explored to introduce ideas of Quantum Mechanics is the Quantum Harmonic Oscillator. For this situation, instead of a particle trapped in a box with infinite potentials all around the edges, the potential gradually slopes upwards as we get further from the center of the region. The effects of this can be likened to if we put a marble in a bowl and watch it roll back and forth across the bowl. The only difference is that this particle will not be slowed down like the marble will be by friction in the bowl. The wave function we are able to derive in this form of potential looks like the follow (and changes as time progresses!).
We see that the wave function seems to oscillate between having four peaks where the particle is very likely to show up and having no peaks, where the particle has no more probable position to show up in. This response is a consequence of the 'bowl' like behavior of the system the particle is contained in. Again, this bowl shaped potential only affects this particle in the way that if we took snapshots of the particle, the probabilities of it showing up in given positions changes with time as we see above.
2D Electron Orbiting the Hydrogen Atom
One of the simplest real world examples of Quantum Mechanics to observe is that of the system of a hydrogen atom. In this case, I want to give the example of the electron being in the 2S orbital. This orbital is the second lowest energy orbital an electron can exist in. In the 2D case, the probability distribution of this electron is circularly (spherically in 3D) symmetric. This means that the probability an electron will be in a given position is only dependent on the distance it is from the center of the hydrogen atom.
In this 2S orbital, there are two peaks in the probability distribution where the electron is likely to be found. The peak at the further radius is much more probable of a position than the closer one (due to a higher energy level the electron will orbit further from the nucleus of the atom). This simulation takes into account the likeliness the electron will be at either of the two radius distances and chooses one based on that probability distribution. This animation can be thought of as a series of 'snapshots' taken of the electron as it orbits around nucleus. Note: the electron does not technically orbit circularly as depicted or only at those distances, but makes for an easier depiction of the scenario. The electron can actually exist at any radius from the atom (even technically an infinite distance away although the probability is infinitely small) according to the probability distribution, but it is easier to visualize the two most probable peaks.
We can see the effect of the probability distribution with the cluster of electron snapshots being more dense at the further radius than in the center.
Now that we have taken a brief excursion through the excitement of laying down the groundwork and visualizing Quantum Mechanical situations in a 2D environment, it is time to step it up a level.
3D Grid and Math Function Response
To get an even better sense of Quantum Mechanics and how to visualize their implications, it is only natural to view them in their three dimensional context. For this, I had to build a three dimensional grid to represent the systems we will observe.
This came with a variety of issues. The first being that a three dimensional system of the same side lengths had an immediate and horrendous effect on how the program ran. To account for this, the number of spheres in each of the dimensions of the grid had to be shrunk down from 60 to 16. The two dimension 60x60 grid gave us 3600 spheres while a three dimension 16x16x16 grid gives us 4096 spheres. Even though this is much larger than 3600, the program did not take too large of a hit in terms of runtime.
The second issue is that we are no longer able to visualize the variety of information we want by the height of the sphere in the grid as we did in the two dimensional case as that space is now being occupied by other spheres in the z direction. To combat this, both the size of the sphere and color/brightness will change to represent values. The size will get larger with large absolute values from our equations (more positive and more negative values). The colors will change to a purplish for a positive color and yellow/green color for negative. With this, we are able to now visualize information in a three dimensional situation.
Similar to the two dimensional case, we will start with represented a three dimensional Sine function with this new grid. Again, pink/purple means a high positive value and yellow/green means a more negative value
3D Particle-in-a-box Scenario
For the three dimensional corollary to the particle-in-a-box, the math works almost exactly the same, we are just adding another dimension into the mix. The wave function structure of being simple sines is exactly the same, we just have one more sine wave in the z-direction. This turns it into something that looks like this.

Notice how we see similar behavior to the two dimensional case except instead of four peaks in the wave function, we now see eight. This is directly a response to the number of dimensions we have in the system. Recall how in the two dimensional case the two peaks in each direction are the result of the energy level being 2. If we were to run a one dimensional particle-in-a-box we would have 2 peaks (2 raised to the 1st power). In the two dimensional case we have four (2 raised to the 2nd power). Same goes in this case with eight peaks (2 raised to the 3rd power). As our dimensions increase we would continue to see the number of peaks raise in the same pattern, although we would have no way of comprehending how those scenarios would look.
Moving on from the interesting effects of dimensionality on the system, if we were to square the wave function similar as we did in the two dimensions, our scene now looks like:

These eight clusters that we see are the eight most probable regions we would find a particle if we were to take a snapshot of the system.
3D Quantum Harmonic Oscillator Scenario
Time to get weird! In the two dimensional case of the quantum harmonic oscillator, we imagined the potential as a bowl and the particle as a marble. When we scale it up a dimension, the best way to visualize the new potential constraining the particle is in a similar way that gravity does. As we can observe a ball acting under gravity as always being pulled towards the center of the gravitational field, it is correct to think of the three dimensional potential acting in a similar manner. The particle will always be "drawn" towards to the center of this potential. Under these conditions we see the wave function evolves with times like so.
There are two very interesting things to note here. The first is that we see this system has scaled up geometrically the exact same way as our particle-in-a-box scenario when going from two dimensions into three. The second is that taking this dimensional scaling into account, the behavior of the three dimensional oscillator is the exact same as that of the two dimensional oscillator. There are some exciting implications here about the conservation of behaviors in systems across dimensions (which is very useful in higher level explorations in Quantum systems).
3D Electron Orbiting the Hydrogen Atom
Time for one of the most interesting visualizations I was able to create. In this scenario, the electron is behaving the exact same way as it does in the two dimensional orbiting case we have seen above. The only difference is that now the electron is free to move around the whole spherical shell at the given radius (versus the circle from before).
At first glance, this visualization might seem like complete chaos. If you really watch it knowing the behavior is exactly the same as the two dimensional case, you can see the smaller cluster of lights appearing in the very center of the sphere. These correspond to the smaller radius of electron orbit within the two dimensional case. The other lights are those occurrences of the electron appearing at the outer radius.
Also, the motion the electron may look sporadic, not following any kind of orbit as we traditionally think of the word. This is exactly the point of the visualizations. The wave and probability functions of the particle only tell us where it is likely to exist if we took a snapshot of the system. So the visualization above (barring generalizations we have made in the wave functions) is actually more accurate to what we might see if we could take successive snapshots of this electron orbiting a hydrogen atom than visualizations that show an electron orbiting the atoms nuclear like planets around the sun!
A Lesson About Infinity
One thing you will quickly learn when studying physics is that physical systems hate infinities. Whenever an infinity shows up within a system, it typically falls apart terribly. I learned this the hard way when originally building the 3D grid and playing around with tangent functions (that will go to infinity after a bit of time). Here is one of those bloopers where an infinity managed to completely destroy the program.

Music Visualizer
One last fun side excursion I took during the process of my capstone project was creating a music visualizer. It was very convenient as the framework I had already built for the 2D grid works perfectly for visualizing music. All I had to do build a mechanism that can take a sound file and sample its whole frequency range at every frame and map those present frequencies to a distance from the center of the grid. The results give a dynamic and pleasing visualization for any song you supply it.
I was inspired to build this as I had started making my own music at the beginning of my senior year of college wanted to make another medium to interact with my music. Below is the visualizer on a snippet of a song I have recently been working on!
