Path: blob/master/activities/SPH-simulation.ipynb
934 views
Task 2
This homework is an activity intended to practice the basic concepts of python and some of the functions offered by NumPy and Matplotlib.
Due to: May 17
Gas in cosmological simulations
For this task we are going to use a dataset of gas particles of a cosmological simulation. To do so, the cosmological code GADGET2 was used, implementing the hydrodynamical scheme SPH (Smoothed Particle Hydrodynaics). This cosmological simulation is consistent with the WMAP7 cosmology, and it has a comoving lenght of per side (a cubic box), with a resolution of particles of gas.
The information of the gas particles can be downloaded from here. The order of the columns is:
ID of each particle.
X coordinate [ units].
Y coordinate [ units].
Z coordinate [ units].
X velocity component [ units].
Y velocity component [ units].
Z velocity component [ units].
Mass of each particle. Same for all [ units].
Internal Energy.
Density.
Pressure.
Temperature.
Redshift.
Cosmological time [units in age of the universe].
Phase diagram of the gas
Using preferably ipython notebooks, perform the next activities:
Load the previous dataset for the gas particles of the simulation.
Normalize the density in order to obtain the density contrast. To do so, divide the column of densities by the value:
where is the density parameter of baryonic matter. Obtaining
Using the function histogram2d of NumPy and the function imshow of Matplotlib, compute the phase diagram Density-Temperature-Pressure. You should obtain something like:
Note that the 2D histogram is calculated over the of each property.
Spatial distribution
Gas particles inside dark matter halos exhibit a characteristic profile (white region in the next figure), being possible to extract those particles just by looking at the phase diagram.
Make a 3D scatter plot of all the gas particles of the simulation. You shoud obtain something like this:
Using the ranges and and the masking functions (e.g. X[X>5]), extract the coordinates of the gas particles satisfying both conditions. Then, in the same windows, make a 3D scatter plot of these particles (use a different color).
Tip: you can find a relatively complete example of the usage of 2D histograms in this notebook.
How to plot a 3D scatter
For making a 3D scatter, it is necessary to import the package Axes 3D in order to activate the 3D plotting.