All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Simulation of a 1D Super-sonic nozzle flow simulation using Macormack Method Schematic representation of convergent divergent nozzle. In the above described convergent divergent nozzle, while simulating for the flow parameters, an assumptions has been made that the flow property will only vary with x. Thus the uniform…
Vipul Anand
updated on 08 Apr 2021
Simulation of a 1D Super-sonic nozzle flow simulation using Macormack Method
Schematic representation of convergent divergent nozzle.
In the above described convergent divergent nozzle, while simulating for the flow parameters, an assumptions has been made that the flow property will only vary with x. Thus the uniform flow property along cross section is assumed. The assumption made here, makes the simulation, quasi-one-Dimensional flow simulation.
The physical phenomenon of the stated problem is governed by the following equations:-
The equations are presented in 2 forms, Conservative and Non-Conservative Form.
Conservative Form
Continuity Equation:-
∂(ρA)∂t+∂(ρAV)∂x=0∂(ρA)∂t+∂(ρAV)∂x=0
Momentum Equation:-
∂(ρAV)∂t+∂(ρAV2)∂x=-A∂p∂x
Energy Equation:-
∂[ρ(e+V22)A]∂t+∂[ρ(e+V22)VA]∂x=-∂(pAV)∂x
Non Conservation Form
Continuity Equation:-
A∂ρ∂t+V∂(ρA)∂x=-ρA∂V∂x
Momentum Equation:-
ρ∂V∂t+ρV∂V∂x=-∂p∂x
Energy Equation:-
ρ∂e∂t+ρV∂e∂x=-p∂V∂x-pV∂(lnA)∂x
In order to non dimensionalise the variables, we will be using reservoir values as the base.
Non-Dimensional values will be represented with ' superscript
Velocity
V′=Va0
Temperature
T′=TT0
Density
ρ′=ρρ0
Length
x′=xL
time
t′=tLa0
Pressure
P′=PP0
Area
A′=AA0
Where,
A0 is the throat area.
a0 is √γRT0 represents speed of sound in the reservoir.
P0,ρ0,T0 is the reservoir pressure, density and temperature.
Maccormack Method
It is a 2 step method for discretization of hyperbolic partial differential equations. The method is second order accurate in time and space domain. The first step called predictor step is used to find so called predicted value for the next time step. Then, in corrector step, the predicted value for next time step is corrected using backward differencing in space domain.
Governing Equations:-
1. Conservation Form using dimentionless variables:-
Continuity Equation:-
∂(ρ′A′)∂t′+∂(ρ′A′V′)dx′=0
Momentum Equation:-
∂(ρ′A′V′)dt′+∂[ρ′A′V′2+(1γ)p′A′]∂x′=1γp′∂A′∂x′
Energy Equation :-
∂[ρ′(e′γ-1+γ2V′2)A′]∂t′+∂[ρ′(e′γ-1+γ2V′2)V′A′+p′A′V′]∂x′=0
Dependent variables are not the primitive variables while solving conservation form equations, So they need to be converted into solution vectors for solving and later they need to be decoded into primitive variables after solving.
Defining Source(J), Flux(F) and Solution Vectors(U) for the solution of above equation we get,
U1=ρ′A′
U2=ρ′A′V′
U3=ρ′(e′γ-1+γ2V′2)A′
F1=ρ′A′V′
F2=ρ′A′V′2+1γp′A′
F3=ρ′(e′γ-1+γ2V′2)V′A′+p′A′V′
J2=1γp′(∂A′)
time deravatives of solution vectors:-
∂U1∂t′=-∂F1∂x′
∂U2∂t′=J2-∂F2∂x′
∂U3∂t′=-∂F3∂x′
The premitive variables can be decoded back from solution vectors using below expressions:-
ρ′=U′A′
V′=U2U1
T′=e′=(γ-1)(U3U1-γ2V′2)
p′=ρ′T′
Transforming the governing equation entirely in the form of solution vecors
F1=U2
F2=U22U1+γ-1γ(U3-γ2U22U1)
F3=γU2U3U1-γ(γ-1)2U32U21
J2=γ-1γ(U3-γ2U22U1)∂(lnA′)∂x′
Predictor Step :-
Calculating time deravative of the solution vectors:-
(∂U1∂t′)ti=-Ft1(i+1)-Ft1(i)Δx′
(∂U2∂t′)ti=Jt2(i+1)-Jt2(i)Δx′-Ft2(i+1)-Ft2(i)Δx′
(∂U3∂t′)ti=-Ft3(i+1)-Ft3(i)Δx′
Claculating the predictor values
ˉUt+Δt1(i)=(∂U1∂t′)ti.Δt′
ˉUt+Δt2(i)=(∂U2∂t′)ti.Δt′
ˉUt+Δt3(i)=(∂U3∂t′)ti.Δt′
Corrector Step:-
Calculating time deravitive:-
(¯∂U1∂t′)t+Δti=-ˉFt+Δt1(i)-ˉFt+Δt1(i-1)Δx′
(¯∂U2∂t′)t+Δti=ˉJt+Δt2(i)-ˉJt+Δt2(i-1)Δx′-ˉFt+Δt2(i)-ˉFt+Δt2(i-1)Δx′
(¯∂U3∂t′)t+Δti=-ˉFt+Δt3(i)-ˉFt+Δt3(i-1)Δx′
Claculating average deravative:-
(∂U1∂t′)av=12[(∂U1∂t′)ti+(¯∂U1∂t′)t+Δti]
(∂U2∂t′)av=12[(∂U2∂t′)ti+(¯∂U2∂t′)t+Δti]
(∂U3∂t′)av=12[(∂U3∂t′)ti+(¯∂U3∂t′)t+Δti]
Calculating corrected values:-
Ut+Δt1(i)=(∂U1∂t′)av.Δt′
Ut+Δt2(i)=(∂U2∂t′)av.Δt′
Ut+Δt3(i)=(∂U3∂t′)av.Δt′
After the above step the solution vectors are decoded into non dimensional primitive values.
2. Non Conservation Form
Continuity Equation:-
∂ρ′∂t′=-ρ′∂V′∂x′-ρ′V′∂(lnA′)∂x′-V′∂ρ′∂x′
Momentum Equation:-
∂V′∂t′=-V′∂V′∂x′-1γ(∂T′∂x′+T′ρ′∂ρ′∂x′)
Energy Equation:-
∂T′∂t′=-V′∂T′∂x′-(γ-1)T′[∂V′∂x′+V′∂(lnA′)∂x′]
Maccormak Strategy for Non-Conservation part:-
Calculating time deravatives for current time step, to be used to calculate values for predictor step.
(∂ρ∂t)ti=-ρti[Vtt+1-VtiΔx]-ρtiVti[ln(Ai+1)-ln(Ai)Δx]-Vti[ρti+1-ρtiΔx]
(∂V∂t)ti=-Vti[Vti+1-VtiΔx]-1γ[Tti+1-TtiΔx+Ttiρti(ρti+1-ρtiΔx)]
(∂T∂x)ti=-Vti[Tti+1-TtiΔx]-(γ-1)Tti[Vti+1-VtiΔx+Vti(ln(Ai+1)-ln(Ai)Δx)]
Computing predictor values for rho, velocity and temperature.
(ˉρ)t+Δti=ρti+(∂ρ∂t)tiΔt
(ˉV)t+Δti=Vti+(∂V∂t)tiΔt
(ˉT)t+Δti=Tti+(∂T∂t)tiΔt
Calculating deravatives for corrector steps:-
(¯∂ρ∂t)t+Δti=-(ˉρ)t+Δti[(ˉV)t+Δti-(ˉV)t+Δti-1Δx]-(ˉρ)t+Δti(ˉV)t+Δti[ln(Ai)-ln(Ai-1)Δx]-(ˉV)t+Δti[(ˉρ)t+Δti-(ˉρ)t+Δti-1Δx]
(¯∂V∂t)t+Δti=-(ˉV)t+Δti[(ˉV)t+Δti-(ˉV)t+Δti-1Δx]-1γ[(ˉT)t+Δti-(ˉT)t+Δti-1Δx+(ˉT)t+Δti(ˉρ)t+Δti((ˉρ)t+Δti-(ˉρ)t+Δti-1Δx)]
(¯∂T∂x)t+Δti=-(ˉV)t+Δti[(ˉT)t+Δti-(ˉT)t+Δti-1Δx]-(γ-1)Tt+Δti[(ˉV)t+Δti-(ˉV)t+Δti-1Δx+(ˉV)t+Δti(ln(Ai)-ln(Ai-1)Δx)]
Calculating average of deravatives:-
(∂ρ∂t)av=12[(∂ρ∂t)ti+(¯∂ρ∂t)t+Δti]
(∂V∂t)av=12[(∂V∂t)ti+(¯∂V∂t)t+Δti]
(∂T∂t)av=12[(∂T∂t)ti+(¯∂T∂t)t+Δti]
Calculating the final values for next time step:-
ρt+Δti=ρti+(∂ρ∂t)avΔt
Vt+Δti=Vti+(∂V∂t)avΔt
Tt+Δti=Tti+(∂T∂t)avΔt
pt+Δti=ρt+Δti.Tt+Δti
The Time Step Calculation of both the scheme has been discribed below:-
In order for the solution to be stable the effect of courant no. as been taken into consideration.
Δt=CΔxa+V
where,
C is the courant No. As in the literatue, for stable analysis, C is taken to be 0.5.
Δtfor each forward step is calculated for each grid point at once using the previous time step values of a, v. Then the minimum Δt is choosen for the present time step calculation. This has been imlemented in the code using a seperate function called updateDt.
The Total time steps taken as 1400. The value has been derived from the below refrenced literature, which suggests, it to be way beyond the steady state.
The initial and boundary Condition has been used as prescribed in the Anderson, P. J. D., Anderson, J. D. (1995). Computational Fluid Dynamics. Colombia: McGraw-Hill Education.
The program developed to study the above case is as follows:-
The program developed is organized in classes and a main driver script.
It contains, class initialCondition for storing the initial class for the simulation, quasiOnedim for storing the simulation functions and parameters, Result class to store the result of the simulation.
The quasiOnedim class:-
classdef quasiOnedim
%Class implementing Maccormack's method for quasi-one-Dim convergent-divergent nozzle
% Implementing the class requires following parameters:-
% n = No. of Node Points
% L = Length of the domain
% gamma = Specific Heat
% initObj = initialCondition object
% C = Courant No.
% nt = Total time steps
properties
n
L
% x-axis grid
x
% x-axis grid size
dx
% calculated time step
dt
% Area of the given profile
A
gamma
% Values of the non dimensional variables at time t = 0
% Non Dimentional density
rho
% Non - Dimentional Velocity
v
% Non - Dimentional temperature
T
C
nt
end
methods
function obj = quasiOnedim(n,L,gamma,initObj,C,nt)
%Initializes the declared properties
obj.n = n;
obj.L = L;
obj.x = linspace(0,L,n);
obj.dx = obj.x(2) - obj.x(1);
obj.A = 1 + 2.2*(obj.x - 1.5).^2;
obj.gamma = gamma;
obj.nt = nt;
obj.rho = initObj.rho;
obj.v = initObj.v;
obj.T = initObj.T;
obj.C = C;
end
function obj = updateDt(obj)
%Update the time step using scheme discussed in the theory
%section
a = sqrt(obj.T);
delt = (obj.C * obj.dx) ./ (a + obj.v);
dt_temp = min(delt);
obj.dt = dt_temp;
end
function [obj,result] = conservativeCD(obj)
% Implementing Conservative Governing Equation using
% Maccormak's Method.
% Declaring the result variable for saving transient result
transient_result = ones(obj.nt,obj.n,7);
dt_simulation = ones(obj.nt,1);
% Initializing result object
result = Result(1,1,1,1,1,1,1);
% Solution vectors declaration.
u1 = obj.rho .* obj.A;
u2 = obj.rho .* obj.A .* obj.v;
u3 = obj.rho .* (obj.T/(obj.gamma-1) + (obj.gamma/2) * (obj.v.^2)) .* obj.A;
% Time loop
for z = 1:obj.nt
% updating time step size for stability
obj = updateDt(obj);
% Storing the initial values as a previous time step
% data
u1Prev = u1;
u2Prev = u2;
u3Prev = u3;
% Declaring the Flux Vectors
f1 = u2;
f2 = (u2.^2 ./ u1) + ((obj.gamma-1)/obj.gamma) * (u3 - (obj.gamma/2) * (u2.^2 ./ u1));
f3 = (obj.gamma * ((u2 .* u3) ./ u1)) - (obj.gamma*(obj.gamma-1)/2) * (u2.^3 ./ u1.^2);
% Predictor Step claculation as discussed int the theory
for i = 2: obj.n-1
% Deravative of the flux term
df1Dx = (f1(i+1) - f1(i)) / obj.dx;
df2Dx = (f2(i+1) - f2(i)) / obj.dx;
df3Dx = (f3(i+1) - f3(i)) / obj.dx;
daDx = (obj.A(i+1) - obj.A(i)) / obj.dx;
% Source Term calculation
J2(i) = (1/obj.gamma) * obj.rho(i) * obj.T(i) * daDx;
% Deravative of Solution vectors
du1DtPred(i) = -df1Dx;
du2DtPred(i) = -df2Dx + J2(i);
du3DtPred(i) = -df3Dx;
% Updating the predictor step values
u1(i) = u1(i) + du1DtPred(i) * obj.dt;
u2(i) = u2(i) + du2DtPred(i) * obj.dt;
u3(i) = u3(i) + du3DtPred(i) * obj.dt;
end
% Update Flux Vectors
f1 = u2;
f2 = (u2.^2 ./ u1) + ((obj.gamma-1)/obj.gamma) * (u3 - (obj.gamma/2) * (u2.^2 ./ u1));
f3 = (obj.gamma * ((u2 .* u3) ./ u1)) - (obj.gamma*(obj.gamma-1)/2) * (u2.^3 ./ u1.^2);
% Decoding the variables
obj.rho = u1 ./ obj.A;
obj.v = u2 ./ u1;
obj.T = (obj.gamma - 1) * (u3 ./ (obj.rho .* obj.A) - (obj.gamma/2) * obj.v.^2);
% Corrector step Calculation
for i = 2: obj.n-1
% Deravative of updated flux
df1Dx = (f1(i) - f1(i-1)) / obj.dx;
df2Dx = (f2(i) - f2(i-1)) / obj.dx;
df3Dx = (f3(i) - f3(i-1)) / obj.dx;
daDx = (obj.A(i) - obj.A(i-1)) / obj.dx;
J2(i) = (1/obj.gamma) * obj.rho(i) * obj.T(i) * daDx;
du1DtCorrec(i) = -df1Dx;
du2DtCorrec(i) = -df2Dx + J2(i);
du3DtCorrec(i) = -df3Dx;
end
% Calculating the Average Derivative
du1Dt = 0.5 * (du1DtPred + du1DtCorrec);
du2Dt = 0.5 * (du2DtPred + du2DtCorrec);
du3Dt = 0.5 * (du3DtPred + du3DtCorrec);
% Updating the solution vectors
for j = 2: obj.n-1
u1(j) = u1Prev(j) + du1Dt(j) * obj.dt;
u2(j) = u2Prev(j) + du2Dt(j) * obj.dt;
u3(j) = u3Prev(j) + du3Dt(j) * obj.dt;
end
% Applying Boundary Conditions
% Inlet BC
obj.rho(1) = 1;
obj.T(1) = 1;
u1(1) = obj.rho(1) * obj.A(1);
u2(1) = 2 * u2(2) - u2(3);
u3(1) = u1(1) * (obj.T(1)/(obj.gamma-1) + (obj.gamma/2) * ((u2(1) / u1(1))^2));
% Outlet BC
u1(obj.n) = 2 * u1(obj.n-1) - u1(obj.n-2);
u2(obj.n) = 2 * u2(obj.n-1) - u2(obj.n-2);
u3(obj.n) = 2 * u3(obj.n-1) - u3(obj.n-2);
% Decoding the properties using solution vectors
obj.rho = u1 ./ obj.A;
obj.v = u2 ./ u1;
obj.T = (obj.gamma - 1) * (u3 ./ (obj.rho .* obj.A) - (obj.gamma/2) * obj.v.^2);
P = obj.rho .* obj.T;
M = obj.v ./ sqrt(obj.T);
massFlow = obj.rho .* obj.v .* obj.A;
%Saving time series data
transient_result(z,:,1) = obj.rho;
transient_result(z,:,2) = obj.T;
transient_result(z,:,3) = obj.v;
transient_result(z,:,4) = P;
transient_result(z,:,5) = M;
transient_result(z,:,6) = massFlow;
dt_simulation(z) = obj.dt;
end
% Updating the declared Result object
result.rho = transient_result(:,:,1);
result.T = transient_result(:,:,2);
result.v = transient_result(:,:,3);
result.P = transient_result(:,:,4);
result.M = transient_result(:,:,5);
result.massFlow = transient_result(:,:,6);
result.dt = dt_simulation;
end
function [obj,result] = nonConservativeCD(obj)
% Implements nonconservative form for the simulation
% Initializing the result variable for storing the transient
% results
transient_result = ones(obj.nt,obj.n,6);
dt_simulation = ones(obj.nt,1);
% Initializing the results object
result = Result(1,1,1,1,1,1,1);
for z = 1:obj.nt
% Storing the inital values to be used as previous time step
% data
rhoOld = obj.rho;
vOld = obj.v;
TOld = obj.T;
% Time step calculation based on Stability
obj = updateDt(obj);
% Predictor Step claculation as discussed int the theory
for i = 2: obj.n-1
% Calculating the deravitives
dRhoDx = (obj.rho(i+1) - obj.rho(i)) / obj.dx;
dvDx = (obj.v(i+1) - obj.v(i)) / obj.dx;
dtDx = (obj.T(i+1) - obj.T(i)) / obj.dx;
dlogaDx = (log(obj.A(i+1)) - log(obj.A(i))) / obj.dx;
% Continuity, Momentum and Energy Equation
dRhoDtPred(i) = -(obj.rho(i) * dvDx) - (obj.rho(i) * obj.v(i) * dlogaDx) - (obj.v(i) * dRhoDx);
dvDtPred(i) = -(obj.v(i) * dvDx) - (1/obj.gamma) * (dtDx + (obj.T(i)/obj.rho(i)) * dRhoDx);
dTdtPred(i) = -(obj.v(i) * dtDx) - (obj.gamma - 1) * obj.T(i) * (dvDx + obj.v(i) * dlogaDx);
% Updating the predicted values
obj.rho(i) = obj.rho(i) + dRhoDtPred(i) * obj.dt;
obj.v(i) = obj.v(i) + dvDtPred(i) * obj.dt;
obj.T(i) = obj.T(i) + dTdtPred(i) * obj.dt;
end
% Calculation of Corrector Step
for i = 2: obj.n-1
% Coalculating the deravitives
dRhoDx = (obj.rho(i) - obj.rho(i-1)) / obj.dx;
dvDx = (obj.v(i) - obj.v(i-1)) / obj.dx;
dtDx = (obj.T(i) - obj.T(i-1)) / obj.dx;
dlogaDx = (log(obj.A(i)) - log(obj.A(i-1))) / obj.dx;
% Continuity, Momentum and Energy Equation calculation
dRhoDtCorrect(i) = -(obj.rho(i) * dvDx) - (obj.rho(i) * obj.v(i) * dlogaDx) - (obj.v(i) * dRhoDx);
dvDtCorrect(i) = -(obj.v(i) * dvDx) - (1/obj.gamma) * (dtDx + (obj.T(i)/obj.rho(i)) * dRhoDx);
dTDtCorrect(i) = -(obj.v(i) * dtDx) - (obj.gamma - 1) * obj.T(i) * (dvDx + obj.v(i) * dlogaDx);
end
% Calculating the Average Derivative
dRhoDtAvg = 0.5 * (dRhoDtPred + dRhoDtCorrect);
dvDtAvg = 0.5 * (dvDtPred + dvDtCorrect);
dTDtAvg = 0.5 * (dTdtPred + dTDtCorrect);
% Updating the final values in the variables
for j = 2: obj.n-1
obj.rho(j) = rhoOld(j) + dRhoDtAvg(j) * obj.dt;
obj.v(j) = vOld(j) + dvDtAvg(j) * obj.dt;
obj.T(j) = TOld(j) + dTDtAvg(j) * obj.dt;
end
% Apply=ing Boundary Conditions
% Inlet BC
obj.v(1) = 2 * obj.v(2) - obj.v(3);
% Outlet BC
obj.rho(obj.n) = 2 * obj.rho(obj.n-1) - obj.rho(obj.n-2);
obj.v(obj.n) = 2 * obj.v(obj.n-1) - obj.v(obj.n-2);
obj.T(obj.n) = 2 * obj.T(obj.n-1) - obj.T(obj.n-2);
P = obj.rho .* obj.T;
M = obj.v ./ sqrt(obj.T);
massFlow = obj.rho .* obj.v .* obj.A;
% Updating the transient values
transient_result(z,:,1) = obj.rho;
transient_result(z,:,2) = obj.T;
transient_result(z,:,3) = obj.v;
transient_result(z,:,4) = P;
transient_result(z,:,5) = M;
transient_result(z,:,6) = massFlow;
dt_simulation(z) = obj.dt;
end
% Updating the result object
result.rho = transient_result(:,:,1);
result.T = transient_result(:,:,2);
result.v = transient_result(:,:,3);
result.P = transient_result(:,:,4);
result.M = transient_result(:,:,5);
result.massFlow = transient_result(:,:,6);
result.dt = dt_simulation;
end
end
end
the initialCondition class
classdef initialCondition
%The class stores the initial condition for the numerical analysis
% It has following parameters:
% rho = non-dim- density
% T = non-dim Temperature
% v = non-dim Velocity
properties
rho
T
v
end
methods
function obj = initialCondition(rho,T,v)
%Implements the initial condition and initializes the object
obj.rho = rho;
obj.T = T;
obj.v = v;
end
end
end
The Result class
classdef Result
%Defines the Result class for storing time-series simulation data
% It has following parameters:-
% rho - non-dimensional-density
% T = non-dimensiona-Temperature
% v = non-dimensiona-velocity
% P = non-dimensiona-Pressure
% M = Mach No.
% massFlow = non dimensional mass flow
% dt = time step size
properties
rho
T
v
P
M
massFlow
dt
end
methods
function obj = Result(rho,T,v,P,M,massFlow,dt)
%Initializes the result variable
obj.rho = rho;
obj.T = T;
obj.v = v;
obj.P = P;
obj.M = M;
obj.massFlow = massFlow;
obj.dt = dt;
end
end
end
The main driver script
close all
clear all
clc
n = 31;
gamma = 1.4;
C = 0.5;
totalTimeSteps = 1400;
%% Domain declaration
L = 3;
x = linspace(0,L,n);
A = 1 + 2.2*(x - 1.5).^2;
%% initial conditions
% Initial Temperature and velocity values in domain at time 0.
% Conservative
Rho = ones(1,n);
T = ones(1,n);
for m = 1:n
if x(m) >= 0 && x(m) < 0.5
Rho(m) = 1;
T(m) = 1;
end
if x(m) >= 0.5 && x(m) < 1.5
Rho(m) = 1 - 0.366 * (x(m) - 0.5);
T(m) = 1 - 0.167 * (x(m) - 0.5);
end
if x(m) >= 1.5 && x(m) <= 3
Rho(m) = 0.634 - 0.3879 * (x(m) - 1.5);
T(m) = 0.833 - 0.3507 * (x(m) - 1.5);
end
end
v = 0.59 ./ (Rho .* A);
%% Simulation Setup
% Conservative
conservative_initialCond = initialCondition(Rho,T,v);
conservative = quasiOnedim(n,L,gamma,conservative_initialCond,C,totalTimeSteps);
[conservative,result_conservative] = conservativeCD(conservative);
% Non - Conservative
Rho = 1 - 0.3146*x;
T = 1 - 0.2314*x;
v = (0.1 + 1.09*x) .* T.^0.5;
nonconservative_initialCond = initialCondition(Rho,T,v);
nonconservative = quasiOnedim(n,L,gamma,nonconservative_initialCond,C,totalTimeSteps);
[nonconservative,result_nonconservative] = nonConservativeCD(nonconservative);
%% Plotting
close all
%% Plotting
timeStepAxis = linspace(0,totalTimeSteps,totalTimeSteps);
throat_index = find(A==min(A));
% 1. Steady-state distribution of primitive variables inside the nozzle
figure(1)
subplot(1,2,1)
plot(x,result_conservative.rho(totalTimeSteps,:), 'linewidth',2, 'color', 'b')
hold on
plot(x,result_conservative.v(totalTimeSteps,:), 'linewidth',2, 'color', 'g')
hold on
plot(x,result_conservative.T(totalTimeSteps,:), 'linewidth',2, 'color', 'r')
hold on
plot(x,result_conservative.P(totalTimeSteps,:), 'linewidth',2, 'color', 'c')
xlabel("X Domain")
ylabel("Non Dimension Magnitude")
title("Conservative Form")
legend("rho", 'velocity','Temperature','Pressure','location','best')
subplot(1,2,2)
plot(x,result_nonconservative.rho(totalTimeSteps,:), 'linewidth', 2, 'color', 'b')
hold on
plot(x,result_nonconservative.v(totalTimeSteps,:), 'linewidth',2, 'color', 'g')
hold on
plot(x,result_nonconservative.T(totalTimeSteps,:), 'linewidth',2, 'color', 'r')
hold on
plot(x,result_nonconservative.P(totalTimeSteps,:), 'linewidth',2, 'color', 'c')
xlabel("X Domain")
ylabel("Non Dimensional Magnitude")
title("Non - Conservative Form")
sgtitle("Steady-State Distribution of Non Dimensional Primitive Variables")
legend("rho", 'velocity','Temperature','Pressure','location','best')
% 2. Time-wise variation of the primitive variables
figure(2)
subplot(1,2,1)
plot(timeStepAxis,result_conservative.rho(:,throat_index), 'linewidth',2, 'color', 'b')
hold on
plot(timeStepAxis,result_conservative.v(:,throat_index), 'linewidth',2, 'color', 'g')
hold on
plot(timeStepAxis,result_conservative.T(:,throat_index), 'linewidth',2, 'color', 'r')
hold on
plot(timeStepAxis,result_conservative.P(:,throat_index), 'linewidth',2, 'color', 'c')
hold on
plot(timeStepAxis,result_conservative.M(:,throat_index), 'linewidth',2, 'color', 'm')
xlabel("Time Steps")
ylabel("Non Dimensional Magnitude")
title("Conservative Form")
legend("rho","velocity","Temperature","Pressure","Mach No.")
xlim([0,totalTimeSteps])
ylim([0, 2])
subplot(1,2,2)
plot(timeStepAxis,result_nonconservative.rho(:,throat_index), 'linewidth',2, 'color', 'b')
hold on
plot(timeStepAxis,result_nonconservative.v(:,throat_index), 'linewidth',2, 'color', 'g')
hold on
plot(timeStepAxis,result_nonconservative.T(:,throat_index), 'linewidth',2, 'color', 'r')
hold on
plot(timeStepAxis,result_nonconservative.P(:,throat_index), 'linewidth',2, 'color', 'c')
hold on
plot(timeStepAxis,result_nonconservative.M(:,throat_index), 'linewidth',2, 'color', 'm')
xlabel("Time Steps")
ylabel("Nin Dimensional Magnitude")
title("Non - Conservative Form")
sgtitle("Time-wise variation of the Non Dimensional variables at throat section")
legend("rho","velocity","Temperature","Pressure","Mach No.",'location','best')
xlim([0,totalTimeSteps])
ylim([0, 2])
%3. Variation of Mass flow rate distribution inside the nozzle at different time steps during the time-marching process
figure(3)
subplot(1,2,1)
plot(x,result_conservative.massFlow(1,:), 'linewidth',2, 'color', 'b')
hold on
plot(x,result_conservative.massFlow(50,:), 'linewidth',2, 'color', 'g')
hold on
plot(x,result_conservative.massFlow(100,:), 'linewidth',2, 'color', 'r')
hold on
plot(x,result_conservative.massFlow(150,:), 'linewidth',2, 'color', 'c')
hold on
plot(x,result_conservative.massFlow(200,:), 'linewidth',2, 'color', 'm')
hold on
plot(x,result_conservative.massFlow(totalTimeSteps,:), 'linewidth',2, 'color', 'y')
xlabel("X-Domain")
ylabel("Non Dimensional Mass Flow Rate")
title("Conservative Form")
legend("1dt", "50dt", "100dt", "150dt", "200dt", "steady-state", 'location', 'best')
ylim([0,2])
subplot(1,2,2)
plot(x,result_nonconservative.massFlow(1,:), 'linewidth',2, 'color', 'b')
hold on
plot(x,result_nonconservative.massFlow(50,:), 'linewidth',2, 'color', 'g')
hold on
plot(x,result_nonconservative.massFlow(100,:), 'linewidth',2, 'color', 'r')
hold on
plot(x,result_nonconservative.massFlow(150,:), 'linewidth',2, 'color', 'c')
hold on
plot(x,result_nonconservative.massFlow(200,:), 'linewidth',2, 'color', 'm')
hold on
plot(x,result_nonconservative.massFlow(totalTimeSteps,:), 'linewidth',2, 'color', 'y')
title("Non-Conservative Form")
xlabel("X-Domain")
ylabel("Non Dimensional Mass Flow Rate")
legend("1dt", "50dt", "100dt", "150dt", "200dt", "steady-state", 'location', 'best')
ylim([0,2])
sgtitle("Variation of Non Dimensional Mass flow rate distribution at different Time-Steps")
% 4. Comparison of Normalized mass flow rate distributions of both forms
figure(4)
plot(x,result_conservative.massFlow(totalTimeSteps,:), 'linewidth',2, 'color', 'r')
hold on
plot(x,result_nonconservative.massFlow(totalTimeSteps,:), 'linewidth',2, 'color', 'c')
xlabel("X-Domain")
ylabel("Non Dimensional Mass Flow Rate")
legend('Conservative Form', 'Non Conservative Form')
title('Comparison of Normalized mass flow rate distributions')
%% Grid Independence
% For grid independence Lets run the simulation for n = 61 points for
% conservation form
n = 61;
x = linspace(0,L,n);
A = 1 + 2.2*(x - 1.5).^2;
Rho = ones(1,n);
T = ones(1,n);
for m = 1:n
if x(m) >= 0 && x(m) < 0.5
Rho(m) = 1;
T(m) = 1;
end
if x(m) >= 0.5 && x(m) < 1.5
Rho(m) = 1 - 0.366 * (x(m) - 0.5);
T(m) = 1 - 0.167 * (x(m) - 0.5);
end
if x(m) >= 1.5 && x(m) <= 3
Rho(m) = 0.634 - 0.3879 * (x(m) - 1.5);
T(m) = 0.833 - 0.3507 * (x(m) - 1.5);
end
end
v = 0.59 ./ (Rho .* A);
conservative_initialCond_grid_i = initialCondition(Rho,T,v);
conservative_grid_i = quasiOnedim(n,L,gamma,conservative_initialCond_grid_i,C,totalTimeSteps);
[conservative_grid_i,result_conservative_grid_i] = conservativeCD(conservative_grid_i);
% throat index when grid size is changed
throat_index_grid_i = find(A==min(A));
diff_rho = max(max(abs(result_conservative.rho(totalTimeSteps,throat_index)...
- result_conservative_grid_i.rho(totalTimeSteps,throat_index_grid_i))));
diff_M = max(max(abs(result_conservative.M(totalTimeSteps,throat_index)...
- result_conservative_grid_i.M(totalTimeSteps,throat_index_grid_i))));
diff_P = max(max(abs(result_conservative.P(totalTimeSteps,throat_index)...
- result_conservative_grid_i.P(totalTimeSteps,throat_index_grid_i))));
diff_T = max(max(abs(result_conservative.T(totalTimeSteps,throat_index)...
- result_conservative_grid_i.T(totalTimeSteps,throat_index_grid_i))));
percent_change_rho = (diff_rho/result_conservative.rho(totalTimeSteps,throat_index))*100
percent_change_M = (diff_rho/result_conservative.M(totalTimeSteps,throat_index))*100
percent_change_P = (diff_rho/result_conservative.P(totalTimeSteps,throat_index))*100
percent_change_T = (diff_rho/result_conservative.T(totalTimeSteps,throat_index))*100
Findings from above numerical analysis are as follows:-
1. Steady-state distribution of primitive variables inside the nozzle
The above plot represents the steady state variation of different parameters along the domain. Visually the conservation and non conservation form results appear similar. As described below from the table where, the parameter valeus at the throat is compared, It can be seen that the non conservation form is more near to analytical soultion when the soultion has reached steady state.
2. Time-wise variation of the primitive variables
In the above plot where, transient variation in variables is presented. It can be seen that, in conservative form there is less variation in the inital time steps, when comared with non conservative form. The initial condition is more improved in the conservative form. After around 400 time steps the solution is seen to be stable visualy.
3. Variation of Mass flow rate distribution inside the nozzle at different time steps during the time-marching process
Transient mass flow rate suffers from similar trend. Less variation is seen in the conservative form as compared with non conservative form.
4. Comparison of Normalized mass flow rate distributions of both forms
Above plot represents the magnified view of steady form of both conservative as well as non conservative form of governing equations. It can be seen that there is less variation in conservative form as compared to the non conservative form.
Comparision of Steady state results, between conservation and Non Conservation form with Changing Grid Size
No. of Grid Point | non dim ρ | non dim T | non dim P | M | |
Exact Solution | 0.634 | 0.833 | 0.528 | 1.0 | |
Non Conservation form | 31 | 0.6387 | 0.8365 | 0.5342 | 0.9994 |
Conservation Form | 31 | 0.6507 | 0.8401 | 0.5466 | 0.9812 |
Conservation | 61 | 0.6386 | 0.8353 | 0.5334 | 1.0001 |
Also Change in percentage change in values of parameters between no. of grid point 31 and 61 is too low.
for Non Dimensional Density its 1.8516%
for Mach No. its 1.2278%
for Non Dimensional pressure its 2.2039%
for Non Dimensional Temprature its 1.4340%
With this much less variation when grid size is almost doubled, we can say that we have achieved grid independence.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Senstivity Analysis - GRI Mechanism
Introduction: Sensitivity analysis given an overview of magnitude of variation of an independent variable over dependent variable. It is the study that helps in investigation of factors that has the potential to alter the given outcome. Since our study is focussed on the chemical reactions, the reactants and their initial…
04 Jul 2022 02:31 PM IST
FULL HYDRO case set up (PFI)
Objective:- Simulate PFI - engine in Converge CFD Geometry The prepared geometry from the previous section has been used in the present simulation. Simulation Type of Simulation Crank angle-based IC engine simulation The given parameters were, RPM of 3000 Connecting rod of length 0.18m Stroke of length 0.09m…
04 Jul 2022 02:25 PM IST
Simulation of Flat Plate Heat Sink
Detailed Objectives and Motivation Flat plate heats sinks are most common cooling solution for low to medium heat dissipating electronic equipment. Its ease in manufacturing attracts diverse range of material selection with required thermal properties. Selection of material is not the only part and parcel in manufacturing…
04 Jul 2022 02:24 PM IST
Simulation of Flow over a Cylinder and Explaining the phenomenon of Karman Vortex Street
Project Report - Flow over a Cylinder Introduction Flow past object, has been a topic of interest since long time. The phenomenon is very common in engineering designs. The complex nature of physics and behaviour of transport phenomenon around the object is still being actively studied. The nature of flow changes at critical…
04 Jul 2022 01:49 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.