In [7]:

```
import math
#Input data
C = 500. #Airplane velocity in m/s
T = 20.+273 #Temperature in K
k = 1.4 #Adiabatic consmath.tant
R = 287 #Specific gas consmath.tant in J/kg-K
#Calculation
a = math.sqrt(k*R*T) #Sound velocity in m/s
M = C/a #Mach number
alp = math.degrees(math.asin((1/M))) #Mach angle in degree
#Output
print 'Mach angle is %3.3f degree'%(alp)
```

In [8]:

```
import math
#Input data
a1 = 2.2 #Area ratio (A/At)
Po = 10 #Stagnation Pressure in bar
#Calculation
#Two values of mach number at a1 from gas tables
M1 = 0.275 #Mach number from gas tables
p1 = 0.949 #Presure ratio (P/Po)
P1 = Po*p1 #back pressure in bar
M2 = 2.295 #Mach number from gas tables
p2 = 0.0806 #Presure ratio (P/Po)
P2 = Po*p2 #back pressure in bar
#Output
print 'A)When M = %3.3f, back pressure is %3.2f bar \
\nB)When M = %3.3f, back pressure is %3.3f bar'%(M1,P1,M2,P2)
```

In [9]:

```
import math
#Input data
M = 0.8 #Mach number
T = 20+273 #Temperature in K
k = 1.4 #Adiabatic consmath.tant
#Calculation
To = T*(1+(((k-1)/2)*M**2)) #Temperature of air at nose of aircraft in K
To1 = To-273 #Temperature of air at nose of aircraft in degree Centigrade
#Output
print 'Temperature of air at nose of aircraft is %3.1f degree Centigrade'%(To1)
```

In [11]:

```
import math
#Input data
P = 1. #Pressure in bar
T = 400. #Temperature in K
C = 400. #Air velocity in m/s
k = 1.4 #Adiabatic consmath.tant
R = 287. #Specific gas consmath.tant in J/kg-K
Cp = 1005. #Specific heat capacity at constnat pressure in J/kg-K
#Calculation
To = T+(C**2/(2*Cp)) #Stagnation Temperature in K
Poi = P+((P*C**2)/(R*T*2)) #Stagnation Pressure (if it is incompressible) in bar
Poc = P*(To/T)**(k/(k-1)) #Stagnation Pressure (if it is compressible) in bar
#Output
print 'Stagnation Temperature is %3.1f K \
\nC)Stagnation Pressure: \
\nIf it is incompressible is %3.4f bar \
\nIf it is compressible is %3.4f bar'%(To,Poi,Poc)
```

In [12]:

```
import math
#Input data
v1 = 8 #Intial volume in litres
P1 = 0.7 #Intial pressure in MPa
v2 = 7.8 #Final volume in litres
P2 = 2.7 #Final pressure in MPa
#Calculation
k = (P2-P1)/(math.log(v1/v2)) #Bulk modulus of elasticity of a liquid in MPa
#Output
print 'Bulk modulus of elasticity of a liquid is %3.3f MPa'%k
```

In [13]:

```
import math
#Input data
To = 15+273 #Air Temperature in K
Cp = 1005 #Specific heat capacity at constnat pressure in J/kg-K
#Calculation
Cmax = math.sqrt(2*Cp*To) #Highest possible velocity in m/s
#Output
print 'Highest possible velocity is %3.2f m/s'%Cmax
```

In [7]:

```
import math
#Input data
M = 0.25 #mach number
D = 0.04 #Diamter in m
f = 0.002 #frictional factor
#Calculation
X = 8.483 #fanno parameter from gas tables at M
Lmax = (X*D)/(4*f) #Lenggth of the pipe in m
#Output
print 'Length of the pipe is %3.3f m'%Lmax
```

In [14]:

```
import math
#Input data
M = 3. #mach number
D = 0.04 #Diamter in m
f = 0.002 #frictional factor
#Calculation
X = 0.522 #fanno parameter from gas tables at M
L = (X*D)/(4*f) #Lenggth of the pipe in m
#Output
print 'Lenggth of the pipe is %3.2f m'%L
```

In [15]:

