Sei sulla pagina 1di 54

The Navier-Stokes Equation and 1D Pipe Flow

Simulation of Shocks in a Closed Shock Tube

Ville Vuorinen,D.Sc.(Tech.)

Department of Energy Technology, Internal Combustion Engine Research Group


Aalto University

Department of Energy Technology

Shock Waves in Experimental Fluid Dynamics


The Picture Below is a Schlieren Photograph of AK-47 Firing a Round

Matlab and PDEs


Ville Vuorinen
Aalto University

2/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Shock Waves in 3D Computational Fluid Dynamics


Supersonic Jet in a Crossflow (Courtesy of Kawai et al.)

Matlab and PDEs


Ville Vuorinen
Aalto University

3/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Non-Linear vs Linear Partial Differential Equations


The pictures above were all examples of high speed Navier-Stokes
equation dynamics.

Matlab and PDEs


Ville Vuorinen
Aalto University

4/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Non-Linear vs Linear Partial Differential Equations


The pictures above were all examples of high speed Navier-Stokes
equation dynamics.
The convection-diffusion (CD) equation is a linear PDE and its
behavior is well understood: convective transport and mixing.

Matlab and PDEs


Ville Vuorinen
Aalto University

4/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Non-Linear vs Linear Partial Differential Equations


The pictures above were all examples of high speed Navier-Stokes
equation dynamics.
The convection-diffusion (CD) equation is a linear PDE and its
behavior is well understood: convective transport and mixing.
However, many natural phenomena are non-linear which gives much
more degrees of freedom and complexity.

Matlab and PDEs


Ville Vuorinen
Aalto University

4/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Non-Linear vs Linear Partial Differential Equations


The pictures above were all examples of high speed Navier-Stokes
equation dynamics.
The convection-diffusion (CD) equation is a linear PDE and its
behavior is well understood: convective transport and mixing.
However, many natural phenomena are non-linear which gives much
more degrees of freedom and complexity.
Example 1: 1D flow of compressible gas in an exhaust pipe.

Matlab and PDEs


Ville Vuorinen
Aalto University

4/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Non-Linear vs Linear Partial Differential Equations


The pictures above were all examples of high speed Navier-Stokes
equation dynamics.
The convection-diffusion (CD) equation is a linear PDE and its
behavior is well understood: convective transport and mixing.
However, many natural phenomena are non-linear which gives much
more degrees of freedom and complexity.
Example 1: 1D flow of compressible gas in an exhaust pipe.
Example 2: 3D turbulent mixing and combustion in a combustion
engine.

Matlab and PDEs


Ville Vuorinen
Aalto University

4/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Non-Linear vs Linear Partial Differential Equations


The pictures above were all examples of high speed Navier-Stokes
equation dynamics.
The convection-diffusion (CD) equation is a linear PDE and its
behavior is well understood: convective transport and mixing.
However, many natural phenomena are non-linear which gives much
more degrees of freedom and complexity.
Example 1: 1D flow of compressible gas in an exhaust pipe.
Example 2: 3D turbulent mixing and combustion in a combustion
engine.
In this lecture we link the CD-equation to the compressible
Navier-Stokes equation.

Matlab and PDEs


Ville Vuorinen
Aalto University

4/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Non-Linear vs Linear Partial Differential Equations


The pictures above were all examples of high speed Navier-Stokes
equation dynamics.
The convection-diffusion (CD) equation is a linear PDE and its
behavior is well understood: convective transport and mixing.
However, many natural phenomena are non-linear which gives much
more degrees of freedom and complexity.
Example 1: 1D flow of compressible gas in an exhaust pipe.
Example 2: 3D turbulent mixing and combustion in a combustion
engine.
In this lecture we link the CD-equation to the compressible
Navier-Stokes equation.
Finally, the 1D Euler equation is presented and we discuss its
numerical solution involving shock-waves in exhaust pipes of
combustion engines.
Matlab and PDEs
Ville Vuorinen
Aalto University

4/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The General Form of Any Transport Phenomenon


Also the Navier-Stokes Equation is of This Form

The Convection-Diffusion Equation for the Quantity


temporal derivative

