Part (i): One-dimensional linear interpolation between rows in a table

Given:

Numerical tables of values for temperature T, pressure P and specific volume v

P = 1.00 MPa P = 1.50 MPa
T ($^{\circ}$C) v (m^3/kg) T ($^{\circ}$C) v (m^3/kg)
200 0.20602 200 0.13245
240 0.22756 240 0.14831

Find:

The specific volume $v$ for $P=1.00$ MPa and $T=213$ $^{\circ}$C.

Solution:

Consider linear interpolation between two adjacent points $(x_L,y_L)$ and $(x_H,y_H)$ in a table.

x y
$x_L$ $y_L$
$x_H$ $y_H$

Given a value of $x_M$ such that $x_L < x_M < x_H$, then linear interpolation implies that

$$ \dfrac{y_M - y_L}{x_M - x_L} = \dfrac{y_H - y_L}{x_H - x_L}\\ $$

Then

$$ y_M = y_L + (x_M - x_L)*\dfrac{y_H - y_L}{x_H - x_L}\\ $$

For this problem, (x,y) corresponds to (T,v). Then, for $P=1.00$ MPa

$$ v_{213} = v_{200} + (T_{213} - T_{200})*\dfrac{v_{240} - v_{200}}{T_{240} - T_{200}}\\ $$

The following computation block implements this result for linear interpolation to determine $v$ for $P=1.00$ MPa and $T=213$$^{\circ}$C using the given data table.

In [1]:
#Linear interpolation computation block for T = 213 C and P = 1 Mpa

v_200C_1000kPa = 0.20602 #value of specific volume at 200 C and 1 MPa, m^3/kg
v_240C_1000kPa = 0.22756 #value of specific volume at 240 C and 1 MPa, m^3/kg

T = 213 #C

v_213C_1000kPa = v_200C_1000kPa + (T - 200)*(v_240C_1000kPa - v_200C_1000kPa)/(240 - 200)

print('v @(T=213 C, P=1 MPa) = ',round(v_213C_1000kPa,5),'m^3/kg')
v @(T=213 C, P=1 MPa) =  0.21302 m^3/kg

Part(ii): One-dimensional linear interpolation between columns in a table

Given:

Table from Part (i)

Find:

Values for $v$ at P = 1.2 MPa, T =200 $^{\circ}$C and P = 1.2 MPa, T =240$^{\circ}$C.

Solution:

For this problem,(x,y) in the linear interpolation relation above corresponds to (P,v) for each value of T such that

$$ v_M = P_L + (P_M - P_L)*\dfrac{v_H - v_L}{P_H - P_L}\\ $$

This is applied in the following computational block to find $v$ at P = 1.2 MPa for both T =200$^{\circ}$C and T =240 $^{\circ}$C.

In [2]:
P = 1.2 #MPa

# Interpolate specific volume at 1.2 MPa and 200 C:
v_200C_1500kPa = 0.13245 #value of specific volume at 200 C and 1.5 MPa, m^3/kg
v_200C_1200kPa = v_200C_1000kPa + (P - 1)*(v_200C_1500kPa - v_200C_1000kPa)/(1.5 - 1)

# Interpolate specific volume at 1.2 MPa and 240 C
v_240C_1500kPa = 0.14831 #value of specific volume at 240 C and 1.5 MPa, m^3/kg
v_240C_1200kPa = v_240C_1000kPa + (P - 1)*(v_240C_1500kPa - v_240C_1000kPa)/(1.5 - 1)

print('v @(T=200 C, P=1.2 MPa) = ',round(v_200C_1200kPa,5),'m^3/kg')
print('v @(T=240 C, P=1.2 MPa) = ',round(v_240C_1200kPa,5),'m^3/kg')
v @(T=200 C, P=1.2 MPa) =  0.17659 m^3/kg
v @(T=240 C, P=1.2 MPa) =  0.19586 m^3/kg

Part (iii): Two-dimensional interpolation using intermediate results from Part (ii)

Given:

Results from Part (ii)

Find:

Value for v at P = 1.20 MPa, T = 213$^{\circ}$C

Solution:

Using the new table entries at 1.2 MPa as determined in (ii):

In [3]:
# Interpolate specific volume at 1.2 MPa and 213 C:

v_213C_1200kPa = v_200C_1200kPa + (T - 200)*(v_240C_1200kPa - v_200C_1200kPa)/(240 - 200)

