# Question¶

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

### 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
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 [ ]: