import math
#Given
R = 848.0;#gas consmath.tant in m Kgf/Kgmole K
M = 29.0;#molecular weight of air
g = 9.81;
T1 = 90+273.0;#initial temperature in K
y = 1.4;#gamma = Cp/Cv
W = 800/3600.0;#Mass rate of air in Kg/sec
P1 = 3.5;#initial pressure in atm
d = 2.5;#diameter of the pipe in cm
#To find out the pressure at the final point
v1 = (R*T1)/(M*P1*1.033*10**4);#specific volume in cubic meter/Kg
u1 = (W*v1)/(math.pi*(d**2*(10**-4))/4);#inital velocity in m/sec
#Assume final temperature as
T2 = [300,310];
#Assume specific heat capacity in J/KgK corresponding to the above temperature as
Cp = [2987.56,2983.56];
us = []
u2 = []
for i in range(0,2):
us.append((g*y*R*T2[i]/M)**(1/2));#sonic velocity attained in m/sec
u2.append(((u1**2)-((2*g*Cp[i]/M)*(T2[i]-T1)))**(1/2));#From equation 9.18 & 9.19 (page no 170)
if us[i]-u2[i] <= 1:
u2 = u2[i];
Tnew2 = T2[i];
v2 = u2*(math.pi/4)*(d**2/10**4)*(1/W);
P2 = (P1*v1*Tnew2)/(T1*v2);
print "The pressure at the final point is %f atm"%(P2);
#end
import math
#Given
A1 = 0.002 #inlet area in sq meter
A2 = 0.0005 #throat area in sq meter
P1 = 1.3*10**4 #inlet pressure in Kgf/sq m
P2 = 0.7*10**4 #throat pressure in Kgf/sq m
g = 9.81
v = 12*10**(-4) #specific volume in cubic m /Kg
#To find out the mass rate of alcohol
u2 = ((v*2*g*(P1-P2))/(1-((A2/A1)**2)))**(0.5) #throat velocity in m/sec
W = (u2*A2)/v
print "The mass rate of alcohol is ",
print "%.4f" %W,
print " Kg/sec"
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy
#Given
P1 = 50.0;#initial pressure in Kgf/sq m
T1 = 45+273.0;#initial temperature in K
g = 9.81;
y = 1.35;#gamma
R = 848.0;#gas consmath.tant in m Kgf/Kgmole K
M = 29.0;#molecular weight of air
d = 1.0;#pipe diameter in cm
#(i)To plot velocity,specific volume,mass velocity against P2/P1
#(ii)To calculate the critical pressure,critical mass velocity and mass rate of flow
#(i)Plotting of graph
V1 = (R*T1)/(M*P1*1.033*10**4);#initial volume of the gas in cubic m/Kg
#P3 = P2/P1 (say)
#Assume P3 values as
P3 = [1.0,0.8,0.6,0.4,0.2,0.1,0.05];
G = [0,0,0,0,0,0,0];
u2 = []
v2 = []
G = []
for i in range(0,7):
u2.append((((2*g*y*R*T1)/((y-1)*M))*(1-(P3[i]**((y-1)/y))))**(1/2.0));#final velocity in m/sec
for i in range(0,7):
v2.append(V1/(P3[i]**(1/y)));#final specific volume in cubic meter/Kg
for i in range(0,7):
G.append(u2[i]/v2[i]);#Mass velocity in Kg/sq m sec
plt.plot(P3,u2,"o-")
plt.title("Velocity vs P2/P1")
plt.xlabel("P2/P1")
plt.ylabel("Velocity")
plt.show()
plt.plot(P3,G,"+-")
plt.title("Mass velocity vs P2/P1")
plt.xlabel("P2/P1")
plt.ylabel("Mass Velocity")
plt.show()
P_3 = [1.0,0.8,0.6,0.4,0.2,0.1,0];
plt.plot(P_3,v2,"*-")
plt.title("Sp. volume vs P2/P1")
plt.xlabel("P2/P1")
plt.ylabel("Specific Volume")
plt.show()
#(ii)Calculation of critical pressure,critical mass velocity and mass rate of flow
#From equation 9.37(page no 181)
P2 = P1*(2/(y+1))**(y/(y-1));
print "The critical pressure is %f atm"%(P2);
#From equation a (page no 183)
u2 = (((2*g*y*R*T1)/((y-1)*M))*(1-((P2/P1)**((y-1)/y))))**(1/2.0);
print " The critical velocity is %f m/sec"%(u2);
#From equation b (page no 183)
v2 = ((R*T1)/(M*P1*1.033*10**4))/((P2/P1)**(1.0/y));
print " The critical specific volume is %f cubic meter/Kg"%(v2);
#From relation c (page no 183)
Gnew = float(u2)/v2;
print " The critical mass velocity is %f Kg/sq meter sec"%(Gnew);
W = Gnew*(math.pi/4.0)*(d/(100.0))**2;
print " Mass rate of flow through nozzle is %f Kg/sec"%(W);
#end
import math
#Given
A1 = 0.1;#Inlet area in sq meter
u1 = 60.0;#inlet velocity in m/sec
v1 = 0.185;#inlet specific volume in cubic meter/Kg
H1 = 715.0;#inlet enthalpy in Kcal/Kg
H2 = 660.0;#exit enthalpy in Kcal/Kg
v2 = 0.495;#exit specific volume in cubic meter/Kg
g = 9.81
#To calculate the area at exit of nozzle and hence decide the type of the nozzle
#From the first law
u2 = ((u1**2)-(2*g*(H2-H1)*427))**(1/2);
W = (u1*A1)/v1;#Mass rate of gas in Kg/sec
A2 = (W*v2)/u2;#Area at exit of nozzle
if(A2 < A1):
print "The nozzle is convergent";
else:
print "The nozzle is divergent";
#end