Question

Reorganise the ideal gas equation by substituting in the molar mass, M, and the mass density, ρ, of the gas to give a relationship between the pressure and the density.

The data below refer to dimethyl ether (methoxymethane, CH3OCH3) gas at 25 oC.

a) Plot a graph of the data to demonstrate whether the gas acts as an ideal gas. Comment on the graph and the behaviour of the gas.

b) From the results, calculate the relative molar mass of the gas and compare it with the value obtained by adding up the relative atomic masses.


p/Pa

12231

25195

36970

60367

85231

101325

ρ/kgm-3

0.232

0.489

0.733

1.250

1.870

2.300

In [1]:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set('poster', palette='colorblind')
from scipy.optimize import curve_fit
from scipy.constants import R

def ideal_gas(rho, M):
    # convert celsius to Kelvin
    T = 25 + 273.15
    gradient  = (R * T) / M
    p = gradient * rho
    return p
In [ ]:
C = 12.011
H = 1.008
O = 15.999
print('Molecular mass of dimethyl ether = {:.2f} g'.format(2 * C + O + 6 * H))
In [ ]:
p = np.array([12231, 25195, 36970, 60367, 85231, 101325])
rho = np.array([0.232, 0.489, 0.733, 1.250, 1.870, 2.300])
data_points = 6
a = curve_fit(ideal_gas, rho[:data_points], p[:data_points])
plt.figure(figsize=(15, 7)); plt.plot(rho, p, 'o', label='data')
plt.plot(rho, ideal_gas(rho, a[0]), label='{}'.format(data_points))
plt.xlabel('Density/kgm$^{-3}$'); plt.ylabel('Pressure/Pa'); plt.legend(); plt.show()
print("data points={}; mass={:.2f} g; real mass={:.2f} g".format(
    data_points, a[0][0] * 1000, 2 * C + O + 6 * H))
In [ ]: