Week 7 - Simulation of a 1D Supersonic nozzle flow simulation using Macormack Method
Question:
In this challenge you are going to simulate the isentropic flow through a quasi 1D subsonic-supersonic nozzle. You will derive both the conservation and non-conservation forms of the governing equations and solve them using the MacCormack's technique. You need to determine the steady-state temperature distribution for the flow-field variables and investigate the difference between the two forms of governing equations by comparing their solutions.
Objectives:
You need to show the following plots inside your report
1. Steady-state distribution of primitive variables inside the nozzle
2. Time-wise variation of the primitive variables
3. Variation of Mass flow rate distribution inside the nozzle at different time steps during the time-marching process
4. Comparison of Normalized mass flow rate distributions of both forms
Solution:
Here we goanna solve the Quasi 1D subsonic-supersonic nozzle in two different forms conservative form and non-conservative form;
Governing equations:
<!-- [if !supportLists]-->· <!--[endif]-->Conservative equation and one conservative form of equation are mathematically equivalent.
<!-- [if !supportLists]-->· <!--[endif]-->One com can be converted into another form. Quite easily and exactly.
<!-- [if !supportLists]-->· <!--[endif]-->Conservative and non-conservative are different only in world of numerical discretization.
<!-- [if !supportLists]-->· <!--[endif]-->Whereas conservative form are more accurate and it tends to work well Discontinuities, Exist in domain
Whereas our domain looks like the figure given below, in which we say it as 1D flow but in actual it is 2D only. During inlet and divergent the Mach number is Going to be less than one. Whereas at subsonic calculate the Mac number will be larger than one. So in this challenge we are going to see. Behavior of the Mach number of pressure temperature and density throughout the nozzle.

Fig 1. 1D subsonic-supersonic Nozzle
Now lets derivative first non-conservative form and then conservative form mathematically;
1.NON-CONSERVATIVE FORM:
We have Rate of change of mass;
`∫∫∫(∂/(∂t))(ρ dv)=∂/(∂t)∫∫∫ρ.dv`
Where `(ρ.dv)` is control volume and above equation is also equal to “inflow – outflow ” and equalize to negative of surface integral.
“The only mass entering of exiting will be through one of the triangle which is going to be surface integral”
Surface integral is `=-∫∫ρ.v.ds` ;
So, the equation now becomes;
`∂/(∂t)∫∫∫ρ.dv+∫∫ρ v ds=0` ……………………1
Where ds is control volume which we can see in fig.2 , in which we put the slice of nozzle flow, where the thickness of slice is dx. Where on left side control volume consistent. With quasi 1D assumption. The density velocity pressure and integral energy is noted by ρ V P and E. respectively are uniform over the area a similarly right side of the control volume. The density velocity pressure and integral energy denoted by ρ+dρ, v+dv, p+dp and e+de respectively are uniform over the area A+dA.

