In [1]:

```
# All the quantities are expressed in SI units
from math import sqrt,pi
R = 287.;
gam = 1.4;
V_inf = 250.;
# (a)
# At sea level
T_inf = 288.;
# the velocity of sound is given by
a_inf = sqrt(gam*R*T_inf);
# thus the mach number can be calculated as
M_inf = V_inf/a_inf;
print"(a)The Mach number at sea level is:M_inf =",M_inf
# similarly for (b) and (c)
# (b)
# at 5km
T_inf = 255.7;
a_inf = sqrt(gam*R*T_inf);
M_inf = V_inf/a_inf;
print"(b)The Mach number at 5 km is: M_inf = ",M_inf
# (c)
# at 10km
T_inf = 223.3;
a_inf = sqrt(gam*R*T_inf);
M_inf = V_inf/a_inf;
print"(c)The Mach number at 10 km is: M_inf =",M_inf
```

In [2]:

```
# All the quantities are expressed in SI units
import math
T = 320; # static temperature
V = 1000; # velocity
gam = 1.4; # ratio of specific heats
R = 287; # universal gas constant
# the speed of sound is given by
a = math.sqrt(gam*R*T);
# the mach number can be calculated as
M = V/a;
print"The Mach number is:\nM =",M
```

In [3]:

```
# All the quantities are expressed in SI units
gam = 1.4; # ratio of specific heats
# (a)
M = 2; # Mach number
# the ratio of kinetic energy to internal energy is given by
ratio = gam*(gam-1)*M*M/2;
print"(a)The ratio of kinetic energy to internal energy is:",ratio
# similarly for (b)
# (b)
M = 20;
ratio = gam*(gam-1)*M*M/2;
print"\n(b)The ratio of kinetic energy to internal energy is:",ratio
```

In [4]:

```
# All the quantities are expressed in SI units
M = 2.79; # Mach number
T = 320; # static temperature from ex. 7.3
p = 1; # static pressure in atm
gam = 1.4;
# from eq. (8.40)
T0 = T*(1+((gam-1)/2*M*M));
# from eq. (8.42)
p0 = p*((1+((gam-1)/2*M*M))**(gam/(gam-1)));
print"The total temperature and pressure are:\nT0 =",T0,"K","\nP0 =",p0,"atm"
```

In [5]:

```
# All the quantities are expressed in SI units
import math
M = 3.5; # Mach number
T = 180; # static temperature from ex. 7.3
p = 0.3; # static pressure in atm
gam = 1.4;
R = 287;
# from eq. (8.40)
T0 = T*(1+((gam-1)/2*M*M));
# from eq. (8.42)
p0 = p*((1+((gam-1)/2*M*M))**(gam/(gam-1)));
a = math.sqrt(gam*R*T);
V = a*M;
# the values at local sonic point are given by
T_star = T0*2/(gam+1);
a_star = math.sqrt(gam*R*T_star);
M_star = V/a_star;
print"T0 =",T0,"K","\nP0 =",p0,"atm","\nT* =",T_star,"k","\na* =",a_star,"m/s","\nM* =",M_star
```

In [6]:

```
# All the quantities are expressed in SI units
p_inf = 1;
p1 = 0.7545;
M_inf = 0.6;
gam = 1.4;
# from eq. (8.42)
p0_inf = p_inf*((1+((gam-1)/2*M_inf*M_inf))**(gam/(gam-1)));
p0_1 = p0_inf;
# from eq. (8.42)
ratio = p0_1/p1;
# from appendix A, for this ratio, the Mach number is
M1 = 0.9;
print"The mach number at the given point is:\nM1 =",M1
```

In [7]:

```
# All the quantities are expressed in SI units
import math
T_inf = 288; # freestream temperature
p_inf = 1; # freestream pressure
p1 = 0.7545; # pressure at point 1
M = 0.9; # mach number at point 1
gam = 1.4; # ratio of specific heats
R=1.;#
# for isentropic flow, from eq. (7.32)
T1 = T_inf*((p1/p_inf)**((gam-1)/gam));
# the speed of sound at that point is thus
a1 = math.sqrt(gam*R*T1);
# thus, the velocity can be given as
V1 = M*a1;
print"The velocity at the given point is:\nV1 =",V1,"m/s"
```

In [8]:

