# Variables
T = 500. #K
Qr = 5.*10**6 #kJ
T2 = 600. #K
# Calculations
dSS = Qr/T
dSS2 = -Qr/T2
Ds = dSS+dSS2
# Results
print "Entropy change of the system = %d kJ/K"%(dSS)
print " Entropy change of the surroundings = %d kJ/K"%(dSS2)
print " Entropy change if the universe = %.f kJ/K"%(Ds)
import math
# Variables
p1 = 2.758 #Mpa
p2 = 0.552 #Mpa
T1 = 700. #K
T2 = 700. #K
n = 1.
R = 8.3143
Cv = 21.
Cp = 29.3
# Calculations
dsa = n*R*math.log(p1/p2)
T3 = 437.5 #K
dsb = Cv*math.log(T3/T2)
T4 = 350. #K
dsc = Cp*math.log(T4/T3)
T5 = 634. #K
dsd = 0.
T6 = 700. #K
dse = Cp*math.log(T6/T5)
dstotal = dsa+dsb+dsc+dsd+dse
# Results
print "Entropy change in case a = %.3f kJ/kmol K"%(dsa)
print " Entropy change in case b = %.3f kJ/kmol K"%(dsb)
print " Entropy change in case c = %.3f kJ/kmol K"%(dsc)
print " Entropy change in case d = %.3f kJ/kmol K"%(dsd)
print " Entropy change in case e = %.3f kJ/kmol K"%(dse)
print " Entropy change in total process = %.3f kJ/kmol K"%(dstotal)
import math
# Variables
ratio = 1./2
R = 8.314
p1 = 0.5 #kPa
p2 = 0.1 #kPa
# Calculations
ya = ratio/(1+ratio)
ds = -ya*R*math.log(ya) - (1-ya)*R*math.log(1-ya)
dss = R*math.log(p1/p2)
# Results
print "Entropy of mixing = %.3f kJ/kmol K"%(ds)
print " Total entropy change of the universe = %.2f kJ/kmol K"%(dss)
import math
# Variables
s1 = 7.096 #kJ/kg K
s2 = 7.915 #kJ/kg K
s3 = 7.16 #kJ/kg K
s4 = 7.014 #kJ/kg K
s5 = 6.999 #kJ/kg K
# Calculations
dsa = s2-s1
dsb = s3-s2
dsc = s4-s3
dsd = s5-s4
dse = s1-s5
dstotal = dsa+dsb+dsc+dsd+dse
# Results
print "Change in entropy in process a = %.3f kJ/kg K"%(dsa)
print " Change in entropy in process b = %.3f kJ/kg K"%(dsb)
print " Change in entropy in process c = %.2f kJ/kg K"%(dsc)
print " Change in entropy in process d = %.3f kJ/kg K"%(dsd)
print " Change in entropy in process e = %.3f kJ/kg K"%(dse)
print " Change in entropy in total process = %.3f kJ/kg K"%(dstotal)
import math
# Variables
m1 = 5000. #kg/h
cp1 = 3.2 #kJ/kg K
cp2 = 4.186 #kJ/kg K
t1 = 220. #C
t2 = 30. #C
T1 = 210. #C
T2 = 20. #C
# Calculations
m2 = m1*cp1*(t1-t2)/(cp2*(T1-T2))
ds = m1*cp1*math.log((t2+273.1)/(t1+273.1)) + m2*cp2*math.log((T1+273.1)/(T2+273.1))
# Results
print "Change in entropy = %.f kJ/h K"%(ds)
# Variables
s1 = 218.8 #kJ/kmol K
s2 = 188.85 #kJ/kmol K
s3 = 237.8 #kJ/kmol K
s4 = 205.2 #kJ/kmol K
# Calculations
ds = s1+s2-s3-0.5*s4
# Results
print "Entropy change = %.2f kJ/kmol K"%(ds)
# Variables
Q = 6. #kJ/kg
p1 = 1.5 #Mpa
p2 = 0.1 #Mpa
t1 = 500. #C
t2 = 140.8 #C
h1 = 3473.1 #kJ
h2 = 2758.1 #kJ
s1 = 7.5698 #kJ/K
s2 = 7.5698 #kJ/K
eff = 0.85
Ts = 293.1 #K
# Calculations
Wideal = h2-h1
Ws = eff*Wideal
dH = -Q-Ws
H2 = h1+dH
S2 = 7.8005
ds = S2-s1
Wlost = Ts*ds+Q
# Results
print "lost work = %.1f kJ"%(Wlost)
import math
# Variables
m = 5000. #/kg/h
cp = 3.2 #kJ/kg K
Ts = 30.+273.1 #K
t1 = 220. #C
t2 = 40. #C
Q = 2.88*10**6 #kJ
# Calculations
Q = m*cp*(t2-t1)
dss = m*cp*math.log((t2+273.1)/(t1+273.1))
Wlost = Ts*dss-Q
eff = Ts*dss/Q
# Results
print "Lost work = %d kJ"%round(Wlost,-4)
print " Efficiency = %.3f"%(eff)
import math
# Variables
R = 8.314
cp = 35.58
n = 100./16
T1 = 300. #K
T2 = 500. #K
k = 1.305
P2 = 3. #Mpa
P1 = 0.5 #Mpa
Ts = 290. #K
# Calculations
cv = cp-R
Wi = n*R*T1/(k-1) *((P2/P1)**((k-1)/k) -1)
Hi = Wi
Ha = n*cp*(T2-T1)
eta = abs(Hi/Ha)
dss1 = cp*math.log(T2/T1) - R*math.log(P2/P1)
Wl1 = Ts*dss1
dss2 = n*cp*math.log(T2/T1)
dss3 = abs(Ha/Ts)
dsst = dss2+dss3
Wl2 = -Ts*dss2 +Ha
Wlost = Wl1+Wl2
# Results
print "Thermodynamic efficiency = %.3f"%(eta)
print " Net work lost = %d kJ"%(Wlost)
# Variables
T1 = 673. #K
T2 = 293. #K
# Calculations
eta = (T1-T2)/T1
# Results
if eta >= 0.5:
print "Max efficiency = %.3f and an efficiency of 0.5 is possible"%(eta)
else:
print "Max efficiency = %.3f and an efficiency of 0.5 is not possible"%(eta)
# Variables
T1 = 280. #K
T2 = 300. #K
# Calculations
cop = T1/(T2-T1)
# Results
print "coefficient of performance = %.1f"%(cop)
# Variables
P = 2. #Mpa
T1 = 212.4+273.1 #K
T2 = 25+273.1 #K
h1 = 2799.5
h2 = 104.89
s1 = 6.3409
s2 = 0.3674
# Calculations
dh = h1-h2
ds = s1-s2
exergy = dh-T2*ds
# Results
print "exergy = %.1f kJ/kg"%(exergy)
import math
# Variables
R = 8314.3
T = 700. #K
T2 = 437.5 #K
T3 = 350. #K
T4 = T3
p2 = 0.552 #Mpa
p1 = 2.758 #Mpa
p3 = 0.345 #Mpa
cp = 29.3
R0 = 8.3143
k = 1.4
n = 1.
P0 = 0.103 #Mpa
# Calculations
cv = cp-R0
p3 = p2*T3/T2
p3 = 0.345
T5 = T4*(p1/p3)**((k-1)/k)
G1 = n*R*T*math.log(p2/p1)
V700 = R*10**3 *T/(p2*10**9)
Sa = 209.
Sb = 199.2
Sc = 204.7
S2 = (T2-T)/6 *(Sa+4*Sc+Sb )
G2 = V700*(p3-p2)*10**3 -S2
saa = 199.2
sbb = 192.6
savg = (saa+sbb)*0.5
G3 = -savg*(T3-T2)
pmid = (p3+p2)/2
vmid = 2.88
sav = 192.7
v4 = 8.435 #m**3
v5 = 1.911 #m**3
integ = (p1-p3)*10**3 /6 *(v4+4*vmid+v5)
G4 = integ - sav*(T5-T3)
Sav = 194.25
G5 = -Sav*(T-T5)
Gt = G1/10**3 +G2+G3+G4+G5
# Results
print "in case 1, Change in gibbs free energy = %.f kJ"%(G1/10**3)
print " in case 2, Change in gibbs free energy = %.f kJ"%(G2)
print " in case 3, Change in gibbs free energy = %d kJ"%(G3)
print " in case 4, Change in gibbs free energy = %d kJ"%(G4)
print " in case 5, Change in gibbs free energy = %d kJ"%(G5)
print " Net change in gibbs energy = %d kJ"%(Gt)
# note : rounding off error.
import math
# Variables
v = 1./430
pi = 4.08 #Mpa
pf = 10. #Mpa
pf2 = 1. #Mpa
pii = 0.1 #Mpa
R = 8314.3
n = 1./28
T = 273.1
# Calculations
logpr = v*(pf-pii)*10**6 /(R*T*n)
pr = math.exp(logpr)
p = pr*pi
logpr = v*(pf2-pii)*10**6 /(R*T*n)
pr = math.exp(logpr)
p2 = pr*pi
# Results
print "Final pressure = %.2f Mpa"%(p)
print " Final pressure in case 2 = %.2f Mpa"%(p2)
import math
# Variables
Hvap = 338.14 #kJ/kg
T = 409.3 #K
# Calculations
dss = Hvap/T
dg = 0
# Results
print "change in entropy and gibbs energy of system are %.3f kJ/kg K and %d kJ/kg respectivey"%(dss,dg)
print " change in entropy and gibbs energy of universe are %.3f kJ/kg K and %d kJ/kg respectivey"%(-dss,-dg)
import math
# Variables
T = 373.1 #K
R = 8314.3
Pd = 0.1013*10**6 #Pa
P = 10. #Mpa
p3 = 5.*10**6 #Pa
vf = 0.0373
a = 424.447
# Calculations
Vd = R*T/Pd
V = 0.5
dss = -R*(math.log(p3/Pd) + math.log((V-vf)/(Vd-vf)))
dhh = R*T/10**3 - p3/10**3 *V+ a/V**2
# Results
print "Change in entropy = %.4f kJ/kmol K"%(dss/10**3)
print " change in enthalpy = %.f kJ/kmol"%(dhh)
import math
# Variables
Tc = 647.3 #K
dh = 1.1
Db = -2
v2 = 0.234
v1 = 0.27
# Calculations
dh2 = dh+Db*(v2-v1)
dhh = dh2*Tc
dhbar = dhh*4.18/18
h1 = 3777.5 #kJ/kg
h2 = 3928.2 #kJ/kg
dhs = h2-h1
err = abs(dhs-dhbar)/dhs
# Results
print "Enthalpy departure = %d kJ/kg"%(dhbar)
print " Percentage error = %.1f "%(err*100)
# Variables
w = 0.3448
R = 8.3143
Tc = 647.3
# Calculations
h0 = 0.57
h1 = 0.05
h2 = h0+w*h1
h3 = h2*R*Tc
dh = -h3
# Results
print "Enthalpy departure = %d kJ/kmol"%(dh)
print ("The answer is a bit different due to rounding off error in the textbook")
import math
# Variables
ta = 310. #K
pa = 80. #kPa
r = 10.
k = 1.4
R = 8.3143
n = 5./29
cv = 20.93
# Calculations
Qab = 0
tb = ta*r**(k-1)
va = R*ta/pa
vb = va/r
pb = R*tb/vb
Wab = -n*R*ta/(k-1) *((pb/pa)**((k-1)/k) -1)
vc = vb
Qbc = 500 #kJ
Wbc = 0
tc = tb+ Qbc/(n*cv)
pc = R*tc/vc
Qcd = 0
td = tc/r**(k-1)
vd = va
pd = td/tc*(vc/vd)*pc
Wcd = -n*R*tc/(k-1) *((pd/pc)**((k-1)/k)-1)
Wda = 0
Qda = n*cv*(ta-td)
eta0 = 1-1/r**(k-1)
# Results
print "Efficiency of cycle = %.3f"%(eta0)
p = [pa, pb, pc, pd]
t = [ta, tb, tc, td]
Q = [Qab, Qbc, Qcd, Qda]
W = [Wab, Wbc, Wcd, Wda]
print ('Pressure (kPa) = ')
print (p)
print ("Temperature (K) = ")
print (t)
print ("Heat (kJ) = ")
print (Q)
print ("Work done (kJ) = ")
print (W)
# Variables
ta = 310. #K
tc = 917.3 #K
td = 365.2 #K
n = 0.602
k = 1.4
# Calculations
lntb = 1/(1-n)/k
tb = tc- lntb*(td-ta)
rc = (tb/ta)**(1/(k-1))
# Results
print "Temperature at B = %.1f K"%(tb)
print " Compression ratio = %d "%(rc)
print ("The answer given in textbook for rc is wrong. please check using a calculator")
# Variables
pr = 4.
k = 1.4
ta = 298. #K
pa = 0.1 #Mpa
pdr = 0.01
tc = 900. #K
pri = 0.005 #Mpa
# Calculations
pb = pr*pa
nji = 1- (pr)**((1-k)/k)
tb = ta*(pb/pa)**((k-1)/k)
pc = pb-pdr
pd = pa+pri
td = tc*(pd/pc)**((k-1)/k)
# Results
p = [pa, pb, pc, pd]
t = [ta, tb, tc, td]
print "ideal thermal efficiency = %.3f "%(nji)
print ("pressure (Mpa) = ")
print (p)
print ("temperature (K) = ")
print (t)
import math
# Variables
sd = 4.9269 #kJ/kg/K
sf = 1.1453 #kJ/kg/K
sg = 7.5320 #kJ/kg/K
hf = 359.86 #kJ/kg
hg = 2653.5 #kJ/kg
hd = 2409.7 #kJ/kg
# Calculations
x = (sd-sg)/(sf-sg)
he = x*hf+(1-x)*hg
etar = (hd-he)/(hd-hf)
# Results
print "Thermal efficiency = %.4f"%(etar)
# Variables
sd = 6.7039 #kJ/kg/K
sf = 1.1453 #kJ/kg/K
sg = 7.5320 #kJ/kg/K
hf = 359.86 #kJ/kg
hg = 2653.5 #kJ/kg
hd = 3717.9 #kJ/kg
# Calculations
x = (sd-sg)/(sf-sg)
he = x*hf+(1-x)*hg
etar = (hd-he)/(hd-hf)
# Results
print "Thermal efficiency = %.4f"%(etar)
# Variables
ha = 2510.6 #kJ/kg
hd = 125.78 #kJ/kg
# Calculations
kg = (10**6)/(ha-hd)
# Results
print "circulation rate = %d kg steam/h"%(kg)
# Variables
tin = 298. #K
tout = 273. #K
tout2 = 308. #K
tin2 = 294. #K
# Calculations
eta1 = (tin-tout)/tin
eta2 = abs((tin2-tout2)/tin2)
# Results
print "Efficiency in case 1 = %.3f"%(eta1)
print " efficiency in case 2 = %.3f"%(eta2)
import math
# Variables
ma = 500. #kg/h
cp1 = 3.2 #kJ/kg K
ta = 20. #C
mb = 200.
mc = 300. #kg/h
cp2 = 2.8 #kJ/kg K
tc = 80. #C
tb = 80. #C
me = 50. #kg/h
te = 120. #C
td = 120. #C
hg = 503.7
he = 2706.3
# Calculations
Ws = (mb+me)*hg + mc*cp2*(tc) - me*he -ma*cp1*(ta)
# Results
print "Net work done = %d kJ/h"%(Ws)
# Variables
hc = 150. #Btu/lb
he = -115. #Btu/lb
hg = 168. #Btu/lb
# Calculations
frac = (hg-hc)/(hg-he)
# Results
print "Fraction of solid = %.3f"%(frac)
# Variables
H = 2696.5 #kJ/kg
hg = 2706.7 #kJ/kg
hf = 504.7 #kJ/kg
# Calculations
x = (H-hf)/(hg-hf)
x2 = 1
# Results
print "In case 1, fraction of vapor = %.3f"%(x)
print " In case 2, fraction of vapor = %.3f"%(x2)