Computational Astrophysics L1
Computational Astrophysics L1
David Hobbs
Lund Observatory
ASTM22
Course Marks
Presentation will be given for 15 minutes on your chosen topic and must be closely related to
astrophysical simulations
Projects
Project 1: (See Lecture 1 – 20%)
Make a simulation to solve the N-body problem and investigate the time evolution of the
Trojan satellites of Jupiter for 300 years using an initial time step of 0.01 years. Implement a
4th order Runge Kutta numerical integrator.
The merger of two spiral galaxies, a process that leads to the inflow of gas into the
galaxy centres, causing rapid growth of the central supermassive black holes.
The energy input associated with the gas accretion eventually expels a lot of the gas in a
quasar-driven wind, terminating the black hole growth and greatly reducing residual
star formation in the formed elliptical galaxy. (Reference publication: Springel et al.)
Galaxy
cluster
Authors:
Klaus Dolag
1 1
H0 = 100h [kms M pc ]
so h = 0.73 today
1 1
and H0 = 73 [kms M pc ]
Introduction to numerical methods
Introduction
Observations of astrophysical phenomena on every scale imply that
hydrodynamical flow and orbital mechanics are vital to understand the universe.
Also the theory of radiation flow, which links our instruments to these events, is a
third important element in the interpretation of physical phenomena.
Objectives
This first lecture focuses on the basic concepts of numerical hydrodynamics.
This introductory lecture will discuss:
• General numerical simulations
• Grid based methods
• Eulerian approach
• Lagrangian approach
• Meshfree methods
• Meshfree particle methods
• Smoothed Particle Hydrodynamics
Subsequent lectures will discuss numerical details of SPH and N-body
techniques, with a focus on numerical implementation and examples.
General numerical simulations
In general, numerical simulations follow a basic procedure as illustrated below.
In the equations p, ρ, e, v and x are pressure, density, internal energy, velocity and position vectors respectively.
The Greek subscripts α and β are the coordinate directions (e.g. x,y,z) and summation is implied over repeated indices.
Eulerian versus Lagrangian
The conservation equations are derived using conservation of mass, momentum and energy in the
Boltzmann transport equation (BTE).
BTE describes the statistical flow through position and velocity phase space, subject to forces.
• The Euler equations describe the evolution of the state of the medium at a fixed location in
space.
✴ We have V0 at t=0 and X → Vt at t=t and x.
• The Lagrangian equations employ a co-moving spatial coordinate of a fluid element and the
property of the particle is traced as a function of time. D/Dt describes changes within the
element such as its state and location.
✴ At t=0 we have V0 and X → at t=t we have Vt and x.
The derivation of both sets of equations can be found in ref. [1] and [4].
Significance of the time derivatives
The differences between the two sets of equations comes from the definition of the total time
derivative which consists of a local and a convective derivative:
• D/Dt is the total time derivative (substantial, material or global derivative) and is
physically the time rate of change following a moving Lagrangian fluid element.
• ∂/∂t is the local derivative that is the time rate of change at a fixed point.
• vα∂/∂vα is the convective derivative: physical change due to the movement of the fluid
element from one location to another.
Leonhard Paul Euler Joseph-Louis Lagrange,
(15 April 1707 – 18 September 1783) (25 January 1736 – 10 April 1813)
was a pioneering Swiss mathematician and was an Italian/French mathematician and
physicist who spent most of his life in Russia and astronomer, making significant contributions to
Germany. He is renowned for his work in many fields. On the recommendation of Euler and
mathematics, mechanics, fluid dynamics optics D'Alembert, in 1766 he succeeded Euler as the
and astronomy. director of mathematics at the Prussian Academy.
Grid-based methods
The two fundamental frames in grid methods
• the Eulerian description is a spatial description
• the Lagrangian description is a material description
By combining the complementary features of both methods, the advantages can be maximized.
Done in Coupled Eulerian Lagrangian (CEL) and Arbitrary Eulerian Lagrangian (AEL) methods.
They can be more stable but also require complicated mapping between the two types of mesh.
Mesh generation is a problem
Grid-based methods are widely used but have inherent difficulties which limit their
application.
• In Eulerian grid methods constructing regular grids for irregular geometry is complex
and time consuming.
• In Lagrangian grid methods computing the mesh for the object is time consuming.
• Treating large deformations usually requires rezoning techniques, which are tedious,
error prone and time consuming.
Grid based methods are not so suitable for simulating explosions, high velocity impacts
because of the large deformations, inhomogeneities, moving material interfaces, etc.
Grid based methods are not suitable for discrete physical particles, e.g.
• the interaction of stars in astrophysics
• movement of millions of atoms
• dynamical behavior of molecules
Hence, there is a strong interest in the equivalent meshfree methods.
The key idea is to provide accurate and stable numerical solutions to PDE's or integral
equations with all kinds of possible boundary conditions
-using a set of arbitrarily distributed particles (or nodes) without any mesh.
Early work modified the internal structure of the grid-based methods to make them more
adaptive, versatile and robust.
Note: These exercises are designed to make your think about this first lecture, only a
paragraph or two is required on each (although longer responses are welcome too) and feel
free to use the internet and the reference books to find extra information.
References
[1] Bodenheimer P., Laughlin G.P., Rozczka M. and Yorke H.W., Numerical Methods in
Astrophysics, Taylor & Francis, (2007).
[2] Aarseth S., Tout C. and Mardling R, The Cambridge N-Body Lectures (Lecture Notes in
Physics)
[3] Liu G.R. and Liu M.B., Smoothed Particle Hydrodynamics: a meshfree particle method,
World Scientific, (2007)
[4] Shu f., The Physics of Astrophysics, vol. I & II, Mill Valley, CA: University Science
Books, (1991 & 1992)
[5] Monaghan J.J., Smoothed Particle Hydrodynamics, Annual Review of Astronomy and
Astrophysics, 30:543-574, (1992)
[6] Benz W., Smoothed Particle Hydrodynamics: a review, NATO workshop, Les; Arcs,
France, (1989)
[7] Lucy L.B., Numerical approach to testing the fission hypothesis, Astronomical Journal,
82:1013-1024, (1977)
[8] P. Cossins, Chapter 3, Smoothed Particle Hydrodynamics, Ph.D. Thesis, Leicester (2010)
Computational Astrophysics
Lecture 1: Introduction to N-body techniques
David Hobbs
Lund Observatory
ASTM22
N-body techniques
The classical astrophysical N-body problem consists of each member of an aggregate of N
(i=1,…,N) point masses, having masses mi, experiencing an acceleration from the
gravitational attractions of all the other bodies in the system.
(1)
The description of the problem is completed by specifying the initial positions (xi at t = 0)
and velocities (vi at t=0) for the N particles.
Solutions of this problem range from the orbit of the moon to the structure of the
Kirkwood gaps in the asteroid belt and countless other phenomena.
This richness arises from strong nonlinearity in the equation as a slight change in
initial conditions can lead to very different outcomes – chaos.
The N-body problem involves calculating
1. the force on each particle at a given time
2. determining the new position of the particle at a future time
Solving second order differential equations
Solving second order differential equations like equation (1) is done by reformulating the N
second-order equations as a set of 2N coupled first-order equations.
Any ordinary second-order differential equation of the form
Using this equation (1) becomes Evolution of the system in (2) takes the form
as
where the update variables, Wln+1, are calculated from information available at tn.
By repeatedly applying this formula the position and velocity of the particles can be
propagated into the future in time steps of h. This is know as Euler’s method.
In practice this is not sufficiently stable for long integrations so more sophisticated methods are
used but this simple form illustrates the basic principle well.
The error in Euler’s method
Euler’s method is not good because of error accumulation.
The exact equation is given by a Taylor series expansion.
Euler’s method is just the first two terms – it’s a first order method.
The rest of the terms sum to give the total error.
Euler’s method is asymmetry as the increment is based on the value of W at the beginning
of the interval h.
The values Wb provide a more accurate estimate of the slope in the interval h.
A 4th order Runge-Kutta method is commonly used:
A single iteration evaluates
•the initial slope at the start
•two midpoint slopes
•the slope at the end
The four slopes are then
combined with weights
2nd order
Project 1
Make a simulation to solve the N-body problem and investigate the time evolution of the
Trojan satellites of Jupiter for 300 years using an initial time step of 0.01 years. Implement
the 4th order Runge Kutta numerical integrator. Plot and/or show video of the results
relative to the common centre of gravity of the system. Consider the use of adaptive time
steps to minimize numerical error drift and extend the basic simulation to generate
interesting results for your report.