#Initialization of variables
T2 = 30. #C
T1 = 20. #C
cv = 716.
m = 15. #kg
cp = 1003.
#calculations
di = cv*(T2-T1)
dU = di*m
dh = cp*(T2-T1)
dH = dh*m
#Results
print "Change in Internal energy = %d N m"%(dU)
print " Change in Enthalpy = %d Nm"%(round(dH,-3))
#Initialization of variables
cv = 716.
m = 15. #kg
cp = 1003.
T1 = 20.+273 #K
k = 1.4
ratio = 0.4
#calculations
T2 = int((T1)*(1/ratio)**(k-1))
P1 = 95. #kN/m**2
P2 = int(P1*T2/(T1)/ratio)
di = round(cv*(T2-T1),-2)
dU = di*m
dh = round(cp*(T2-T1),-2)
dH = dh*m
#Results
print "Final temperature = %d K"%(T2)
print " Final pressure = %d kN/m**2"%(P2)
print " Change in Internal energy = %d N m"%(dU)
print " Change in Enthalpy = %d Nm"%(dH)
#The answers are a bit different due to rounding off error.please check.
import math
#Initialization of variables
k = 1.4
R = 1773.
v = 600. #fps
T = 660. #K
P = 100. #psia
cp = 6210.
g = 32.2
#calculations
c = math.sqrt(k*R*T)
M = v/c
rho = k*P*144/c**2
Ps = P*144 + 0.5*(rho)*v**2 *(1+ 0.25*M**2)
Ts = (cp/g *T + v**2 /(2*g))*g/cp
#Results
print "Stagnation pressure = %d lb/ft**2"%(Ps)
print " Stagnation temperature = %.f R"%(Ts)
# note :Please check the units of the answer.
import math
#Initialization of variables
g = 32.2
A = 0.0218 #ft**2
P1 = 25.6 #psia
T1 = 540. #K
k = 1.4
R = 1715.
#calculations
G = g*A*P1*144/math.sqrt(T1) *math.sqrt(k/R *(2/(k+1))**((k+1)/(k-1)))
#Results
print "Flow rate = %.2f lb/s"%(G)
import math
#Initialization of variables
P1 = 50. #psia
T1 = 540. #K
g = 32.2
R = 1715.
k = 1.4
P3 = 13.5 #psia
A2 = 0.0218 #ft**2
cp = 6000.
#calculations
Pc = 0.528*P1
V32 = round(R*T1/g *k/(k-1) *(1- (P3/P1)**((k-1)/k)),-2)
V3 = round(math.sqrt(V32*2*g),-1)
G3 = g*A2*P1*144/math.sqrt(T1) *math.sqrt(k/R *(2/(k+1))**((k+1)/(k-1)))
T3 = T1 - V3**2 /(2*cp)
gam3 = g*P3*144/(R*T3)
gam2 = (Pc/P3 *gam3**k )**(1/k)
V2 = G3/gam2/A2
T2 = (V3**2 -V2**2)/(2*cp) + T3
A3 = G3/gam3/V3
D3 = math.sqrt(4/math.pi *A3)
G2 = G3
#Results
print " velocity at section 3 = %d fps"%(V3)
print " Flow rate at section 3 = %.3f lb/s"%(G3)
print " temperature at section 3 = %d R"%(T3)
print " velocity at section 2 = %d fps"%(V2)
print " Flow rate at section 2 = %.3f lb/s"%(G2)
print " temperature at section 2 = %d R"%(T2)
print " Required Diameter = %.2f in"%(D3*12)
# book anwers are wrong. please check.
#Initialization of variables
P1 = 10. #psia
T1 = 460+40. #R
R = 1715.
k = 1.4
V1 = 1400. #fps
#calculations
rho1 = P1/(R*T1)
c1 = math.sqrt(k*R*T1)
M1 = V1/c1
P2 = P1 * (2*k*M1**2 - (k-1))/(k+1)
V2 = V1*((k-1)*M1**2 +2)/((k+1)*M1**2)
rho2 = rho1*V1/V2
T2 = P2/rho2/R
P22 = 122.5
V22 = 286
T22 = 328
#Results
print "Pressure at point 2 = %.1f psia and %.1f N/m**2"%(P2,P22)
print " Velocity at point 2 = %d fps and %d m/s"%(V2,V22)
print " Temperature at point 2 = %d R and %d K"%(T2,T22)
print ("Similarly it can be done for SI units")
# note : ronding off error. please check.
import math
#Initialization of variables
A = 140. #in**2
P = 48. #lb/in**2
mu = 3.78*10**-7
g = 32.2
G = 100. #lb/s
p = 80. #lb/in**2
T = 65.+460 #R
k = 1.4
R = 1715.
#calculations
Rh = A/P /12
R1 = G*4*Rh/ (mu*g*A/144)
R2 = R1
f = 0.0083
gam1 = p*g*144/(R*T)
V1 = G*144/gam1/A
c = math.sqrt(k*R*T)
M1 = V1/c
M2 = 1/math.sqrt(k)
D = 4*Rh
L = ((1-M1**2 /M2**2)/(k*M1**2) - 2*math.log(M2/M1) )*D/f
Ln = 500 #ft
P2 = math.sqrt((p*144)**2 - G**2 *R*T/(g**2 *(A/144)**2 *f*Ln/D))
Pa = 12.2
#Results
print "Max. length = %d ft"%(round(L,-1))
print " Pressure required = %.1f psia"%(P2/144 -Pa)
import math
#Initialization of variables
G = 100. #lb/s
g = 32.2
V2 = 300. #fps
V1 = 250. #fps
#calculations
Qh = (V2**2 -V1**2)/(2*g)
Q = Qh*G
#Results
print "Thermal energy added = %.2f ft lb/s"%(Q)
#Initialization of variables
gam1 = 0.41
g = 32.2
V1 = 250. #fps
R1 = 8.2*10**6
f = 0.0083
A = 0.97 #ft**2
G = 100. #lb/s
k = 1.4
P = 80. #pressure - psia
ratio = 0.8
R = 1715
#calculations
rho1 = gam1/g
X = G**2 /(gam1*A)**2 + 2*k/(k-1) *(P*144/rho1)
P2 = (k-1)/2/k *(X*ratio*rho1 - G**2 /(g**2 *A**2 *ratio*rho1))
L = 563 #ft
rho2 = ratio*rho1
V2 = G/(rho2*g*A)
T2 = P2/(rho2*R)
#Results
print "Length = %d ft"%(L)
print " velocity = %.f fps"%(V2)
print " Temperature = %d R"%(T2)
# note : rounding off error