Chapter 2: Types of Energy

Example 2.1, page no. 19

In [1]:
import scipy.integrate

#initialization
k = 20                        #lb/in
x = 3                         #in

#calculation
def fun(x):
    y = k*x
    return y

w = scipy.integrate.quadrature(fun, 0.0, 3.0)

#result
print "Work done = %d in-lb" %(round(w[0]))
Work done = 90 in-lb

Example 2.2, page no. 22

In [2]:
import scipy.integrate

#initialization
w   =   0.1                           #lbm
Pv   =   30000                        #ft-lb/lbm
v1   =   14.0                         #ft^3 /lbm
v2   =   3.0                          #ft^3/lbm

#calculation
def func(v):
    W   =   Pv/v
    return W

temp   =   scipy.integrate.quadrature(func, v1, v2,)
Work   =   w * temp[0]

#result
#Answer varies a bit from the text due to rounding off of log value
print "Work done   =   %d ft-lb" %Work
Work done   =   -4621 ft-lb

Example 2.3, page no. 27

In [9]:
import scipy.integrate

#initialization of variables
T1 = 500.0                          #R
T2 = 1000.0                         #R
w = 2.0                             #lbm

#calculations
def c(T):
    cp=0.282+0.00046*T
    return cp

Q = scipy.integrate.quadrature(c, T1, T2,)[0]
Heat = Q*w

#results
print "Heat flow = %d B" %(Heat)
Heat flow = 626 B

Example 2.4, page no. 29

In [12]:
import scipy.integrate

#initialization
T1 = 500.0                      #R
T2 = 1060.0                     #R
w = 1                           #lbm

#calculation
def v(T):
    cv = 0.258-120/T +40000/T**2
    return cv

Q = scipy.integrate.quadrature(v, T1, T2,)[0]
cvm=Q/(T2-T1)

#result
print "The amount of heat: ", round(Q,1), "B/lbm"
print "Mean specific heat = %.3f B/lbm F" %cvm
The amount of heat:  96.6 B/lbm
Mean specific heat = 0.172 B/lbm F

Example 2.5, page no. 31

In [13]:
#initialization
w=1                         #lbm
Sw=0.3120                   #B/lbm R
Ss=1.7566                   #B/lb R
T=672                       #R

#calculation
Q=T*(Ss-Sw)


#result
print "Latent heat of water = %d B/lbm" %Q
Latent heat of water = 970 B/lbm

Example 2.6, page no. 31

In [15]:
import scipy.integrate

#initialization
w=1                         #lbm
T1=492                      #R
T2=672                      #R
cp=1                        #B/lbm F

#calculation
dQ=cp*(T2-T1)
def ds(T):
    s=1/T
    return s

entropy = scipy.integrate.quadrature(ds, T1, T2,)[0]

#results
print "Entropy change = ", round(entropy, 3), "B/lbm R" 
Entropy change =  0.312 B/lbm R