print('v @(T=213 C, P=1.2MPa) = ',round(v_213C_1200kPa,5),'m^3/kg')
v @(T=213 C, P=1.2MPa) =  0.18285 m^3/kg

An alternative two-dimensional interpolation approach would be to first use the original data and linear interpolation to determine values for v at (1 MPa, 213 $^{\circ}$C) and (1.5 MPa, 213 $^{\circ}$C) and then use those values to determine an interpolated value for v at (1.2 MPa, 213 $^{\circ}$C). This would give the nearly same result.

Part (iv): Integration of equations used in evaluating boundary work

Given:

A process involving compression of a gas in a closed system where the volume (V) is decreasing and the pressure (P) is increasing. The work input to the gas from an initial state 1 to a final state 2 is determined by evaluating the following integral:

$$ W_{\rm 12} = \int \dfrac{C}{V^n} dV $$

where $ C = P_1 V_1^n = P_2 V_2^n = PV^n $

and n is a constant that depends on the process. In addition, the following data are provided and assigned to variables for calculations.

In [4]:
V_1 = 0.005 #m^3 
P_1 = 100 #kPa
P_2 = 800 #kPa

Find:

a) Work (kJ) for case $n=1.4$.

b) Work (kJ) for case $n=1$.

Solution:

a) For the case of $n > 1$, then

$$ W_{\rm 12} = P_1 V_1^n \int\limits_{V_1}^{V_2} \dfrac{dV}{V^n} = P_1 V_1^n \dfrac{{V_2}^{1-n}-{V_1}^{1-n}}{1-n} = \dfrac{P_1 V_1^n {V_2}^{1-n}-{P_1 V_1}}{1-n} $$

However, we also have $ P_1 V_1^n = P_2 V_2^n $. So,

$$ W_{\rm 12} = \dfrac{P_2 V_2-P_1 V_1}{1-n} $$

where $V_2$ is determined as $ V_2 = V_1 {\left( \dfrac{P_1}{P_2} \right)}^{1/n} $

The following code evaluates the work for $n = 1.4$.

In [5]:
# Determine V_2 for part a with n = 1.4:
n_a = 1.4 #-
V_2_a = V_1*(P_1/P_2)**(1/n_a)

# For n > 1, the integral for work is:"
W_12_a = -(P_2*V_2_a - P_1*V_1)/(n_a - 1) #units are kN-m which is kJ

print('Work, W_12_a = ',round(W_12_a,3),'(kJ)')
Work, W_12_a =  -1.014 (kJ)

b) For the case of $n = 1$, then

$$ W_{\rm 12} = P_1 V_1^n \int\limits_{V_1}^{V_2} \dfrac{dV}{V} = P_1 V_1 ln\left( \dfrac{V_2}{V_1} \right) $$

where $V_2$ is still determined as $ V_2 = V_1 {\left( \dfrac{P_1}{P_2} \right) }^{1/n} $

The following code evaluates the work for $n = 1$.

In [6]:
from math import log

# Determine V_2 for part b with n = 1:
n_b = 1 #-
V_2_b = V_1*(P_1/P_2)**(1/n_b)
 
# For n = 1, the integral for work is"
W_12_b = P_1*V_1*log(V_2_b/V_1)

print('Work, W_12_b = ',round(W_12_b,3),'(kJ)')
Work, W_12_b =  -1.04 (kJ)

Part (v): Simple application of the Ideal Gas Model

Given:

A system that contains a gas whose properties can be represented using the ideal gas model according to

$$ P V = n \bar{R} = m R T $$

with $R = \dfrac{\bar{R}}{M}$

Also, the following specific data is provided and assigned to variables for calculations. Note that $T$ and $P$ must be absolute temperatures and pressures when using the ideal gas equation.

In [7]:
R_bar = 8.314 #kJ/(kmol K)
V_gas =  0.1 #m^3
m_gas = 7 #kg
P_gas = 2000 #kPa
T_gas = 80 + 273.15  #K

Find:

Molecular weight of the gas

Solution:

Solving for the specific gas constant using the ideal gas model results in

$$ R = \dfrac{P V}{m T} $$

Then $ M = \dfrac{\bar{R}}{R} $

In [8]:
R_gas = P_gas*V_gas/(m_gas*T_gas)
MW_gas = R_bar/R_gas
print('Molecular Weight, MW = ',round(MW_gas,2),'(kg/kmol)')
Molecular Weight, MW =  102.76 (kg/kmol)