{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Einstein Toolkit Tutorial "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First we need to download some packages needed to compile the Einstein Toolkit."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you use a Mac, you should first install MacPorts https://www.macports.org/install.php.\n",
"And then you can install the packages you need by executing these commands in a terminal:
\n",
"sudo port install subversion mercurial wget git
\n",
"sudo port install pkgconfig gcc7 openmpi fftw-3 gsl jpeg zlib hdf5 +fortran +gfortran openssl py-matplotlib
\n",
"\n",
"If you use Ubuntu, you should install the packages you need using these commands in a terminal:
\n",
"sudo apt-get install subversion git mercurial wget python python-matplotlib curl
\n",
"sudo apt-get install build-essential perl gfortran g++ libmpich-dev
\n",
"sudo apt-get install libfftw3-dev libgsl-dev libatlas-base-dev libjpeg-dev libssl-dev
\n",
"sudo apt-get install libhdf5-dev hdf5-tools libnuma-dev libltdl-dev libhwloc-dev zlib1g-dev
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we create the directory where the tutorial material will be located"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!mkdir Einstein_Toolkit_CINECA"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%cd Einstein_Toolkit_CINECA"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this directory we now download the files used for this tutorial"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!wget http://brunogiacomazzo.org/ETK_Tutorial_CINECA_2018/einsteintoolkit_CINECA.th"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!wget http://brunogiacomazzo.org/ETK_Tutorial_CINECA_2018/tov_ETK_2018_CINECA.par"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now create the directory where the simulation data will be stored"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!mkdir simulations"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we download the components of the Einstein Toolkit needed to run this tutorial"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!curl -kLO https://raw.githubusercontent.com/gridaphobe/CRL/ET_2018_09/GetComponents"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!chmod a+x GetComponents"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: the following command sometimes may fail with an error similar to this:\n",
"\"Server SSL certificate verification failed: issuer is not trusted\".
\n",
"In this case, open a terminal and type:
\n",
"svn co
\n",
"where should be replaced with the address that is printed by the SSL certificate error.
\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!./GetComponents einsteintoolkit_CINECA.th "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%cd Cactus"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!cp ../tov_ETK_2018_CINECA.par ./par"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we set up simfactory"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!./simfactory/bin/sim setup-silent"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we compile the Einstein Toolkit (this may take ~30 minutes or more)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#uncomment the line that refers to your operating system\n",
"#!./simfactory/bin/sim build --machine=osx-macports --thornlist=thornlists/einsteintoolkit_CINECA.th\n",
"#!./simfactory/bin/sim build --machine=ubuntu --thornlist=thornlists/einsteintoolkit_CINECA.th"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And now we are ready to run a simple simulation. In the example we use 2 MPI processes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!./simfactory/bin/sim create-run tov_test --procs 2 --num-threads 1 --parfile=./par/tov_ETK_2018_CINECA.par --basedir=../simulations/"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once the simulation has finished we can go in the output directory and have a look at the results."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%cd ../simulations/tov_test/"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%cd output-0000/tov_ETK_2018_CINECA/"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!ls"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# This cell enables inline plotting in the notebook\n",
"%matplotlib inline\n",
"\n",
"import matplotlib\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's have a look at the maximum of the rest-mass density"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lin_data = np.genfromtxt(\"hydrobase-rho.maximum.asc\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lin_data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.plot(lin_data[:,1],lin_data[:,2])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.15"
}
},
"nbformat": 4,
"nbformat_minor": 2
}