-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiffuser.m
More file actions
43 lines (35 loc) · 1.29 KB
/
Copy pathdiffuser.m
File metadata and controls
43 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
% This is for subsonic flow and we are expanding the flow!
% Things to take care of!
% 1. What is unstart!
function [x,A2,M_req,P3,T3] = diffuser(M_in, T_in, P_in,A_in,T_inf,M_inf,M_req)
disp("Calculating Properties Across Diffuser ...")
% Defininng initial properties!
gaama = 1.4;
M2 = M_in;
% Finding stagnation values at the inlet.
T_0 = T_in*(1 + .5*(gaama-1)*M_in^2);
P_0 = P_in*(1 + .5*(gaama-1)*M_in^2)^(gaama/(gaama-1));
% Defining arrays to store future state properties.
A2 = [A_in];
T3 = [];
P3 = [];
if imag(M_req) ~= 0
disp("...ERROR! DIFFUSER ERROR. CAN'T ATTAIN THE REQUIRED TEMPERATURE!")
end
M_out = [];
if M2 <= M_req
disp("ERROR: DIFFUSER CANT INCREASE FLOW SPEED!!");
else
while M2 >= M_req % This NEEDS TO BE FIXED!
M_out = [M_out,M2];
M2 = M2 - .0005;
area_ratio = (M2/M_in)*((1+.5*(gaama-1)*M_in^2)/(1+.5*(gaama-1)*M2^2))^((gaama+1)/(2*(gaama-1)));
A2 = [A2,A_in/area_ratio];
T3 = [T3,T_0/(1+.5*(gaama-1)*M2^2)];
P3 = [P3,P_0/((1+.5*(gaama-1)*M2^2)^(gaama/(gaama-1)))];
end
end
x = linspace(0,6*(A2(end)-A2(1)),length(A2));
x = [x,x];
A2 = [A2,-A2];
end