Running an Example

Now that you have built the code, you will want to run an example! Let’s start with a hydrodynamics only example, the 3D Sod Shock.

Sod Shock

To run the Sod Shock example, you need to follow the following instructions (requires python3 with the h5py and other standard scientific packages, as well as wget for grabbing the glass).

cd examples/HydroTests/SodShock_3D
../swift --hydro --threads=4 sodShock.yml
python3 1

This will run the ‘SodShock’ in 3D and produce a nice plot that shows you how the density has varied. Try running with GIZMO-MFV (this will take significantly longer than with SPH) to see the difference. For that, you will need to reconfigure with the following options:

./configure \
--with-hydro=gizmo-mfv \

To see the results that you should get, you should check out our developer wiki at

If you don’t get these results, please contact us on our GitHub page at

Small Cosmological Volume

As a second example, we run a small cosmolgical volume containing dark matter only starting at redshift \(z = 50\). Like for the Sod Shock example, it suffices to configure (./configure) and compile (make) the code without any extra flags.

After downloading the initial conditions, we run the code with cosmology and self-gravity:

cd examples/SmallCosmoVolume/SmallCosmoVolume_DM
../../../swift --cosmology --self-gravity --threads=8 small_cosmo_volume_dm.yml

We can plot the solution with the included python script as follows:

python3 31

The script requires the swiftsimio library, which is a dedicated and maintained visualisation and analysis library for SWIFT.

An additional example containing both baryonic and dark matter is examples/SmallCosmoVolume/SmallCosmoVolume_hydro. To run with hydrodynamics, the --hydro flag needs to be provided as well:

cd examples/SmallCosmoVolume/SmallCosmoVolume_hydro
../../../swift --cosmology --self-gravity --hydro --threads=8 small_cosmo_volume.yml

The solution can again be plotted using the script.