# Chapter 4:The First Law of Thermodynamics¶

## Ex4.1:PG-62¶

In [5]:
#initialization of variables
K=100 # spring constant in kN/m
d=0.8 # dispacement of spring in m
# to get total work we integrate from 0 to 0.8 displacement
x1=0; # lower limit of integration
x2=0.8;  # upper limit of integration

# we find work
def integrand(x,K):
return K*x

W12, err = quad(integrand, x1, x2, K) # integrating to get work
Q12=W12; # by first law of thermodynamics
print "The Heat transfer is ",int(Q12)," J"

The Heat transfer is  32  J


## Ex4.2:PG-65¶

In [10]:
# initialization of variables
P= 5*746 # power of fan converted in watt
t=1*60*60 # time converted to seconds

# by first law of thermodynamics Q=delU + W
# Q=0 hence -W=delU
# first we find work input
W=-P*t # work in J
delU=-W # from 1st law
print "The internal energy increase is ",float(delU)," J"
# The answer is approximated in textbook

 The internal energy increase is  13428000.0  J


## Ex4.3:PG-65¶

In [17]:
# initialization of variables
P=400 # pressure in kPa
T1=200 # initial temperature in degree celsius
V1= 2 # initial volume in m^3
Q=3500 # heat added in kJ
v1=0.5342 # specific volume of steam at 200 degree celcius and 0.4 Mpa pressure from table C.3
u1=2647 # specific internal energy in kJ/kg @ pressure = 0.4 MPa
m=V1/v1 # mass in kg
# we have a relation Between u2 and v2 from 1st law of thermodynamics
v2=1.06 # specific volume at state 2 by trial and error and interpolation
V2=m*v2
u2=((3500-400*(V2-V1))/m)+2647 # specific internal energy for v2=1.06 by trial and error

# on interpolation from steam table at 0.4 MPa we get temperature
T2=644 # temperature in degree celsius
print "The temperature for u2=",round(u2)," kJ and  v2 =",round(v2,3)," kg/m^3 is \n ",int(T2)," degree celsius"
# this numerical is solved by trial and error thus refer to Appendix C

The temperature for u2= 3372.0  kJ and  v2 = 1.06  kg/m^3 is
644  degree celsius


## Ex4.4:PG-67¶

In [20]:
# initialization of variables
P=400 #  pressure in kPa
T1=200 # initial tmperature in degree celsius
V=2 # initial volume in m^3
Q=3500 # heat added in kJ

#solution
h1=2860 # initial enthalpy @ 200*C and 400 kPa from steam table
v=0.5342 # specific volume from steam table C.3
m=V/v;
h2=(Q/m)+h1; # final enthalpy in kJ/kg from energy equation

# NOW USING THIS ENTHLAPY AND INTERPOlATING FROM STEAM TABLE

T2=600+(92.6/224)*100

print "The Final temperature is  ",int(T2)," degree Celsius"
# result is obtained from interpolation on steam table

The Final temperature is   641  degree Celsius


## Ex4.5:PG-71¶

In [24]:
# initialization of variables
T1=300 # initial temperature in degree celsius
T2=700 # final temperature in degree celsius
P=150 # pressure in kPa
m=3 # mass of steam in kg

# solution
# part (a)

# now we make function to integrate
def integrand(T):
return 2.07+(T-400)/1480

I, err = quad(integrand, T1, T2) # integrating specific heat over temperature range
delH=m*I #integrate('2.07+(T-400)/1480','T',T1,T2) # expressing as function of temperature and integrating

print" The change in Enthalpy is ",int(delH)," kJ \n"

# part(b)
CPavg=delH/(m*(T2-T1)) # avg value of specific heat at constant pressure
print " The average value of Cp is ",round(CPavg,2)," kJ/kg.*C"

 The change in Enthalpy is  2565  kJ

The average value of Cp is  2.14  kJ/kg.*C


## Ex4.6,PG-72¶

In [29]:
m=1 # mass of nitrogen in kg
T1=300 # initial temperature in Kelvin
T2=1200 # final temperature in Kelvin
M=28.0 # in kg/kmol
# part(a)
# the enthalpy change is found from gas table in App.E
delh=36777-8723 # from gas table
delH=delh/M
print " The entalpy change from gas table is ",round(delH)," kJ/kg \n"

# part (b)
Cp=1.042 # from table B.2
delH=Cp*(T2-T1)
print " The entalpy change  by assuming constant specific heat is ",round(delH)," kJ/kg"

 The entalpy change from gas table is  1002.0  kJ/kg

The entalpy change  by assuming constant specific heat is  938.0  kJ/kg


## Ex4.7:PG-76¶

