Contents

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

Here are some alternative approaches to getting a reasonable looking tabular output.

import tabulate

data = [['P (atm)', 'V (L/mol)',   'Z']]

for p in [56, 111.3, 222.6, 445.2, 1113, 2226]:
    sol = root(vdw_zero, 0.5, args=(p,))
    
    V = sol.x[0]
    Z = p * V / R / T
    data += [[p, V, Z]]
    
print(tabulate.tabulate(data, headers='firstrow'))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[2], line 6
      3 data = [['P (atm)', 'V (L/mol)',   'Z']]
      5 for p in [56, 111.3, 222.6, 445.2, 1113, 2226]:
----> 6     sol = root(vdw_zero, 0.5, args=(p,))
      8     V = sol.x[0]
      9     Z = p * V / R / T

NameError: name 'root' is not defined
import pandas as pd

data = []

for p in [56, 111.3, 222.6, 445.2, 1113, 2226]:
    sol = root(vdw_zero, 0.5, args=(p,))
    
    V = sol.x[0]
    Z = p * V / R / T
    data += [[p, V, Z]]
    
pd.DataFrame(data, columns=['P (atm)', 'V (L/mol)',   'Z'])
P (atm) V (L/mol) Z
0 56.0 0.574892 0.871827
1 111.3 0.233509 0.703808
2 222.6 0.077268 0.465777
3 445.2 0.060654 0.731261
4 1113.0 0.050875 1.533409
5 2226.0 0.046175 2.783482
# Run this cell to generate a pdf from this notebook
# Click the generated links to preview and download it.
# Report errors to Professor Kitchin
from f22_06623 import pdf
%pdf