涡喷发动机建模中的gastab函数代码
时间: 2023-12-11 15:05:33 浏览: 135
涡喷发动机建模中的gastab函数代码如下:
```python
def gastab(mach, alt):
"""
Computes the gas properties for air as a function of altitude and Mach number.
Parameters:
-----------
mach : float
Mach number
alt : float
Altitude (m)
Returns:
--------
gamma : float
Specific heat ratio
R : float
Gas constant (J/kg-K)
T : float
Temperature (K)
p : float
Pressure (Pa)
rho : float
Density (kg/m^3)
sos : float
Speed of sound (m/s)
"""
# Gas constants
R0 = 287.05287 # J/kg-K
g0 = 9.80665 # m/s^2
gamma0 = 1.4
# Temperature and pressure ratios
T0 = 288.15 # K
p0 = 101325 # Pa
beta = 1 - 6.87535e-6*alt
T = T0*beta
p = p0*(beta**(g0/(R0*288.15)))
rho = p/(R0*T)
sos = np.sqrt(gamma0*R0*T)
# Compute specific heat ratio and gas constant
if mach < 1:
gamma = gamma0
R = R0
else:
gamma = gamma0*(1.0 - 0.5*(gamma0 - 1.0)*(mach**2 - 1.0)/(gamma0 + 1.0))
R = R0/(1.0 + 0.5*(gamma0 - 1.0)*(mach**2 - 1.0)/(gamma0 + 1.0))
return gamma, R, T, p, rho, sos
```
这个函数的作用是计算空气的气体属性,包括比热比、气体常数、温度、压力、密度和声速。它的输入参数为马赫数和海拔高度,输出为上述气体属性。
阅读全文