-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththermoprops.m
50 lines (44 loc) · 1.71 KB
/
thermoprops.m
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
44
45
46
47
48
49
50
function [props]=thermoprops(Td,c1,V,c2)
% Function to find out relevant thermodynamic properties of atmospheric air
% based on either the altitude (z) or freestream pressure (p) and
% temperature (T)
% Inputs: Td: Thermodynamic class object; defined by either z or (p,T)
% c1: Case 'alt' or 'pT'
% z: Atmospheric altitude (m); 0 if unknown
% p: Static pressure (Pa); 0 if unknown
% T: Static temperature (T); 0 if unknown
% V: Freestream velocity class object; defined by either M or Uinf.
% c2: Case 'M' or 'u'
% M: Mach number
% Uinf: Freestream velocity (m/s)
% Outputs: props: Class object containing all relevant thermodynamic
% property static and stagnation values based on equilibrium air.
%--------------------------------------------------------------------------
switch c1
case 'alt'
z = Td.z;
[~,~,T,p,nu,~] = atmos(z);
% Obtain entropy and enthalpy based on equilibrium air
[~,s,rho,e,a,h,~] = gasState(T,0,p,0,0,0);
case 'pT'
p = Td.p;
T = Td.T;
% Obtain entropy and enthalpy based on equilibrium air
[p,s,rho,e,a,h,T] = gasState(T,0,p,0,0,0);
% Obtain dynamic viscosity using Sutherland's law
mu = 1.716e-5*(T/273.15)^(3/2)*(273.15+110.4)/(T+110.4);
nu = mu/rho;
end
switch c2
case 'M'
% Calculate speed
M = V.M;
u = M*a;
case 'u'
u = V.Uinf;
end
% Calculate stagnation enthalpy
h0 = h + u^2/2; % J/kg
% Calculate stagnation properties from s and h0
[p0,~,rho0,e0,a0,h0,T0] = gasState(0,0,0,0,s,h0);
props = thermopropsclass(z,p,p0,T,T0,rho,rho0,h,h0,a,a0,e,e0,s,nu);