z}|{

convection term

diffusion term

source term

z }| { z
}|
{
z }| {
+ (u) () = S ()

convects and diffuses in a fluid (e.g. air,water...).


could represent e.g. concentration of soot particles in cigarette
smoke or water temperature in ocean currents etc.
is the density of the fluid and u = u(x,y,z,t) the velocity field, and
the diffusivity (e.g. heat diffusivity) of .

Matlab and PDEs


Ville Vuorinen
Aalto University

5/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The Full, Compressible Navier-Stokes Equation


Motion of Gases at Sub- and Supersonic Flows
uj
+
= 0 (Conservation of Mass)
t
xj
(ui uj )

ui
+
=
(pij + ij ) (Conservation of Momentum)
t
xj
xj
e (uj (e + p))

 T 
+
=
(ij ui )+

(Conservation of Energy)
t
xj
xj
xj xj

Matlab and PDEs


Ville Vuorinen
Aalto University

6/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Conservative vs Primitive Variables


Definition
The variables , ui and e are termed conservative because they
are conserved.

Matlab and PDEs


Ville Vuorinen
Aalto University

7/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Conservative vs Primitive Variables


Definition
The variables , ui and e are termed conservative because they
are conserved.
Pressure, velocity and temperature (p, ui and T ) are termed
primitive variables.

Matlab and PDEs


Ville Vuorinen
Aalto University

7/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Conservative vs Primitive Variables


Definition
The variables , ui and e are termed conservative because they
are conserved.
Pressure, velocity and temperature (p, ui and T ) are termed
primitive variables.

Reconstruction of Primitive Variables from Conservative


ui = ui /
T = (e 0.5(u21 + u22 + u23 ))/(cv )
p = RT

Matlab and PDEs


Ville Vuorinen
Aalto University

7/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Conservation of Mass
In the Absence of Nuclear Reactions

Conservation of Mass
temporal derivative

convection of mass due to velocity

z}|{

z }| {
uj
xj

Matlab and PDEs


Ville Vuorinen
Aalto University

= 0, j = 1, 2, 3

8/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Momentum is Conserved

Conservation of Momentum
temporal derivative

convection of momentum

z }| {
ui
t

z }| {
(ui uj )
xj

pressure gradient and viscous terms

z
=

Matlab and PDEs


Ville Vuorinen
Aalto University

}|
{

(pij + ij )
xj

, i, j = 1, 2, 3

9/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Energy is Conserved
But It May Transfer into Heat via Viscous Effects

Conservation of Energy

temporal derivative

convection of pressure and energy

z}|{
e
t

z
}|
{
(uj (e + p)))
xj

Matlab and PDEs


Ville Vuorinen
Aalto University

heat diffusion

viscous work

}|
{
 T 

=
(ij ui ) +

, j = 1, 2, 3
xj
xj xj
z

}|

10/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Energy is Conserved
But It May Transfer into Heat via Viscous Effects

Conservation of Energy

temporal derivative

convection of pressure and energy

z}|{
e
t

z
}|
{
(uj (e + p)))
xj

heat diffusion

viscous work

}|
{
 T 

=
(ij ui ) +

, j = 1, 2, 3
xj
xj xj
z

}|

Note:
The energy e is the total energy i.e. e = (cv T + 0.5|u|2 ). Thus all the
energy (at an arbitrary point) is expressed as a sum of kinetic and
thermodynamic energies.

Matlab and PDEs


Ville Vuorinen
Aalto University

10/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Definitions (1)

Equation of State and Internal Energy of Gas


p = RT and e = cv T + 1/2u2
where
cv = specific heat,
e = e(x, y, z, t) = total energy per unit volume,
u2 = u(x, y, z, t)2 = velocity magnitude squared and
R = molar gas constant.

Matlab and PDEs


Ville Vuorinen
Aalto University

11/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Definitions (2)

Speed of Sound
a=

p
RT

where a = speed of sound, R = molar gas constant, and = cp /cv =


adiabatic constant.

Matlab and PDEs


Ville Vuorinen
Aalto University

12/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Definitions (3)

Mach Number
Ma = u/a
where u = local flow velocity. When Ma < 1 flow is subsonic, when
Ma = 1 flow is sonic (e.g. in converging nozzle), and when Ma > 1 flow
is supersonic.

Matlab and PDEs


Ville Vuorinen
Aalto University

