March 19 - a summary

Here is a summary for yesterday.

Today we started with a bit of chit chat about pi day. I talked about a video I saw that estimate the value of pi using dice and random chance, so I'll share that link.

We reviewed our progress from the last weeks by generating a bit of pseudo code for our simulation and highlighting the high level objectives and methods we were building our code around. Here's a cleaned up and augmented record of what we want for our solar system simulation, including some new logic on collisions we built up together over the session

Initialization

  • Generate particles and their initial states
    • Assign masses - determine their radius from mass
    • Assign positions
    • Assign velocities
    • Assign acceleration
  • Draw the particles onto a digital canvas
  • Decide on rules for interactions, i.e., forces each particle feels as a function of the current state
    • Gravitational attraction between pairs
  • Decide how long a time step is going to be

Step in time to update particles' states

  • For each particle...
    • Find the distance from every other particle
    • Calculate the force on the particle by summing up all the forces felt due to every other particle
    • Recalculate the acceleration the particle feels based on its mass and the total force it feels
  • Update the velocities and positions of each particle using the acceleration calculated above using the velocity Verlet algorithm
  • Check for collisions, i.e., if particles are closer together than the sum of their radii
    • Combine collided particles into a single new particle
    • Update velocity of new particle using local conservation of momentum
    • Update position of new particle as the center of mass of the original collided particles
    • Recalculate forces based on the new configuration of particles
  • Draw the updated particles onto the digital canvas
  • Repeat the steps in time

The session was really spent on playing with the logic surrounding the collision event. We looked deeply at the case where 2 particles collide, and hopefully we came away with a much stronger understanding of the concepts of center-of-mass and conservation of linear momentum, which came out mathematically to be simple weighted sums, i.e., mass averages.

But, as all interesting endeavors go, we had plenty of set backs and problems to solve. I knew ahead of time that there would be details to sort out, but I specifically held myself back from sorting them out, hoping that it would be a more real experience to discover the problems in real time with the students and struggle together to solve them. Spotting and articulating problems is hard so I of course took lead on that, but it was it was really the students who drove the conversation on how to proceed and solve them. Here are some of the main problems we faced:

  • How do we deal with collisions between more than 2 particles?
  • In counting up our collisions, can we simply delete old particles before we count up all potential collisions?
  • Once we finish with our collisions, what do we do with the old forces we calculated?

It's interesting to note that although I've written them in an order from basic to detailed, we uncovered them almost in exactly the opposite order - another demonstration that it takes effort to even understand the problem!

So we spent a lot of unforeseen time visualizing our collisions in tables like the one on the right.

We were all pretty optimistic about finishing the program yesterday, but this is the real world! I hope that over the next 2 weeks we will all keep these problems in the back of our minds and refine the strategies we discussed. A big question I have is whether or not we can combine the logics of collision and force calculations to make the algorithm more efficient.

Just to wrap it all up: we are attempting this simulation to check if we can predict the orbiting/spinning nature of bodies in space starting from a completely random collection of particles (and also because we all agree it would be really cool). I believe it is these sort of activities that give us a firmer sense of what it takes to model the physical world, what the challenges and shortcomings are, and how we can dig for deeper truths about the features of how the world actually works. The core of this exploration is the same for fluids modeling; in fact there are real methods that are used for modeling both fluids and galaxies (although it's not what we are doing here).

See you next time!

Alex

Joanna Cutts