```
import math
#Input data
M = 0.2 #Mach number
To = 120.+273 #Stagnation Temperature in K
Cp = 1005. #Specific heat capacity at constnat pressure in J/kg-K
#Calculation
t1 = 0.174 #Temperature ratio (To/Tot) from Rayleigh gas tables
Tot = To/t1 #Critical stagnation temperature in K
q = Cp*(Tot-To)*10**-3 #Maximum amount of heat transfer in kJ/kg
#Output
print 'Maximum amount of heat transfer is %3.2f kJ/kg'%q
```

In [16]:

```
import math
#Input data
p1 = 0.75 #Pressure ratio (Po2/Po1) Since Stagnation pressure drop is 25%
Cp = 1150. #Specific heat capacity at constnat pressure in J/kg-K
k = 1.33 #Adiabatic consmath.tant
#Calculation
ds = ((k-1)/k)*Cp*math.log(1/p1) #Increase in entropy in J/kg-K
#Output
print 'Increase in entropy is %3.2f J/kg-K'%ds
```

In [17]:

```
import math
#Input data
Mi = 2.2 #Inlet Mach number
T = 100.+273 #Temperature in K
Cp = 1005. #Specific heat capacity at constnat pressure in J/kg-K
#Calculation
t1 = 0.508 #Temperature ratio (To/Tot) from isentropic gas tables @Mi
To = T/t1 #Stagnation Temperature in K
t2 = 0.756 #Temperature ratio (To/Tot) from Rayleigh gas tables @Mi
Tot = To/t2 #Critical stagnation temperature in K
q = Cp*(Tot-To)*10**-3 #Maximum amount of heat transfer in kJ/kg
#Output
print 'Maximum amount of heat transfer is %3.4f kJ/kg'%q
```

In [18]:

```
import math
#Input data
Mx = 1.5 #Mach number
P = 40. #Static pressure in kPa
#Calculation
p1 = 3.413 #Pressure ratio in (Poy/Px) from normal shock gas tables @Mx
Poy = p1*P #Pressure acting on front of the body in kPa
#Output
print 'Pressure acting on front of the body is %3.1f kPa'%Poy
```

In [19]:

```
import math
#Input data
M = 2. #Mach number at shock
#Calculation
p1 = 4.5 #Pressure ratio (Py/Px) from normal shock gas tables @M
e = p1-1 #Strength of shock wave
#Output
print 'Strength of shock wave is %3.1f'%e
```

In [20]:

```
import math
#Input data
Mx = 7 #mach number upstream of shock
P = 2 #pressure @Mx in bar
T = 57+273 #Temperature @Mx in K
R = 287 #Specific gas consmath.tant in J/kg-K
#Calculation
p1 = 0.72 #Pressure ratio (Poy/Pox) from normal shock gas tables @Mx
ds = R*math.log(1/p1) #Irreversibility in J/kg-K
#Output
print 'Irreversibility is %3.2f J/kg-K'%ds
```

In [21]:

```
import math
#Input data
Px = 45. #Static pressure in kPa
T = -20.+273 #Static temperature in K
Poy = 395. #Stagnation pressure in kPa
k = 1.4 #Adiabatic consmath.tant
R = 287 #Specific gas consmath.tant in J/kg-K
#Calculation
p1 = Poy/Px #Pressure ratio
Mx = 2.536 #Mach number from normal shock gas tables @p1
Cx = Mx*math.sqrt(k*R*T) #Air velocity in m/s
#Output
print 'Mach number is %3.3f \
\nAir velocity is %.f m/s'%(Mx,Cx)
```

In [22]:

```
import math
#Input data
Cx = 750. #velocity upstream of shock in m/s
Px = 1. #Pressure upstream of shock in bar
Tx = 10.+273 #Temperature upstream of shock in K
k = 1.4 #Adiabatic consmath.tant
R = 287. #Specific gas consmath.tant in J/kg-K
#Calculation
Mx = Cx/math.sqrt(k*R*Tx) #Mach number upstream of shock
My = 0.545 #Mach number downstream of shock from normal shock gas tables, Mistake in textbook
t1 = 1.875 #Temperature ratio (Ty/Tx)
Ty = Tx*t1 #Static temperature downstream of shock in K
p1 = 5.583 #Pressure ratio (Py/Px)
Py = Px*p1 #Static pressure downstream of shock in bar
Cy = My*math.sqrt(k*R*Ty) #velocity downstream of shock in m/s
#Output
print 'Downstream of shock: Velocity is %3.3f m/s Pressure is %3.3f bar Temperature is %3.3f K'%(Cy,Py,Ty)
```

