User Tools

Site Tools


  • Cosmology
  • Planet Formation


August 2018:Kunsthalle Exhibit

June 2018: Euclid Star Prize


Simulations in the Natural Sciences II

ESC202:Spring 2020: Monday Lecture: 13:00-14:00 Exercises: 14:00-17:00 in Room 36 J 33

TAs: Stefan Schafroth (

Corona Virus Measures

Dear Students, I would like to keep the class going over the next few weeks. In order to adapt I will provide a video lecture from the 23. March onwards until lectures can take place again. Communication will take place via this web-site regarding all assignments as well. As the announcement about the closure of lectures was made on 13. March, it was not possible to provide a video lecture for the 16. March. I will however upload lecture notes for 16. March (today) and I ask you to complete the tree-code based simulation of the planetesimals orbiting the Sun. I hope that we can resume class meetings during the final 1/3 of the semester during the “project phase” of the course. Many thanks for your understanding!

Joachim Stadel

Video Lectures

Videos for the lectures can be found here (they are too large for my Wiki):

ESC202 Video downloads


17. Feb. 2020: Tree Structures and Dimensional Searching

2. Mar. 2020: Gravity Tree Walk

16./23. Mar. 2020: Introduction to SPH (Videos sph1.mp4 and sph2.mp4 see above link)


Should be handed in every Sunday night by 21:00 following the Monday lecture. Assignments should be individual and should be in python and provide a correct virtual environment!

For help getting started with virtual environments, please read carefully Python Virtual Environments for Pip and Python Virtual Environments for Conda.

You should email 3 things to Stefan (

  1. The working python source code
  2. The requirements.txt file for your virtual environment
  3. A .pdf or .png image or animation of the output of your program



Please add the names of the people you work together (if you do) to the comment section of your python scripts.

Create a virtual environment using


- run virtualenv yourenv_name to create a virtual environment

- run source yourenv_name/bin/activate to activate yourenv_name

- install necessary libraries that you want using pip install package_name

- work in that directory, get your outputs (*.pdf, *.png, *jpeg, *.mp4, etc…)

- run pip freeze > requirements.txt to get your list of libraries


- run conda create -n yourenvname python=x.x anaconda to create a virtual environment

- run source activate yourenvname to activate yourenv_name

- install necessary libraries that you want using conda install -n yourenv_name package_name

- work in that directory, get your outputs (*.pdf, *.png, *jpeg, *.mp4, etc…)

- run conda list –export > requirements.txt to get your list of libraries

List of assignments

1.k-Nearest Neighbors algorithm (you can set k=8 or other values to test). You should check the code via direct computation (O(N^2)). Solution is expected to include a priority queue over the 8 NN particles, but could also explore the use of a further prioq over the nearest cells during the treewalk as discussed in the lecture.

2. Extended to Sunday 22.03.2020: Gravity simulation using 2-D trees. Implement a 2-D gravity tree-code to solve the forces between the 12'095 planetesimals in the early solar system. While the data structure is 2-D, the forces and motions are actually 3-D. The data file below contains the planetesimals in the following format (one per line): <x y z vx vy vz m r> in unit of AU, AU/day, solar mass and AU. Recall these are the same units used in the ESC201 course for the solar system simulations. You will have to use the Gaussian gravitational constant k^2 instead of G.

esc202-planetesimals data file

spin/esc202_fs2020.txt · Last modified: 2020/03/23 13:32 by stadel