In [34]:
# initialization of variables
x=0.7 # quality of steam
P1=200 # initial pressure in kPa
P2=800 # final pressure in kPa
V=2 # volume in m^3
# The values are taken from TABLE C.2
vf1=0.0010 # specific volume of saturated liquid at 200 kPa
vg1=0.8857 # specific volume of saturated gas at 200 kPa
uf1=504.5  # specific internal energy of saturated liquid @ state 1
ug1=2529.5 # speciific internal energy of saturated gas @ state 1

v1=vf1+x*(vg1-vf1); # specific volume of vapour
m=V/v1

u1=uf1+x*(ug1-uf1) # specific internal energy of vapour @ state 1
v2=v1 # constant volume process
u2=((0.6761-0.6203)*(3661-3853)/(0.6761-0.6181))+3853 # from steam table @ 800kPa by interpolating
Q=m*(u2-u1) # heat transfer
print "The heat transfer is ",round(Q,3)," kJ"
# The answer in the textbook is approximated

The heat transfer is  5630.537  kJ


## Ex4.8:PG-76¶

In [37]:
# initialization of variables
V=0.02 # volume in m^3
P=400 # pressure in kPa
T1=50+273 # initial temperature in kelvin
T2=700+273 # final temperature in kelvin
Q=50 # heat added in kJ
R=287 # constant for air
Cp=1 # constant for specific heat of air

# using the ideal gas equation

m=P*1000*V/(R*T1) # mass of air in kg
W=Q-(m*Cp*(T2-T1)) # work done from first law
# result
print "The Paddle work is ",round(W,2)," kJ"

The Paddle work is  -6.09  kJ


## Ex4.9,PG-77¶

In [41]:
# initialization of variables
V1=2 # initial volume in m^3
V2=0.2 # final volume in m^3
T1=20+273 # temperature in kelvin
P=200 # pressure in kPa
R=0.287 # constant for air
gama=1.4 # polytropic index for air
Cv=0.717 # specific heat at constant volume for air

#solution

#using the ideal gas equation
m=(P*V1)/(R*T1) # mass in kg
T2=T1*((V1/V2)**(gama-1)) # final temperature

W=-m*Cv*(T2-T1) # work from first law
print "The Work is ",int(W)," kJ"
# solution is approximated in textbook

The Work is  -1510  kJ


## Ex4.10:PG-79¶

In [45]:
import math
# initialization of variables
P1=2000.0 # initial pressure in kPa
T1=600.0 # initial temperature in degree celsius
p2=600.0 # final pressure in kPa
T2=200.0 #   final temperature in degree celsius
d1=0.06 # diameter of inlet pipe in metre
d2=0.120 # diameter of outlet pipe in metre
V1=20.0 # velocity at inlet in m/s

# solution
# from superheat table C.3 values are noted
v1=0.1996 # specific volume of superheated steam @ 600*C and 2000 kPa
v2=0.3520 # specific volume of superheated steam @ 200*C and 2000 kPa
rho1=1/v1 #  initial density
rho2=1/v2 # final density
A1=(math.pi*d1**2)/4 # inlet area
A2=(math.pi*d2**2)/4 # exit area

V2=(rho1*A1*V1)/(rho2*A2) # from continuity equation
print " The Exit velocity is ",round(V2,2)," m/s \n"

mdot=rho1*A1*V1 # mass flow rate
print" The mass flow rate is ",round(mdot,3)," kg/s"

 The Exit velocity is  8.82  m/s

The mass flow rate is  0.283  kg/s


## Ex4.11:PG-82¶

In [50]:
# initialization of variables
P1=8000 # initial pressure in kPa
T1=300  # temperature in degree celsius
P2=2000 # final pressure in kPa

# solution
h1=2785 # specific enthalpy of steam in kJ/kg @ 8000 kPa and 300 degree celsius from  steam table
h2=h1 # throttling process thus enthalpy is constant
T2=212.4 # from steam table as we know enthalpy and pressure
hf2=909 # specific enthalpy of saturated liquid @ 2000 kPa and 300 degree celsius
hg2=2799.5 # specific enthalpy of saturated gas @ 2000 kPa and 300 degree celsius
x2=(h2-hf2)/(hg2-hf2) # quality of steam

vg2=0.0992 # specific    volume of saturated gas @ 2000 kPa and 212.4*c
vf2=0.0012 # specific volume of saturated liquid @ 2000 kPa and 212.4*c
v2=vf2+x2*(vg2-vf2) # from properties of pure substance

print "The Final Temperature and Specific volume is ",round(T2,1),"*C and ",round(v2,3)," m^3/kg"

The Final Temperature and Specific volume is  212.4 *C and  0.098  m^3/kg


