from __future__ import division
# Given data
P = 10 # in bar
P = P *10**5 # in N/m**2
V = 2 #volume of water in m**3
W = P * V # in J
W = W * 10**-6 # in MJ
print "Work done = %0.0f MJ " %W
# Given data
P = 1.013 # atm pressure in bar
P = P * 10**5 # in N/m**2
area= 1000*10**-4 # in m**2
L_w = 1000 # in N
P_L = L_w/area # Pressure due to load in N/m**2
PressOnPiston = P_L+P # absolute pressure to piston in N/m**2
a = 10**-3 # in m**2
U = PressOnPiston*a # in Joules
print "Energy required to pump 1 kg of water at 0°C into the cylinder = %0.1f joules" %U
# Part (b)
absPressure= 111.3*10**3 # in N/m**2
increaseInVol= (1.02-1)*10**-3 # in m**3
u_f= increaseInVol*absPressure # in joules
print "Energy required to effect the change in volume = %0.3f joules " %u_f
# Part (c)
increaseInVol= (1.52-0.001) # in m**3
ExternalWorkDone= absPressure*increaseInVol # in joules
print "External work done = %0.3f kJ" %(ExternalWorkDone*10**-3)
# Given data
m_s = 92.3 # mass of steam in kg
m_w = 0.78 # mass of water in kg
m = m_s + m_w # total mass in kg
D_s = 92.3 # Dry steam in kg
D_F = D_s/m # Dryness fraction
print "Dryness fraction = %0.2f " %D_F
# Given data
L = 693.3 # Liquid heat in kJ/kg
L1 = 125.7 # Liquid heat of feed water in kJ/kg
m = 2 # mass of water in kg
Q = m * (L-L1) # in kJ
print "Heat required to raise temperature = %0.1f kJ " %Q
print "The water is still liquid at the end of the heat supply"
# Given data
x = 0.9
h_f = 762.2 # in kJ/kg
h_fg = 2013.8 # in kJ/kg
H_wet = h_f + (x*h_fg) # in kJ/kg
En = 125.7 # Enthapy of liquid in kJ/kg
H_wet = H_wet - En # in kJ
print "When dry fraction is 0.9, Heat required, to convert = %0.1f kJ " %H_wet
# Part (b) when dry fraction is saturated
H_sat = h_f + h_fg # in kJ/kg
H_sat = H_sat-En # in kJ
print "Heat required when steam is dry and saturated = %0.1f kJ " %H_sat
C_P = 2.093 # in kJ/kg-K
t_sup = 300 # in degree C
t_sat = 179.9 # in degree C
H_sup = h_f + h_fg + C_P*(t_sup-t_sat) # in kJ
H_sup1 = H_sup - En # in kJ
print "Heat required when the steam is super heated = %0.1f kJ " %H_sup1
# Given data
x = 0.95
v_f = 0.001
v_g = 0.1238 # in m**3/kg
V_wet = ((1-x)*v_f)+(x*v_g) # in m**3 correction little diff in ans
print "Specific volume of wet steam = %0.5f m**3 " %V_wet
print "When the steam is dry saturated, the specific volume = %0.4f m**3/kg " %v_g
T_sat = 201.3 # in degree C
T_sat = T_sat + 273 # in K
T_sup = 300 # in degree C
T_sup = T_sup + 273 # in K
V_sup = v_g * (T_sup/T_sat) # in m**3
print "When the steam is superheated, the specific volume = %0.2f m**3 " %V_sup
# Given data
h_f = 720.7 # in kJ
h_fg = 2046.6 # in kJ
v_g = 0.2405 # in m**3
x = 0.9
P = 8*10**2 # in kN/m**2
U_sat = h_f+x*h_fg-x*v_g*P # in kJ
print "When the steam is wet, the internal energy = %0.2f kJ " %U_sat
En = 2767.3 # Enthalpy of dry saturated stream
U_sat = En-(v_g*P) #in kJ/kg
print "When the steam is dry and saturated, the internal energy = %0.2f kJ/kg " %U_sat
C_P = 2.093
del_s = 100 # in degree C
H_sup = h_f + h_fg + (C_P*del_s) # in kJ/kg
t_sat = 170.4+273 # in K
V_sup = (v_g*(t_sat+del_s))/t_sat # in m**3
U_sup = H_sup - P*V_sup # in kJ/kg
print "When the steam is super heated, the internal energy = %0.1f kJ/kg " %U_sup
# Given data
x = 0.88 # dryness fraction
h_fg = 2392.7 # in kJ/kg
H_wet = x * h_fg # in kJ/kg
Vs = 14.67 # Specific volume in m**3/kg
V_wet = x * Vs # in m**3/kg
Q = H_wet/V_wet # in kJ/m**3
print "Heat to be extracted = %0.1f kJ/m**3 " %Q
# Given data
P = 12*10**2 # in kN/m**2
h_f = 798.1 # in kJ/kg
h_fg = 1984.5 # in kJ/kg
x = 0.8
H_wet = h_f + (x*h_fg) # in kJ/kg
v_f = 0.001 # in m**3
v_g = 0.1684 # in m**3
V_wet = ((1-x)*v_f) + (x*v_g) # in m**3
En = H_wet/V_wet # kJ/m**3
print "The enthalpy = %0.3f kJ/m**3 " %En
U_wet = H_wet - ( V_wet * P ) # in kJ
U_wet1 = (U_wet/V_wet) # in kJ/m**3
print "Internal energy = %0.3f kJ/m**3 " %U_wet1
# Note: There is calculation error to find the value of V_wet.( the correct value of V_wet is 0.13492 not 0.1308),
# so there is some difference between the output of coding and the answer of the book
from math import log
# Given data
T = 0 # in degree C
T = T + 273 # in K
T_sat = 179.9 # in degree C
T_sat = T_sat + 273 # in K
x = 0.8
h_fg = 2013.8 # in kJ/kg
c_f = 4.188
Phi_wet = c_f*log(T_sat/T)+x*h_fg/T_sat # in kJ/kg-K
print "The entropy of wet steam = %0.2f kJ/kg-K " %Phi_wet
Phi_g = (c_f*(log(T_sat/T))) + (h_fg/T_sat) # in kJ/kg-K
print "The entropy of dry saturated steam = %0.2f kJ/kg-K " %Phi_g
C_P = 2.3
T_sup = 200+273 # in K
Phi = c_f *log(T_sat/T) + h_fg/T_sat+ C_P*log(T_sup/T_sat) # in kJ/kg-K
print "The entropy of superheated steam = %0.2f kJ/kg-K " %Phi
from math import log
# Given data
T_sat = 198.3 # in degree C
T_sat = T_sat + 273 # in K
T_sup = 300 # in degree C
T_sup = T_sup + 273 # in K
c_f = 4.188
h_fg = 1945 # in kJ/kg-K
T = 273 # in K
C_P = 2.093 # in kJ/kg-K
Phi_sup =c_f *log(T_sat/T)+h_fg/T_sat+C_P*log(T_sup/T_sat) # in kJ/kg-K
print "The value of specific entropy = %0.2f kJ/kg-K " %Phi_sup
#Given data
P = 16 # in bar
m_w = 73 # in gm
m_s = 980 # in gm
x = m_s/(m_s+m_w)
print "Dryness fraction of steam = %0.2f " %x
# Given data
P1 = 7 # in bar
P2 = 1.2 # in bar
h_f1 = 696.9 # in kJ/kg
h_fg1 = 2065 # in kJ/kg
h_g2 = 2684.9 # in kJ/kg
T_sup = 112 # in degree C
T_sat = 104.77 # in degree C
C_P = 2.1 # in kJ/kg
x1 = (h_g2+(C_P*(T_sup-T_sat))-h_f1)/h_fg1
print "Dryness fraction of steam = %0.3f"%x1
# Given data
P1 = 14 # in bar
P2 = 1.2 # in bar
h_f1 = 830
h_fg1 = 1958
h_g2 = 2684.9
x = (h_g2-h_f1)/h_fg1
print "Dryness fraction of steam = %0.4f" %x
# Given data
m_s = 2.2 # in kg
m_w = 0.18 # in kg
x1 = m_s/(m_s+m_w)
h_f1 = 743
h_fg1 = 2031
h_g2 = 2685
C_P = 2
T_sup = 115 # in degree C
T_sat = 104.8 # in degree C
x2 = (h_g2 + (C_P*(T_sup-T_sat)) - h_f1)/h_fg1
x = x1 * x2
print "The dryness fraction of steam = %0.4f" %x
# Given data
h_f1 = 232 # in kJ/kg
h_fg = 2369 # in kJ/kg
x = 0.8
h_f2 = 167.5 # in kJ/kg
H_wet1 = h_f1 + (x*h_fg) # in kJ/kg
H_wet = H_wet1 - h_f2 # in kJ/kg
T1 = 38 # in degree C
T2 = 25 # in degree C
T = T1-T2 # in degree C
SpeHeat = 4.188 # in kJ/kg-K
m = H_wet/(T*SpeHeat) # in kJ/kg
print "The quantity of circulating water required of condensed steam = %0.0f kJ/kg " %round(m)
# Given data
V1 = 0.4 # volume of dry saturated steam
P1 = 1.5 # in MN/m**2
print "Part (i) : For Isothermal operation :"
Vs = 0.1318 # specific volume of dry steam
m = V1/Vs # quantity of steam present in the vessel in kg
h_f1= 844.6 # in kJ/kg
x1= 0.5 # dryness fraction
h_fg1= 1945.2 # in kJ/kg
Specific_Enth= h_f1+x1*h_fg1 # in kJ/kg
En= Specific_Enth*m # kJ
print "Enthalpy of the fluid = %0.2f kJ " %En
HeatLost= m*(1-x1)*h_fg1 # in kJ
print "The loss of heat during the constant temperature process = %0.1f kJ " % HeatLost
print "Part (ii) : For Hyperbolic operation :"
h_f2= 1008.3 # in kJ/kg
h_fg2= 1794 # in kJ/kg
Vs= 0.0659 # Specific volume after compression in m**3/kg
Vs1= 0.0666 # Specific volume of dry saturated steam in m**3/kg
x2=Vs/Vs1
H_wet= h_f2+x2*h_fg2 # in kJ/kg
H= m*H_wet # in kJ
print "Enthalpy of the fluid = %0.1f kJ" %H
# Note : The calculation in the book is not accurate
from numpy import pi
# Given data
P = 13.5 # power developed by engine in kW
P1 = 12 # Steam consumption of the engine in kg/kWh
S_C = P*P1 #steam consumed per hour in kg
S_C = S_C/60 # in kg/min
x = 0.85
V_g = 1.430
Volume = x * V_g # in m**3/kg
Volume = S_C * Volume # in m**3
d = 15*10**-2 #diameter of exhaust pipe in meter
A = (pi/4) * (d)**2 # in m**2
C = Volume/A # in meter/minute
print "The velocity of steam = %0.1f metre/minute" %C
# Given data
P = 2 #pressure of steam in bar
m = 0.1 #mass of steam in kg
V = 0.080 #volume of steam in m**3
V1 = 0.8872 #volume of 1kg dry saturated steam in m**3
x = V/(m*V1)
print "Dryness fraction of steam = %0.3f" %x
import math
# Given data
P1 = 7+ 1 # in bar
H = 2767 # Enthalpy in kJ/kg
P2 = 1.5+1 # in bar
H1 = 2717 # enthalpy of 1kg of dry steam in kJ/kg
H_sup = H - H1 # Superheated of 1kg of steam in kJ
S1 = 2.17 # super heated steam in kJ/kg-K
theta = H_sup/S1 # in degree C
T_sat = 127.4 # in degree C
T_sup = T_sat + theta # in degree C
print "The super heated temperature = %0.0f degree C " %(T_sup)
# Note : The calculation in the book is not accurate
# Given data
T_sat = 99.6 # in degree C
h_fg = 2258 # in kJ/kg
m = 1 # steam output of the boiler in (assumed)
m1 = 0.03 # exhaust steam
x = 0.9
T1 = 21 # in degree C
Cp = 4.187 # kJ/kg-K
# Formula m1*(Cp*(T_sat-t)+x*h_fg)= m*Cp*(t-T1)
t= (m1*(Cp*T_sat+x*h_fg)+m*Cp*T1)/(Cp*(m+m1))
print "Temperature of the feed water leaving the heater = %0.1f degree C " %t
# Given data
T = 20 # in degree C
H1 = 3039 # Enthalpy in kJ/kg
H2 = 2725 # Enthalpy of 1kg dry saturated steam
H_sup = H1-H2 # superheat of 1kg of steam in kJ/kg
H= 2621.4 # heat required for 1kg or water in kJ
m = H_sup/H # in kg
print "Quantity of water = %0.2f kg " %m
# Given data
x = 0.9
h_f1 = 1087.4 # in kJ/kg
h_fg1 = 1712.9 # in kJ/kg
H_wet1 = h_f1 + (x*h_fg1) # in kJ/kg
H_sup2 = 3095 # in kJ/kg
H = H_sup2 - H_wet1 # in kJ/kg
print "Heat recieved = %0.0f kJ/kg " %H
# Given data
V_fg =0.1632 # in m**3
T_sup = 200 # in degree C
T_sup = T_sup + 273 # in K
T_sat = 188 # in degree C
T_sat = T_sat + 273 # in K
V_sup = (V_fg*T_sup)/T_sat # in m**3/kg
V = 0.24 # Capacity of the vessel in m**3
Q = V/V_sup # in kg
V1 = 0.9774 #volume of 1kg dry saturated steam in m**3
x = V_sup/V1
print "Dryness fraction of steam = %0.4f" %x
# Given data
V = 0.6 # in m**3
P2 = 2*10**2 # in kN/m**2
P1 = 10*10**2 # in kN/m**2
m = V/0.1946 # in kg
V_s = 0.8872 # Specific volume of dry saturated steam in m**3
x = 0.1946/V_s
h_f1 = 505 # in kJ/kg
h_fg1 = 2202 # in kJ/kg
H2 = m*(h_f1 + (x*h_fg1)) # in kJ
H1 = m*2776 # in kJ
Q = (H2-H1) - (V*(P2-P1)) # in kJ
print "The mass of steam in the vessel = %0.2f kg " %m
print "The dryness fraction of steam = %0.4f the vessel " %x
print "The amount o heat transferred = %0.0f kJ " %int(Q)
print "Thus during cooling process there is loss of heat"
# Given data
x1 = 0.95
P1 = 9 # in bar
P1= P1*10**2 # in kN/m**2
h_f1 = 743 # in kJ/kg
h_fg1 = 2030 # in kJ/kg
V = 0.204 # in m**3
x2 = 0.544
P2 = 5 # in bar
P2= P2*10**2 # in kN/m**2
h_f2 = 640 # in kJ/kg
h_fg2 = 2108 # in kJ/kg
H_wet1 = h_f1 + (x1*h_fg1) # in kJ/kg
print "Total energy = %0.1f kJ/kg " %H_wet1
U1 = H_wet1 - P1*V # in kJ/kg
print "The internal energy = %0.1f kJ/kg " %U1
V_g1 = 0.204 # in m**3
V1 = 0.3753 #volume of 1kg of dry stream in m**3
x2 = V_g1/V1
H_wet2 = h_f2 + (x2*h_fg2) # in kJ
U2 = H_wet2 - P2*V # in kJ
del_U = U1-U2 # in kJ
H = del_U/V # in kJ
print "Heat removed from 1 m**3 of steam = %0.1f kJ " %H
# Given data
P1 = 2.1 # in MN/m**2
P1= P1*10**3 #in kN/m**2
P2 = 0.7 # in MN/m**2
P2= P2*10**3 #in kN/m**2
V1 = 0.1281 # in m**3
x = 0.9
n = 1.25
h_f1= 920 # in kJ/kg
h_fg1= 1878.6 # in kJ/kg
h_f2= 697.0 # in kJ/kg
h_fg2= 2065.0 # in kJ/kg
V_wet1 = x * 0.0949 # in m**3/kg
m = V1/V_wet1 # in kg
print "Mass of steam = %0.1f kg " %m
V2 = V1*((P1/P2)**(1/n)) #in m**3
del_W = (P1*V1-P2*V2)/(n-1) # in kJ
print "External work done = %0.1f kJ " %del_W
V_2 = V2/m # in m**3/kg
x2 = V_2/0.273
H1= h_f1+x*h_fg1 # in kJ/kg
U1= H1-P1*V_wet1 # in kJ/kg
H2= h_f2+x2*h_fg2 # in kJ/kg
U2= H2-P2*V_2 # in kJ/kg
del_E = m*(U2-U1) #in kJ
print "Change in internal energy = %0.1f kJ " %del_E
Q = del_W +del_E # in kJ
print "Heat exchange = %0.1f kJ " %Q
print "Heat is lost to the surroundings."
# Given data
h_f1 = 670 # in kJ/kg
h_fg1 = 2085 # in kJ/kg
h_f2 = 475 # in kJ/kg
h_fg2 = 2221 # in kJ/kg
P2 = 6*10**2 # in kJ/kg
P1 = 1.6*10**2 # in kJ/kg
n = 1.1
x1 = 0.9
V1 = 0.3159 # in m**3
V2 = 1.092 # in m**3
H_wet = h_f1 + (x1*h_fg1) # in kJ/kg
V_wet1 = x1*V1 # in m**3
V_wet2 = V_wet1*(P2/P1)**(1/n) # in m**3
x2 = V_wet2/V2
H_wet2 = h_f2 + (x2*h_fg2) # in kJ/kg
U2= H_wet2-H_wet+P2*V_wet1-P1*V_wet2 # in kJ/kg
W= (P2*V_wet1-P1*V_wet2)/(n-1) # in kJ/kg
Q= U2+W # in kJ/kg
print "Heat recieved by steam = %0.1f kJ/kg " %Q
# Given data
P1 = 0.85*10**3 # in kN/m**2
P2 = 0.17*10**3 # in kN/m**2
n = 1.13
x1 = 0.95
V1 = x1*0.227 # in m**3/kg
V2 = V1 * ((P1/P2)**(1/n)) # in m**3/kg
x2 = V2/1.032
print "Final dryness fraction of steam = %0.3f" %x2
W = (P1*V1-P2*V2)/(n-1) # in kJ/kg
print "Change in internal energy = %0.1f kJ/kg " %W
import math
# Given data
Cp= 2.3 # in kJ/kg-K
T_sat= 179.9 # in °C
T_sat= T_sat+273 # in K
H= 3052 # enthalpy in kJ/kg
P= 10*10**2 # in kN/m**2
h_f= 763 # in kJ/kg
h_fg= 2015 # in kJ/kg
V= 0.1944 # in m**3
# Formula H= h_f+h_fg*Cp*(t_sup-T_sat)-P*V*(t_sup/T_sat)
t_sup= (h_f+h_fg-Cp*T_sat-H)/(P*V/T_sat-Cp) # in K
t_sup= t_sup-273 # in °C
print "The final temperature of the steam = %0.0f °C " %math.ceil(t_sup)
from math import log
# Given data
m1 = 3 # in kg
m2 = 2 # in kg
T1 = 10 # in degree C
T2 = 80 # In Degree C
T = ((m1*T1)+(m2*T2))/(m1+m2) # in degree C
T = T + 273 # in K
T1 = T1 + 273 # in K
T2 = T2 + 273 # in K
c_f = 4.188
del_phi1 = m1 * c_f*log(T/T1) # in kJ/K
del_phi2 = m2 * c_f*log(T/T2) # in kJ/K
Phi = del_phi1 + del_phi2 # in kJ/K
print "Total change in entropy = %0.3f kJ/K " %Phi
# Given data
P1 = 15 # in bar
P2 = 0.15 # in bar
T_sat = 198.3 # in degree C
T_sat = T_sat + 273 # in K
h_fg1 = 1947 # in kJ/kg
h_fg2= 2369 # in kJ/kg
h_g1 = 845 # in kJ/kg
h_f2 = 232 # in kJ/kg
f_g2 = 7.985 # in kJ/kg-K
x1 = 0.8
Phi_f1 = 2.315 # in kJ/kg-K
Phi_f2 = 0.772 # in kJ/kg-K
Phi1 = Phi_f1 + ((x1*h_fg1)/T_sat) # in kJ/kg-K
H1 = h_g1 + (x1*h_fg1) # in kJ/kg-K
Phi2 = Phi1 # in kJ/kg-K
x2 = (Phi1 - Phi_f2)/(f_g2 - Phi_f2)
H2 = h_f2 + (x2*h_fg2) # in kJ/kg
Eta = ((H1-H2)/(H1-h_f2))*100 # in %
print "Part (i) When the steam supply is wet and dryness fraction is 0.8"
print "Rankine efficiency = %0.1f %% " %Eta
delH = H1-H2 #theoretical work of steam in kJ/kg
W = delH*60/100 # in kJ/kg
Energy_Equivalent= 3600 # in kJ
Steam_C = Energy_Equivalent/W # Steam consumption in kg
print "Steam consumption per kW-hr = %0.2f kg" %Steam_C
print "Part (ii) When the steam supply is dry and saturated"
H_1 = 2792 # in kJ/kg
Phi_g1 = 6.445 # in kJ/kg-K
x_2 = (Phi_g1-Phi_f2)/(f_g2-Phi_f2)
H_2 = h_f2 + (x_2*h_fg2) # in kJ/kg
Eta1 = (H_1-H_2)/(H_1-h_f2)
print "Rankine efficiency =",round(Eta1,3),"=",round(Eta1*100,1),"%%"
W1 = (H_1-H_2)*60/100 # in kJ/kg
Steam_C= Energy_Equivalent/W1 # in kg
print "Steam consumption per kW-hr = %0.2f kg is :" %Steam_C
print "Part (iii) When steam is superheated and temperature is 300°C"
H_1 = 3039 # in kJ/kg
Phi_1 = 6.919 # in kJ/kg-K
x_2 = (Phi_1 - Phi_f2)/(f_g2-Phi_f2)
H_2 = h_f2 + (x_2 * h_fg2) # in kJ/kg
Eta = (H_1 - H_2)/(H_1-h_f2)
print "Rankine efficiency =",round(Eta,3),"=",round(Eta*100,1),"%%"
W2 = (H_1-H_2)*60/100 # in kJ/kg
Steam_C= Energy_Equivalent/W2 # in kg
print "Steam consumption per kW-hr = %0.2f kg " % Steam_C
# Given data
T1 = 400 # in degree C
T1 = T1 + 273 # in K
T2 = 72.7 # in degree C
T2 = T2 + 273 # in K
Eta = ((T1-T2)/T1)*100 # in %
print "For carnot cycle : "
print "Rankine efficiency = %0.1f %% " %Eta
H1 = 3248 # in kJ/kg
h_f2 = 304.5 # in kJ/kg
del_H = 809.2 # in kJ/kg
Eta = (del_H/(H1-h_f2))*100 # in %
print "For Rankine cycle : "
print "Rankine efficiency = %0.2f %% " %Eta
# Given data
P1 = 15 # in bar
H1 = 3039 # in kJ/kg
V_g1 = 0.1697 # in m**3/kg
Phi1 = 6.919 # in kJ/kg-K
P2_desh = 3.5*10**2 # in kN/m**2
Phi_g2 = 6.941 # in kJ/kg-K
Phi_f2 = 1.727 # in kJ/kg-K
P2 = 0.15*10**2 # in kN/m**2
h_f2 = 232 # in kJ/kg
x = (Phi1-Phi_f2)/(Phi_g2 - Phi_f2)
h_f = 584 # in kJ/kg
h_fg = 2148 # in kJ/kg
H2 = h_f + (x*h_fg) # in kJ/kg
V = 0.5241 # in m**3
V2=x*V # in m**3/kg
W = (H1-H2) + (P2_desh-P2)*V2 #work output of the cycle in kJ/kg
Eta = W/(H1-h_f2)*100 # in %
print "The efficiency of the cycle = %0.1f %% " %Eta
Energy_equivalent= 3600 # in kJ
S_consumption = Energy_equivalent/W # in kg
V = S_consumption* V_g1 # in m**3
print "Total volume of steam = %0.2f m**3 " %V