13/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Definitions (4)

Viscous Stress Tensor for Newtonian Fluids


ij = ij

2
u,
3

uj
ui
+
. The dynamic viscosity = , where is the
xj
xi
kinematic viscosity.
where ij =

Matlab and PDEs


Ville Vuorinen
Aalto University

14/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The Euler Equations


The Inviscid NS-Equation ( = 0)

The Euler Equations in 1D


u
+
=0
t
x
u (u2 + p)
+
=0
t
x
e (u(e + p))
+
=0
t
x
p = RT and e = cv T + 1/2u2

Matlab and PDEs


Ville Vuorinen
Aalto University

15/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Solutions to the Euler Equations


The Euler Equations in 1D
The Euler equations are a very good model for 1D (and 3D!) flow
simulations where viscous effects are small which is often the case.

Matlab and PDEs


Ville Vuorinen
Aalto University

16/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Solutions to the Euler Equations


The Euler Equations in 1D
The Euler equations are a very good model for 1D (and 3D!) flow
simulations where viscous effects are small which is often the case.
The Euler eqs contain discontinuities which are termed shocks if
p, T, are all discontinuous.

Matlab and PDEs


Ville Vuorinen
Aalto University

16/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Solutions to the Euler Equations


The Euler Equations in 1D
The Euler equations are a very good model for 1D (and 3D!) flow
simulations where viscous effects are small which is often the case.
The Euler eqs contain discontinuities which are termed shocks if
p, T, are all discontinuous.
The Euler eqs contain discontinuities which are termed contact
discontinuities if only T is discontinuous.

Matlab and PDEs


Ville Vuorinen
Aalto University

16/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Solutions to the Euler Equations


The Euler Equations in 1D
The Euler equations are a very good model for 1D (and 3D!) flow
simulations where viscous effects are small which is often the case.
The Euler eqs contain discontinuities which are termed shocks if
p, T, are all discontinuous.
The Euler eqs contain discontinuities which are termed contact
discontinuities if only T is discontinuous.
The Euler eqs can be analyzed by eigenvalue analysis and it is seen
that information can propagate at velocities 1 = u a, 2 = u and
3 = u + a.

Matlab and PDEs


Ville Vuorinen
Aalto University

16/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Solutions to the Euler Equations


The Euler Equations in 1D
The Euler equations are a very good model for 1D (and 3D!) flow
simulations where viscous effects are small which is often the case.
The Euler eqs contain discontinuities which are termed shocks if
p, T, are all discontinuous.
The Euler eqs contain discontinuities which are termed contact
discontinuities if only T is discontinuous.
The Euler eqs can be analyzed by eigenvalue analysis and it is seen
that information can propagate at velocities 1 = u a, 2 = u and
3 = u + a.
For example in a fully supersonic flows i > 0, i = 1, 2, 3 so that
information can not propagate upstream the flow.
Matlab and PDEs
Ville Vuorinen
Aalto University

16/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Pressure and T in a 1D Closed Shock Tube Using


Lax-Wendroff (1st Order vs 2nd Order) Method
CD=contact discontinuity; SD=shock discontinuity

Matlab and PDEs


Ville Vuorinen
Aalto University

17/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Pressure Field in 1D Closed Shock Tube vs Time

Matlab and PDEs


Ville Vuorinen
Aalto University

18/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Temperature Field in 1D Closed Shock Tube vs


Time

Matlab and PDEs


Ville Vuorinen
Aalto University

19/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Numerical Solution of the Euler Equations


The Simplest Approach: the Explicit Euler Time-Integration Method

k kn

n+1
t
t
(u)kn+1 (u)kn
u

t
t
(e)kn+1 (e)kn
e

t
t
Note: again k is the space index and n the time index.
Note: do not confuse the Euler time integration method with Euler
equations although Euler refers to the same scientist.
Matlab and PDEs
Ville Vuorinen
Aalto University

20/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Numerical Solution of the Euler Equations


Central Differences for the Spatial Derivatives

(u)k+1
(u)k1
u
n
n

x
2x
(u2 + p)
(u2 + p)k+1
(u2 + p)k1
n
n

x
2x
u(e + p)
(u(e + p))k+1
(u(e + p))k1
n
n

