# Part(a)
import math
V1 = 0.95 # Inlet volume flow rate in m**3/kg
P1 = 100 # Pressure at inlet in kPa
v1 = 7 # velocity of flow at inlet in m/s
V2 = 0.19 # Exit volume flow rate in m**3/kg
P2 = 700 # Pressure at exit in kPa
v2 = 5 # velocity of flow at exit in m/s
w = 0.5 # mass flow rate in kg/s
u21 = 90 # change in internal energy in kJ/kg
Q = -58 # Heat transfer in kW
W = - w*( u21 + (P2*V2-P1*V1) + ((v2**2-v1**2)/2) ) + Q # W = dW/dt
print "\n Example 5.1"
print "\n The rate of work input is ",abs(W) ," kW"
#The answers given in textbook is wrong
# Part (b)
A = (v2/v1)*(V1/V2) # A = A1/A2
d_ratio = math.sqrt(A) # d = d1/d2
print "\n The ratio of the inlet pipe diameter and outet pipe diameter is ",d_ratio ," "
#The answers vary due to round off error
import math
V1 = 0.37 # volume flow rate at inlet in m**3/kg
P1 = 600# Inlet pressure in kPa
v1 = 16 # Inlet velocity of flow in m/s
V2 = 0.62 # volume flow rate at exit in m**3/kg
P2 = 100# Exit pressure in kPa
v2 = 270 # Exit velocity of flow in m/s
Z1 = 32 # Height of inlet port from datum in m
Z2 = 0 #Height of exit port from datum in m
g = 9.81 # Acceleration due to gravity
Q = -9 # Heat transfer in kJ/kg
W = 135 # Work transfer in kJ/kg
U12 = (P2*V2-P1*V1) + ((v2**2-v1**2)/2000) + (Z2-Z1)*g*1e-3 + W - Q # Change in internal energy in kJ
print "\n Example 5.2"
print "\n The internal energy decreases by ",round(U12) ," kJ"
#The answers vary due to round off error
import math
P1 = 4 # Boiler pressure in MPa
t1 = 400 # Exit temperature at boiler in degree Celsius
h1 = 3213 # Enthalpy at boiler exit in kJ/kg
V1 = 0.073 # specific volume at boiler exit in m**3/kg
P2 = 3.5 # Pressure at turbine end in MPa
t2 = 392 # Turbine exit temperature in degree Celsius
h2 = 3202 # Enthalpy at turbine exit in kJ/kg
V2 = 0.084 # specific volume at turbine exit in m**3/kg
Q = -8.5 # Heat loss from pipeline in kJ/kg
v1 = math.sqrt((2*(h1-h2+Q)*1e3)/(1.15**2-1)) # velocity of flow in m/s
A1 = (math.pi/4)*0.2**2 # Area of pipe in m**2
w = (A1*v1)/V1 # steam flow rate in Kg/s
print "\n Example 5.3"
print "\n The steam flow rate is ",w ," Kg/s"
#The answers vary due to round off error
import math
h1 = 313.93 # Enthalpy of water at heater inlet in kJ/kg
h2 = 2676 # Enthalpy of hot water at temperature 100.2 degree Celsius
h3 = 419 #Enthalpy of water at heater inlet in kJ/kg
w1 = 4.2 # mass flow rate in kg/s
print "\n Example 5.4"
w2 = w1*(h3-h1)/(h2-h3)# Steam rate
print "\n The amount of heat that should be supplied is ",w2*3600 ," Kg/h"
#The answers vary due to round off error
import math
t1 = 15 # Heat exchanger inlet temperature in degree Celsius
t2 = 800 # Heat exchanger exit temperature in degree Celsius
t3 = 650 # Turbine exit temperature in degree Celsius
t4 = 500 # Nozzle exit temperature in degree Celsius
v1 = 30 # Velocity of steam at heat exchanger inlet in m/s
v2 = 30# Velocity of steam at turbine inlet in m/s
v3 = 60 # Velocity of steam at nozzle inlet in m/s
w = 2 # mass flow rate in kg/s
cp = 1005 # Specific heat capacity of air in kJ/kgK
print "\n Example 5.5"
Q1_2 = w*cp*(t2-t1) # rate of heat transfer
print "\n The rate of heat transfer to the air in the heat exchanger is ",Q1_2/1e3 ," kJ/s"
W_T = w*( ((v2**2-v3**2)/2) + cp*(t2-t3)) # power output from the turbine
print "\n The power output from the turbine assuming no heat loss is ",W_T/1000 ," kW"
v4 = math.sqrt( (v3**2) + (2*cp*(t3-t4)) ) # velocity at the exit of the nozzle
print "\n The velocity at the exit of the nozzle is ",v4 ," m/s"
#The answers vary due to round off error
import math
ha = 260 # Enthalpy of air in kJ/kg
hg = 912 # Enthalpy of gas in kJ/kg
Va = 270 # Velocity of air in m/s
wf = 0.0190 # mass of fuel in Kg
wa = 1 # mass of air in Kg
Ef = 44500 # Chemical energy of fuel in kJ/kg
Q = 21 # Heat loss from the engine in kJ/kg
print "\n Example 5.6"
Eg = 0.05*wf*Ef/(1+wf) # As 5% of chemical energy is not released in reaction
wg = wa+wf # mass of flue gas
Vg = math.sqrt(2000*(((ha+(Va**2*0.001)/2+(wf*Ef)-Q)/(1+wf))-hg-Eg))
print "\n Velocity of exhaust gas is ",Vg ," m/s"
#Answer given in textbook is wrong
import math
# Given that
V = 0.12 # Volume of tank in m**3
p = 1 # Pressure in MPa
T = 150 # Temperature in degree centigrade
P = 0.1 # Power to peddle wheel in kW
print "\n Example 5.8"
u0 = 0.718*273 # Internal energy at 0 degree Celsius
# Function for internal energy of gas
def f1(t):
u = u0+(0.718*t)
pv = 0.287*(273+t)
return (u,pv)
U,PV=f1(T)
hp = U+PV # At 150 degree centigrade
m_a = P/hp
print "\n The rate at which air flows out of the tank is ",round(m_a*3600,2) ," kg/h"
#The answers vary due to round off error