computatonal fluid dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/cfd.pdf ·...

92
PHY 604: Computatonal Methods for Physics and Astrophysics II Computatonal Fluid Dynamics

Upload: others

Post on 04-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Computatonal Fluid Dynamics

Page 2: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Hydrodynamics

● When we discussed PDEs, we focused so far on scalar PDEs

● Ofen we wish to study systems of PDEsP

● Here we'll look at the equatons of hydrodynamics

– Nonlinear system of hyperbolic PDEs

– We'll see many of our ideas extend to this case

– These same ideas can be applied to other hyperbolic systems

Page 3: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

CFD

● Colorful Fluid Dynamics

– We model our system of interest as a fuid

– Evoluton dictated by conservaton laws:

Computatonal

Conservaton of mass

Conservaton of momentum

Conservaton of energy

Page 4: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Conservatve System

● This can be writen in conservaton law form:

– With

● To close this system, we need an equaton of state

● Simplest: gamma-law

Page 5: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Conservatve System

● To make it look more like advecton, we write this in quasi-linear formP

– Express fux vector in terms of

Page 6: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Conservatve System

● Compute the Jacobian:

– The system can now be writen as:

Note: this actually is only true in Cartesian coordinates, since the pressure enters the momentum equaton as a gradient, not a divergence

Page 7: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Primitve Variable Formulaton

● We can instead cast things in terms of the primitve variables: density, velocity, and pressure

● Our system becomes (blackboard):

– Notce that the Jacobian for this formulaton is much simpler

Page 8: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Lagrangian derivatve

● Consider the full tme-rate-of-change of a fuid quantty:

– This depends on the path x(t) we choose to followP

● Eulerian frame:

– We keep our reference positon fxed in tme, and we watch the fow move past us, so dx/dt = 0

● Lagrangian frame:

– We pick a path that is equal to the fuid velocity—this way we track the fow of an individual fuid element

– The Lagrangian derivatve (also called the material, convectve, advectve, … derivatve) is

Page 9: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Primitve Variable Formulaton

● Note: we don't need to assume a gamma-law gas—we can derive this for a general equaton of state too

● Express:

– Where the full derivatve of entropy is zero when there are no heat sources (reactons, difusion, …)

● The frst adiabatc index is:

– Giving:

Page 10: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Eigensystem

● Recall that a system is hyperbolic if the eigenvalues are real and fniteP

● For our system, the eigenvalues are:

– These are the speeds at which informaton propagates in our system

– Three distnct wave speeds for 3 equatons

– We'd get the same eigenvalues from the Jacobian of the conserved system

● There is a rich mathematcal descripton of the theory of hyperbolic systems of conservaton lawsP

– The book by LeVeque is an excellent introductonP

Page 11: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Eigensystem

● We can also fnd the eigenvectors:

– These are normalized such that

Sympy notebook: euler.ipynb

Page 12: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Characteristc Variables

● A fnal form of the system is in terms of the characteristc variables

– Construct matrices of the lef and right eigenvectors

● Satsfy: LR = RL = I

– Defne dw = L dq

– Our system can be writen as:

Blackboard derivatonPPP

Page 13: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Characteristc Variables

● Here, w are the characteristc variables

● The three equatons are decoupled:

– If our system were linear, we'd be done:

● Transform into characteristc variables● Each characteristc variable advects at a given wave speed, without

interactng with one-another● Solve and then transform back to primitve form (or conserved form)

– We're non-linear: the wave-speeds and eigenvectors change with the soluton

Page 14: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Jumps Across Waves

● The characteristc system is telling us something interestng alreadyP

– Consider an inital discontnuity in the primitve variables

– Each wave will carry a jump in their associate characteristc quantty away from the discontnuity at their speed

– The corresponding jump in the primitve variable is just dq = L-1dw = R

dw

Page 15: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Jumps Across Waves

All primitve quanttes jump across the u-c wave

Only density jumps across the middle (u) wave

All primitve varaibles jump across the u+c wave

Page 16: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Jumps Across Waves

Page 17: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Soluton Methodology

● This system has similarites to the advecton equaton we already studiedP

– We can take a similar approach

● We will use the fnite-volume discretzaton:

– Second-order in tme requires tme-centering the righthand side

Page 18: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Soluton Methodology

