ME 200 – Thermodynamics I – Spring 2020

Homework 5: Boundary Work

Part (i): Boundary Work - Spring and Piston

Part (ii): Boundary Work - Polytropic Process

Part (i): Boundary Work - Spring and Piston

Given:

Air is contained within a piston-cylinder system as shown below. Initially, a linear spring inside the cylinder is not compressed by the piston. Then, an external force on the piston slowly compresses the gas and spring until the volume is half the original, Throughout the process, the gas in the cylinder is held at constant temperature. Additional data are given in the code window below.

In [1]:
#Given Inputs
import math
A_p = 0.005 # piston cross-sectional area, [m^2]
P_atm = 100 # atmospheric pressure, [kPa]
V_1 = 0.0002 # initial volume of gas, [m^3]
V_2 = V_1/2 # final volume of gas, [m^3]
k_spring = 50 # spring constant, [kN/m]

Find:

(a) P-V diagram for the gas \ (b) Sketch of the force per unit piston area, $F/A_p$, versus V exerted by the piston on the spring-gas system with numerical values at each end of the process.\ (c) Work (kJ) done by the piston on the spring-gas system\ (d) Work (kJ) done by the external force on the piston

Assumptions:

1) piston is weightless and frictionless, 2) quasi-equilibrium compression process, 3) ideal gas for air

System Sketch:

Basic Equations:

$$\Sigma F=0, P = \dfrac{F}{A}, PV = mRT, W = \int{Fdx}, W = \int{PdV}$$

Solution:

(a) P-V diagram for the gas

It is necessary to develop an expression for how pressure (P) varies with volume (V) and to determine the initial and final states. At the initial condition, there is no external force ($F_{in}=0$) and the spring force is zero ($F_{spring}=0$). Thus, a static force balance on the piston (see free body diagram) gives

$$F_{atm} = F_{air,1} \rightarrow P_{atm}A_p = P_{air,1}A_p \rightarrow P_{air,1} = P_{atm}$$

Then

In [2]:
P_air_1 = P_atm
print('P_air_1 = ',round(P_air_1,2),'kPa')
P_air_1 =  100 kPa

During the process, the temperature is constant. Then, for an ideal gas within a closed system (gas is the system with $m$ = constant), $PV = mRT$ = constant. Thus,the pressure varies inversely with volume during the process according to

$$P_{air} = P_{air,1}\dfrac{V_1}{V}$$

and the final pressure is

In [3]:
P_air_2 = P_air_1*V_1/V_2
print('P_air_2 = ',round(P_air_2,2),'kPa')
P_air_2 =  200.0 kPa

The P-V diagram for the process that the air undergoes between initial and final states is shown below. Pressure is non-linear with volume, but the non-linearity is not severe within the range of volumes considered.

In [4]:
# General imports for plotting
from matplotlib import pyplot as plt
import matplotlib.ticker as mticker
import numpy as np
%matplotlib inline

#Create an array for V and P
V = np.linspace(V_2,V_1,100,endpoint = True)
P = P_air_1*V_1/V

# P-V plot
fig1 = plt.figure()
ax1 = fig1.add_axes([0,0,1,1])

#Plot the solutions
ax1.plot([V_2,V_1],[P_air_2,P_air_1],'ob',ms = 6)

#Plot the behavior
ax1.plot(V,P,'r',lw = 1)

#Add plotting options
ax1.set_xlim(0,0.0003)
ax1.set_ylim(0,250)
ax1.set_title('P-V Diagram')
ax1.set_xlabel(r'V [m$^3$]')
ax1.set_ylabel('P [kPa]')
ax1.text(V_1*0.95,P_air_1*1.2,r'(P$_1$,V$_1$)',fontsize=12)
ax1.text(V_2,P_air_2*1.1,r'(P$_2$,V$_2$)',fontsize=12)
Out[4]:
Text(0.0001, 220.00000000000003, '(P$_2$,V$_2$)')

(b) Piston force per unit piston area, $F/A_p$, versus V

For a quasi-equilibrium process, the net force acting against the piston by the spring-gas system during the compression process results from a static force balance at the interface between the piston and the spring-gas system, such that

$$F_p = P_{air}A_p + k_{spring}x_{spring}$$

However, for a cylinder $x_{spring} = (V_1 - V)/A_p$. Therefore,

$$P_p = \dfrac{F_p}{A_p} = P_{air,1}\dfrac{V_1}{V }+ k_{spring}\dfrac{V_1 - V}{A_p^2}$$

The above relationship describes how the piston force per unit area increases with decreasing volume from 0 to a final pressure of $P_{p,2}$. The final pressure and resulting plot are given below.

In [5]:
P_p_2 =P_air_2 + k_spring*(V_1 - V_2)/A_p**2
print('P_p_2 = ',round(P_p_2,5),'kPa')
P_p_2 =  400.0 kPa
In [6]:
#Create an array for Fp/Ap
P_p = P_air_1*V_1/V + k_spring*(V_1 - V)/A_p**2

# Piston force plot
fig2 = plt.figure()
ax2 = fig2.add_axes([0,0,1,1])

#Plot the solutions
ax2.plot([V_1,V_2],[P_air_1,P_p_2],'db',ms = 8,mfc = 'none')

#Plot the behavior
ax2.plot(V,P_p,'r-',lw = 1)

#Plotting options
ax2.set_xlim(0,0.0003)
ax2.set_ylim(0,500)
ax2.set_title('Piston Force Diagram')
ax2.set_xlabel(r'V [m$^3$]')
ax2.set_ylabel('F$_p$/A$_p$ [kPa]')
ax2.text(V_1*0.95,40,r'(P$_{p,1}$,V$_1$)',fontsize=12)
ax2.text(V_2,P_p_2*1.1,r'(P$_{p,2}$,V$_2$)',fontsize=12)
Out[6]:
Text(0.0001, 440.00000000000006, '(P$_{p,2}$,V$_2$)')

