Cosmological Simulations 1: Generating your own slice of the Cosmic Web
By: Neerav Kaushal
Tags: Astronomy, Simulation, Universe, Astrophysics, Cosmology

I will be using the publicly available QUIJOTE¹ cosmological simulations which is a suite of 44,100 N-body simulations and a set of tools in Python called Pylians² that contains the commonly employed routines to read and analyse cosmological simulations. A single realization at redshift 0 with a fiducial cosmology will be used. There can be a number of cosmological simulations of the same Universe, each with a different random seed, just like multiple ensembles of the same thermodynamic system. Each of these ensembles is called a realization of our Universe. Fiducial cosmology means a standard cosmological model with some fixed parameters against which we can compare a variety of simulations with tweaked parameters. One important aspect of our fiducial cosmology is the absence of massive neutrinos [Note: Neutrinos are the second most abundant particles in the Universe after photons or radiation]. The simulation consists of 512³ Cold Dark Matter particles evolved in a simulation box of size 1000 Mpc/h from a initial redshift of 127 to the current epoch.

Considering you have properly installed the Pylians library in your machine, the first step would be to import the necessary libraries:

readsnap and readgadget read the simulation snapshot and MAS_library computes the density field. A typical comsological simulation can be in ASCII, RAMSES or GADGET file format.

Next, some parameters will be set

path directs to the snapshot of a fiducial cosmology for realization 1 and redshift 0 (snap_004 is redshift 0, snap_003 is redshift 0.5 and so on. Read Quijote documentation for more details). CIC or Cloud-In-Cell is a type of particle mesh algorithm that determines the interpolation scheme used to assign densities to grid cells. The number of pixels in the image will be grid². boxsize is the edge length of our simulation box which is a 1000 Mpc/h. Some types of simulations use a spherical region instead of a cubical volume. threads are the number of processor threads we want to use for our computation. Linear scale will be used to plot the density field. ptypes is the particle type, where 1 refers to Cold Dark Matter, 2 is Neutrinos, 3 is for Stars, etc. The particular region of the box whose density field we want to visualize is given by the axes limits in the last three lines.

Now, we will compute the overdensity of our region. Overdensity refers to the amount of fluctuation in the density of the matter at a particular point, from the average density of the simulation region.

So, the overdensity tells us about the cold dark matter density fluctuations in the Universe.

In line 1, the positions of all 512³ particles is read. The initial positions are in kpc and are converted to Mpc by dividing by 1000. These positions are explicitly stored in numpy arrays in line 2. Then, the particles that fall in our simulation region are selected on the basis of their indices in line 3 and the positions are updated in line 4. We then renormalize the coordinates and project the positions on a 2D plane. MASL.MA then computes the density field of the particles and then we compute the overdensity field by the formula stated above.

The final step now is to plot the density field. Let’s create an elaborate function for plotting this field

Finally, we plot the field

And voilà! We have our very own slice of a Cosmic Web.