In [23]:

```
import math
#Calculation
#Differentiating P = m*(Cj-u)*u and equating it to zero we get jet speed ratio as 0.5
sig = 0.5 #Jet speed ratio
eff_max = ((2*sig)/(1+sig)) #Propulsive efficiency for optimum thrust power, wrong notation in textbook.
#Output
print 'Propulsive efficiency for optimum thrust power is %3.3f'%(eff_max)
```

In [24]:

```
import math
#Input data
u = 1200*(5./18) #Flight velocity in m/s
Cj = 800. #Effective jet velocity in m/s
#Calculation
sig = u/Cj #jet speed ratio
eff = ((2*sig)/(1+sig))*100 #Propulsive efficiency in %
#Output
print 'Propulsive efficiency is %3.1f percent'%eff
```

In [25]:

```
import math
#Input data
m = 5. #Propellent rate in kg/s
Pamb = 1.013 #Ambient pressure in bar
Pe = 1.02 #Nozzle exit pressure in bar
D = 0.1 #Nozzle exit diameter in m
Ce = 1400. #Exit jet velocity in m/s
#Calculation
Ae = math.pi*D**2/4 #Exit area in m**2
F = (m*Ce)+((Pe-Pamb)*Ae) #Thrust in N
#Output
print 'Thrust is %3i N'%F
```

In [26]:

```
import math
#Input data
Is = 230. #Specific Impulse in sec
m = 1. #Propellent flow in kg/s
g = 9.81 #Acceleration due to gravity in m/s**2
#Calculation
F = m*Is*g #Thrust in N
#Output
print 'Thrust is %3.1f N'%F
```

In [27]:

```
import math
#Input data
u = 1500. #Flight velocity in m/s
eff = 0.75 #Propulsive efficiency
#Calculation
#Converting relation eff = (2*sig)/(1+sig**2) into 2nd degree polynomial of sig
sig = ((2-(math.sqrt(4-(4*eff*eff))))/(2*eff)) #Jet speed ratio
Cj = u/sig #Jet velocity in m/s
#Output
print 'Jet velocity is %3.2f m/s'%Cj
```

In [3]:

```
import math
#Input data
Cj = 2700. #Jet velocity in m/s
u = 1350. #Flight velocity in m/s
m = 78.6 #Propellent flow in kg/s
#Calculation
F = m*Cj*10**-3 #Thrust in kN
P = F*u*10**-3 #Thrust power in MW
sig = u/Cj #Jet speed ratio
eff = ((2*sig)/(1+sig**2))*100 #Propulsive efficiency in %
#Output
print 'Thrust is %3.1f kN \
\nThrust power is %3.2f MW \
\nPropulsive efficiency is %3i percent'%(F,P,eff)
```

In [2]:

```
import math
#Input data
D = 12683.*1000 #Diameter of Earth in m
g = 9.81 #Acceleration due to gravity in m/s
h = 500.*1000 #Altitude in m
#Calculation
Uorb = (D/2)*math.sqrt(g/((D/2)+h)) #Orbital velocity in m/s
Uesc = math.sqrt(2)*Uorb #Escape velocity in m/s
#Output
print 'Orbital velocity is %3.2f m/s \
\nEscape velocity is %3.2f m/s'%(Uorb,Uesc)
```

In [1]:

```
import math
#Input data
u = 10080*(5./18) #Flight velocity in m/s
Cj = 1400. #Jet velocity in m/s
m = 5. #Propellent flow in kg/s
#Calculation
F = m*Cj*10**-3 #Thrust in kN
P = F*u*10**-3 #Thrust power in MW
sig = u/Cj #Jet speed ratio
eff = ((2*sig)/(1+sig**2)) #Propulsive efficiency
#Output
print 'Propulsive power is %3.1f MW \
\nPropulsive efficiency is %3.1f'%(P,eff)
```