I created a Python package to simulate the interstellar medium (ISM) of galaxies for my Astro 330 Scientific Computing in Astrophysics class. The package entitled ISsiM is an N-body Smooth Particle Hydrodynamics (SPH) fluid simulator.
Allows you to create "galaxy" objects that are collections of points distributed in an exponential disk with a velocity determined by the Bessel function equation for orbital velocity in an exponential disk. These objects can then be simulated forward in time. The package can generate images to watch the simulation in real-time. Once the simulation has completed, you can output 2D projection videos and images of the entire simulation.
The gravity is simulated using simple direct N-body physics where all points have a certain mass and exert a force on all other points based on Newton's law of gravitation. The fluid simulation that allows for collision between particles and the formation of spiral features uses SPH physics based on a tutorial by Philip Mocz. Every particle is turned into a Gaussian density profile (as pictured to the left) called a smoothing kernel that allows us to estimate the density at all points. Pressure is then calculated using the density with the polytropic equation. The force from pressure on each particle is calculated using the Euler equation of a compressible fluid.
You can download the package directly from my GitHub https://github.com/dannytalk/ISsiM or by simply typing pip install issim into any Python environment to install from PyPI.