import scipy.integrate
#intialization of variables
T1 = 40+460.0 #temperature(R)
T2 = 340+460.0 #temperature(R)
#calculation
def Cv(T):
cv = 0.162+0.00046*T
return cv
du = scipy.integrate.quadrature(Cv, T1, T2)[0]
#result
print "Change in specific internal energy = %.1f B/lbm" %du
#initialization
cp = 0.24 #B/lbm F
R = 53.3 #ft-lb/lbm F
#calculation
cv = cp-R/778.0
#result
print "Specific heat at constant volume = %.3f B/lbm F" %cv
import scipy.integrate
#initialization
T1 = 1400+460.0 #temperature(R)
T2 = 1200+460.0 #temperature(R)
#calculation
def Cp(T):
cp = 0.317- 1.2*100/T + 4*10**4/T**2
return cp
dh = scipy.integrate.quadrature(Cp, T1, T2)[0]
#result
print "Change in stagnation enthalpy = %.1f B/lbm" %dh
import scipy.integrate
#initialization
T1 = 100+460.0 #temperature(R)
T2 = 300+460.0 #temperature(R)
P1 = 15.0 #pressure(lb/in^2)
P2 = 30.0 #pressure(lb/in^2)
Cp = 0.3 #constant pressure(B/lbm F)
R = 40.0 #gas constant(ft-lb/lbm R)
#calculation
def fun(f):
s=Cp/f
return s
def fun1(f):
s2=R/(f*778)
return s2
ds1 = scipy.integrate.quadrature(fun, T1, T2)[0]
ds2 = scipy.integrate.quadrature(fun1, P1, P2)[0]
ds = ds1 - ds2
#result
print "Change in entropy = %.4f B/lbm R" %ds
#initialization
T1 = 40+460.0 #temperature(R)
T2 = 340+460.0 #temperature(R)
P1 = 15.0 #pressure(lb/in^2)
cp = 0.24
cv = 0.171
#calculation
gamma=cp/cv
P2=P1 *((T2/T1)**(gamma/(gamma-1)))
#result
print "Final pressure = %.1f lb/in^2" %P2
import math
#initialization
P1 = 16.0 #lb/in^2
P2 = 14.0 #lb/in^2
Tt = 83+460.0 #R
gamma = 1.4
cp = 0.24 #B/lbm F
#calculation
T = Tt *(P2/P1)**((gamma-1)/gamma)
dh = cp*(Tt-T)
V = math.sqrt(2*32.2*778*dh)
#result
print "Actual temperature in the flow = %d R" %T
print "Flow velocity = %d ft/sec" %V
#difference in answeres is due to internal rounding off in Python
import math
import scipy.integrate
#initialization
T1 = 400.0+460.0 #R
P1 = 100.0 #lb/in^2
P2 = 20.0 #lb/in^2
T2 = 140.0+460.0 #R
Cp = 50.0
#calculation
Pratio = P1/P2
Tratio = T1/T2
C = math.log(Tratio)/math.log(Pratio)
n=1/(1-C)
v1=Cp*T1/(144*P1)
v2=Cp*T2/(144*P2)
w=144*P1*v1**n
def fun(v):
p=w/v**n
return p
Work = scipy.integrate.quadrature(fun, v1, v2)[0]
#result
print "Work done = %f ft-lb/lbm" %Work
import math
#initialization
P1 = 15.0 #lb/in^2
P2 = 20.0 #lb/in^2
T1 = 40+460 #R
T2 = 540+460 #R
#calculation
#From table 6 at the two temperatures"
phi1 = 0.58233
phi2 = 0.75042
ds = phi2-phi1-53.3*math.log(P2/P1)/778.0
#result
print "Entropy change = %.5f B/lbm R" %ds
#part a
P2 = 1460.0 #pressure 2
P1 = 1900.0 #pressure 1
V2 = 1900.0 #volume 1
V1 = 1460.0 #volume 2
pratio = (P2/P1)**3.5
vratio = (V2/V1)**2.5
print "Pressure ratio is ", round(pratio,2)
print "Volume ratio is ", round(vratio,2)
#part b
#from table 6
Pr2 = 50.34 #pressure 2
Pr1 = 141.51 #pressure 1
Vr2 = 10.743 #volume 1
Vr1 = 4.974 #volume 2
pratio = (Pr2/Pr1)
vratio = (Vr2/Vr1)
print "Pressure ratio is ", round(pratio,2)
print "Volume ratio is ", round(vratio,2)