Chapter 2 - First law of thermodynamics

Example: 2.1 Page: 39

In [3]:
from __future__ import division
from sympy.mpmath import quad

print "Example: 2.1 - Page: 39\n\n"

# Solution

#*****Data*****#
#deff('[E] = f1(T)','E = 50 + 25*T + 0.05*T**2')## [J]
#deff('[Q] = f2(T)','Q = 4000 + 10*T')## [J]

def f1(T):
    E = 50 + 25*T + 0.05*T**2
    return E

def f2(T):
    Q = 4000 + 10*T
    return Q
Ti = 400## [K]
Tf = 800## [K]
#*************#

# From the first law of thermodynamics:
# W = Q - delta_E
# W = f2 -f1

W = quad(lambda T:(4000 + 10*T) - (50 + (25*T) + (0.05*T**2)),[Ti,Tf])#
print "The work done during the process is %.2f kJ\n"%(W/1000)#
Example: 2.1 - Page: 39


The work done during the process is -9486.67 kJ

Example: 2.2 Page: 40

In [4]:
from __future__ import division
print "Example: 2.2 - Page: 40\n\n"

# Solution

#*****Data*****#
U1 = 1000## [kJ]
Q = -600# # [kJ]
W = -100## [kJ]
#************#

# The system is considered to be a closed system. No mass transfer takes place across the system. The tank is rigid. 
# So, the kinetic and the potential energies is zero.
# Therefore:
# delta_E = delta_U + delta_PE + delta_KE
# delta_E = delta_U
# From the first law of thermodynamics:
# Q = delta_U + W
# delta_U = Q - W
# U2 - U1 = Q - W
U2 = U1 + Q - W## [kJ]
print "The final internal energy of the fluid is %d kJ\n"%(U2)#
Example: 2.2 - Page: 40


The final internal energy of the fluid is 500 kJ

Example: 2.3 Page: 40

In [5]:
from __future__ import division
print "Example: 2.3 - Page: 40\n\n"

# Solution

#*****Data*****#
W = -3## [hp]
Q = -4000## [kJ/h]
#**************#

# The work done by the stirrer on the system is given by
W = W*745.7## [W]
# The amount of heat transferred to the suroundings can be expressed in terms of J/s:
Q = Q*1000/3600## [J/s]
# From the first law of thermodynamics:
# Q = delta_U - W
delta_U = Q - W## [J/s]
print "The change in the internal energy of the system would be %.2f J/s\n"%(delta_U)#
Example: 2.3 - Page: 40


The change in the internal energy of the system would be 1125.99 J/s

Example: 2.4 Page: 41

In [6]:
from __future__ import division
print "Example: 2.4 - Page: 41\n\n"

# Solution

#*****Data*****#
# From Fig. 2.4 (Page: 41)
# For process A-1-B:
Q1 = 60## [kJ]
W1 = 35## [kJ]
# For process A-2-B:
W2 = 50## [kJ]
# For process B-3-A:
W3 = -70## [kJ]
#************#

# For process A-1-B:
# The internal energy of the process A-1-B can be estimated as:
# Q = delta_U + W
delta_U = Q1 - W1## [kJ]
# For process A-2-B:
Q2 = delta_U + W2## [kJ]
# For process B-3-A:
Q3 = -delta_U + W3## [kJ]
print "The amount of heat transferred from the system to the surroundings during process B-3-A is %d kJ\n"%(-Q3)#
Example: 2.4 - Page: 41


The amount of heat transferred from the system to the surroundings during process B-3-A is 95 kJ

Example: 2.5 Page: 41

In [7]:
from __future__ import division
print "Example: 2.5 - Page: 41\n\n"

# Solution

#*****Data*****#
# For constant pressure process 1-2:
W12 = -100## [kJ]
Q12 = -50## [kJ]
# For constant volume process 2-3:
Q23 = 80## [kJ]
# process 3-1: Adiabatic process
#**************#

# The internal energy of process 1-2 can be calculated as:
delta_U12 = Q12 - W12## [kJ]
print "Change in Internal Energy for process 1-2 is %d kJ\n"%(delta_U12)#
# For the process 2-3:
# As the process is constant volume process:
W23 = 0## [kJ]
delta_U23 = Q23 - W23## [kJ]
print "Change in Internal Energy for process 2-3 is %d kJ\n"%(delta_U23)#