x
2x
Note: again k is the space index and n the time index.
Note: do not confuse the Euler time integration method with Euler
equations although Euler refers to the same scientist.
Matlab and PDEs
Ville Vuorinen
Aalto University

21/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The Euler Equations Have to Be Stabilized with


Numerical Viscosity
We Add Artificial Viscosity Terms to RHS of the
Equations
u
2
+
= 2
t
x
x
2 u
u (u2 + p)
+
=
t
x
x2
e (u(e + p))
2 e
+
= 2
t
x
x
p = RT and e = cv T + 1/2u2

Matlab and PDEs


Ville Vuorinen
Aalto University

22/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The Euler Equations Have to Be Stabilized with


Numerical Viscosity
The artificial viscosity > 0 and it smoothes sharp shock fronts and
allows numerical stability.

Matlab and PDEs


Ville Vuorinen
Aalto University

23/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The Euler Equations Have to Be Stabilized with


Numerical Viscosity
The artificial viscosity > 0 and it smoothes sharp shock fronts and
allows numerical stability.
The practical role of extra terms is low-pass filtering of the
high-frequency components (i.e. small wiggles) from numerical
solution.

Matlab and PDEs


Ville Vuorinen
Aalto University

23/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The Euler Equations Have to Be Stabilized with


Numerical Viscosity
The artificial viscosity > 0 and it smoothes sharp shock fronts and
allows numerical stability.
The practical role of extra terms is low-pass filtering of the
high-frequency components (i.e. small wiggles) from numerical
solution.
If = 0 a simulation will not run for many timesteps.

Matlab and PDEs


Ville Vuorinen
Aalto University

23/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The Euler Equations Have to Be Stabilized with


Numerical Viscosity
The artificial viscosity > 0 and it smoothes sharp shock fronts and
allows numerical stability.
The practical role of extra terms is low-pass filtering of the
high-frequency components (i.e. small wiggles) from numerical
solution.
If = 0 a simulation will not run for many timesteps.
The small wiggles tend to grow exponentially and blow up the
solution.

Matlab and PDEs


Ville Vuorinen
Aalto University

23/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The Euler Equations Have to Be Stabilized with


Numerical Viscosity
The artificial viscosity > 0 and it smoothes sharp shock fronts and
allows numerical stability.
The practical role of extra terms is low-pass filtering of the
high-frequency components (i.e. small wiggles) from numerical
solution.
If = 0 a simulation will not run for many timesteps.
The small wiggles tend to grow exponentially and blow up the
solution.
It is easy to show that good limits for are (roughly)

x2
x2

where larger gives smoother solutions


10 2 t
2 t
(x =grid spacing and t = timestep size).

Matlab and PDEs


Ville Vuorinen
Aalto University

23/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The Second Derivative (1D Laplacian) is Discretized as Follows

Example: the Momentum Term


2 u
(u)nk+1 2(u)kn + (u)nk1

x2
x2

Matlab and PDEs


Ville Vuorinen
Aalto University

24/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Boundary Conditions (BCs)

Modeling of boundaries is a crucial part of CFD-simulations e.g.


wall, inflow, outflow.

Matlab and PDEs


Ville Vuorinen
Aalto University

25/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Boundary Conditions (BCs)

Modeling of boundaries is a crucial part of CFD-simulations e.g.


wall, inflow, outflow.
To simplify a bit, here we explain one way of modeling a wall.

Matlab and PDEs


Ville Vuorinen
Aalto University

25/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Boundary Conditions (BCs)

Modeling of boundaries is a crucial part of CFD-simulations e.g.


wall, inflow, outflow.
To simplify a bit, here we explain one way of modeling a wall.
Say, in a 1D pipe flow with closed ends we first set zero derivative
(gradient) for p and T by e.g. p(1)=p(2) and T(1)=T(2).

Matlab and PDEs


Ville Vuorinen
Aalto University

25/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Boundary Conditions (BCs)

Modeling of boundaries is a crucial part of CFD-simulations e.g.


wall, inflow, outflow.
To simplify a bit, here we explain one way of modeling a wall.
Say, in a 1D pipe flow with closed ends we first set zero derivative
(gradient) for p and T by e.g. p(1)=p(2) and T(1)=T(2).
Then, e.g. rho(1)=p(1)/(R*T(1)).