(c) Work (kJ) done by the piston on the spring-gas system

The work done by the piston on the spring-gas system ($W_p$) is due to the piston force ($F_p$) acting through a distance

$$W_{p,12} = -\int\limits_{x_1}^{x_2}F_pdx = -\int\limits_{V_1}^{V_2}\dfrac{F_p}{A_p}dV = -\int\limits_{V_1}^{V_2}\left(P_{air,1}\dfrac{V_1}{V }+ k_{spring}\dfrac{V_1 - V}{A_p^2}\right)dV$$

Then

$$W_{p,12} = -P_{air,1}V_1\ln \left(\dfrac{V_2}{V_1}\right) + \dfrac{1}{2{A_p}^2}k_{spring}\left(V_1-V_2\right)^2$$

The result is implemented in the following code window to determine the work.

In [7]:
W_air_12 = -P_air_1*V_1*math.log(V_2/V_1)        # portion of piston work done on air in the cylinder, [kJ]
W_spring_12 =  0.5*k_spring*(V_1-V_2)**2/A_p**2  # portion of piston work done on the spring. [kJ]
W_p_12 = W_air_12 + W_spring_12                  # piston work done on spring-gas system, [kJ]
print('W_p_12 = ',round(W_p_12,4),'kJ')
W_p_12 =  0.0239 kJ

(d) Work (kJ) done by the external force on the piston

From a static force balance on the piston, the external applied force is

$$F_{in} = F_p - P_{atm}A_p$$

Then, the work done by the external force is

$$W_{in,12} = \int\limits_{x_1}^{x_2}F_{in}dx = \int\limits_{x_1}^{x_2}F_pdx - \int\limits_{x_1}^{x_2}P_{atm}A_pdx = W_{p,12} + \int\limits_{V_1}^{V_2}P_{atm}dV = W_{p,12}+P_{atm}\left(V_2-V_1\right)$$
In [8]:
W_atm_12 = P_atm*(V_2 - V_1)           # work done on piston by atmosphere, [kJ]
W_in_12 = W_p_12 + W_atm_12            # work done by external force on the piston, [kJ]
print('W_in_12 = ',round(W_in_12,5),'kJ')
W_in_12 =  0.01386 kJ

Part (ii): Boundary Work - Polytropic Process

Given:

A polytropic expansion process ($PV^n$ = constant) with:

In [9]:
# Given inputs

V_1 = 0.040 # initial volume, [m^3]
V_2 = 0.100 # final volume, [m^3] 
P_1 = 200   # initial pressure, [kPa]

Find:

Work for the process (kJ) for three cases:\ (a) $n=0$\ (b) $n=1$\ (c) $n=1.3$ Sketch all 3 processes on a P-V diagram.

System Sketch:

Basic Equations:

$$W = \int{PdV}$$

Solution:

(a) $n=0$

With $n=0$, $PV^n=P=P_1=P_2$. Thus, the boundary work is

$$W_{12} = \int\limits_{V_1}^{V_2}{PdV}=P_1(V_2-V_1)$$
In [10]:
P_2_a = P_1
W_12_a = P_1*(V_2 - V_1)
print('W_12_a = ',round(W_12_a,4),'kJ')
W_12_a =  12.0 kJ

(b) $n = 1$

With $n = 1$, $PV = constant = P_1V_1 = P_2V_2$ . Therefore, $P = P_1V_1/V$ such that

$$ W_{12} = \int\limits_{V_1}^{V_2}{PdV}=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) $$
In [11]:
P_2_b = P_1*V_1/V_2
W_12_b = P_1*V_1*math.log(V_2/V_1)
print('W_12_b = ',round(W_12_b,3),'kJ')
W_12_b =  7.33 kJ

(c): $n = 1.3$

For $n > 1, PV^n = P_1V_1^n = P_2V_2^n$, such that $P = P_1(V_1/V)^n$ and

$$ W_{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_2 V_2-P_1 V_1}{1-n} $$
In [12]:
n = 1.3
P_2_c = P_1*(V_1/V_2)**n
W_12_c = (P_2_c*V_2 - P_1*V_1)/(1 - n)
print('W_12_c = ',round(W_12_c,2),'kJ')
W_12_c =  6.41 kJ

The P-V diagrams are shown below.

In [13]:
#Create an arrays for the three cases
V = np.linspace(V_2,V_1,100,endpoint = True)

#Case a
n_a = 0
P_a = P_1*(V_1/V)**n_a

#Case b
n_b = 1
P_b = P_1*(V_1/V)**n_b

#Case c
n_c = 1.3 
P_c = P_1*(V_1/V)**n_c

# P-V plots
fig3 = plt.figure()
ax3 = fig3.add_axes([0,0,1,1])

#Plot P-V n = 0
ax3.plot(V,P_a,'r-',lw = 1, label = 'n=0')

#Plot P-V n = 1
ax3.plot(V,P_b,'b-.',lw = 1, label = 'n=1')

#Plot P-V n = 1.3
ax3.plot(V,P_c,'k--',lw = 1, label = 'n=1.3')

#Add plotting options
#ax1.set_ylim(0,250)
ax3.set_title('P-V Diagram')
ax3.set_xlabel(r'V [m$^3$]')
ax3.set_ylabel('P [kPa]')
ax3.legend(loc=0)
Out[13]:
<matplotlib.legend.Legend at 0x114ac36d0>