# For process 3-1:
# Since the process is adiabatic, ther is no heat transfer between the system and the surrounding.
Q31 = 0## [kJ]
# For a cyclic process, the internal energy change is zero.
# delta_U12 + delta_U23 + delta_U31 = 0
delta_U31 = -(delta_U12 + delta_U23)## [kJ]
# Putting the value of delta_U31:
W31 = Q31 - delta_U31## [kJ]
print "Change in Internal Energy for process 3-1 is %d kJ\n"%(delta_U31)#
print "The work done during the adiabatic process is %d kJ\n"%(W31)#
Example: 2.5 - Page: 41


Change in Internal Energy for process 1-2 is 50 kJ

Change in Internal Energy for process 2-3 is 80 kJ

Change in Internal Energy for process 3-1 is -130 kJ

The work done during the adiabatic process is 130 kJ

Example: 2.6 Page: 44

In [8]:
from __future__ import division
print "Example: 2.6 - Page: 44\n\n"

# Solution

#*****Data*****#
m = 1## [kg]
Temp = 373## [K]
P = 101325## [N/square m]
V_Liquid = 1.04*10**(-3)## [cubic m/kg]
V_Vapour = 1.673## [cubic m/kg]
Q = 2257## [kJ]
#**************#

# Work done due to expansion:
Wexpansion = P*(V_Vapour - V_Liquid)## [N-m]
deltaU = Q - Wexpansion/1000## [kJ]
deltaH = deltaU + Wexpansion/1000## [kJ]

print "Change in Internal Energy is %.2f kJ\n"%(deltaU)#
print "Change in enthalpy is %d kJ\n"%(deltaH)#
Example: 2.6 - Page: 44


Change in Internal Energy is 2087.59 kJ

Change in enthalpy is 2257 kJ

Example: 2.7 Page: 45

In [9]:
from __future__ import division
print "Example: 2.7 - Page: 45\n\n"

# Solution

#*****Data*****#
n = 1## [mol]
Temp = 353## [K]
P = 1## [atm]
Hv = 380## [J/g]
Mwt = 78## [g/mol]
R = 8.314## [J/K mol]
#*************#

Q = Hv*Mwt## [J/mol]
# Since Vv >> Vl:
# P*(Vv - Vl) = P*Vv =n*R*Temp
Wexpansion = n*R*Temp## [J]
# By first law of thermodynamics:
deltaU = Q - Wexpansion## [J]
deltaH = deltaU + Wexpansion## [J]

print "Change in Internal Energy is %.2f J\n"%(deltaU)#
print "Change in Enthalpy is %d J\n"%(deltaH)#
print "Amount of Heat supplied is %d J\n"%(Q)#
print "Work done is %.2f J\n"%(Wexpansion)#
Example: 2.7 - Page: 45


Change in Internal Energy is 26705.16 J

Change in Enthalpy is 29640 J

Amount of Heat supplied is 29640 J

Work done is 2934.84 J

Example: 2.8 Page: 45

In [10]:
from __future__ import division
print "Example: 2.8 - Page: 45\n\n"

# Solution

#*****Data*****#
deltaU = 200## [cal]
Vinit = 10## [L]
Vfinal = 50## [L]
#deff('[P] = f(V)','P = 10/V')#
def f(V):
    P=10/V
    return P
#**************#

# By definition of enthalpy:
# deltaQ = deltaU + PdV
deltaQ = deltaU + quad(f,[Vinit,Vfinal])*24.2## [cal]
print "Change in enthalpy is %.2f cal\n"%(deltaQ)#
Example: 2.8 - Page: 45


Change in enthalpy is 589.48 cal

Example: 2.9 Page: 48

In [11]:
from __future__ import division
print "Example: 2.9 - Page: 48\n\n"

# Solution

#*****Data*****#
m_water = 1## [kg]
Cv = 4.18## [kJ/kg K]
m_stirrer = 40## [kg]
h = 25## [m]
g = 9.81## [m/square s]
#***************#

# Since the system is thermally insulated:
# Q = 0
# From the first law of thermodynamics:
# dQ = dE + dW
# As E = U + Ek +Ep and Ek = Ep = 0
# dQ = dU + dW
dT = g*h/Cv## [K]
print "Rise in Temperature is %.2f K\n"%(dT)#
Example: 2.9 - Page: 48


Rise in Temperature is 58.67 K

Example: 2.10 Page: 53

In [12]:
from __future__ import division
print "Example: 2.10 - Page: 53\n\n"

# Solution

#*****Data*****#
T1 = 300## [K]
V1 = 30## [L]
V2 = 3## [L]
Cv = 5## [cal/mol]
R = 2## [cal/K mol]
#*************#

