from __future__ import division
# Given data
Q= 1000 # in kJ
T1= 1000 # in K
T2= 400 # in K
delta_Qsource= -Q/T1 # in kJ/K
delta_Qsystem= Q/T2 # in kJ/K
delta_Qnet=delta_Qsystem+delta_Qsource # in kJ/K
print "The entropy production accompanying the heat transfer = %0.1f kJ/K " %delta_Qnet
T0= 300 # in K
Q1= Q-T0*abs(delta_Qsource) # in kJ
Q2= Q-T0*abs(delta_Qsystem) # in kJ
LossOfEnergy= Q1-Q2 # in kJ
print "The decrease in available energy after heat transfer = %0.0f kJ " %LossOfEnergy
from scipy.integrate import quad
# Given data
T1= 800+273 # in K
T2= 400+273 # in K
T3= 179+273 # in K
T0= 25+273 # in K
Q= 2018.4 # heat taken by water in kJ/kg
# Formula mCp*(T1-T2)= Q
mCp= Q/(T1-T2)
def integrand(t):
return 1/t
ans, err = quad(integrand, T1, T2)
delta_Qgas= mCp*ans # in kJ/K
delta_Qwater= Q/T3 # in kJ/K
delta_Qnet= delta_Qwater+delta_Qgas # in kJ/K
print "Net entropy changes = %0.3f kJ/K " %delta_Qnet
E1= T0*abs(delta_Qgas) # Original unavailable energy in kJ
E2= T0*delta_Qwater #unavailable energy after heat transfer in kJ
E= E2-E1 # in increase in unavailable energy in kJ
print "The increase in unavailable energy = %0.2f kJ " %E
# Note: In the book, the calculation is not accurate