38
Numerical Cosmology & Galaxy Formation 1 Benjamin Moster Lecture 6: Hydro schemes - Grid codes

Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

Numerical Cosmology& Galaxy Formation

1

Benjamin Moster

Lecture 6: Hydro schemes - Grid codes

Page 2: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 3: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 4: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 5: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

The Bullet cluster

5

collisionlessdark matter

collisionlessdark matter

collisional gas

Numerical Cosmology & Galaxy Formation 6 25.05.2016

Page 6: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 7: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

Eulerian vs Lagrangian methods

7 Numerical Cosmology & Galaxy Formation 6 25.05.2016

Page 8: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

The Euler equations

8 Numerical Cosmology & Galaxy Formation 5 18.05.2016

On the blackboard…(see scanned notes)

Page 9: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

The Euler equations

9 Numerical Cosmology & Galaxy Formation 6 25.05.2016

• The equations of hydrodynamics can be written in terms of

conserved quantities

Page 10: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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)

Page 11: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

Advection on a grid

11 Numerical Cosmology & Galaxy Formation 6 25.05.2016

Page 12: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

Advection on a grid

12 Numerical Cosmology & Galaxy Formation 6 25.05.2016

Page 13: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

• 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

Page 14: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

Advection on a grid

14 Numerical Cosmology & Galaxy Formation 6 25.05.2016

Page 15: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 16: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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:

Page 17: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 18: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 19: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 20: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 21: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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:

Page 22: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 23: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 24: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

Riemann problems

24 Numerical Cosmology & Galaxy Formation 6 25.05.2016

• Solutions are self-similar, i.e. they depend only on

Page 25: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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))

Page 26: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 27: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 28: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 29: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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).

Page 30: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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)

Page 31: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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)

Page 32: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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)

Page 33: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 34: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

Moving-mesh hydrodynamics

31 Numerical Cosmology & Galaxy Formation 6 25.05.2016

Page 35: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

Moving-mesh hydrodynamics

32 Numerical Cosmology & Galaxy Formation 6 25.05.2016

Page 36: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

Eulerian vs Lagrangian methods

33 Numerical Cosmology & Galaxy Formation 6 25.05.2016

Page 37: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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

Page 38: Numerical Cosmology & Galaxy Formation€¦ · Lecture 6: Hydro schemes - Grid codes. Outline of the lecture course ... • The solution is almost always sought using numerical methods

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