Fig 2. Control volume
Therefore;
`∂/(∂t)∫∫∫ρ dv=∂/(∂t)∫∫∫ρ A dx=∂/(∂t) (ρA)dx`
Surface integral term will be,
`∫∫ρ v ds=-ρvA+(ρ+dρ)(v+dv)(A+dA)`
After simplifying above term and ignoring all small terms for example multiplication of dA, dv and dρ. Because as dx is small All these differences are small and product of these differences are even more small.
Term remains will be;
`∫∫ρ v ds=ρAdv+dρAv+ρvdA`
If we see above term, we can see it is application of chain rule (simplification of above term),
`∫∫ρ v ds=d(ρAv)`………………….2
If we put equation 2 in equation 1 we get;
`∂/(∂t) (ρAdx)+d(ρAv)=0` …………………3
Dividing equation 3 by dx, we get
`∂/(∂t) (ρA)+∂/(∂x) (ρAv)=0` …………….4.1
Equation 4 is the partial differential equation form of continuity equation suitable for unsteady passive 1 dimensional flow. It ensures that mass is conserved for this model of flow It is interesting to pause at a moment and compare this with a general continuity equation. Part 3D flow specialise for one day if flow for such case equation becomes
`(∂ρ)/(∂t)+(∂(ρv))/(∂x)=0`
Where V is X component of velocity, clearly equation is different from equation 4 above equation applies to truly 1D flow, where A is constant with respect to X. It does not represent proper statement of conservation of mass for our model of Quasi 1D flow, where A is equal to A(x) Instead, equation 4 is proper statement of mass conservation for our model. Of course, note that for the special case of constant area flow, equation 4 Reduce to above equation.
Now from above continuity equation we get the momentum equation as it is long derivation part and we don’t need to involve in that so we write here directly;
`∂/(∂t) (ρAv)+∂/(∂x) (ρAv^2 )=-A (∂p)/(∂x)` ………….4.2
Above term represents the momentum equation and both the term continuity and momentum are in conservative form and to make it in non-conservative form we need to apply the u*v rule using that rule we get the non-conservative form of continuity and momentum equation;
`∂/(∂t) (ρA)+v ∂(ρA)/(∂x)=-ρA (∂v)/(∂x)` …………. continuity equation in non-conservative form
`ρ (∂v)/(∂t)+ρv (∂v)/(∂x)=-(∂p)/(∂x)` ………………. Momentum equation in non-conservative form
Energy equation will be;
`∂/(∂t) (ρ v^2/2 A)+∂/(∂x) (ρ v^3/2 A)=-Av (∂ρ)/(∂x)` ………..4.3
In non-conservative form;
`ρ(∂T)/(∂t)+ρv(∂T)/(∂x)=-p(∂v)/(∂x)-pv(∂(lnA))/(∂x)` ……………Energy equation in non-conservative form
As an incident, somebody our continuity momentum and energy equation for unsteady quasi red one dimensional flow are given by above equations. See, you see three equation with the unknown variables. Rho V, P and T. The pressure can be eliminated from this equation by using the equation of state.
`p=ρRT`
Along with its derivative;
`(∂ρ)/(∂x)=R(ρ (∂t)/(∂x)+T (∂ρ)/(∂x))`
With this the governing equations will be;
`∂/(∂t) (ρA)+ρv (∂(A))/(∂x)+ρA (∂v)/(∂x)+vA (∂ρ)/(∂x)=0` ………. Continuity equation
`ρ (∂v)/(∂t)+ρv (∂v)/(∂x)=-R(ρ(∂T)/(∂x)+T (∂p)/(∂x))` ………. Momentum equation
`ρ (∂T)/(∂t)+ρvc_v (∂T)/(∂x)=-ρRT[(∂v)/(∂x)+v (∂(lnA))/(∂x)]` …. Energy equation
At this stage, we could really proceed to set up an readily solution of above continuity momentum and energy equation. Note that these are written in terms of dimension variable. This is fine and many CFD solution are carried out directly in terms of such, dimensional variable. Indeed, this has an added engineering advantage, because it gives you feeling for the magnitude of real physical quantities as the solution progresses. However, for nozzle flows the flow field variable are frequently expresses in terms of non-dimensional variable. Where the flow variable p/p0, ρ/ρ0, and T/T0 vary between 0 and 1 which is an aesthetic advantage when presenting the result. Because fluid dynamics dealing with nozzle flow so frequently use this non-dimensional term.
Therefore, where the Reservoir temperature and density are denoted by T0 and ρ0 respectively. Define the non-dimensional temperature and density respectively as;
`T^'=T/T_0 ; ρ^'=ρ/ρ_0 ;`
Where the prime denotes a dimensionless variable moreover letting l denote the length of nozzle we define a dimensional less length as;
`x^'=x/L`
Denoting the speed of sound in reservoir as a0 where;
`a_0=√γRT_0`
We define dimensionless velocity as ;
`v^'=v/a_0`
Finally, we ratio the local area A to the sonic throat area A* and define a dimensionless area as;
`A^'=A/(A^*)`
Now as we have set of governing equations, variables now let’s see the methodology;
`(∂(ρ^' A^' ))/(∂t) ((ρ_0 A)/(L/a_0 ))+(ρ^' A^' ∂v^')/(∂x^' ) ((ρ_0 Aa_0)/L)+(ρ^' v^' ∂A^')/(∂x^' ) ((ρ_0 Aa_0)/L)+(v^' A^' ∂ρ^')/(∂x^' ) ((ρ_0 Aa_0)/L)`
Note that A is function of x only; it is not a function of time hence in above equation the time derivative can be written as ;
`(∂(ρ^' A^' ))/(∂t^' )=A^' (∂ρ')/(∂t')`
The continuity equation becomes;
`(∂ρ^')/(∂t^' )=-ρ^' (∂v^')/(∂x^' )-ρ^' v^' (∂(lnA^' ))/(∂x^' )-v^' (∂ρ^')/(∂x^' )` ………….C
And similarly we get another equations
Momentum equation becomes
`(∂v^')/(∂t)= -v (∂v^')/(∂x^' )-(1/γ)((∂T^')/(∂x^' )+T^'/ρ^' ((∂ρ^')/(∂x))` …………..M
Energy equation becomes;
`(∂T^')/(∂t^' )=-v^' (∂T^')/(∂x^' )-(γ-1) T^' [(∂v^')/(∂x^' )+v^' (∂(lnA^' ))/(∂x^' )]` ……. E
Methodology:
1. Mesh
2. Discretize
3. Solve conditions
<!-- [if !supportLists]-->· <!--[endif]-->Initial condition
<!-- [if !supportLists]-->· <!--[endif]-->Boundary condition
Where in one dimensional domain the mesh looks like breaking of line in different parts or dividing that line by number of nodes we want.
But discretization we are going to do is using MacCormack technique;
1.1.MacCormack technique
McCormack technique is variant of lax Wendorff approach. But is much simpler in its application. McCormack is also an explicit finite difference technique, which is second order accurate in both space and time It becomes most popular, explicit, finite difference method for solving fluid flow.

