In [5]:

```
#ques1
#to determine isentropic stagnation pressure and temperature
T=300;#Temperature of air in K
P=150;#Pressure of air in kPa
v=200;#velocity of air flow n m/s
Cp=1.004;#specific heat at constant pressure in kJ/kg
To=v**2/(2000*Cp)+T;#stagnation temperature in K
k=1.4;#constant
Po=P*(To/T)**(k/(k-1));#stagnation pressure in kPa
print 'Stagnation Temperature is ',round(To,1),' K \n'
print 'Stagnation Pressure is ',round(Po,2),'kPa \n'
```

In [6]:

```
#ques2
#to determine the force
#initializing variables
mdot=-1 # mass flow rate out of control volume in kg/s
Vx=-1 # x component of velocity of control volume in m/s
Vy=10 # y component of velocity of control volume in m/s
Fx=mdot*Vx # Force in X direction
Fy=mdot*Vy # Force in Y direction
print "the force the man exert on the wheelbarrow",round(Fx),"N"
print "the force the floor exerts on the wheelbarrow",round(Fy),"N"
```

In [11]:

```
#ques3
#determining the thrust acting on a control surface
#i-inlet
#e-exit
#using momentum equation on control surface in x direction
me=20.4;#mass exiting in kg
mi=20;#mass entering in kg
ve=450;#exit velocity in m/s
vi=100;#inlet velocity in m/s
Pi=95;#Pressure at inlet in kPa
Pe=125;#Pressure at exit in kPa
Po=100;#surrounding pressure in kPa
Ai=0.2;#inlet area in m^2
Ae=0.1;#exit area in m^2
Rx=(me*ve-mi*vi)/1000-(Pi-Po)*Ai+(Pe-Po)*Ae;#thrust in x direction in kN
print "Thrust acting in x direction is ",round(Rx,2),"kN"
```

In [19]:

```
#ques4
#to determine increase in enthalpy
#initializing variables
#i-inlet
#e-exit
T=25+273 # temperature in kelvin
v=0.001003 # specific volume of water in kg/m^3 at 25 *c from table B.1.1
ve=7;#exit velocity in m/s
vi=30;#inlet velocity in m/s
Pi=350;#Pressure at inlet in kPa
Pe=600;#Pressure at exit in kPa
#using momentum equation on control surface
Pes= (vi**2-ve**2)/(2*v*1000)+Pi # exit pressure for reversible diffuser
delH=(vi**2-ve**2)/(2*1000.0) # change in enthalpy from first law in kJ/kg
delU=delH-v*(Pe-Pi) # change in internal energy in kJ/kg
delS=delU/T # change in entropy in kJ/kg.K
print"the exit pressure for reversible diffuser is ",round(Pes),"kPa"
print"the increase in enthalpy is ",round(delH,5),"kJ/kg"
print"the increase in internal energy is ",round(delU,5),"kJ/kg"
print"the increase in entropy is ",round(delS,6),"kJ/kg.K"
```

In [24]:

```
#ques5
#determining velocity of sound in air
import math
k=1.4;#constant
R=0.287;#gas constant
#at 300K
T1=300;# temperature in kelvin
c1=math.sqrt(k*R*T1*1000)
print "Speed of sound at 300 K is",round(c1,1)," m/s"
#at 1000K
T2=1000;# temperature in kelvin
c2=math.sqrt(k*R*T2*1000)
print "Speed of sound at 1000 K is",round(c2,1)," m/s"
```

In [30]:

```
#ques6
#determining mass flow rate through control volume
import math
k=1.4;#constant
R=0.287;#gas constant
To=360;#stagnation Temperature in K
T=To*0.8333;#Temperature of air in K, 0.8333 stagnation ratio from table
v=math.sqrt(k*R*T*1000);#velocity in m/s
P=528;#stagnation pressure in kPa
d=P/(R*T);#stagnation density in kg/m^3
A=500*10**-6;#area in m^2
ms=d*A*v;#mass flow rate in kg/s
print" Mass flow rate at the throat section is",round(ms,4),"kg/s"
#e-exit state
Te=To*0.9381;#exit temperature in K, ratio from table
ce=math.sqrt(k*R*Te*1000);#exit velocity of sound in m/s
Me=0.573;#Mach number
ve=Me*ce;
Pe=800;#exit pressure in kPa
de=Pe/R/Te;
mse=de*A*ve;
print" Mass flow rate at the exit section is",round(mse,4)," kg/s"
```

In [39]:

```
#ques7
#determining exit properties in a control volume
import math
Po=1000;#stagnation pressure in kPa
To=360;#stagnation temperature in K
#when diverging section acting as nozzle
Pe1=0.0939*Po;#exit pressure of air in kPa
Te1=0.5089*To;#exit temperature in K
k=1.4;#constant
R=0.287;#gas constant for air
ce=math.sqrt(k*R*Te1*1000);#velocity of sound in exit section in m/s
Me=2.197;#mach number from table
ve1=Me*ce;#velocity of air at exit section in m/s
print "When diverging section act as a nozzle :-"
print "Exit pressure is",round(Pe1,4)," kPa"
print "Exit Temperature",round(Te1,1)," K"
print "Exit velocity is",round(ve1,1)," m/s "
#when diverging section act as diffuser
Me=0.308;
Pe2=0.0936*Po;#exit pressure of air in kPa
Te2=0.9812*To;#exit temperature in K
ce=math.sqrt(k*R*Te2*1000);#velocity of sound in exit section in m/s
ve2=Me*ce;
print "When diverging section act as a diffuser :-"
print "Exit pressure is",round(Pe2,1)," kPa"
print "Exit Temperature",round(Te2,2)," K"
print "Exit velocity is",round(ve2,)," m/s "
# The value of Exit pressure when diverging section acts as diffuser is wrong
```

In [2]:

```
#ques8
#Determine the static pressure and temperature of supersonic nozzle
#x-inlet
#y-exit
# using the data from previous example
Mx=2.197 # Mach number at x
Px=93.9 # IN kPa
Tx=183.2 # IN K
P0x=1000 # IN kPa
T0x = 360 # in K
My=0.547 # Mach number at y From Table A.13
Py = 5.46*Px # From Table A.13
Ty = 1.854 * Tx # From Table A.13
P0y= 0.630 * P0x # From Table A.13
print "Exit pressure after shock is",round(Py,1)," kPa"
print "Exit Temperature after shock is",round(Ty,1)," K"
print "Exit stagnation pressure after shock is",round(P0y,1)," kPa"
```

In [50]:

```
#ques9
#determining exit plane properties in control volume
#x-inlet
#y-exit
Mx=1.5;#mach number for inlet
My=0.7011;#mach number for exit
Px=272.4;#inlet pressure in kPa
Tx=248.3;#inlet temperature in K
Tox=360 # stagnation temperature in Kelvin
Pox=1000.0;#stagnation pressure for inlet
Py=2.4583*Px;# Pressure at 1.5 mach in kPa
Ty=1.320*Tx;# temperature at 1.5 mach in K
Poy=0.9298*Pox;# pressure at 1.5 mach in kPa
Toy=Tox # constant
Me=0.339 # from table with A/A*=1.860 and M < 1
Pe=0.9222*Py;#Exit Pressure in kPa
Te=0.9771*Toy;#Exit temperature in K
Poe=0.9222*Poy;#Exit pressure in kPa
print "Exit Mach no.=",Me
print "Exit temperature =",round(Te,2),"K "
print "Exit pressure =",round(Poe,1),"kPa"
```