Before you turn this problem in, make sure everything runs as expected. First, restart the kernel (in the menubar, select Kernel\(\rightarrow\)Restart) and then run all cells (in the menubar, select Cell\(\rightarrow\)Run All).
Make sure you fill in any place that says YOUR CODE HERE or “YOUR ANSWER HERE”, as well as your name and collaborators below:
NAME = ""
COLLABORATORS = ""
In the book Problem solving in chemical and biochemical engineering with POLYMATH, Excel and Matlab by Cutlip and Shacham there is a problem (7.1) where you want to plot the compressibility factor for CO2 over a range of 0.1≤Pr<=10. To do this, we need to know how the volume varies with Pr for a constant Tr=1.1 using the van der Waal equation of state.
The van der Waal equation of state is:
\(P=\frac{RT}{V−b}−\frac{a}{V^2}\)
We define the reduced pressure as Pr=P/Pc, and the reduced temperature as Tr=T/Tc.
The approach we consider is to derive an expression for \(dV/dPr\). We proceed as follows:
\(\frac{dV}{dPr} = \frac{dV}{dP} \frac{dP}{dPr}\).
The first term on the right is also \((\frac{dP}{dV})^{-1}\) which we can derive from the van der Waal equation. The second term on the right is just a constant from the definition of the reduced pressure.
With some work you can derive this differential equation:
\(\frac{dP}{dV} = -\frac{RT}{(V-b)^2} + \frac{2a}{V^3}\)
Combine this information to derive the required ODE \(\frac{dV}{dPr}\) and express it in one or more functions in Python.
We are given an initial condition: at Pr=0.1, Tr=1.1, V=3.676.
Use this information to calculate V as a function of Pr by integrating the differential equation you derived in the previous step. Here is some additional information you need.
R = 0.08206 # gas constant
Pc = 72.9 # critical pressure
Tc = 304.2 # critical temperature
a = 27 * R**2 * Tc**2 / (Pc * 64)
b = R * Tc / (8 * Pc)
Tr = 1.1
Finally, the compressibility is defined as \(Z = \frac{P V}{R T}\). Plot the compressibility as a function of Pr.
Your solution should look like
.
When you are done, download a PDF and turn it in on Canvas. Make sure to save your notebook, then run this cell and click on the download link.
%run ~/f23-06623/f23.py
%pdf