This program shows the wavefunctions of a time-perturbed quantum harmonic oscillator. It uses a discrete position basis and directly diagonalizes to solve for its stationary states. It then uses the interaction picture to simplify the time evolution properties and allow it to respond to the time-dependent perturbation. I am using the RK4 algorithm to adjust the b-coefficients of each eigenstate while it evolves.
Image 1: This shows a very narrow pulse causing the QHO to move into multiple excited states. Note that it obeys the selection rules and only pushes states up in multiples of two.
Image 2: This shows a broad pulse hitting the QHO. While there are many changes initially, it returns to its original ground state oscillation as is predicted by the adiabatic theorem.
Language: Python
This program shows the electron density of different molecules. To create the electron density cloud, I used atomic P and S orbitals from carbon and hydrogen and then computed the overlap matrix and diagonalized to find the coefficients for each orbital. The display then fills up the generated molecular orbitals with the number of valence electrons.
Image 1: This shows the molecular orbital structure of benzene.
Image 2: This shows the molecular orbital structure of ethane.
Language: MATLAB
Full writeup attached at left.
The campus electronics group was cleaning out their broken parts a few months back. I like messing around with broken electronics, so I started looking through their trash. I came across a heating element which consisted of a coil of wire wrapped around a transformer with the leads attached to the heating tip. Obviously whoever designed it only wanted the tip to heat up and not the coil, so they used a different metal/gauge so that most of the power was dissipated there and not in the transformer coil. I wanted to figure out the difference in resistivity between the two metals to see how large this power differential actually was. This got me thinking: using just an ohm-meter, how can you determine the resistivity rho(x) of any loop of wire of length L by only taking resistance measurements along its length at?
This problem spans functional equations, graph theory, functional analysis, and operator theory. Please get in touch at cjblake@uchicago.edu if you have any insights.
Language: MATLAB
This program uses the Liénard–Wiechert potentials to describe the time-retarded electric and magnetic fields created from accelerating point charges.
Image 1: Near-field electric field from vertically accelerating point charge.
Image 2: Near-field magnetic field from vertically accelerating point charge.
Language: Processing
This program models the Allee effect which says that the mean population fitness is proportional to the population density due to an increased need to compete for resources. This simulation shows a group of 8 "sweepers" on the left (the low density environment) and 32 "sweepers" on the right side (the high density environment). In each generation, little red food dots pop up in the environment. The sweepers roam the environment until they "see" a piece of food. Their field of vision of a sweeper is the arc and the smaller circle surrounding it. Each sweeper in the first generation is assigned random values for traits like sweep angle, sweep radius, speed, and inner radius. After all the food is gone, the sweepers are ranked according to how many pieces they picked up. The top half of the rankings are allowed to breed (1st with 2nd, 3rd with 4th, etc) where their "genetic" information is combined with a mutation factor. Through this simulation I was able to show that the Allee effect does in fact have a strong effect over just a few generations as can be seen with the reflex sweep angles and high sweep radii for the sweepers in the high density group as compared to the low density group.
Language: Java
The brachistochrone is the curve of fastest descent of an object sliding along a curve under the influence of gravity. However, the optimal path is an "inverted" cycloid which is complicated to calculate. I set out to find the fastest polynomial of different degrees. With each successive degree, the optimal curve should get faster and faster as it approaches a better approximation of the actual brachistochrone curve (note: this is slightly different from a proper Taylor series as the polynomials are defined as to hit the start and end points exactly). For each polynomial of degree n, there are n-1 degrees of freedom in parameters to define the curve. There is only one parameter to manipulate to explore all possible parabolas hitting the two end points, but there are two parameters to manipulate for cubics and so on. This program explores those degrees of freedom via gradient descent looking to find the set of fastest coefficients for a given degree. What makes this search for the fastest polynomial difficult is the abundance of local minima in the time taken for each curve, so extensive searching in the possible "phase space" is required to find the fastest curve. Theoretically this problem is easily solvable using calculus of variations, but I thought looking at it like an optimal control problem would be more fun.
Language: C++
This program uses a hard-disk model as described in kinetic molecular theory to model the elastic collisions between molecules. Each molecule was treated as a hard disk that would bounce off other molecules while preserving both momentum and kinetic energy. In this particular scenario, a collision would also have some chance of causing a molecule to "isomerize" and change forms. The red state has a higher chemical potential than the blue state, and the equilibrium reaction can be seen between the two at a certain temperature. There is also an activation energy that each molecule must have to in order to change forms. Just as in real kinetics, changing the mean starting velocity (and thus energy and temperature) of the molecules caused a shift in equilibrium. The calculated Keq of this particular reaction as it reached equilibrium was approximately 1.88.
Language: Java
This program used the same base as the gas kinetics program. All interactions between the "molecules" are elastic collisions that preserve both momentum and kinetic energy. Each molecule starts with the same speed facing random directions, but after a period of time their speed distribution relaxes towards the 2D Maxwell-Boltzmann distribution, just as expected. It shows some gases with higher speeds and some with lower speeds just as a result of how the collisions take place.
Language: Java
This program used the same base as the equipotential lines program except in 3 dimensions. There is an array of 3D static charges that are randomly generated in space. I then drew a Gaussian surface in the form of a cube around a region of the space. I performed an approximate surface integral of the region by summing the dot products of the flux across the surface normal vectors. Using Gauss's law, this surface flux is proportional to the charge enclosed by the permittivity constant. Using the approximated surface integral of the electric field, I was able to estimate the enclosed charge with an error of roughly 0.3%.
Language: Processing
This program models different ways a line of cars might respond to one car at the front suddenly braking to a near stop. The cars brake according to the difference in speed between them and the car in front of them and their ideal following time delayed by some reaction time factor. Each set of five lanes of cars has a range of variability for a given characteristics like following time, reaction time, severity of braking, speed, and distraction (extremely long reaction times). Through this simulation I was able to see what kinds of traits make for extremely dangerous driving (speeding, slow reaction times, short follow distances, and high and low braking severities). It also features a custom plotting system to display realtime data from multiple graphs.
Language: C++
This program is a twist on the classic snake game where the user controls a snake that travels around a grid without hitting walls or itself and grows when it eats an "apple". This program was simple enough to make, so I programmed an artificial neural network from scratch (no external libraries, just lots of 2D and 3D arrays) to make the computer play the game. The inputs to the network are the distances in each direction relative to the orientation of the head (ie how many pixels from the "left" side of the head to the wall, front, right, etc) and the relative coordinates of the current apple with respect to the current position and orientation of the head. This was then fed forward through the layers of the neural network to make a decision as to continue forward, turn left, or turn right. Backpropagation was not feasible in this case because of the number of possibilities the snake can take to get the apple and the fact that there are many successful ways of doing it. The simulation became very good at avoiding crashing into walls but more work will have to be done to perfect the apple tracking system, despite some of its successes (as shown in the picture). I also wrote a program to visualize the guts of the artificial neural network. As shown, it has 5 inputs on the left, 3 hidden layers of 5 nodes each and the output layer with 3 options (left, straight, right). As is standard in feedforward artificial neural networks, each path between nodes was assigned a weight that was different for all snakes. Similar to the Allee effect program, only the best snakes in each generation were allowed to "reproduce" by creating a slew of slight mutations of the "parent" in the next generation. A certain number of snakes in the next generation were also given completely new "genetic material" as to prevent just a few snake strategies dominating any other potential successes. This program was adapted from an AP Computer Science assignment on 2D arrays into a full Instagram post.
Language: Java
This program shows a collection of static charges (positive is white, negative is black with red outline). These charges create an electric field (not shown), and thus each point can be assigned a voltage. An equipotential line is the curve on which every point has the same voltage. In order to create the equipotential lines shown (different colors are different voltages), I picked a collection of equally spaced voltage values and multiple points along each one. Because electric field is the gradient of voltage, all electric field lines are perpendicular to the equipotential lines. To make the lines, I used those predetermined voltage points on the equipotential lines and and used Euler's method to step along the direction that is orthogonal to the electric field at that point. I continued stepping along in this way until I came back to the starting point or for a predetermined number of steps, whichever came first. The instability of Euler's method can be seen in the way some equipotential lines may cross each other or stray away from other threads at the same voltage.
Image 1: Equipotential lines for random collection of random charges.
Image 2: Quadrupole
Language: Processing
This program models how heat diffuses in a thermally conductive material. Fourier's law for heat flow (identical to Fick's first law of diffusion) says that the amount of flux is proportional to the gradient of the concentration (in this case that concentration is temperature). This is essentially modeling that partial differential equation in a lattice where each box is defined a temperature that evolves with time. Each next state is calculated without changing the values of the current state, and all the values are updated at once to avoid causality issues.
Language: Processing