Matlab and PDEs


Ville Vuorinen
Aalto University

25/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Boundary Conditions (BCs)

Modeling of boundaries is a crucial part of CFD-simulations e.g.


wall, inflow, outflow.
To simplify a bit, here we explain one way of modeling a wall.
Say, in a 1D pipe flow with closed ends we first set zero derivative
(gradient) for p and T by e.g. p(1)=p(2) and T(1)=T(2).
Then, e.g. rho(1)=p(1)/(R*T(1)).
For a wall the velocity reflects back so e.g. U(1)=-U(2).

Matlab and PDEs


Ville Vuorinen
Aalto University

25/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Boundary Conditions (BCs)

Modeling of boundaries is a crucial part of CFD-simulations e.g.


wall, inflow, outflow.
To simplify a bit, here we explain one way of modeling a wall.
Say, in a 1D pipe flow with closed ends we first set zero derivative
(gradient) for p and T by e.g. p(1)=p(2) and T(1)=T(2).
Then, e.g. rho(1)=p(1)/(R*T(1)).
For a wall the velocity reflects back so e.g. U(1)=-U(2).
Thus, e.g. rhoU(1)=rho*U(1) and similarly for rhoe(1) =
rho(1)*(Cv*T(1) + 0.5*U(1)*U(1)) .

Matlab and PDEs


Ville Vuorinen
Aalto University

25/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Boundary Conditions (BCs)

Modeling of boundaries is a crucial part of CFD-simulations e.g.


wall, inflow, outflow.
To simplify a bit, here we explain one way of modeling a wall.
Say, in a 1D pipe flow with closed ends we first set zero derivative
(gradient) for p and T by e.g. p(1)=p(2) and T(1)=T(2).
Then, e.g. rho(1)=p(1)/(R*T(1)).
For a wall the velocity reflects back so e.g. U(1)=-U(2).
Thus, e.g. rhoU(1)=rho*U(1) and similarly for rhoe(1) =
rho(1)*(Cv*T(1) + 0.5*U(1)*U(1)) .
From this kind of BCs a back and forth bouncing pulse results.

Matlab and PDEs


Ville Vuorinen
Aalto University

25/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Matlab Implementation

The folder /demos2012/shocktube/ shows demo files in which the


Explicit Euler method is applied for the Euler equations.

SolveEulerEquation1D.m is the solver which can be executed by


command SolveEulerEquation1D.
The files PlottingFigure.m, SurfaceAnimation.m and
DrawingSurface.m show how graphs can be drawn, surface motion
be animated etc. Look at the end of these files to see how .png
pictures can be saved.

Matlab and PDEs


Ville Vuorinen
Aalto University

26/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Summary

An introduction to Navier-Stokes equation was given.

Matlab and PDEs


Ville Vuorinen
Aalto University

27/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Summary

An introduction to Navier-Stokes equation was given.


The Euler equations are a simpler case of the NS-eqs ( = 0),
The Euler equations have discontinuities solutions e.g. shocks.

Matlab and PDEs


Ville Vuorinen
Aalto University

27/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Summary

An introduction to Navier-Stokes equation was given.


The Euler equations are a simpler case of the NS-eqs ( = 0),
The Euler equations have discontinuities solutions e.g. shocks.
We tested how increased viscosity allows numerical capturing of
shock waves via low pass filtering of wiggles i.e. small wavelengths.

Matlab and PDEs


Ville Vuorinen
Aalto University

27/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Summary

An introduction to Navier-Stokes equation was given.


The Euler equations are a simpler case of the NS-eqs ( = 0),
The Euler equations have discontinuities solutions e.g. shocks.
We tested how increased viscosity allows numerical capturing of
shock waves via low pass filtering of wiggles i.e. small wavelengths.
Again, the demonstrated Euler time integration method is not used
in practive but it is a copy-paste type effort to extend the method to
Runge-Kutta methods which are very robust and much used also in
3D realistic flows.

Matlab and PDEs


Ville Vuorinen
Aalto University

27/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

The End

Thank you

Questions?

Matlab and PDEs


Ville Vuorinen
Aalto University

28/28
Simulation Course, 2012
Simulation of Shocks in a Closed Shock Tube

Potrebbero piacerti anche