numerical cosmology & galaxy formation€¦ · lecture 6: hydro schemes - grid codes. outline...
TRANSCRIPT
Numerical Cosmology& Galaxy Formation
1
Benjamin Moster
Lecture 6: Hydro schemes - Grid codes
Outline of the lecture course
• Lecture 1: Motivation & Historical Overview
• Lecture 2: Review of Cosmology
• Lecture 3: Generating initial conditions
• Lecture 4: Gravity algorithms
• Lecture 5: Time integration & parallelization
• Lecture 6: Hydro schemes - Grid codes
• Lecture 7: Hydro schemes - Particle codes
• Lecture 8: Radiative cooling, photo heating
• Lecture 9: Subresolution physics
• Lecture 10: Halo and subhalo finders
• Lecture 11: Semi-analytic models
• Lecture 12: Example simulations: cosmological box & mergers
• Lecture 13: Presentations of test simulations
2 Numerical Cosmology & Galaxy Formation 5 18.05.2016
Computational Cosmology
• Cosmological model + initial conditions + simulation code = galaxies
SDSSCMB
generation theinitial conditions
running the simulation
analyzingthe data
3 Numerical Cosmology & Galaxy Formation 5 18.05.2016
Why hydrodynamics?
• Everything we see is gas or made from gas
• Need to follow the hydrodynamics: To form galaxies and starsTo study the interstellar, intergalactic and intracluster medium
4 Numerical Cosmology & Galaxy Formation 6 25.05.2016
The Bullet cluster
5
collisionlessdark matter
collisionlessdark matter
collisional gas
Numerical Cosmology & Galaxy Formation 6 25.05.2016
Why hydrodynamics?
• Problems are so complex that analytical methods are inadequate.
• The solution is almost always sought using numerical methods
• No single numerical recipe for all hydrodynamic problems
• Each problem may involve different additional physics: e.g. radiation-hydrodynamics or magneto-hydrodynamics
• Two broad categories: Eulerian methods (fixed position) Lagrangian methods (fixed element)
6 Numerical Cosmology & Galaxy Formation 6 25.05.2016
Eulerian vs Lagrangian methods
7 Numerical Cosmology & Galaxy Formation 6 25.05.2016
The Euler equations
8 Numerical Cosmology & Galaxy Formation 5 18.05.2016
On the blackboard…(see scanned notes)
The Euler equations
9 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• The equations of hydrodynamics can be written in terms of
conserved quantities
Advection on a grid
10 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Let’s consider a simpler problem first and assuming u = const.
• discretize space into cells for numerical treatment
• need to advect the mass such that total mass is conserved➡ calculate mass fluxes at cell interfaces➡ remove mass from the cell on one side of the interface and add it to the cell on the other side (this ensures mass conservation)
Advection on a grid
11 Numerical Cosmology & Galaxy Formation 6 25.05.2016
Advection on a grid
12 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• next higher order: piecewise linear within cell
•
• average density at interface over time step Δt
• Flux:
Advection on a grid
13 Numerical Cosmology & Galaxy Formation 6 25.05.2016
Advection on a grid
14 Numerical Cosmology & Galaxy Formation 6 25.05.2016
Advection on a grid
15 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Higher order schemes, such as the piecewise linear Lax-Wendroff
scheme shown here, produce oscillations near discontinuities
• Piecewise linear elements can have overshoots
• Successful method to prevent overshoots is the use of slope limitersModify the slope if this is necessary to prevent overshoots
Characteristics
16 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• With a suitable advection scheme we can solvewith u = constant
• However, the full Euler equations are coupled:
Characteristics
17 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Can we decouple these equations?First we rewrite them (for simplicity in 1D) by defining:
• We then get
Characteristics
18 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• The Euler equations in terms of q1,q2,q3 are then given by with
• Can be written more compact using the Jacobian
Characteristics
19 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Consider a simple system with A(q) = A = constant We get:
• The equations can then be decoupled by finding the eigensystem of
the matrix A
• Decompose the state q in the eigenbasisand find the equations for the individual components
Characteristics
20 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Using this decomposition with
• And therefore
• This is a simple advection equation with characteristic velocity λm
• We can thus solve the coupled set of equations by expanding the state vector in the eigenbasisadvecting each qm with its characteristic velocity recomputing the new state from the updated
Characteristics
21 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Each of these modes propagating with a characteristic velocity is
called a characteristic
• For the full Euler equations A(q) ≠ constant➙ eigenvectors depend on q (and thus position) ➙ no global decomposition of the state vector possible
• Locally we find:
Characteristics
22 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Decompose the state vector locally at each cell interface and advect
the components with their local characteristic velocities
Riemann problems
23 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• What about shocks and contact discontinuities?➙ eigensystems differ significantly on both sides
• Consider the full Riemann problem e.g. for uL = uR = 0
Riemann problems
24 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Solutions are self-similar, i.e. they depend only on
Godunov method
25 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Assume piecewise constant fluid state
• Exactly solve Riemann problem at each interface(i.e. solve algebraic equations iteratively)
• Choose small enough time step, such that solutions of neighboring interfaces do not overlap
• Calculate new average of conserved quantities at end of time step
• Easy as flux f(q(x=x0)) is constant for self-similar q((x−x0)/(t−t0))
Godunov method
25 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Assume piecewise constant fluid state
• Exactly solve Riemann problem at each interface(i.e. solve algebraic equations iteratively)
• Choose small enough time step, such that solutions of neighboring interfaces do not overlap
• Calculate new average of conserved quantities at end of time step
• Easy as flux f(q(x=x0)) is constant for self-similar q((x−x0)/(t−t0))
For linear problems: same as advecting the components in the eigenbasis
But accounts for shocks and contact discontinuities
Cons: Diffusive as constant fluxes correspond to donor-cell advection
The MUSCL-Hancock scheme
26 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Create a 2nd order Godunov method by
- using a higher-order reconstruction(piecewise linear, piecewise parabolic)
- computing the left and right q values at the interface
- advance these values in half a time step
- use these values in the Riemann solver as if the state is constant on each side of the interface
- • used in many codes, e.g.: Ramses, Arepo
Roe’s linearized Riemann solver
27 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Exact Riemann solvers can be slow (e.g. for magneto-hydrodynamics)
• Alternatively linearise the problem at each interface by settingA(q) → A(qave) with qave: average value between left and right state
• A solution can then be found by decomposing the left and right
states into the eigenbasis of A(qave)
• And advecting the components with the corresponding characteristic
velocity➡ yields a solution in smooth parts of the flow ➡ every reasonable average value for qave should work there
Roe’s linearized Riemann solver
28 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• It is possible to choose the average qave such that the linearized
Riemann solver also gives the correct propagation of contact
discontinuities and shocks
• Roe average:
• When using this average one can show that the “jump” corresponds
exactly to one eigenvector with a eigenvalue given by the correct
velocity (e.g. the shock velocity).
Adaptive mesh refinement
29 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• In AMR the local resolution is adapted according to refinement
criteria (usually high density)
Adaptive mesh refinement
29 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• In AMR the local resolution is adapted according to refinement
criteria (usually high density)
Adaptive mesh refinement
29 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• In AMR the local resolution is adapted according to refinement
criteria (usually high density)
Moving-mesh hydrodynamics
30 Numerical Cosmology & Galaxy Formation 6 25.05.2016
• Alternatively one can define a mesh based on a set of points using a Voronoi tessellation
• Points can be allowed to move, e.g. with the fluid ➙ then almost Lagrangian
• Procedure: use unspilt scheme transform to frame of moving interfacesolve Riemann problemtransform back
Moving-mesh hydrodynamics
31 Numerical Cosmology & Galaxy Formation 6 25.05.2016
Moving-mesh hydrodynamics
32 Numerical Cosmology & Galaxy Formation 6 25.05.2016
Eulerian vs Lagrangian methods
33 Numerical Cosmology & Galaxy Formation 6 25.05.2016
Eulerian vs Lagrangian methods
33 Numerical Cosmology & Galaxy Formation 6 25.05.2016
Pros: accurate hydro, automatic automatic refinement on accurate hydro refinement on density, density, Galilean invar., Galilean invariant conserves angular mom.
Cons:needs AMR to overhead (~30%) for Often problems with get to high mesh construction contact discontinuities resolution slow convergence
Up next
• Lecture 1: Motivation & Historical Overview
• Lecture 2: Review of Cosmology
• Lecture 3: Generating initial conditions
• Lecture 4: Gravity algorithms
• Lecture 5: Time integration & parallelization
• Lecture 6: Hydro schemes - Grid codes
• Lecture 7: Hydro schemes - Particle codes
• Lecture 8: Radiative cooling, photo heating
• Lecture 9: Subresolution physics
• Lecture 10: Halo and subhalo finders
• Lecture 11: Semi-analytic models
• Lecture 12: Example simulations: cosmological box & mergers
• Lecture 13: Presentations of test simulations
34 Numerical Cosmology & Galaxy Formation 6 25.05.2016