Fig 3. 2D Grid
In above fig there is two-dimensional grid where we will address time marching solution using MacCormack technique as before we assume flow field at each grid point is known as time(t) and we proceed to calculate flow field variables at same grid point at time t+∆t.
First consider the density at grid point (i,j) at time (t+∆t), in McCormack method this is obtain from;
`ρ_(i,j)^(t+∆t)=ρ_(i,j)^t+((∂ρ)/(∂t))_(avg) ∆t` …………….5
Where drho/dt represents mean value of drho/dt between times t and t+∆
The time derivative are equivalent at time and carrying out second derivative. Is necessary to obtain 2nd order accuracy In contrast equation 5 the value of dp/dt is calculated.
So as to preserve second order accuracy without the need of calculate value of 2nd time derivative which is term in which involves lot of algebra with McCormack technique This algebra is circumvented.
Similar relation are written for other flow field variables
`u_(i,j)^(t+∆t)=u_(i,j)^t+((∂u)/(∂t))_(avg) ∆t` ………………6
`v_(i,j)^(t+∆t)=v_(i,j)^t+((∂v)/(∂t))_(avg) ∆t` ………………7
`e_(i,j)^(t+∆t)=e_(i,j)^t+((∂e)/(∂t))_(avg) ∆t` ……………….8
Now let’s see how we calculate the average value of derivative;
There are two major steps in McCormack technique which is predictor and corrector step,
1.1.1.Predictor step
In continuity equation 5 replace the spatial derivative on right hand side with forward differences.
`((∂ρ)/(∂t))_(i,j)^t=-[ρ_(i,j)^t (u_(i+1,j)^t-u_(i,j)^t)/∆x+u_(i,j)^t ((ρ_(i+1,j)^t-ρ_(i,j)^t ))/∆x+ρ_(i,j)^t ((v_(i,j+1)^t-v_(i,j)^t)/∆x)+v_(i,j)^t ((ρ_(i,j+1)^t-ρ_(i,j)^t)/∆x)]` …………9
In equation 9 all flow variable at Time (t) are nonvalues. That is, right hand side is known. Now obtain predicted value of density for first two term of Taylor series as follow;
`ρ_(i,j)^(t+∆t)=ρ_(i,j)^t+((∂ρ)/(∂t))_(i,j)^t ∆t` …………...10
In equation 10 ρi,jt is known and (dρ/dt)t i,j . Is known from equation 9 <!-- [if gte msEquation 12]>
And similarly for other variables;
`u_(i,j)^(t+∆t)=u_(i,j)^t+((∂u)/(∂t))_(i,j)^t ∆t`……………11
`v_(i,j)^(t+∆t)=v_(i,j)^t+((∂v)/(∂t))_(i,j)^t ∆t` …………….12
`e_(i,j)^(t+∆t)=e_(i,j)^t+((∂e)/(∂t))_(i,j)^t ∆t` …………….13
1.1.2. Corrector step
In character state, we first obtain a predictor value of time derivative at time t+∆t, `((∂ρ)/(∂t))_(i,j)^(t+∆t)`By substituting the predicted value of rho, u and v into right side of continuity equation, replacing spatial derivatives with backward differencing.
`((∂ρ)/(∂t))_(i,j)^(t+∆t)=-[ρ_(i,j)^(t+∆t) (u_(i,j)^(t+∆t)-u_(i-1,j)^(t+∆t))/∆x+u_(i,j)^(t+∆t) ((ρ_(i,j)^(t+∆t)-ρ_(i-1,j)^(t+∆t) ))/∆x+ρ_(i,j)^(t+∆t) ((v_(i,j)^(t+∆t)-v_(i,j-1)^(t+∆t))/∆x)+v_(i,j)^(t+∆t) ((ρ_(i,j)^(t+∆t)-ρ_(i,j-1)^(t+∆t))/∆x)]` …14
The average value of time derivative of density, which appears in equations 5 is obtained from arithmetic mean of. `((∂ρ)/(∂t))_(i,j)^t` obtain from equation 9 and `((∂ρ)/(∂t))_(i,j)^(t+∆t)`from equation 14.
`((∂ρ)/(∂t))_avg=0.5[((∂ρ)/(∂t))_(i,j)^t+((∂ρ)/(∂t))_(i,j)^(t+∆t) ]` …………..15
Equation 15 allow us to obtain final corrected value of density at time (t+∆t) from equation 5. Repeated below
`ρ_(i,j)^(t+∆t)=ρ_(i,j)^t+((∂ρ)/(∂t))_(avg) ∆t`
The Mccomack technique as described above because two step predictor and corrector sequence is used with forward differences on predictor and backward differences on corrector is second order accurate method.
Coming back to non-conservative form;
Using the McCormack technique our governing equation for predictor step we get is (with ref to equation 9);
From continuity equation;
`((∂ρ)/(∂t))_(i,j)^t=-[ρ_(i,j)^t ((v_(i+1)^t-v_i^t)/∆x)+ρ_i^t v_i^t ((ln〖A_(i+1)-lnA_i 〗 ))/∆x+v_(i,j)^t ((ρ_(i+1)^t-ρ_i^t)/∆x)]`……16
From momentum equation;
`(∂v^')/(∂t)= -v((v_(i+1)^t-v_i^t)/∆x)-(1/γ)(((T_(i+1)^t-T_i^t)/∆x)+T^'/ρ^' ((ρ_(i+1)^t-ρ_(i,)^t)/∆x))` ……………17
From energy equation:
`(∂T^')/(∂t^' )=-v^' ((T_(i+1,j)^t-T_(i,j)^t)/(∆x))-(γ-1) T^' [((v_(i+1,j)^t-v_(i,j)^t)/(∆x))+v^' ((ln〖A_(i+1)-lnA_i 〗 ))/(∆x)]` ………18
Using equation 10 we know;
`ρ_(i,j)^(t+∆t)=ρ_(i,j)^t+((∂ρ)/(∂t))_(i,j)^t ∆t` ………..19.a
`v_(i,j)^(t+∆t)=v_(i,j)^t+((∂v)/(∂t))_(i,j)^t ∆t` ………..19.b
`T_(i,j)^(t+∆t)=T_(i,j)^t+((∂T)/(∂t))_(i,j)^t ∆t` ………..19.c
Moving to corrector step, we return to our governing equations and apply the spatial derivative with backward differencing this time;
`((∂ρ)/(∂t))_(i,j)^(t+∆t)=-[ρ_(i,j)^t ((v_(i,)^t-v_(i,-1)^t)/(∆x))+ρ_i^t v_i^t ((ln〖A_i-lnA_(i-1) 〗 ))/(∆x)+v_(i,j)^t ((ρ_i^t-ρ_(i-1)^t)/(∆x))]`……..20
`((∂v^'))/(∂t)= -v((v_i^t-v_(i-1)^t)/(∆x))-(1/γ)(((T_i^t-T_(i-1)^t)/(∆x))+T^'/ρ^' ((ρ_i^t-ρ_(i-1)^t)/(∆x)))` …………21
`(∂T^')/(∂t^' )=-v^' ((T_i^t-T_(i-1)^t)/(∆x))-(γ-1) T^' [((v_i^t-v_(i-1)^t)/(∆x))+v^' ((ln〖A_i-lnA_(i-1) 〗 ))/(∆x)]` …….22
Now as we get both predictor and corrector value so we can find the average value using equation 16, equation 17 and equation 18.
1.1.3 Time step calculation
In the above equation we used the dt which is time step and for stable solution we need the stable time step so we use the CFL criteria to find the dt using the below formula;
`∆t=(C ∆x)/(a_0^t+v_0^t )`
Where;
a0 speed of sound (also equal to square root of T)
v0 local velocity
C is courant number
And as we get the array of dt so we take the minimum value of dt
1.1.4. Initial Condition:
In present problem we know as density temperature decreases with increase in velocity as the flow expands through the nozzle. Hence we choose initial condition that qualitatively behave in the same fashion for simplicity let us assume linear variation of flow field variables as function of x for the present case we assume the following values at time t = 0
`ρ=1-0.3146x` …….23.1
`T=1-0.2314x` ……..23.2
`v=(0.1+1.09x) T^0.5` ……..23.3
`A = 1+2.2(x-1.5)^2`…..23.4
1.1.5. Boundary Condition for Non-conservative form:
Here are two phase of boundary condition lets see which are these;
1)Subsonic Inflow Boundary:
Here we must allow one variable to float, we choose velocity because on physical we know the mass flowing through nozzle must be allowed to proper steady state and allowing v1 to float makes the most sense as part of this adjustment the value of v1 changes with time and is calculated from information provided by flow field solution over internal points. We use extrapolation line is determined from point 2and 3 as
Slope = `(v3-v2)/(∆x)`
Using slope to find v1 by linear extrapolation we have;
`v1=v2-(v3-v2)/(∆x )`
`V1 = 2*v_2-v_3`
All other flow field variable are specified are specific since point 1 is viewed as essentially the reservoir we stipulate the density and temperature at point 1 to their respective stagnation values ρ0 & T0 respectively. These are held fixed independent of time hence in term of non-dimensional variable we have.
Rho1=1
T1 = 1
2)Subsonic Outflow Boundary;
Here we must allow all flow field variable to float we again choose to linear extrapolation based on flow field values at internal points we have for non-dimensional variables;
`V_n=2*V_(n-1)-V_(n-2)`
`ρ_n=2*ρ_(n-1)-ρ_(n-2)`
`T_n=2*T_(n-1)-T_(n-2)`
1.2.CONSERVATIVE FORM;
If we see above we derived the governing equation for conservative for if we take a look at equation number 4.1, 4.2 and 4.3 which are continuity, momentum and energy equation respectively
Continuity equation:
`∂/(∂t )(ρA)+∂/(∂x) (ρAv)=0` …………..4.1
Momentum equation:
`∂/(∂t) (ρAv)+∂/(∂x) (ρAv^2 )=-A (∂p)/(∂x)` …………4.2
Energy equation:
`∂/(∂t) (ρ v^2/2 A)+∂/(∂x) (ρ v^3/2 A)=-Av (∂ρ)/(∂x)` ………4.3
And like we eliminate the pressure term from governing equations above in non-conservative form similarly we have to do in conservative form also by using nondimensionalize the variable; So our newly formed governing equations becomes,
Continuity equation:
Nondimensionalize the continuity equation;
`(∂(ρ/ρ_0 (A/A_(0 ) ) ))/(∂(t/(L/a_0 ))) ((ρ_0 A^* a_0)/L)+(∂((ρ/ρ_0 )(A/A_0 )(v/a_0 )))/(∂(x/L)) ((ρ_0 A^* a_0)/L)=0`
Equation then becomes;
`∂/(∂t') (ρ'A')+∂/(∂x') (ρ'A'v')=0` ……………..(24)CONTINUITY EQUATION
We can see continuity equation will be as it is,
Momentum equation:
`∂/(∂t) (ρAv)+∂/(∂x) (ρAv^2 )=-A (∂p)/(∂x)` …………4.2
The above equation is already in conservation form let us combine the two x derivatives;
`∂/(∂x) (pA)=p((∂A)/(∂x))+A (∂p)/(∂x)` …………..25
Now we add the equation 4.2 and 25 we get;
`∂/(∂t) (ρAv)+∂/(∂x) (ρAv^2+pA)=p (∂A)/(∂x)`……….26
Now we nondimensionalize the equation 26
`(∂(ρ'A'v'))/(∂t')+(∂(ρ'A'〖v^'〗^2+ρ^' A^' (p_0/(ρa_0^2 ))))/(∂x')=ρ (∂A')/(∂x') (p_0/(ρa_0^2 ))` …….27
Where ,
`(p_0/(ρa_0^2 ))=1/γ`
Hence the momentum equation becomes;
`(∂(ρ'A'v'))/(∂t')+(∂(ρ'A'〖v^'〗^2+ρ^' A^' (1/γ)))/(∂x')=(1/γ)ρ (∂A')/(∂x')` ………..(28)MOMENTUM EQUATION
Similarly, we find the energy equation;
`(∂(ρ(e^'/(γ-1)+γ/2 v^'2 )A))/(∂t')+(∂(ρ'(e^'/(γ-1)+γ/2 v^'2 )v'A'+p'A'v'))/(∂x)=0` ……..(29)ENERGY EQUAT ION
Now we break the terms in solution vector flux vector and source term (if any)
For continuity equation;
Solution vector; `u1=ρ^' A^'`
Flux vector; `F1=ρ'A'v'`
For momentum equation;
Solution vector; `u2=ρ^' A^' v^'`
Flux vector; `F2=ρ'A'〖v^'〗^2+ρ^' A^' (1/γ)`
Source term; `J2=(1/γ)ρ (∂A')/(∂x)'`
For energy equation
Solution vector; `u3=ρ(e^'/(γ-1)+γ/2 v^'2 )A`
Flux vector; `F3=(ρ'(e^'/(γ-1)+γ/2 v^'2 )v'A'+p'A'v')`
With the above elements the governing equation can be written as;
`(∂U1)/(∂t')=-(∂F1)/(∂x' )` ……30.1
`(∂U2)/(∂t')=-(∂F2)/(∂x' )+J_2` ……30.2
`(∂U3)/(∂t')=-(∂F3)/(∂x' )` …………30.3
Then we create the primitive variables, to obtain primitive variable we must decode the U1, U2, U3 as follow, from the given definition of u1, u2, u3 we have;
`ρ^'=u^'/A^'`
`v^'=(u2)/(u1)`
`e^'=T^'=(γ-1)(u3/u2-γ/2 v^'2 )`
`p^'=ρ'T'`
These above primitive variables are use to construct the F1, F2, F3 for next time step, and so forth, & when primitive variables used to construct the F then numerical difficulties arises, so we have to use primitives’ variables in u1, u2, and u3 first to avoid the difficulties
So,
F1=F1(u1,u2,u3)
F2=F2(u1,u2,u3)
F3=F3(u1,u2,u3)
J2=J(u1,u2,u3)
In term of U’s our (F)flux terms become;
`F_1=U_2` ……………………………..31.1
`F_2=((u_2^2)/u_1 +(γ-1)/γ (u_3-γ/2 (u_2^2)/u_1 ))` ………31.2
`F_3=(γu_2 u_3)/u_1 -γ(γ-1)/2 (u_2^3)/(u_(1 )^2 )` ……………..31.3
`J_2=(γ-1)/γ (u_3-γ/2 (u_2^2)/(u_1^2 ))((∂(lnA^') )/(∂x^' ))` ………31.4
1.2.1. Initial conditions
Nozzle area:
`A=1+2.2(x-1.5)^2`
As x lies between 0 and 3
According to geometry the initial condition becomes;
For 0< x>0.5;
ρ’=1.0
T’=1.0
For 0.5 < x> 1.5;
`ρ^'=1.0-0.366(x^'-0.5)`
`T^'=1.0-0.167(x^'-0.5)`
For 1.5 < x> 3;
`ρ^'=0.634-0.3879(x^'-1.5)`
`T^'=0.833-0.3507(x^'-1.5)`
The initial condition for variation of v’ is synthesized by taking advantage of fact that one of the dependent variable in our governing equation namely u2, is physically the local mass flow that u2=ρ’v’A’; therefore let us assume a constant mass flow through nozzle and calculate v’ as;
`v^'=(u_2/(ρ^' A^' ))=(0.59/(ρ^' A^' ))`
And with these condition we also initialize the variables ,
`u_1=ρ'A'`
`u_2=ρ'A'v'`
`u_3=ρ^' ((T^'/(γ-1))+γ/2 v^'2 )A'`
And time step calculation is same as we done in non-conservative form (in sec 1.1.3)
Now let’s use the McCormack technique for solution;
1.2.2. Predictor step for conservative form
Using forward differencing on the flux term derivative we get (using sec 1.1.1);
`((∂F_1)/(∂x))_i^t =(F_1^t (i+1)-F_1^t (i))/dx` …………….32.1
`((∂u_2)/(∂t))_i^t=-((∂F_2)/(∂x))_i^t+J_2^t (i)` ……………….32.2
`((∂F_3)/(∂x))_i^t=(F_3^t (i+1)-F_3^t (i))/(dx)` ……………….32.3
And source term also be need to sync with the Flux terms so;
`J_2^t (i)=(1/γ)ρ(i)T(i)((A(i+1)-A(i))/dx)` ………..32.4
Using above terms, we are going to calculate the solution vector with respect to time derivative;
`((∂u_1)/(∂t))_i^t=-((∂F_1)/(∂x))_i^t` ………………….33
`((∂u_2)/(∂t))_i^t=-((∂F_2)/(∂x))_i^t+J_2^t (i)` …………34
`((∂u_3)/(∂t))_i^t=-((∂F_3)/(∂x))_i^t` ………………….35
Then we obtain the intermediate solution using predicted value and old value solution vector;
`〖u_1^(t+∆t)〗_((i) )=〖u_1^t〗_((i) )+((∂u_1)/(∂t))_i^t ∆t` ………36
`〖u_2^(t+∆t)〗_((i) )=〖u_2^t〗_((i) )+((∂u_2)/(∂t))_i^t ∆t` ……….37
`〖u_3^(t+∆t)〗_((i) )=〖u_3^t〗_((i) )+((∂u_3)/(∂t))_i^t ∆t` ……….38
1.2.3. Corrector step of conservative form:
Like we used forward differencing in predictor step here we have to use the backward differencing in corrector step (ref sec 1.1.2):
`((∂F_1)/(∂x))_i^(t+∆t)=(F_1^(t+∆t) (i)-F_1^(t+∆t) (i-1))/dx` …………39
`((∂F_2)/(∂x))_i^(t+∆t)=(F_2^(t+∆t) (i)-F_2^(t+∆t) (i-1))/dx` …………40
`((∂F_3)/(∂x))_i^(t+∆t)=(F_3^(t+∆t) (i)-F_3^(t+∆t) (i-1))/dx` ………….41
Using above terms, we are going to calculate the solution vector with respect to time derivative;
`((∂u_1)/(∂t))_i^(t+∆t)=-((∂F_1)/(∂x))_i^(t+∆t)` ………………….42
`((∂u_2)/(∂t))_i^(t+∆t)=-((∂F_2)/(∂x))_i^(t+∆t) +J_2^(t+∆t) (i)` ………43
`((∂u_3)/(∂t))_i^(t+∆t)=-((∂F_3)/(∂x))_i^(t+∆t)` ………………….44
And then finally we calculate the average of time derivative by using the predicted value and corrector value;
`((∂u_1)/(∂t))_(avg)^t=0.5[((∂u_1)/(∂t))_i^t+((∂u_1)/(∂t))_i^(t+∆t) ]` ……..45
`((∂u_2)/(∂t))_(avg)^t=0.5[((∂u_2)/(∂t))_i^t+((∂u_2)/(∂t))_i^(t+∆t) ]` ……..46
`((∂u_3)/(∂t))_(avg)^t=0.5[((∂u_3)/(∂t))_i^t+((∂u_3)/(∂t))_i^(t+∆t) ]` ……..47
Now we calculate the final solution by using average derivative and old value of solution vectors which we need for calculating the next time step;
`u_1^(t+∆t) (i)=u_1^t (i)+((∂u_1)/(∂t))_(avg)^t ∆t`
`u_2^(t+∆t) (i)=u_2^t (i)+((∂u_2)/(∂t))_(avg)^t ∆t`
`u_3^(t+∆t) (i)=u_3^t (i)+((∂u_3)/(∂t))_(avg)^t ∆t`
Results:
Fig 4. Change in parameters with respect to length
We can notice that as the flow passes through different length the trend of line behaves likewise like Mach number at subsonic inlet is less than 1, while as it goes toward supersonic outlet the Mach number is going beyond 1.
Fig 5. Change in parameters with respect to time
In above figure (fig 5) we can notice as the time steps increasing the variables become the stable in both form then it may be conservative form or non-conservative form.
Fig 6. Variations in mass flow rate in conservation vs non conservation form
Fig 7. Mass flow rate for various time steps (conservative form)
If we see figure 7 and 8 we can see as the number of time step increases the mass flow rate looks stable and just like if we see the results at time steps above 400 and 700 the pink and magenta line looks more stable and nearer to exact solution
Fig 8. Mass flow rate for various time step (non-conservative form)
Grid independence test:
Let’s compare the steady state results for conservation and non-conservation form
|
Form of solution |
density |
Temperature |
velocity |
|
Exact solution |
0.634 |
0.837 |
0.933 |
|
Conservative form (31) |
0.6426 |
0.8360 |
0.9109 |
|
Non-conservative form (31) |
0.6387 |
0.8365 |
0.9140 |
|
Conservative form(61) |
0.6390 |
0.8357 |
0.9122 |
|
Non-conservative form (61) |
0.6394 |
0.8353 |
0.9137 |
|
Error in conservative(31) |
0.0086 |
0.001 |
0.0221 |
|
Error in non conservative(31) |
0.0047 |
0.0005 |
0.019 |
Table 1. Results study
If we see above table we can notice that in results of non conservative form looks like more accurate method as we can see the error values too with respect to our exact solution. And if we look in form of grid study the results get fine as we increase the density of mesh as we go from 31 to 61 the results look more closer to exact solution so we can say as we increase the mesh and make it more refine the results we get will be more accurate.
Observations & Conclusion:
Let us compare Variation of mass flow obtained with non-conservation and conservation form outgoing equation, both after 1400-time steps. One beyond the time required to converge to steady state This comparison is shown in figure 6. In which the scale of ordinate for mass blue is greatly magnified Here we see the steady state mask flow distribution predicted by conservation form of equation is much more satisfactory that obtain from non-conservation form.
<!-- [if !supportLists]-->1. <!--[endif]-->One of the major observations is the conservation form does a better job. A preserving must work to play field, meaning because the mass flow itself is one of the dependent variables in the equation. Mass flow is primary result from these equations In contrast, the dependent variable in non-conservation form of equation are primitive variables. And the mass flow is obtained only as second user because the conservation form of the equation does a better absorb of considering mass through the flow field. You can begin to understand why they are labelled the conservation form.
<!-- [if !supportLists]-->2. <!--[endif]-->Conservation form yields a better mass flow distribution. The conservation forms simply do a better job of conserving mass.
<!-- [if !supportLists]-->3. <!--[endif]-->The non conservation form leads to smaller residuals. the amount by which the residuality decay is often used as an index of numerical algorithm. In this sense non conservation form does a better job
<!-- [if !supportLists]-->4. <!--[endif]-->The non conservative plan seems to produce More accurate results for the primitive variable and the conservation form seems to produce slightly more accurate results Perplex variables.
<!-- [if !supportLists]-->5. <!--[endif]-->As a work we notice that the solution of conservation form requires marginally more work Most of this is due to need to decode the primitive variable from the flux variable. Such decoding is not necessary when you are solving non conservation form.
Main Code:
Conservative function code:
non-conservative function code: