You are on page 1of 7

MAE 471/561

Project #2 Due: March 28th at beginning of class


1 Overview
This project will focus on solution of the compressible ow in a nozzle. The project description is borrowed
heavily from Andersons text Modern Compressible Flow with Historical Perspective ( Appendix B).
We will solve the equations governing the conservation of mass, momentum, and energy of a compressible
gas. For the one-dimensional problem of interest in this project those equations take the form,
A
t
+
Au
x
= 0 (1)
Au
t
+
Au
2
x
= A
p
x
(2)
(e + u
2
/2)A
t
+
(e + u
2
/2)Au
x
=
pAu
x
(3)
where is the density of the gas, A the cross-sectional area of the nozzle, u is the gas velocity in the x
direction (which is the only direction of the ow in this case), p is the pressure, and e is the internal energy
of the gas (which we can link to the temperature of the gas as e = c
v
T where c
v
is the specic heat at
constant volume and T is the temperature).
As described in Anderson, these equations are actually programmed using dimensionless variables. The
resulting set of equations actually solved in your code will take the form,
A
t
+
Au
x
= 0 (4)
(Au)
t
+

_
Au
2
+ (1/)pA
_
x
=
1

p
A
x
(5)

_
e
1
+

2
u
2
_
A
_
t
+

_
e
1
+

2
u
2
_
uA + pAu
_
x
= 0 (6)
In the above equations the overline represents the dimensionless variables:
=

0
, e = T =
T
T
0
, u =
u
a
0
, a
0
=
_
RT
0
(7)
where the

0

subscripts represent reference values that are the conditions specied at x = 0 and an ideal
gas is assumed. Furthermore remember that R = c
p
c
v
and = c
p
/c
v
. In the following use = 1.4. The
spatial coordinate and time are non-dimensionalized as,
x =
x
L
, t =
t
L/a
0
(8)
1
2 Solution Procedure
We will solve the above system of equations by rst introducing a shorthand,
U
1
t
+
F
1
x
= 0 (9)
U
2
t
+
F
2
x
= J
2
(10)
U
3
t
+
F
3
x
= 0 (11)
where
U
1
= A, U
2
= Au, U
3
=
_
e
1
+

2
u
2
_
A (12)
F
1
= Au, F
2
= Au
2
+ (1/)pA, F
3
=
_
e
1
+

2
u
2
_
uA + pAu (13)
J
2
=
1

p
A
x
(14)
The density , velocity u, temperature T, and pressure p can be expressed in terms of U
1
, U
2
, and U
3
as,
=
U
1
A
, u =
U
2
U
1
, T = e = ( 1)
_
U
3
U
1


2
u
2
_
, p = T (15)
We then write the equations with the time-derivative on the left and remaining terms on the right-hand-side,
U
1
t
=
F
1
x
(16)
U
2
t
=
F
2
x
+ J
2
(17)
U
3
t
=
F
3
x
(18)
The rationale behind the above rearrangement is that we will make approximations to the spatial derivatives
and then advance the resulting system of ordinary differential equations in time.
It is very important to note that the dependent variables to be determined in your code are U
1
, U
2
, and U
3
.
The corresponding functions (referred to as ux terms) F
1
, F
2
, and F
3
are expressed in terms of these
variables and it can be shown,
F
1
= U
2
, F
2
=
U
2
2
U
1
+
1

_
U
3


2
U
2
2
U
1
_
, F
3
=
U
2
U
3
U
1

( 1)
2
U
3
2
U
2
1
, (19)
and the source term J
2
can be expressed as,
J
2
=
1

_
U
3


2
U
2
2
U
1
_
ln A
x
(20)
2
2.1 Numerical Approach
We will solve the above equations using a standard scheme that will allow us to become familiar with some
of the basics behind the numerical approximations that are employed in Computational Fluid Dynamics.
The dependent variables are functions of position (x) and time (t), e.g., = (x, t).
We will solve the equations on a grid where the grid points are denoted x
k
with k = 1 to N and the grid
spacing x = L/(N 1) where L is the length of the nozzle. The equations are advanced in time where
we will denote the time level as t
n
where n = 0, 1, 2, . . ..
In terms of notation, we will denote the variable at grid point x
k
and time t
n
as, for example,
n
k
where

n
k
= (x
k
, t
n
) and U
n
2,k
represents U
2
(x
k
, t
n
).
Our numerical solution will be based on an approach known as predictor-corrector, as outlined in the next
section.
2.1.1 Predictor Step
The predictor step takes the form,
dU
1
dt