Cp = Cv + R## [cal/mol]
gama = Cp/Cv#
# The relation between temperature and volume of ideal gas undergoing adiabatic change is given by:
# (T2/T1) = (V1/V2)**(gama - 1)
T2 = T1 * (V1/V2)**(gama - 1)## [K]
print "The final temperature is %.1f K\n"%(T2)#
Example: 2.10 - Page: 53


The final temperature is 753.6 K

Example: 2.11 Page: 53

In [13]:
from __future__ import division
print "Example: 2.11 - Page: 53\n\n"

# Solution

#*****Data*****#
n = 2## [mol]
T1 = 293## [K]
P1 = 15##[atm]
P2 = 5## [atm]
Cp = 8.58## [cal/degree mol]
#**************#

R = 2## [cal/degree mol]
Cv = Cp - R## [cal /degree mol]
gama = Cp/Cv#
R = 0.082## [L atm/degree K]
# Since the gas is ideal:
V1 = n*R*T1/P1## [L]
# Under adiabatic conditions:
# (V2/V1) = (P1/P2)**(1/gama)
V2 = V1*(P1/P2)**(1/gama)## [L]
print "The final volme is %.2f L\n"%(V2)#

# To determine the final temperature:
# (T2/T1) = (V1/V2)**(gama - 1)#
T2 = T1*(V1/V2)**(gama - 1)## [K]
print "The final temperature is %.2f K\n"%(T2)#

# Adiabatic Work done can be calculated as:
W = (P1*V1 - P2*V2)/(gama - 1)#
print "Adiabatic work done is %.2f L-atm\n"%(W)#
Example: 2.11 - Page: 53


The final volme is 7.44 L

The final temperature is 226.80 K

Adiabatic work done is 35.72 L-atm

Example: 2.12 Page: 57

In [14]:
from __future__ import division
from math import log
print "Example: 2.12 - Page: 57\n\n"

# Solution

#*****Data*****#
m = 1## [kg]
P1 = 8## [atm]
T1 = 50 + 273## [K]
# V1 = V## [L]
# V2 = 5V## [L]
V1_by_V2 = 1/5#
gama = 1.4#
R = 0.082## [L-atm]
#***************#

# Adiabatic process:
print "Adiabatic Process \n"
P2 = P1*V1_by_V2**gama## [atm]
print "Final Pressure is %.2f atm\n"%(P2)#
T2 = T1*V1_by_V2**(gama - 1)## [K]
print "Final Temperature is %f K\n"%(T2)#
Wad = R*(T2 - T1)/(1 - gama)## [L-atm]
print "Adiabatic Work done is %.3f L-atm\n"%(Wad)#
print "\n"

# Isothermal Process:
print "Isothermal Process\n"
# In an isothermal Process, the temperature remans constant:
T2 = T1## [K]
print "Final temperature is %d K\n"%(T2)#
# From the ideal gas:
# (P2*V2/T2) = (P1*V1/T1)
# Since T2 = T1
# P2*V2 = P1*V1
P2 = P1*V1_by_V2## [atm]
print "Final pressure is %.1f atm\n"%(P2)#
W = R*T1*log(1/V1_by_V2)## [L-atm]
print "Work done during the isothermal process is %.2f L-atm\n"%(W)#
Example: 2.12 - Page: 57


Adiabatic Process 

Final Pressure is 0.84 atm

Final Temperature is 169.673696 K

Adiabatic Work done is 31.432 L-atm



Isothermal Process

Final temperature is 323 K

Final pressure is 1.6 atm

Work done during the isothermal process is 42.63 L-atm

Example: 2.13 Page: 58

In [15]:
from __future__ import division
print "Example: 2.13 - Page: 58\n\n"

# Solution

#*****Data*****#
m = 5## [kg]
M = 29## [kg/mol]
T1 = 37 + 273## [K]
P1 = 101.33## [kPa]
T2 = 237 + 273## [K]
Cp = 29.1## [J/mol K]
Cv = 20.78## [J/mol K]
R = 8.314## [J/K mol]
#*****************#

n = m/M#
# From ideal gas equation:
V1 = n*R*T1/P1## [cubic m]

