T0: Introduction:
connecting, compiling, running, reading data
Before the tutorials:
As discussed in the Lecture, it is important to know the length scale on which the basic constituents of a medium intact. Start with the figure

to think about and work out the following:
- Identify the astrophysical systems in this plot and think about what they are.
- What is the physical size of these systems?
- What is the physical state of the matter in these systems and why?
- Can you place some more astrophysical systems on this plot?
Try at least to place the intra-cluster medium and some special regions within the milky way.
- Can you compute the mean free path between particles for some of the astrophysical systems you have in the plot?
- Compare this mean free path to the size of the system.
- Many(?) of these system will be have charged particles. Do they have magnetic fields?
If so, how big are they and what is the expected gyro radius of the particles?
During the tutorials:
After we paired you into the groups and assigned the computational resources to you, try to get all set up!
To do each tutorial, you need to follow some basic steps:
- Step 1: Connect to our machines
- Step 2: Setup the numerical experiment (note that there can be several numerical exercises in each tutorial)
- Step 3: Perform a numerical experiment. To do so, there are again 5 fundamental steps:
- Step 3a: modify the parameter file (typically something.param) and the configuration file for the hydro code (OpenGadget3/Config.sh)
- Step 3b: Compile the hydro code (OpenGadget3)
- Step 3c: Create the initial conditions for the numerical experiment you want to do. Here you can use the programming language of your choice. We will always give examples, but not in all languages. So please get familiar in how to do this step. This is basically defining your experimental setup.
- Step 3d: Let the simulation run
- Step 3e: Visualize the output of the simulation
- Repeat steps 2 and 3 for the next experiment
Step 1: Connecting
- Make sure that you have installed the VPN client.
- Make yourself familiar with how to connect to our computers, make yourself familiar with the shell.
- If you have a working X11 environment running on your Laptop (e.g., a Linux operating system),
then you can just do a
ssh -4 -Y hydro@ltsp05.usm.uni-muenchen.de
where you need to replace the 05 by the number assigned to your group.
- If you do not have a working X11 environment:
- On Windows: install the Cygwin package.
- On macOS: install the XQuartz package. Start the server and see if you can open local clients like xterm from the command line.
- Or you can use the VNC client (instructions can be found here) as in the astrolab.
(Note that a VNC server must be running on the USM machine for this to work.)
Step 2: Setup
- As a first step, make an own group directory and a subdirectory for this tutorial and change into this directory:
-
mkdir MyGroup
-
mkdir MyGroup/Tutorial00
-
mkdir MyGroup/Tutorial00/ExperimentX
-
cd MyGroup/Tutorial00/ExperimentX
- As a second step, copy the simulation program into your directory, e.g.,
-
cp -r $HOME/Hydro/OpenGadget3 .
Step 3: Perform the numerical experiment
- (3a) Copy the parameter file:
cp $HOME/Hydro/box.param .
- In case, change the content of box.param as described for each experiment
- In case, change the content of OpenGadget3/Config.sh as described for each experiment
- (3b) Compile the simulation program:
-
module load intel
(this has to be run only once after you have connected to our machines)
-
module load openmpi
(this has to be run only once after you have connected to our machines)
-
cd OpenGadget3
-
make -j
-
cd ..
- (3c) Write a small program which creates a cube of 10x10x10 particles in a region with the coordinates [0...1].
Give a tiny velocity in x direction and write the data into a initial conditions file box.ic.
- Use the example in the IDL language
cp $HOME/Hydro/IDL/Setup/*.pro .
idl -e setup_grid
- or the example in the C/C++ language
cp $HOME/Hydro/C/gadget_io.h .
cp $HOME/Hydro/C/setup_grid.c .
icc setup_grid.c
./a.out
- or the example in the Fortran language
cp $HOME/Hydro/Fortran/gadget_io.f90 .
cp $HOME/Hydro/Fortran/setup_grid.f90 .
ifort gadget_io.f90 setup_grid.f90
./a.out
- or the example in the Python language
cp $HOME/Hydro/Python/g3read.py .
cp $HOME/Hydro/Python/setup_grid.py .
cp $HOME/Hydro/Python/ic_header .
python3 setup_grid.py
- or the example in the Julia language
cp $HOME/Hydro/Julia/setup_grid.jl .
julia setup_grid.jl
- (3d) Now actually perform the numerical experiment by running the hydro simulation:
module load intel
(this has to be run only once after you have connected to our machines)
module load openmpi
(this has to be run only once after you have connected to our machines)
mpirun -np 1 OpenGadget3/P-Gadget3 box.param
You can control on how many cores are used by
- change the number in the command
-np 1
to larger numbers.
- setting the environment variable
export OMP_NUM_THREADS=1
to larger values.
Note that on our systems the product of both should not exceed 4. If you use the Physics CIP cluster, this can be larger.
- (3e) Write a small program to display the result
- Use the example in the IDL language
cp $HOME/Hydro/IDL/Show/*.pro .
idl -e show
xv frame_0*.jpg -wait 0.1 -wloop
- or the example in the C/C++ language
cp $HOME/Hydro/C/gadget_io.h .
cp $HOME/Hydro/C/show.* .
icc show.c
./a.out snap_* > data.txt
gnuplot show.plt
(press enter to go forward)
- or the example in the Fortran language
cp $HOME/Hydro/Fortran/show.* .
ifort gadget_io.f90 show.f90
./a.out snap_* > data.txt
gnuplot show.plt
(press enter to go forward)
- or the example in the Python language
cp $HOME/Hydro/Python/g3read.py .
cp $HOME/Hydro/Python/show.py .
python3 show.py
firefox basic_animation.mp4
- or the example in the Julia language
cp $HOME/Hydro/Julia/show.jl .
julia show.jl
firefox scatter.gif
You should see an animation like this, with particles moving from left to right:
Programming goals for T0:
Goal of this tutorial is that you learn how to use commands in a unix shell,
how to compile and execute a program,
how to write a simple program (concept of “main”),
how to define variables and calculate values in a program,
how to perform output from a program,
how to start a simulation, and
how to plot the results.
Running on other platforms
If you want to do the tutorials on an other platform (like your own PC), you need
to have at least a C++ compiler installed and an MPI environment.
In addition you need to have the gsl library available,
plus whatever you want to use for creating your plots.
The material you need can be obtained by doing:
wget https://www.usm.uni-muenchen.de/~ildar/hydro_course/ws2223/T00/sources.tar.gz
Further information
Description of the format of snapshot files.