Introduction
GADGET [1] is a freely
available code for cosmological N-body/SPH simulations on massively
parallel computers with distributed memory. GADGET
uses an explicit communication model that is implemented with the
standardized MPI communication interface.
Installation on Linux
GadGet2 requires of GSL (GNU Scientific Library [3]), MPI (MPICH or OpenMPI) and FFTW. The HDF5 is optional. In this post I will explain how to install GSL FFTW and Gadget2. In the most popular Linux distributions are available MPICH and OpenMPI package.
GNU Scientific Library
# wget ftp://ftp.gnu.org/gnu/gsl/gsl-1.9.tar.gz
# tar xvzf gsl-1.9.tar.gz
# cd gsl-1.9
# ./configure --prefix=/opt/envhpc/gsl/1.9
# make
# make install
Instalación de FFTW
# wget www.fftw.org/fftw-2.1.5.tar.gz
# tar xvzf fftw-2.1.5.tar.gz
# cd fftw-2.1.5
# ./configure --prefix=/opt/envhpc/fftw/2.1.5/ --enable-mpi --enable-type-prefix --enable-float
# make
# make install
Gadget2
# wget http://www.mpa-garching.mpg.de/gadget/gadget-2.0.7.tar.g
# tar xvzf gadget-2.0.7.tar.gz
As HDF5 is not installed, we need to comment this line in the Gadget2 Makefile.
Know issues:
main.c:3:24: error fatal: drfftw_mpi.h: Do not exist the file or the directory.
It is needed to change the include drfftw_mpi.h by srfftw_mpi.h [2].
Example of simulation
The Gadget2 source code contains a set of examples. One of them is galaxy colision which runs two disk galaxies into each other, leading to a merger between the galaxies. Each galaxy consists of a stellar disk, and a massive and extended dark matter halo. This example uses plain Newtonian physics, with 20000 disk and 40000 halo particles in total.
Copy the galaxy.param file from parameterfile directory. It is needed to edit it and change the variables InitCondFile, OutputDir and OutputListFilename with the complete path.
InitCondFile /home/user/Gadget-2.0.7/ICs/galaxy_littleendian.dat
OutputDir /home/user/Gadget-2.0.7/Gadget2/galaxy/
EnergyFile energy.txt
InfoFile info.txt
TimingsFile timings.txt
CpuFile cpu.txt
RestartFile restart
SnapshotFileBase snapshot
OutputListFilename /home/user/Gadget-2.0.7/Gadget2/parameterfiles/output_list.txt
And finally, launch the simulation with mpirun (It is needed MPI implementation - OpenMPI or Mpich2):
$ mpirun -np 16 ./Gadget2 galaxy/galaxy.param
How to represent the data?
After simulation, you probably think in represent the data. Splash software [3] allows to represent from snapshots generated by Gadget. The installation on Ubuntu requires of libcairo package:
# apt-get install libcairo2-dev
Download the source splash source code and
edit build/Makefile from Splash Software and change:
X11LIBS= -L/usr/X11R6/lib -lX11
for this line:
X11LIBS=-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libX11.so
Finally:
# make SYSTEM=gfortran
# make install
Once compiled, the program for gadget2 is gsplash, With this we can generate a set of png images and create, for instance, a video with ffmpeg.
$ gsplash snapshot_00*
_ _
(_) _ _ _ _ (_)_
_ (_) ___ _ __ | | __ _ ___| |__ (_) _ (_)
_ (_) _ / __| '_ \| |/ _` / __| '_ \ _ (_)
(_) _ (_) \__ \ |_) | | (_| \__ \ | | | _ (_) _
(_) _ |___/ .__/|_|\__,_|___/_| |_| (_) _ (_)
(_) (_)|_| (_) (_) (_)(_) (_)(_) (_)(_)
( B | y ) ( D | a | n | i | e | l ) ( P | r | i | c | e )
( v2.2.0 [16th Nov 2012] Copyright (C) 2005-2012 )
* SPLASH comes with ABSOLUTELY NO WARRANTY.
This is free software; and you are welcome to redistribute it
under certain conditions (see LICENSE file for details). *
Comments, bugs, suggestions and queries to: daniel.price@monash.edu
Check for updates at: http://users.monash.edu.au/~dprice/splash
Please cite Price (2007), PASA, 24, 159-173 (arXiv:0709.0832) if you
use SPLASH for scientific work and if you plot something beautiful,
why not send me a copy for the gallery?
splash.defaults: file not found: using program settings
6 filenames read from command line
Using default M4 cubic spline (2h) kernel
----------------------- snapshot_000 -----------------------
>> reading default Gadget format <<
time : 0.16666699833882792
z (redshift) : 5.00 (set GSPLASH_USE_Z=yes to use in legend)
Npart (by type) : 0 140005 39616 96877 0 0
Mass (by type) : 0.0000000000000000 1.1077876463313410 0.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000
N_gas : 0
N_total : 276498
N data columns : 10
> allocating memory: parts = 276498 steps = 1 cols = 10
positions 276498
velocities 276498
particle masses 136493
gas properties 0
******************************************************************
An example of this simulation (video):
References
[1] http://www.mpa-garching.mpg.de/gadget/
[2] www.fftw.org/fftw2_doc/fftw_6.html
[3] http://users.monash.edu.au/~dprice/splash/