# Isochoric Process:
print "Isochoric Process\n"
# Volume = constant
V2 = V1## [cubic m]
deltaU = n*Cv*(T2 - T1)## [kJ]
# Since Volume is constant
W = 0#
Q = deltaU + W## [kJ]
# deltaH = deltaU + P*deltaV
# deltaH = deltaU + n*R*deltaT
deltaH = deltaU + n*R*(T2 - T1)## [kJ]
print "Change in Internal Energy is %.2f kJ\n"%(deltaU)#
print "Heat Supplied is %.2f kJ\n"%(Q)#
print "Work done is %d kJ\n"%(W)#
print "Change in Enthalpy is %.2f kJ\n"%(deltaH)#
print "\n"

# Isobaric Process
print "Isobaric Process\n"
# Since Pressure is constant.
P2 = P1## [kPa]
deltaH = n*Cp*(T2 - T1)## [kJ]
Qp = deltaH## [kJ]
# deltaU = deltaH - P*deltaV
# From ideal gas equation:
deltaU = deltaH - n*R*(T2 - T1)## [kJ]
W = Qp - deltaU## [kJ]
print "Change in Internal Energy is %.2f kJ\n"%(deltaU)#
print "Heat Supplied is %.2f kJ\n"%(Qp)#
print "Work done is %.2f kJ\n"%(W)#
print "Change in Enthalpy is %.2f kJ\n"%(deltaH)#
Example: 2.13 - Page: 58


Isochoric Process

Change in Internal Energy is 716.55 kJ

Heat Supplied is 716.55 kJ

Work done is 0 kJ

Change in Enthalpy is 1003.24 kJ



Isobaric Process

Change in Internal Energy is 716.76 kJ

Heat Supplied is 1003.45 kJ

Work done is 286.69 kJ

Change in Enthalpy is 1003.45 kJ

Example: 2.14 Page: 60

In [16]:
from __future__ import division
from math import log10
print "Example: 2.14 - Page: 60\n\n"

# Solution

#*****Data*****#
n = 1## [mol]
T1 = 610## [K]
P1 = 10**6## [N/square m]
T2 = 310## [K]
P2 = 10**5## [N/square m]
Cv = 20.78## [J/mol K]
#*************#

R = 8.314## [J/K mol]

# Step 1: Isothermal Expansion Of Ideal Gas:
print "Step 1: Isothermal Expansion Of Ideal Gas\n"
T1 = 610## [K]
P1 = 10**6## [N/square m]
P2 = 10**5## [N/square m]
# Work done:
W1 = 2.303*n*R*T1*log10(P1/P2)## [J/mol]
# For isothermal expansion:
delta_E1 = 0## [J/mol]
# From first law of thermodynamics:
Q1 = delta_E1 + W1## [J/mol]
print "delta_E for Step 1 is %d J/mol\n"%(delta_E1)#
print "Q for step 1 is %.2f J/mol\n"%(Q1)#
print "W for step 1 is %.2f J/mol\n"%(W1)#
print "\n"

# Step 2: Adiabatic Expansion of ideal gas:
print "Step 2: Adiabatic Expansion of ideal gas\n"
Q2 = 0## [J/mol]
delta_E2 = Cv*(T2 - T1)## [J/mol]
# From first law of thermodynamics:
W2 = Q2 - delta_E2## [J/mol]
print "delta_E for Step 2 is %d J/mol\n"%(delta_E2)#
print "Q for step 2 is %.2f J/mol\n"%(Q2)#
print "W for step 2 is %.2f J/mol\n"%(W2)#
print "\n"

# Step 3: Isothermal Compression Of Ideal Gas:
print "Step 3: Isothermal Compression Of Ideal Gas\n"
T2 = 310## [K]
P1 = 10**5## [N/square m]
P2 = 10**6## [N/square m]
# Work done:
W3 = 2.303*n*R*T2*log10(P1/P2)## [J/mol]
# For isothermal expansion:
delta_E3 = 0## [J/mol]
# From first law of thermodynamics:
Q3 = delta_E3 + W3## [J/mol]
print "delta_E for Step 3 is %d J/mol\n"%(delta_E3)#
print "Q for step 3 is %.2f J/mol\n"%(Q3)#
print "W for step 3 is %.2f J/mol\n"%(W3)#
print "\n"

# Step 4: Adiabatic Compression of ideal gas:
print "Step 4: Adiabatic Compression of ideal gas\n"
T1 = 310## [K]
T2 = 610## [K]
Q4 = 0## [J/mol]
delta_E4 = Cv*(T2 - T1)## [J/mol]
# From first law of thermodynamics:
W4 = Q4 - delta_E4## [J/mol]
print "delta_E for Step 4 is %d J/mol\n"%(delta_E4)#
print "Q for step 4 is %.2f J/mol\n"%(Q4)#
print "W for step 4 is %.2f J/mol\n"%(W4)#
print "\n"