## Ex4.12:PG-84¶

In [78]:
import math
# initialization of variables
P1=4000 # inlet pressure in kPa
T1=500 # inlet temperature in degree celsius
V1=200 # inlet steam velocity in m/s
d1=0.05 # inlet diameter in 'm'
P2=80 # exit pressure in kPa
d2=0.250 # exit diameter in 'm'

# solution
v1=0.08643 # specific volume from steam table @ 4000 kPa and 500*C
v2=2.087 # specific volume from steam table @ 80 kPa and 500*C
rho1=1/v1 # density at inlet
rho2=1/v2 # density at outlet
A1=(math.pi*d1**2)/4 # inlet area
A2=(math.pi*d2**2)/4
mdot=rho1*A1*V1 # mass flow rate
mdot=round(mdot,3) # rounding to 3 significant digits

#now using table C.3
h1=3445 # initial specific enthalpy @ 4000 kPa and 500 *C
h2=2666 # final specific enthalpy @ 80 kPa and 500 *C
WT=-mdot*(h2-h1) # maximum power from first law
print " The power output is ",round(WT)," kJ/s \n "

V2=(A1*V1*rho1)/(A2*rho2)
V2=round(V2) # rounding of digits
delKE=mdot*((V2**2)-(V1**2))/2 # the change in kinetic energy
print " The change in K.E is ",round(delKE)," J/s"

 The power output is  3540.0  kJ/s

The change in K.E is  -6250.0  J/s


## Ex4.13:PG-85¶

In [80]:
import math
# initialization of variables
Wdot=10 # pump power in hp
g=9.81 # acceleration due to gravity
rho=1000 # density of water in kg/m^3
d1=0.06 # inlet dimeter in 'm'
d2=0.10 # oulet diamter in 'm'
V1=10 # velocity of water at inlet in m/s

#solution
A1=math.pi*(d1**2)/4 # area of inlet
A2=math.pi*(d2**2)/4 # area of outlet
V2=A1*V1/A2 # oulet velocity from continuity equation

mdot=rho*A1*V1 # mass flow rate
delP=((((Wdot*746)/mdot)-((V2**2)-V1**2)/(2*g))*rho)/1000 # change in pressure in kPa
print "The rise in pressure is ",round(delP)," kPa"
# The answer is approximated in textbook , our answer is precise

The rise in pressure is  268.0  kPa


## Ex4.14:PG-85¶

In [87]:
import math

# initialization of variables
P1=7000.0 # inlet pressure in Pa
T1=420.0 # inlet temperature in degree celsius
V1=400.0 # inlet velocity in m/s
d1=0.200 # inlet diameter in 'm'
V2=700.0 # exit velocity in m/s
k=1.4 # polytopic index for air
Cp=1000 # specific heat at constant pressure for air in j/kg.K
R=287 # specific gas constant for air

#solution

#part (a)
T2=(((V1**2)-V2**2)/(2*Cp))+T1 # outlet temperature in degree celsius
print " The exit temperature is ",round(T2)," *C \n"

#part (b)

rho1=P1/(R*(T1+273)) # density at entrance
A1=(math.pi*d1**2)/4
mdot=rho1*A1*V1 #
print " The mass flow rate is ",round(mdot,3)," kg/s \n"

# part (c)

rho2=rho1*(((T2+273)/(T1+273))**(1/(k-1))) # density at exit
# now we find the exit diameter
d2=math.sqrt((rho1*V1*(d1)**2)/(rho2*V2))
print " The outlet diameter is ",round(d2,3)," m"

 The exit temperature is  255.0  *C

The mass flow rate is  0.442  kg/s

The outlet diameter is  0.212  m


## Ex4.15:PG-89¶

In [90]:
# initialization of variables
mdots=100 # mass flow rate of sodium in kg/s
Ts1=450 # inlet temperature of sodium in degree celsius
Ts2=350 # exit temperature of sodium in degree celsius
Cp=1.25 # specific heat of sodium in KJ/kg.*C
Tw1=20 # inlet temperature of water in degree celsius
Pw=5000 # inlet pressure of water in kPa

# solution
hw1=88.65 # enthalpy from table C.4
hw2=2794 # enthalpy from table C.3
mdotw=(mdots*Cp*(Ts1-Ts2))/(hw2-hw1) # mass flow rate of water
print " The mass flow rate of water is ",round(mdotw,2)," kg/s \n"
Qdot=mdotw*(hw2-hw1) # heat transfer in kW using energy equation
# result
print " The rate of heat transfer is ",round(Qdot)," kW"

 The mass flow rate of water is  4.62  kg/s

The rate of heat transfer is  12500.0  kW