```
# All the quantities are expressed in SI units
import math
u1 = 680; # velocity upstream of shock
T1 = 288; # temperature upstream of shock
p1 = 1; # pressure upstream of shock
gam = 1.4; # ratio of specific heats
R = 287; # universal gas constant
# the speed of sound is given by
a1 = math.sqrt(gam*R*T1)
# thus the mach number is
M1 = 2;
# from Appendix B, for M = 2, the relations between pressure and temperature are given by
pressure_ratio = 4.5; # ratio of pressure accross shock
temperature_ratio = 1.687; # ratio of temperature accross shock
M2 = 0.5774; # mach number downstream of shock
# thus the values downstream of the shock can be calculated as
p2 = pressure_ratio*p1;
T2 = temperature_ratio*T1;
a2 = math.sqrt(gam*R*T2);
u2 = M2*a2;
print"p2 =",p2,"atm","\nT2 =",T2,"K","\nu2 =",u2,"m/s"
```

In [9]:

```
# All the quantities are expressed in SI units
p1 = 1; # ambient pressure upstream of shock
# (a)
# for M = 2;
p0_1 = 7.824*p1; # total pressure upstream of shock
pressure_ratio = 0.7209; # ratio of total pressure accross the shock
p0_2 = pressure_ratio*p0_1; # total pressure downstream of shock
# thus the total loss of pressure is given by
pressure_loss = p0_1 - p0_2;
print"The total pressure loss is:\n(a)P0_loss=",pressure_loss,"atm"
# similarly
# (b)
# for M = 4;
p0_1 = 151.8*p1;
pressure_ratio = 0.1388;
p0_2 = pressure_ratio*p0_1;
# thus the total loss of pressure is given by
pressure_loss = p0_1 - p0_2;
print"\n(b)P0_loss =",pressure_loss,"atm"
```

In [10]:

```
# All the quantities are expressed in SI units
M_inf = 2.; # freestream mach number
p_inf = 2.65e4; # freestream pressure
T_inf = 223.3; # freestream temperature
# from Appendix A, for M = 2
p0_inf = 7.824*p_inf; # freestream total pressure
T0_inf = 1.8*T_inf; # freestream total temperature
# from Appendix B, for M = 2
p0_1 = 0.7209*p0_inf; # total pressure downstream of the shock
T0_1 = T0_inf; # total temperature accross the shock is conserved
# since the flow downstream of the shock is isentropic
p0_2 = p0_1;
T0_2 = T0_1;
# from Appendix A, for M = 0.2 at point 2
p2 = p0_2/1.028;
T2 = T0_2/1.008;
p2_atm = p2/102000;
print"The pressure at point 2 is:p2 =",p2_atm,"atm",
```

In [11]:

```
# All the quantities are expressed in SI units
M_inf = 10; # freestream mach number
p_inf = 2.65e4; # freestream pressure
T_inf = 223.3; # freestream temperature
# from Appendix A, for M = 2
p0_inf = 0.4244e5*p_inf; # freestream total pressure
T0_inf = 21*T_inf; # freestream total temperature
# from Appendix B, for M = 2
p0_1 = 0.003045*p0_inf; # total pressure downstream of shock
T0_1 = T0_inf; # total temperature downstream of shock is conserved
# since the flow downstream of the shock is isentropic
p0_2 = p0_1;
T0_2 = T0_1;
# from Appendix A, for M = 0.2 at point 2
p2 = p0_2/1.028;
T2 = T0_2/1.008;
p2_atm = p2/102000;
print"The pressure at point 2 is: p2 =",p2_atm,"atm"
```

In [11]:

```
# All the quantities are expressed in SI units
p1 = 4.66e4; # ambient pressure
M = 8; # mach number
# from Appendix B, for M = 8
p0_2 = 82.87*p1; # total pressure downstream of the shock
# since the flow is isentropic downstream of the shock, total pressure is conserved
ps_atm = p0_2/101300; # pressure at the stagnation point
print"The pressure at the nose is:\np_s =",ps_atm,"atm"
```

In [12]:

```
# All the quantities are expressedin SI units
import math
p1 = 2527.3; # ambient pressure at the altitude of 25 km
T1 = 216.66; # ambient temperature at the altitude of 25 km
p0_1 = 38800; # total pressure
gam = 1.4; # ratio of specific heats
R = 287; # universal gas constant
pressure_ratio = p0_1/p1; # ratio of total to static pressure
# for this value of pressure ratio, mach number is
M1 = 3.4;
# the speed of sound is given by
a1 = math.sqrt(gam*R*T1)
# thus the velocity can be calculated as
V1 = M1*a1;
print"The Velocity of the airplane is:\nV1 =",V1,"m/s"
```