\( \newcommand{\PD}[2]{\frac{\partial#1}{\partial#2}} \renewcommand{\vec}[1]{\mathbf{#1}} \newcommand{\ord}{\mathcal{O}} \newcommand{\Mr}{M_\text{r}} \newcommand{\msol}{M_{\odot}} \newcommand{\rsol}{R_{\odot}} \newcommand{\nabad}{\nabla_\text{ad}} \newcommand{\HP}{H_P} \newcommand{\CFL}{\text{CFL}} \)

PHY3033 – Advanced Astrophysics

Computer Lab

Philipp Edelmann
philipp.edelmann@ncl.ac.uk

Goals of this class

  • learn to run the stellar evolution code MESA
  • practical insight into stellar evolution
  • practical understanding of numerical simulations
  • learn how to analyse simulation output
  • learn to work in a Unix environment

The MESA stellar evolution code

  • solves equations of stellar structure
  • physics modules for nuclear reactions, opacities, …
  • can also simulate planets
  • free software (GPL)
  • developed by international community
  • on-the-fly visualisation
  • details in the next session
MESA logo

Equations of stellar structure

\begin{align} \PD{r}{m} &= \frac{1}{4 \pi r^2 \rho},\\ \PD{p}{m} &= - \frac{G m}{4 \pi r^2},\\ \PD{l}{m} &= \epsilon_\text{n} - \epsilon_\nu - c_p \PD{T}{t} + \frac{\delta}{\rho} \PD{p}{t},\\ \PD{T}{m} &= - \frac{G m T}{4 \pi r^4 p} \nabla,\\ \PD{X_i}{t} &= \frac{m_i}{\rho} \left(\sum_j r_{ji} - \sum_k r_{ik} \right). \end{align}
List of fastest supercomputers

top500.org

Rank Site System Cores Rmax (TFlop/s) Rpeak (TFlop/s) Power (kW)
1 National Supercomputing Center in Wuxi
China
Sunway TaihuLight
NRCPC
10,649,600 93,014.6 125,435.9 15,371
2 National Super Computer Center in Guangzhou
China
Tianhe-2 (MilkyWay-2)
NUDT
3,120,000 33,862.7 54,902.4 17,808
3 Swiss National Supercomputing Centre (CSCS)
Switzerland
Piz Daint
Cray Inc.
361,760 19,590.0 25,326.3 2,272
4 DOE/SC/Oak Ridge National Laboratory
United States
Titan
Cray Inc.
560,640 17,590.0 27,112.5 8,209
…
11 United Kingdom Meteorological Office
United Kingdom

Cray Inc.
241,920 7,038.9 8,128.5 3,629

Top 500

Top 500 diagram of operating systems

Getting access to MESA

  • remotely log in to our Linux server
    • no need to set anything up
    • data analysis and plots can be done there or on another computer
    • access to your Windows H: drive
  • install it on your own computer
    • quite easy if you are running Linux or macOS
    • on Windows it can be installed in a virtual machine
      (will be provided if there is interest)

Resources

A very short introduction to Unix

  • family of operating systems sharing common code/design principles
  • developed in the 1970s at Bell Labs
  • portable: from phones to super computers
  • runs majority of internet servers
  • modular design (do one thing well)
  • many free variants: GNU/Linux, BSD, …

The command line

  • typically accessible from a terminal emulator
  • different shells with slightly different interface
    (bash is most common)
  • used to string together several commands (pipes)
  • shells can be used to write scripts

File system tree

  • everything is in one tree (root at /)
  • all file systems are “mounted” at a path
  • directory separator: /
  • some useful directories:
    • /home/username: home directory of the user
      can be abbreviated as ~
    • /tmp: local temporary file storage for everyone, deleted regularly
    • /etc: global configuration files
    • /usr/bin: executables for installed software
    • /media: mounted external file systems (e.g., USB drives)
    • others mostly relevant for administration

Directories

  • see current working directory: pwd or in prompt
  • change directory: cd /tmp
  • list contents of directory: ls
  • extended listing: ls -l
  • current directory: . (e.g., cp /a .)
  • parent directory: .. (e.g., cd ..)

Environment variables

  • names associated with a character string
  • conventionally all upper case (not the content)
  • automatically passed along when running commands
  • can be used when constructing commands:
    echo $USER
  • special variables: PATH, HOME, DISPLAY
  • set variables with
    export MESA_DIR=$HOME/path/to/mesa

Running executables

  • executable name, optionally followed by one or more arguments (e.g., ls -l /tmp)
  • name is searched in PATH variable
    entries separated by :
  • current directory (.) not part of PATH
    run executables with ./myexec
  • full path can always be used
    /bin/ls

Editing files

  • configuration often stored in plain text files
    MESA is controlled through text files
  • MESA output is written to plain text files
  • simplest data format: one byte, one character (ASCII)
  • graphical editors: pluma, kate, mousepad, gedit
  • command-line editors:
    vi, emacs, nano (easy for beginners)

Obtain exercise templates via git

  • git is a version-control system (VCS)
  • often used for (collaborative) software development
  • we distribute templates for exercises with it
  • alternative: zip file on Blackboard
  • get initial copy with
    git clone https://mas-gitlab.ncl.ac.uk/PHY3033/exercises.git
  • update later with
    git pull

Run a MESA session for testing

  1. navigate to the template directory
    exercises/00-test/work using cd
  2. run the command ./mk to compile the example
  3. run the code with ./rn
  4. watch a $1\,M_\odot$ star evolve
  5. you can interrupt it any time with Ctrl+c in the terminal