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 = ""

The van der Waals equation of state for a gas is defined by:

\(\left(P + \frac{a}{V^2}\right)(V - b) = RT\)

where \(a\) and \(b\) are defined by:

\(a = \frac{27}{64}\left(\frac{R^2 T_c^2}{P_c}\right)\)

\(b = \frac{R T_c}{8 P_c}\)

In these equations, \(V\) is the molar volume, \(P\) is the pressure, and \(T\) is the temperature.

\(R\) is the gas constant, \(P_c\) is the critical pressure of the gas, and \(T_c\) is the critical temperature.

The compressibility factor is defined by \(Z = \frac{P V}{R T}\). You can think of this as a measure how ideal the gas is; if \(Z=1\) then it appears to be ideal.

For ammonia, \(P_c = 111.3\) atm, \(T_c = 405.5\) K, and in these units, \(R = 0.08206\) (atm L)/(mol K).

Use the information above to compute the compressibility factor at the following pressures at a temperature of 450 K:

P = 56, 111.3, 222.6, 445.2, 1113, 2226 atm.

For each pressure, print the following quantities in a roughly tabular form:

P, V, Z

Note

You should `scipy.optimize.root for this. It might be possible to solve this problem analytically, and if you want to do that to check your answer that is fine.


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