{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "###### The latest version of this notebook is available at [http://github.com/jckantor/CBE20255](http://github.com/jckantor/CBE20255) for noncommercial use under terms of the [Creative Commons Attribution Noncommericial ShareAlike License](http://creativecommons.org/licenses/by-nc-sa/4.0/).\n", "\n", "J.C. Kantor (Kantor.1@nd.edu)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Classroom Air Quality\n", "\n", "This notebook demonstrates several routine chemical calculations in the context of a hypothetical air quality analysis for a classroom." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem Statement\n", "\n", "Imagine the classroom is suddenly sealed off from the external world. Doors are sealed, the ventilation is cut off. How long could we hold out before we reach a point of inadequate air quality? What about real danger?\n", "\n", "We want to avoid a situation like this (image from the classic submarine movie [Das Boot (1981)](https://www.imdb.com/title/tt0082096/)):\n", "\n", "![](../images/DasBoot.jpg)\n", "\n", "Assumptions:\n", "\n", "* The classroom is 20 meters wide, 12 meters deep, and 3 meters high.\n", "* The class consists of 81 students plus one instructor.\n", "* The composition of dry air is 20.95 mole% $O_2$, 78.09 mole per cent $N_2$, and 0.04 mole percent $CO_2$. The remainder is inerts which can be combined with $N_2$ for the purposes of this analysis.\n", "* According to NASA, an average person needs 0.84 kg of oxygen per day.\n", "* For each molecule of $O_2$ consumed, approximately one molecule of $CO_2$is produced.\n", "* According to NIOSH standards, adequate ventilation requires a $CO_2$ level no more than 1,000 ppmv, and an oxygen level greater than 19.5%.\n", "* \n", "* Humans require an oxygen level of at least 17.5 mole per cent.\n", "* Carbon dioxide levels above 1 mole per cent lead to drowsiness and headaches.\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Solution\n", "\n", "### Step 1. Volume of the room\n", "\n", "The volume of the room is \n", "\n", "$$ V = 20 \\mbox{m} \\times 12 \\mbox{m} \\times 3 \\mbox{m} = \\fbox{720} \\mbox{ m}^3$$\n", "\n", "### Step 2. Initial Molar Quantities\n", "\n", "By the ideal gas law, the total moles of air present in the room is given by\n", "\n", "$$n_\\mbox{air} = \\frac{PV}{RT} = \\frac{101,325 \\mbox{Pa} \\times 720\\mbox{m}^3}{8.314\\frac{\\mbox{Pa}\\cdot\\mbox{m}^3}{\\mbox{gmol}\\cdot\\mbox{K}} \\times 298.16\\mbox{K} } = \\fbox{29,430}\\mbox{ gmol of air}$$ \n", "\n", "### Step 2. Mole Fractions of a Mixture\n", "\n", "Air is a mixture of gases. We use $y_n$ to denote the fraction of all molecules in the mixture that are of type $n$. For this problem\n", "\n", "| Species | Mole Fraction | Value |\n", "| :---: | :-----------: | :---: |\n", "| $O_2$ | $y_{O_2}$ | 0.21 |\n", "| $N_2$ | $y_{N_2}$ | 0.79 |\n", "| $CO_2$ | $y_{CO_2}$ | 0.00 |\n", "| Total | | 1.00 |\n", "\n", "One of these is unknown? How can we find a value for $y_{Ar}$?\n", "\n", "The key is recognize that mole fractions must sum to one, that is\n", "\n", "$$\\sum_{n=1}^N y_n = 1$$\n", "\n", "For this problem\n", "\n", "$$ y_{O_2} + y_{N_2} + y{CO_2} + y_{Ar} = 1 $$\n", "\n", "Solving for $y_{Ar}$\n", "\n", "\\begin{align*}\n", "y_{Ar} & = 1 - y_{O_2} - y_{N_2} - y{CO_2} \\\\\n", "& = 1 - 0.21 - 0.78 - 0.003 = \\fbox{0.007}\n", "\\end{align*}\n", "\n", "We can use this to complete this table of mole fractions for this mixture.\n", "\n", "| Species | Mole Fraction | Value |\n", "| :---: | :-----------: | :---: |\n", "| $O_2$ | $y_{O_2}$ | 0.21 |\n", "| $N_2$ | $y_{N_2}$ | 0.78 |\n", "| $CO_2$ | $y_{CO_2}$ | 0.003 |\n", "| $Ar$ | $y_{Ar}$ | 0.007 |\n", "\n", "### Step 3. Molecular Mass of a Mixture\n", "\n", "Air is a mixture of gases. We use $y_i$ to denote the fraction of all molecules in the mixture that are of type $i$. For this problem\n", "\n", "| Species | Mole Fraction | Value | MW |\n", "| :-----: | :-----------: | :---: | :--: |\n", "| $O_2$ | $y_{O_2}$ | 0.21 | 32.0 |\n", "| $N_2$ | $y_{N_2}$ | 0.78 | 28.0 |\n", "| $CO_2$ | $y_{CO_2}$ | 0.003 | 44.0 |\n", "| $Ar$ | $y_{Ar}$ | 0.007 | 39.9 |\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Average Molecular Mass of Air = 28.9713\n" ] } ], "source": [ "yO2 = 0.21\n", "yN2 = 0.78\n", "yCO2 = 0.003\n", "yAr = 0.007\n", "\n", "MO2 = 32.0\n", "MN2 = 28.0\n", "MCO2 = 44.0\n", "MAr = 39.9\n", "\n", "Mair = yO2*MO2 + yN2*MN2 + yCO2*MCO2 + yAr*MAr\n", "\n", "print(\"Average Molecular Mass of Air =\", Mair)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 2. Density of a Gas\n", "\n", "The ideal gas law reads \n", "\n", "$$PV = nRT$$\n", "\n", "The molar density of a gas is given by\n", "\n", "$$ \\frac{n}{V} = \\frac{P}{RT} $$\n", "\n", "The mass density of a gas is given by\n", "\n", "$$ \\rho = M \\frac{n}{V} = M \\frac{P}{RT}$$\n", "\n", "where $M$ refers to molecular mass." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This problem requires us to perform a material balance for CO2 in the atmosphere. We'll perform the using a 10 step approach outlined in the textbook." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 1. Draw a diagram." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 2. Define the system of interest." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The system of interest is the global atmosphere which we assume is well mixed and of uniform composition." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 3. Choose components and define stream variables." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The chemical component to model is CO2. The stream variables are the mass flowrates of CO2 into and out of the atmosphere." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 4. Convert all units to consistent units of mass or moles." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This problem could be done on either a molar or mass basis. We'll arbitrarily choose to do this in mass units of kg/year. First we convert global emissions to kg/year." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "ename": "SyntaxError", "evalue": "invalid syntax (, line 3)", "output_type": "error", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m3\u001b[0m\n\u001b[0;31m print \"Global CO2 emissions = {:8.3g} kg/yr\".format(mCO2_in)\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" ] } ], "source": [ "mCO2_in = 34.5e9 # inflow, metric tonnes per year\n", "mCO2_in = mCO2_in*1000 # inflow, kg per year\n", "print \"Global CO2 emissions = {:8.3g} kg/yr\".format(mCO2_in)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The rate of accumulation is given as ppm by volume per year. For ideal gases, volume fraction is equivalent to mole fraction. We need to convert the mole fraction, which is the ratio of kg-moles of CO2 to kg-moles of air, to mass fraction which has units of kg of CO2 to kg of air per year." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Accumulation Rate of CO2 = 3.65e-06 kg CO2/kg air\n" ] } ], "source": [ "nCO2_accum = 2.4e-6 # accumulation, kg-mol CO2/kg-mol air/yr\n", "\n", "mwAir = 28.97 # kg air/kg-mol air\n", "mwCO2 = 44.01 # kg CO2/kg-mol CO2\n", "\n", "wCO2_accum = nCO2_accum*mwCO2/mwAir # kg CO2/kg air/yr\n", "\n", "print \"Accumulation Rate of CO2 = {:8.3g} kg CO2/kg air\".format(wCO2_accum)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 5. Define a basis." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The basis for the calculation are flows and change in one year. No additional work is required." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 6. Define system variables." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The system variable is the rate of accumulation of CO2 in kg CO2/year. We need to convert from change in concentration per year to change in total mass per year. The first step is to estimate the total mass of air." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Estimated mass of the atmosphere = 5.27e+18 kg\n" ] } ], "source": [ "# Earth Radius in meters\n", "R = 6371000 # m\n", "\n", "# Earth Area in square meters\n", "A = 4*pi*R**2 # m**2\n", "\n", "# Mass of the atmosphere in kg\n", "g = 9.81 # N/kg\n", "P = 101325 # N/m**2\n", "mAir = A*P/g # kg\n", "\n", "print \"Estimated mass of the atmosphere = {:8.3g} kg\".format(mAir)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To get the rate of change of total CO2, multiply the total mass of by the rate of change of mass fraction of CO2." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Change in CO2 = 1.92e+13 kg CO2/year\n" ] } ], "source": [ "mCO2_accum = wCO2_accum*mAir # kg CO2/year\n", "\n", "print \"Change in CO2 = {:8.3g} kg CO2/year\".format(mCO2_accum)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 7. List specifications" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The inflow and rate of change of CO2 are specified, and calculated above." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 8. Write material balance equations for each species." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$\\mbox{Accumulation} = \\mbox{Inflow} - \\mbox{Outflow} + \\underbrace{\\mbox{Generation}}_{=0} - \\underbrace{\\mbox{Consumption}}_{=0}$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 9. Solve material balance equations." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$\\mbox{Outflow} = \\mbox{Inflow} - \\mbox{Accumulation}$$" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Global CO2 outflow = 1.53e+13 kg CO2/yr\n" ] } ], "source": [ "mCO2_out = mCO2_in - mCO2_accum\n", "\n", "print \"Global CO2 outflow = {:8.3g} kg CO2/yr\".format(mCO2_out)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 10. Check your work." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Fraction retained in the atmosphere" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Fraction of CO2 retained in the atmosphere = 0.56 \n" ] } ], "source": [ "fCO2 = mCO2_accum/mCO2_in\n", "print \"Fraction of CO2 retained in the atmosphere = {:<.2g} \".format(fCO2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "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.5" } }, "nbformat": 4, "nbformat_minor": 2 }