k
=
_
F
n
1,k
F
n
1,k1
x
_
(21)
dU
2
dt

k
=
_
F
n
2,k
F
n
2,k1
x
_
+ J
n
2,k
(22)
dU
3
dt

k
=
_
F
n
3,k
F
n
3,k1
x
_
(23)
The notation |
k
on the left-hand side above denotes the value of the time derivative at grid point x
k
.
As a shorthand we will rewrite the above as,
dU
1
dt

k
= RHS1
n
k
,
dU
2
dt

k
= RHS2
n
k
,
dU
3
dt

k
= RHS3
n
k
(24)
We now advance the resulting ordinary differential equations in time, i.e.,

U
n+1
1,k
= U
n
1,k
+ tRHS1
n
k
, k = 2, . . . , N 1 (25)

U
n+1
2,k
= U
n
2,k
+ tRHS2
n
k
, k = 2, . . . , N 1 (26)

U
n+1
3,k
= U
n
3,k
+ tRHS3
n
k
, k = 2, . . . , N 1 (27)
3
2.2 Corrector Step
The idea is to consider the above variables as predictions of the solution at the next time increment and to
attempt to improve those predictions. We do this by making another evaluation of the equations using our
prediction of the solution,
d

U
1
dt

k
=
_

F
1,k+1


F
1,k
x
_
(28)
d

U
2
dt

k
=
_

F
2,k+1


F
2,k
x
_
+

J
2,k
(29)
d

U
3
dt

k
=
_

F
3,k+1


F
3,k
x
_
(30)
where

F
1,k
,

F
2,k
, and

F
3,k
are evaluated using the predicted values

U
1,k
,

U
2,k
, and

U
3,k
.
Using a similar shorthand as introduced above, we rewrite the system of equations as,
d

U
1
dt

k
= RHS4
n+1
k
,
d

U
2
dt

k
= RHS5
n+1
k
,
d

U
3
dt

k
= RHS6
n+1
k
(31)
We now use these two evaluations of the right-hand sides to calculate what we will accept as the new values
for the dependent variables,
U
n+1
1,k
= U
n
1,k
+
t
2
_
RHS1
n
k
+ RHS4
n+1
k
_
, k = 2, . . . , N 1 (32)
U
n+1
2,k
= U
n
2,k
+
t
2
_
RHS2
n
k
+ RHS5
n+1
k
_
, k = 2, . . . , N 1 (33)
U
n+1
3,k
= U
n
3,k
+
t
2
_
RHS3
n
k
+ RHS6
n+1
k
_
, k = 2, . . . , N 1 (34)
2.3 Boundary Conditions and Nozzle Shape
The values of the variables on the boundaries (i.e., at k = 1 and k = N) are not obtained from solution
of the above equations but instead are specied as boundary conditions. We will specify at the inlet to our
domain (k = 1) the following boundary conditions,
U
1,k=1
= (A)
k=1
= A
k=1
, U
2,k=1
= 2U
2,k=2
U
2,k=3
, U
3,k=1
= U
1,k=1
_
T
1
+

2
u
2
_
(35)
with T(x = 0, t) = T(x = 0, t = 0) and u(x = 0, t) = u(x = 0, t = 0) (we could also use Eq. (15) for u).
At the outlet of our nozzle we will specify the following conditions,
U
1,N
= 2U
1,N1
U
1,N2
, U
2,N
= 2U
2,N1
U
2,N2
, U
3,N
= 2U
3,N1
U
3,N2
(36)
The nozzle shape will be specied as,
A = 1 + 2.2(x 1.5)
2
, 0 x 3 (37)
To obtain the dimensionless area, A, we will divide the above expression by the minimum area (correspond-
ing to x = 1.5).
4
2.4 Initial Conditions and Timestep
To start the computations, the initial values of the variables to be used are,
= T = 1 for 0 x 0.5 (38)
= 1 0.366(x 0.5) , T = 1 0.167(x 0.5) , for 0.5 x 1.5 (39)
= 0.634 0.388(x 1.5) , T = 0.833 0.351(x 1.5) , for 1.5 x 3.0 (40)
The initial velocity will be specied according to,
u =
U
2
A
=
0.59
A
. (41)
Using the above initial distributions the dependent variables are then initially specied as,
U
1
= A, U
2
= Au, U
3
=
_
T
1
+

