How to simulate a fluid

Figure 5 of Price 2010, illustrating a simple SPH simulation: the evolution of a two-dimensional "shock tube." The initial conditions (top panel) are simply a compression of particles at one end of the tube. After a short timestep (bottom panel), the shock propagates through the tube, causing obvious compressions in the x-direction as well as small perturbations in the y-direction.

In my last post, I wrote about an interesting application of hydrodynamical simulations to a particular astrophysical problem, so when I saw this excellent introduction to the inner-workings of these simulation codes, I couldn’t resist highlighting it. Because smoothed particle hydrodynamics (SPH) and other fluid simulations underpin our theoretical understanding of nearly every field of astrophysics, and because they also have applications in many other realms of science, engineering, and even Hollywood special effects, having some familiarity with how they work is extremely valuable.

Price walks the reader through the basics of the SPH method. The fundamental aspect of the code is the mechanism for making measurements of local particle densities, which is done by picking a point in the simulation space and then weighting the distance to nearby particles by a “smoothing kernel” (such as a simple Gaussian function). Once the density is known, Price shows how you can use elementary Lagrangian mechanics (with a hydrodynamic potential energy term) to solve for the equations of motion that tell you how the particles will move during the next time step of the simulation. The beauty of this method is that by approximating the local particle density, you will essentially be able to treat the physics of the particles in a real gas (all Avogadro’s number or so of them!) with just a few datapoints in the simulation.

Price goes in to more detail in explaining how to properly conserve momentum and energy and how to obey the laws of thermodynamics in a simulation (or how to measure the error introduced when you don’t). He ends his paper by including magnetism in the Lagrangian and delving into the consequences thereof (magnetohydrodynamics, or MHD). For great fun, you can download Price’s NDSPMHD SPH code from his website and use it to follow along with the examples in the paper.

If you find Price’s introduction to SPH interesting, there’s a whole world of computation waiting for you. Search the arXiv to learn how theorists incorporate gravity, dark matter, star formation and nucleosynthesis, chemical reactions, and more into their simulations. Of course, for each layer of complexity astronomers have added to these simulations, you can find even more techniques that have been developed to speed up and improve the accuracy of the computation.

About Nathan Sanders

I am one of the members of the team that founded Astrobites in 2010 and a co-founder of ComSciCon, the Communicating Science Workshop for graduate students. I earned my Ph.D. in astronomy at Harvard University in 2014, focusing on observations of supernovae and their host galaxies; investigating how massive stars explode and enrich the interstellar medium. I did my undergraduate work at Michigan State University.

Trackbacks/Pingbacks

  1. Finding dark galaxies from their tidal imprints « astrobites - [...] uses an N-body algorithm to model collisionless particles that interact gravitationally and smooth particle hydrodynamics (SPH) to model a…
  2. Simulating a star at the brink of explosion « astrobites - [...] and Meakin’s latest work improves our understanding of core-collapse supernovae by simulating the evolution of a progenitor star near…
  3. Magnetic Fields and Gravitational Collapse « astrobites - [...] mesh refinement (AMR), as opposed to particle-based approaches such as those discussed by Nathan in an earlier astrobite).  Then…
  4. Why are most molecular clouds not gravitationally bound? « astrobites - [...] the authors simulate the evolution of gas in the Milky Way, using a smoothed particle hydrodynamic code. Many things…
  5. Why are most molecular clouds gravitationally unbound? « ISM and Star Formation - [...] of individual point mass by using a smoothing function (see also this paper and Nathan’s review).  The galaxy is modeled…
  6. Installing and Running Gadget-2 « astrobites - [...] to show how easy it is to run a simulation using Gadget-2, a smoothed particle hydrodynamics (or SPH) code.…
  7. Running your first SPH simulation « astrobites - [...] astrobite will be a sequel to a post I wrote a few months ago on using the smoothed particle…
  8. The Limitations of Smoothed Particle Hydrodynamics | astrobites - [...] used techniques for simulating astrophysical fluids.  Previous astrobites have discussed the the theoretical basis for SPH, how to set…
  9. Simulating the unseen: learning about Jupiter’s unknown impactor through simulations | astrobites - [...] this paper, Pond et al. present hydrodynamic simulations of the event, from the impactor’s entry to the development of…
  10. What are Mars’ moons made of? | astrobites - […] like stars in colliding galaxies. In SPH (which has been detailed in previous Astrobites like this one and this…
  11. What Are Mars’ Moons Made Of? - […] like stars in colliding galaxies. In SPH (which has been detailed in previous Astrobites like this one and this…
  12. A beautiful, yet complicated painting: What is going on in the disk around HD 142527? | astrobites - […] that they might all be due to the known close-in companion. How do they do it? With a full-on…

Leave a Reply