# Net work done for the complete cycle:
W = W1 + W2 + W3 + W4## [J/mol]
print "Net Work done for the complete cycle is %.2f J/mol\n"%(W)#

# The efficiency of the cycle is given by:
eta = 1- T1/T2#
print "The efficiency of the cycle is %.2f\n"%(eta)#
Example: 2.14 - Page: 60


Step 1: Isothermal Expansion Of Ideal Gas

delta_E for Step 1 is 0 J/mol

Q for step 1 is 11679.76 J/mol

W for step 1 is 11679.76 J/mol



Step 2: Adiabatic Expansion of ideal gas

delta_E for Step 2 is -6234 J/mol

Q for step 2 is 0.00 J/mol

W for step 2 is 6234.00 J/mol



Step 3: Isothermal Compression Of Ideal Gas

delta_E for Step 3 is 0 J/mol

Q for step 3 is -5935.61 J/mol

W for step 3 is -5935.61 J/mol



Step 4: Adiabatic Compression of ideal gas

delta_E for Step 4 is 6234 J/mol

Q for step 4 is 0.00 J/mol

W for step 4 is -6234.00 J/mol



Net Work done for the complete cycle is 5744.14 J/mol

The efficiency of the cycle is 0.49

Example: 2.15 Page: 61

In [17]:
print "Example: 2.15 - Page: 61\n\n"

# Mathematics is involved in proving but just that no numerical computations are involved.
# For prove refer to this example 2.15 on page number 61 of the book.

print " Mathematics is involved in proving but just that no numerical computations are involved.\n\n"
print " For prove refer to this example 2.15 on page 61 of the book."
Example: 2.15 - Page: 61


 Mathematics is involved in proving but just that no numerical computations are involved.


 For prove refer to this example 2.15 on page 61 of the book.

Example: 2.16 Page: 62

In [18]:
from __future__ import division
print "Example: 2.16 - Page: 62\n\n"

# Solution

#*****Data*****#
P1 = 1## [bar]
T1 = 300##[K]
V1 = 24.92## [cubic m/kmol]
P2 = 10## [bar]
T2 = 300## [K]
Cp = 29.10## [kJ/kmol K]
Cv = 20.78## [kJ/kmol K]
R = 8.314## [J/mol K]
#**************#

# Basis: 1 kmol of ideal gas:
n = 1#
V2 = P1*V1/P2## [cubic m]

# First Process:
print "First Process\n"
# In the first step of the first process, the cooling of ga takes place at constant pressure.
# Here the volume is reduced appreciably and consequently the temperature decreases.
T_prime = T1*V2/V1## [K]
# Heat Requirement:
Q1 = n*Cp*(T_prime - T1)## [kJ]
deltaH1 = Q1## [kJ]
deltaU1 = deltaH1 - P1*(V2 - V1)## [kJ]
# In the second step, the gas is heated at constant Volume:
# V = constant
Q2 = n*Cv*(T2 - T_prime)## [kJ]
deltaU2 = Q2## [kJ]
deltaH2 = n*R*(T2 - T_prime)## [kJ]
deltaU = deltaU1 + deltaU2## [kJ]
deltaH = deltaH1 + deltaH2## [kJ]
Q = Q1 + Q2## [kJ]
print "Change in Internal Energy is %.2f kJ\n"%(deltaU)#
print "Change in Enthalpy is %.2f kJ\n"%(deltaH)#
print "Heat Requirement is %.2f kJ\n"%(Q)#
print "\n"

# Second Process:
print "Second Process\n"
# In the first step of the second process, the gas is heated at constant volume.
T_prime = T1*P2/P1## [K]
# Heat Requirement:
Q1 = n*Cv*(T_prime - T1)## [kJ]
deltaU1 = Q1## [kJ]
deltaH1 = n*R*(T_prime - T1)## [kJ]
# In the second step, the gas is cooled at constant presure:
# V = constant
Q2 = n*Cp*(T2 - T_prime)## [kJ]
deltaH2 = Q2## [kJ]
deltaU2 = deltaH2 - P1*(V2 - V1)## [kJ]
deltaU = deltaU1 + deltaU2## [kJ]
deltaH = deltaH1 + deltaH2## [kJ]
Q = Q1 + Q2## [kJ]
print "Change in Internal Energy is %.2f kJ\n"%(deltaU)#
print "Change in Enthalpy is %.2f kJ\n"%(deltaH)#
print "Heat Requirement is %.2f kJ\n"%(Q)#
Example: 2.16 - Page: 62