2
u
2
_
A (42)
We will choose the timestep using the formula,
t
n
k
= CFL
x
a
n
k
+ u
n
k
, k = 1, . . . , N (43)
with CFL = 0.5 and where a in the above represents the local sound speed of the gas. Note that you
must non-dimensionalize the above equation before implementing into your code. Notice that we can
compute the time step for every grid point. We then take the minimum value over all the grid points from 1
to N and use that to advance the oweld, i.e.,
t
n
=
N
min
k=1
t
n
k
(44)
5
3 Assignment
The main goal of the project is to compute the steady-state solution and assess the inuence of parameters
such as the grid spacing and time step on the results.
You must hand in your report either handwritten and/or printed out containing all requested gures.
It is not sufcient to simply upload your report to blackboard without a printed version handed in.
You also must upload all codes used to blackboard.
3.1 Required elements of the project
The required elements of your project are outlined below. Remember that your presentation is part of the
grade. Poorly prepared solutions will not be treated kindly.
1. Writeup of the problem statement and approach Non-dimensionalization of the equations and the
way you calculate your stable time step must be contained in your writeup.
2. Computation of the steady-state solution using N = 31 and CFL = 0.5. Plot the density, temper-
ature, pressure, and Mach number from the middle of the nozzle (x = 1.5) versus the time step.
Also plot the residuals from each of the governing equations (mass, momentum, and energy). We will
dene the residuals at time step n for each of these equations as,
mass
n
res
=
_
N1

k=2
(RHS1
n
k
+ RHS4
n+1
k
)
2
_
1/2
(45)
mom
n
res
=
_
N1

k=2
(RHS2
n
k
+ RHS5
n+1
k
)
2
_
1/2
(46)
energy
n
res
=
_
N1

k=2
(RHS3
n
k
+ RHS6
n+1
k
)
2
_
1/2
(47)
The above residuals are to be plotted versus time step. Use a logarithmic scaling for the vertical axis
of these plots.
We will dene the steady-state solution as obtained once all of the residuals are smaller than 10
3
.
Once your solution has attained steady-state plot the distributions of the density, temperature, pressure,
and Mach number in the nozzle.
3. Investigation of the inuence of the CFL number. The above computations are performed using
CFL = 0.5. Plot the residuals versus time step for CFL = 0.8 and CFL = 1.0. Comment on the
plots and effect of the CFL number on the solutions. Then determine the maximum allowable CFL
number by increasing it until your solution becomes numerically unstable (i.e., blows up). Plot the
distributions of the density, temperature, and Mach number through the nozzle for the rst unstable
CFL number at a time prior to the code becoming unstable.
4. Investigation of grid convergence. Check the numerical convergence of your solution by calculating
a second case with N = 61 and CFL = 0.5. Plot the distributions of the density, temperature,
pressure, and Mach number on the same graphs as the results using N = 31. Comment on the plots.
Is this solution converged, i.e., is the numerical solution sensitive to N?
6
5. Required MAE561, extra credit MAE471: Computation of a case with shock capturing. For this
part of the project, the boundary conditions at k = N will be modied as,
U
1,N
= 2U
1,N1
U
1,N2
, U
2,N
= 2U
2,N1
U
2,N2
, U
3,N
=
0.6784A
1
+

2
U
2,N
u
N
(48)
which corresponds to p
N
= 0.6784, which turns out to be an interesting value. The initial conditions
for this part will be prescribed as,
= T = 1 for 0 x 0.5 (49)
= 1 0.366(x 0.5) , T = 1 0.167(x 0.5) , for 0.5 x 1.5 (50)
= 0.634 0.702(x 1.5) , T = 0.833 0.491(x 1.5) , for 1.5 x 2.1 (51)
= 0.5892 + 0.10238(x 2.1) , T = 0.93968 + 0.0622(x 2.1) , for 2.1 x 3.0 (52)
Solve for the ow in the nozzle using N = 61 grid points and with a CFL number of 0.5. Plot the
distributions of the pressure, temperature, and velocity after 1000 timesteps. Also plot the residuals.
Comment on the results.
6. Extra credit MAE471/561: Pre-shock Mach number: Determine the pre-shock Mach number, i.e.
the Mach number of the ow just prior to the shock, from step 5. Document your approach and justify
your answer. Hint: maybe try to perform a grid convergence study. If that does not help, consider
modifying your scheme to reduce potential dispersive errors polluting your solution.
7

You might also like