{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Question\n", "\n", "## 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. \n", "\n", "## The data below refer to dimethyl ether (methoxymethane, CH3OCH3) gas at 25 oC. \n", "\n", "### 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.\n", "\n", "### 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.\n", "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "

### 2.300

" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "slideshow": { "slide_type": "slide" } }, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "sns.set('poster', palette='colorblind')\n", "from scipy.optimize import curve_fit\n", "from scipy.constants import R\n", "\n", "def ideal_gas(rho, M):\n", " # convert celsius to Kelvin\n", " T = 25 + 273.15\n", " gradient = (R * T) / M\n", " p = gradient * rho\n", " return p" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "slide" } }, "outputs": [], "source": [ "C = 12.011\n", "H = 1.008\n", "O = 15.999\n", "print('Molecular mass of dimethyl ether = {:.2f} g'.format(2 * C + O + 6 * H))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "slide" } }, "outputs": [], "source": [ "p = np.array([12231, 25195, 36970, 60367, 85231, 101325])\n", "rho = np.array([0.232, 0.489, 0.733, 1.250, 1.870, 2.300])\n", "data_points = 6\n", "a = curve_fit(ideal_gas, rho[:data_points], p[:data_points])\n", "plt.figure(figsize=(15, 7)); plt.plot(rho, p, 'o', label='data')\n", "plt.plot(rho, ideal_gas(rho, a[0]), label='{}'.format(data_points))\n", "plt.xlabel('Density/kgm\$^{-3}\$'); plt.ylabel('Pressure/Pa'); plt.legend(); plt.show()\n", "print(\"data points={}; mass={:.2f} g; real mass={:.2f} g\".format(\n", " data_points, a[0][0] * 1000, 2 * C + O + 6 * H))" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "

# Back to slides

" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "skip" } }, "outputs": [], "source": [] } ], "metadata": { "celltoolbar": "Slideshow", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" }, "latex_envs": { "LaTeX_envs_menu_present": true, "autoclose": false, "autocomplete": true, "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 1, "hotkeys": { "equation": "Ctrl-E", "itemize": "Ctrl-I" }, "labels_anchors": false, "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": false } }, "nbformat": 4, "nbformat_minor": 2 }