First Process

Change in Internal Energy is -2223.97 kJ

Change in Enthalpy is -5612.22 kJ

Heat Requirement is -2246.40 kJ



Second Process

Change in Internal Energy is -22441.57 kJ

Change in Enthalpy is -56122.20 kJ

Heat Requirement is -22464.00 kJ

Example: 2.17 Page: 62

In [19]:
from __future__ import division
from math import pi
print "Example: 2.17 - Page: 64\n\n"

# Solution

#*****Data*****#
D1 = 1## [m]
P1 = 120## [kPa]
P2 = 360## [kPa]
# P = k*D**3
#***************#

k = P1/D1**3## [proportionality constant]
D2 = (P2/k)**(1/3)## [m]
# Work done by the gas inside the balloon can be estimated as:
# W = integral(P*dV)#
# W = integral((k*D**3)*d((4/3)*pi*r**3)#
# W = (pi*k/6)*integral((D**3)*d(D**3))#
# W = (pi*k/12)*(D2**6 - D1**6)#
W = (pi*k/12)*(D2**6 - D1**6)## [kJ]
print "Workdone by the gas is %.2f kJ\n"%(W)#
Example: 2.17 - Page: 64


Workdone by the gas is 251.33 kJ

Example: 2.18 Page: 65

In [20]:
from __future__ import division
print "Example: 2.18 - Page: 65\n\n"

# Solution

#*****Data*****#
P1 = 10*100## [kPa]
T1 = 250## [K]
P2 = 1*100## [kPa]
T2 = 300## [K]
R = 8.314## [J/mol K]
Cv = 20.78## [kJ/kmol K]
Cp = 29.10## [kJ/kmol K]
#**********#

V1 = R*T1/P1## [cubic m]
V2 = R*T2/P2## [cubic m]

# Calculation based on First Process:
# In this constant-volume process, the initial pressure of 10 bar is reduced to a final pressure of 1 bar and consequently the temperature decreases.
T_prime = P2*V1/R## [K]
deltaU1 = Cv*(T_prime - T1)## [kJ]
deltaH1 = deltaU1 + V1*(P2 -P1)## [kJ]
# Since V = constant
W1 = 0##[kJ]
# By first law of thermodynamics:
Q = W1 + deltaU1## [kJ]

# Calculation based on second process:
# In this process, the gas is heated at constant pressure to the final temperature of T2.
deltaH2 = Cp*(T2 - T_prime)## [kJ]
deltaU2 = deltaH2 - P2*(V2 - V1)## [kJ]
Q = deltaH2## [kJ]
W2 = Q - deltaU2## [kJ]

deltaU = deltaU1 + deltaU2## [kJ]
deltaH = deltaH1 + deltaH2## [kJ]
print "Change in Inernal Enrgy is %.2f kJ\n"%(deltaU)#
print "Change in Enthalpy is %.2f kJ\n"%(deltaH)#
Example: 2.18 - Page: 65


Change in Inernal Enrgy is 1040.65 kJ

Change in Enthalpy is 1456.35 kJ

Example: 2.19 Page: 69

In [21]:
from __future__ import division
print "Example: 2.19 - Page: 69\n\n"

# Solution

#*****Data*****#
T1 = 273## [K]
T2 = 273 + 67## [K]
m_dot = 20000## [kg/h]
Ws = -1.5## [hp]
Q = -38000## [kJ/min]
Z = 20## [m]
Cp = 4.2## [kJ/kg K]
g = 9.81## [m/second square]
#***************#

Q = Q*60/m_dot## [kJ/kg]
Ws = Ws*0.7457*3600/m_dot## [kJ/kg]
PE = g*Z*10**(-3)## [kJ/kg]
# KE is assumed to be negligible.
# For Steady Flow process: dE/dt = 0
# From Eqn. 2.47:
deltaH = Q - Ws - PE## [kJ/kg]
H1 = Cp*(T2 - T1)## [kJ/kg]
H2 = H1 + deltaH## [kJ/kg]

# Now, the temperature of the tank can be determined as:
T = (H2/Cp) + T1## [K]
print "Tempertaure of water in the second tank is %.2f K\n"%(T)#
Example: 2.19 - Page: 69


Tempertaure of water in the second tank is 312.86 K