# Einstein Toolkit Tutorial¶

This tutorial is a smaller version of the Einstein Toolkit tutorial. The tutorial in this page let's you download and install only the Einstein Toolkit modules ("thorns") that are needed in order to run a simple simulation. This tutorial can run on a laptop and should require less than one hour in total.

First we need to download some packages needed to compile the Einstein Toolkit.

If you use a Mac, you should first install MacPorts https://www.macports.org/install.php. And then you can install the packages you need by executing these commands in a terminal:
sudo port install subversion mercurial wget git
sudo port install pkgconfig gcc7 openmpi fftw-3 gsl jpeg zlib hdf5 +fortran +gfortran openssl py-matplotlib

If you use Ubuntu, you should install the packages you need using these commands in a terminal:
sudo apt-get install subversion git mercurial wget python python-matplotlib curl
sudo apt-get install build-essential perl gfortran g++ libmpich-dev
sudo apt-get install libfftw3-dev libgsl-dev libatlas-base-dev libjpeg-dev libssl-dev
sudo apt-get install libhdf5-dev hdf5-tools libnuma-dev libltdl-dev libhwloc-dev zlib1g-dev

Now we create the directory where the tutorial material will be located

In [ ]:
!mkdir Einstein_Toolkit_CINECA

In [ ]:
%cd Einstein_Toolkit_CINECA


In this directory we now download the files used for this tutorial

In [ ]:
!wget http://brunogiacomazzo.org/ETK_Tutorial_CINECA_2018/einsteintoolkit_CINECA.th

In [ ]:
!wget http://brunogiacomazzo.org/ETK_Tutorial_CINECA_2018/tov_ETK_2018_CINECA.par


We now create the directory where the simulation data will be stored

In [ ]:
!mkdir simulations


Now we download the components of the Einstein Toolkit needed to run this tutorial

In [ ]:
!curl -kLO https://raw.githubusercontent.com/gridaphobe/CRL/ET_2018_09/GetComponents

In [ ]:
!chmod a+x GetComponents


Note: the following command sometimes may fail with an error similar to this: "Server SSL certificate verification failed: issuer is not trusted".
In this case, open a terminal and type:
svn co
where should be replaced with the address that is printed by the SSL certificate error.
At this point svn will ask if you want to accept the certificate. Type p to accept the certificate permanently and then rerun the GetComponents command below.

In [ ]:
!./GetComponents einsteintoolkit_CINECA.th

In [ ]:
%cd Cactus

In [ ]:
!cp ../tov_ETK_2018_CINECA.par ./par


Now we set up simfactory

In [ ]:
!./simfactory/bin/sim setup-silent


Now we compile the Einstein Toolkit (this may take ~30 minutes or more)

In [ ]:
#uncomment the line that refers to your operating system
#!./simfactory/bin/sim build --machine=osx-macports --thornlist=thornlists/einsteintoolkit_CINECA.th
#!./simfactory/bin/sim build --machine=ubuntu --thornlist=thornlists/einsteintoolkit_CINECA.th


And now we are ready to run a simple simulation. In the example we use 2 MPI processes.

In [ ]:
!./simfactory/bin/sim create-run tov_test --procs 2 --num-threads 1 --parfile=./par/tov_ETK_2018_CINECA.par --basedir=../simulations/


Once the simulation has finished we can go in the output directory and have a look at the results.

In [ ]:
%cd ../simulations/tov_test/

In [ ]:
%cd output-0000/tov_ETK_2018_CINECA/

In [ ]:
!ls

In [ ]:
# This cell enables inline plotting in the notebook
%matplotlib inline

import matplotlib
import numpy as np
import matplotlib.pyplot as plt


Let's have a look at the maximum of the rest-mass density

In [ ]:
lin_data = np.genfromtxt("hydrobase-rho.maximum.asc")

In [ ]:
lin_data

In [ ]:
plt.plot(lin_data[:,1],lin_data[:,2])