● As we saw in our homework (Burgers' eqP), we need to solve this in conservatve form to get the shock speed correct

● Basic idea: evaluate fuxes at interfaces by predictng the fuid state there, then solve Riemann problem:

Page 19: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Computatonal Hydrodynamics

● Our update looks like:

– Where are fuxes are:

– If we construct the interface to second-order, then the overall method will be second-order accurate

Page 20: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Interface State Predicton

● The simplest method to construct the interface states is to simply use the cell averages

– This is frst order accurate in space and tme

– This method is called Godunov's method

– Doesn't consider how U is changing in space or over the tmestep

Page 21: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Piecewise Linear Reconstructon

● We can get second-order accuracy by reconstructng the cell-average data to be piecewise linear

– It is easier to work with the primitve variables

– We reconstruct each quantty and limit the slopes (just like we did with advecton)

– Predict edge-centered, tme-centered state via Taylor expansion (blackboardPPP)

Page 22: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Piecewise Linear Reconstructon

● We have:

– This is the amount of the primitve variable that reaches the interface over the tmestep

– Recall that the jumps in q are carried by 3 waves

– We only want to include a jump if that wave was moving toward the interface—we need to do a characteristc decompositon

(blackboard derivatonPPP)

Page 23: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Piecewise Linear Reconstructon

● Notce the quantty: λt/Δx —this is the CFL number for each wave

● To consider only the waves moving toward the interface, we alter the sum slightly:

– The right state at this interface is similarly constructed:

Page 24: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Piecewise Linear Reconstructon

● The decompositon of the jumps into the sum over the lef and right eigenvectors is sometmes called a characteristc projecton

– Note that we explictly see here that each wave carries a jump proportonal to the right eigenvector

– (l ⋅ Δq) is the projecton of the primitve variable jump into the characteristc variables

● Many sources introduce a reference state chosen so as to minimize the efect of the characteristc decompositon—this is because we are linearizing a nonlinear system

Page 25: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Piecewise Parabolic

● The most popular method in astrophysics is PPM (piecewise parabolic method)

– Reconstruct the data in each cell as a parabola

– The parabolic profles are limited to prevent generaton of new extrema (see Colella & Woodward 1984 for a descripton of the original method)

– General form:

Page 26: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Piecewise Parabolic

● The reconstructon polynomial recovers the cell-average:

● To use the parabolic interpolant, we start with our interface state for piecewise linear:

– Recognize that for a linear profle:

Page 27: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Piecewise Parabolic

● This suggests we can insert the average under our parabolic profle to construct the interface state:

– Where

Page 28: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Piecewise Parabolic

● The PPM interface states are then:

– Where

Page 29: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem

● No mater the method used to predict the interface states, we now have lef and right states at each interface

● Unlike the linear advecton or Burger's equaton, we rarely solve the Riemann problem for the Euler equatons exactlyP

– We need to consider what is carried by each wave

– Diferent types of waves are present depending on the behavior of the characteristcs

Page 30: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem

● Wave type is determined by whether the characteristcs converge, are parallel, or diverge

– We already saw shocks and rarefactons with Burger's equaton

– A contact discontnuity is where the soluton jumps, but there is no compression or expansion

Shock wave Contact Discontnuity Rarefacton

Page 31: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem

● Across the middle wave (λ = u), only the density jumps

– So the velocity is the same on either side—no convergence or divergenceP

– The middle wave is always a contact discontnuity

● The lef and right waves can be either a shock or rarefacton

Page 32: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem

● The Riemann problem for the Euler equatons looks like:

– Solving the Riemann problem means fnding the 4 quanttes:

Page 33: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Wave Structure

● There are several diferent wave confguratons

1-rarefacton and 3-shock

1-shock and 3-rarefacton two shocks

two rarefactons

Page 34: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Wave Structure

● And the can span the inital interface or all be on one side

supersonic fow to the lef supersonic fow to the right

Page 35: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem

● The basic soluton idea is to link the lef and right states (which we know) to the star state using our understanding of what happens across the lef and right waves

Page 36: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem: Rarefacton

● If we are not compressing, then we are a rarefacton

● Let's look at the system of equatons with entropy instead of pressure as a variableP

– Entropy evoluton:

– We need to replace the pressure gradient in the momentum equaton:

Page 37: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem: Rarefacton

● System becomes:

or

Page 38: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem: Rarefacton

● The eigenvalues of that matrix are the same, but the eigenvectors will tell us how entropy behaves across each wave:

– Entropy only jumps across the contact, not the lef and right way

● Considering entropy is only really useful for rarefactons

– Shocks involve dissipatve processes, so entropy needs to increase

– This is why you need to solve a total energy instead of an entropy equaton for shocks

Page 39: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem: Rarefacton

● Consider waves originatng at a discontnuity (this is the Riemann problem)

● We come in with a jump in the primitve variables, q

– The corresponding jump in characteristc variables is Δw = L Δq

– Each wave carries a jump in its characteristc variable

● Consider the right (+) wave:

– It moves at speed u + c

– A piece of Δq will jump across this wave (let's call the quantty that jumps w(+))

– But w(+) will be constant across the other waves then

– We can use this to link the states across the lef (-) wave

Page 40: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem: Rarefacton

● w(+) is constant across the (-) waveP This is defned as

● This is:

● The general soluton to this is:

– We can't integrate this for a general EOS

Page 41: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem: Rarefacton

● If we assume a gamma-law ideal gas, then we know

– for isentropic fows

– γ is the constant rato of specifc heats

● Integraton of this gives (blackboard):

● Similarly, we'd fnd

across lef rarefacton

across right rarefacton

Page 42: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem: Rarefacton

● We can now connect the lef and star state across a rarefacton:

– We also know:

– So:

and

Page 43: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem: Shock

● If the fow is compressing, then we have a shock

– Rankine-Hugoniot jump conditons provide the soluton

– We already saw this when we did Burgers' equaton

● We'll work in the frame of the shock, and we'll only consider the lef wave

– Jump conditons become:

● Where the hat denotes the frame of the shock,

Page 44: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem: Shock

● Jump conditons are:

● With a bit of algebra (blackboard), we have:

This is the mass fuxNote that:

Page 45: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Problem: Shock

● How do we solve these?

– We will come in with a (more on this in a minute)

– Root fnd on:

● Get the mass fux,

● Get the star velocity:

Page 46: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Summary of Riemann Problem

● We need to consider the acton of all 3 waves

– Middle wave is always a contact

– Lef and right can be either shock or rarefacton

● Rarefacton:

– Entropy is constant across the wave

– Riemann invariants tell us how to connect the soluton across the wave to the star region

● Shock:

– Must be dissipatve

– Jump conditons tell us how to connect to the star state across the shock

Page 47: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Wave Structure

● The characteristc structure becomes:

Using the correct relaton across each wave allows us to link the 4-states and solve the Riemann problemP

Rankine-Hugoniot conditons

1-rarefacton contact

3-shock

Page 48: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Soluton

● For a gamma-law gas, the shock soluton can be found analytcally, and we get:

– The constancy of the pressure and velocity across the contact gives:

(LeVeque EqP 14P51, 14P52)

(LeVeque EqP 14P54, 14P55)

Page 49: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Soluton

● This can be solved using standard root fnding techniques

● Gets you

● The density to the lef and right of the contact can be found via the Riemann invariants (rarefacton) or jump conditons (shock)

– This completes the entre soluton

Page 50: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Soluton

● We can look at the soluton to the Riemann problem graphically

● Sod problem:

– Plot shows the curves that each state can reach through a shock (dashed) or rarefacton (solid)

– Soluton is the intersecton

– Here we must have a lef rarefacton and a right shock

code: riemann-phases.pyp* = 0.303130178051 u* = 0.927452620049

Page 51: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Soluton

Page 52: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Sampling the Soluton

● We only need to know the Riemann soluton on our interface

– Which region are we in?

● We need to evaluate the various speeds

1-rarefacton contact

3-shock

Page 53: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Sampling the Soluton

● If the lef or right wave is a shock, the speed comes from our jump conditons

– Lef: we had

● An analytc expression for this can be writen down for a gamma-law gas● A similar expression (but with a '+') is found for a shock at the right wave

● For a contact, we just use

● For a rarefacton, there are 2 speeds

– Consider the lef rarefacton

● Head travels at:● Tail travels at:

Page 54: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Sampling the Soluton

● To complete the rarefacton speed we need the density in the star region:

– Gamma-law gas:

● We know entropy is constant, so we can just do:

– General gas:

● Use the contact's characteristc variable:

– This can be integrated across the rarefacton

Page 55: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Sampling the Soluton

● We evaluate the soluton to the Riemann problem along x/t = 0

– If S0 > 0, then we are either the lef or lef-star state

● The check the speed of the lef shock / rarefacton to determine lef or lef-star

– This gives you the state on the interface

– If S0 < 0, then we are either the right or right-star state

1-rarefacton contact

3-shock

Page 56: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Sampling the Soluton

● Caveat: the rarefacton could span the axis

– We can integrate the Riemann invariants to get the state inside the rarefacton

Page 57: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Riemann Soluton

● Once we get the state on the interface, we can construct the fuxes through the interface:

Page 58: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

General Soluton

● We solve the Euler equatons for a general problem (not a single jump) by constructng the interface states and then solving a Riemann problem at each interface

– The Riemann problem captures the shock—we get the shock speed correct

– The overall method is conservatve

Page 59: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Conservaton

● Recall that when you did your Burgers' equaton homework, the non-conservatve diferencing gave you the wrong shock speed

Page 60: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Structure of a Simulaton Code

● The structure of your code is nearly identcal to the codes we did for advecton:

– Initalize

● We need to initalize all the conserved state, U

– Evolve

● Compute tmestep

– We restrict things so that no informaton can cross more than one zone in a tmestep:

● Fill ghost cells

– The number of ghost cells will depend on the width of our stencil– PPM requires 4 ghost cells on each end of the domain

Page 61: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Structure of a Simulaton Code

– Evolve (contnued)

● Construct interface states

– We looked at piecewise constant, piecewise linear, and piecewise parabolic reconstructon

– In all cases, we wind up with a lef and right primitve variable state at every interface

● Solve Riemann problem

– This takes the tme-centered, edge-centered primitve variable states and returns the state on the interface

Page 62: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Structure of a Simulaton Code

– Evolve (contnued)

● Conservatve update:

Page 63: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Boundary Conditons

● Boundary conditons should match the physics you are modeling

● Common ones:

– Refectng / solid wall: ghost cells refect their partner across the physical boundaryP Normal velocity component changes sign

– Outlow: zero-gradient given to all ghost cells

● Note: this is not perfect, because at the boundary, some characteristc waves may fow inward (for subsonic fows)

– Hydrostatc: in the presence of gravity, provide pressure support to hold up an atmosphere

Page 64: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Structure of a Simulaton Code

● Solving the Riemann problem (even for a gamma-law gas) can be expensive

– Ofen we use approximatons

– Approximate state methods:

● Approximate the primitve variable state in the star region● Some examples: two-shock and two-rarefacton solvers

– Approximate fux methods:

● Approximate the fux directly from the jump conditons without getng an approximate state

● Some examples: HLL methods

– Linearized methods:

● Linearize the system and solve the Riemann problem as you would for a linear hyperboic system

● Example: Roe solver

Page 65: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Bells and Whistles

● We described the basics, but there are some other features typically implemented in hydro codes:

– Flatening: shocks self-steepen (characteristcs converge), and can become too sharpP Flatening adds some dissipaton near shocks to smear them out a bit

– Species advecton: nuclear or chemical species can be advected with the fow:

– Source terms: source terms (ePgP gravity) do not change the characteristc structure, but do partcipate in the predicton to the interfaces

– Other geometries: extensions to cylindrical and spherical geometries involves volume and area factors throughout the code

Page 66: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Test Problems

● There are several standard test problems with known analytc solutons

● Simplest is to just run a Riemann problem (shock tube) with your solver

Page 67: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Sod Problempiecewise constant

code: hydro1d

● Sod problem exhibits all 3 types of waves

● Setup:

– 128 zones

– Piecewise constant reconstructon

– 2-shock approximate Riemann solver

● Notce how smeared out the contact is

Page 68: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Sod Problempiecewise parabolic

code: hydro1d

● With piecewise parabolic profles, all the waves look beter

● Contact is stll the worst—no self-steepening

Page 69: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Double Rarefactonpiecewise constant

code: hydro1d

● Divergent fow:

● This generates a vacuum state

● Setup:

– 128 zones

– Piecewise constant reconstructon

– 2-shock approximate Riemann solver

Page 70: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Double Rarefactonpiecewise parabolic

code: hydro1d

● Much beter fow with ppm

Page 71: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Double Rarefacton

code: hydro1d

● But solvers have a hard tme getng the internal energy right in the vacuum region

– e from ppm soluton

Page 72: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Strong Shockpiecewise constant

code: hydro1d

● Strong shock followed closely by contact

● Very difficult to get the shock structure correct

● Setup:

– 128 zones

– Piecewise constant reconstructon

– 2-shock approximate Riemann solver

Page 73: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Strong Shockpiecewise parabolic

code: hydro1d

● We do beter with ppm reconstructon

Page 74: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Diferent Coordinate Systems

● Consider 1-d spherical coordinates

– This looks like a Cartesian system with a geometric source term

● Strategy:

– When doing the predicton to the interfaces, explicitly include the geometric source term

● Eigenvectors don't change here

Page 75: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Diferent Coordinate Systems

– Do the conservatve update with the actual spherical divergence

● Note: the pressure term does not appear in the momentum fux anymore● We diference the momentum equaton as:

Page 76: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Sedov-Taylor Blast Wave

● Dump a lot of energy into a single point

● Ambient pressure is negligible

● Analytc soluton for spherical and cylindrical geometries was worked out by Sedov (1959) Taylor, and others

● Can be difficult for a code to model since the point-energy is spread over a zone

– Standard method for initalizing spreads the energy over a few zones, gets the corresponding pressure, and initalizes using pressure

Page 77: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Sedov-Taylor Blast Wave

● PPM soluton (with 2-shock Riemann solver)

● 128 zones on [0, 0P5]

code: hydro1d

Page 78: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Multdimensions

● What happens to the transverse velocity in a mult-d system?

● 2-d conserved system:

Page 79: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Multdimensions

● Primitve variable system:

Page 80: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Multdimensions

● Consider fow in the x-directon

– Eigenvalues of A(x) are: u-c, u, u, u+c

● Middle eigenvalue is degenerate

– Right eigenvectors are:

● The transverse velocity only jumps over the contact● In this sense, it is simply advected and either its lef or right value is used

Page 81: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Multdimensions

● Interface predicton proceeds as we saw with advecton

– Here's the unsplit version:

● Conservatve update:

Page 82: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Multdimensional Hydro

● Unsplit methods generally preserve symmetries on the grid beter

Dimensionally split Unsplit

This is a standard test problem where there are 4 states (2x2) initally, with the upper lef and lower right state identcal—the soluton should be symmetric about the diagonalP These calculaton use 256x256 zonesP Aside from the splitng, the algorithm is identcalP

Page 83: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Source Terms

● Consider gravitatonal source:

– This looks like it requires an implicit update, but we update these in turn, and we have the new tme-level state as needed

Page 84: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

PlaytmePPP

● I have 2 codes online that implement these methods:

– hydro1d:

● Implements the Godunov, PLM, and PPM hydro methods in 1-d● Gravity source terms● Writen in Fortran 95/2003● htp://benderPastroPsunysbPedu/hydro1d/

– pyro:

● Implements 2-d PLM compressible hydro (dimensionally unsplit)● Also does 2-d advecton, 2-d incompressible, 2-d multgrid, 2-d difusion

● Writen mostly in python, with some Fortran (through f2py)

Page 85: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Ex: Low Mach Hydro

● How do the ideas we discussed in this course enter into real research?

● What I do: low Mach number hydrodynamics

– Reformulate the equatons of hydrodynamics in the limit that the Mach number is very small

– Apply this to low speed convectve burning in astrophysical environments (SNe Ia, X-ray bursts, stellar evoluton, PPP)

Page 86: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Why Low Mach Number Hydro?

● We know that for explicit methods, we are limited by the tmestep constraint:

● Highly subsonic fow,

● We want:

– Either go implicit or remove sound waves from the systemP We do the laterPPP

a

b

c

▶ A Mach 0P01 front moving to the right (a) initally, (b) afer 1 step, (c) afer 100 stepsP

Page 87: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Low Mach Approximaton

● Reformulaton of compressible Euler equatons

– Retain compressibility efects due to heatng and stratfcaton

– Asymptotc expansion in Mach number decomposes pressure into thermodynamic and dynamic parts

– Analytcally enforce hydrostatc equilibrium through base state:

● Require pressure stay close to hydrostatc pressure:

– with contnuity

Page 88: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Low Mach Approximaton

– For gamma-law gas, this can be expressed as:

– For a general gas:

● β0 is density like variable

– S represents heatng

● Sound waves decoupled from the system

Page 89: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Filtering Sound Waves

● Elliptc constraint: instantaneous acoustc equilibriaton

compressible

low Mach

Page 90: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Full System

● We solve:

Page 91: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve

PHY 604: Computatonal Methods for Physics and Astrophysics II

Soluton Technique

● React for Δt/2

– Strang-splitng: solve ODEs corresponding to the reacton parts only

● Advect for Δt

– Scalar equatons are done just like the linear advecton equaton

– Velocity equaton is done like Burger's equaton

● React for fnal Δt/2

● Enforce the constraint

– Velocity feld does not satsfy constraint

– Perform an approximate projecton

● Actually we do things slightly more complicated than this, but this gets the gist

Page 92: Computatonal Fluid Dynamicsbender.astro.sunysb.edu/classes/numerical_methods/lectures/CFD.pdf · PHY 604: Computatonal Methods for Physics and Astrophysics II Lagrangian derivatve