{ "cells": [ { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "_NQmCvCoBG-H" }, "source": [ "\n", "*This notebook contains course material from [CBE20255](https://jckantor.github.io/CBE20255)\n", "by Jeffrey Kantor (jeff at nd.edu); the content is available [on Github](https://github.com/jckantor/CBE20255.git).\n", "The text is released under the [CC-BY-NC-ND-4.0 license](https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode),\n", "and code is released under the [MIT license](https://opensource.org/licenses/MIT).*" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "Om81BYbeBG-J" }, "source": [ "\n", "< [Units, Quantities, and Engineering Calculations](http://nbviewer.jupyter.org/github/jckantor/CBE20255/blob/master/notebooks/01.00-Units-Quantities-and-Engineering-Calculations.ipynb) | [Contents](toc.ipynb) | [Units and Conversions for Home Heating](http://nbviewer.jupyter.org/github/jckantor/CBE20255/blob/master/notebooks/01.02-Units-and-Conversions-for-Home-Heating.ipynb) >

" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "VjocRulUBG-J", "slideshow": { "slide_type": "slide" } }, "source": [ "# Units and Engineering Calculations" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "nMF5VVHUBG-K" }, "source": [ "## Summary\n", "\n", "The purpose of this [Jupyter notebook](http://jupyter.org/notebook.html) is to get you started with units and engineering calculations. \n", "\n", "Things to master:\n", "\n", "* Unit systems\n", "* Unit conversions\n", "* Difference between mass and weight, and the difference between kg-m, kg-f, and lbm and lbf\n", "* Concept of mole, and the difference between g-mol, kg-mol, and any other kind of mole\n", "* Absolute versus Gauge Pressure\n", "* Typical values of temperature and pressure in real-world applications\n", "* Working with units in python using the pint library." ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "V7VnI3PuBG-L" }, "source": [ "## Units of Engineering" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "V7VnI3PuBG-L" }, "source": [ "### The Fundamental Units of Measurement\n", "\n", "There are seven fundamental units in the Système International d'Unités (SI) system, all other unit can be generated from these.\n", "\n", "| Dimension | SI Units | CGS | English |\n", "| :------- | :--- | :----- | :------ |\n", "| Mass | kilogram (kg) | gram (g) | lb-mass, slug |\n", "| Length | meter (m) | centimeter (cm) | inch (in); foot (ft) |\n", "| Time | second (s) | second (s) | second (sec) |\n", "| Temperature | degree Kelvin (K) | degree Celsius (°C) | degree Rankine (°R) |\n", "| Quantity | mole (gmol) | mole (gmol) | mole (gmol) |\n", "| Current | Ampere (A) | abampere | |\n", "| Luminous Intensity | candela (cd) | stlib [luminance] | candlepower, etc. |" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "CGLfVvo1BG-M" }, "source": [ "> **Exercise.** Give an everyday example of something with about 1 SI unit of the corresonding dimension." ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "m0RkeH9SBG-N" }, "source": [ "### Coherent Derived Units\n", "\n", "The SI system describes 22 'derived units' that are expressed in terms of the fundamental units. The following diagram from [NIST illustrates the relationship among the SI units](http://physics.nist.gov/cuu/Units/SIdiagram.html).\n", "\n", "![](http://physics.nist.gov/cuu/Units/i/SubwayDiagram.gif)\n", "\n", "Calculations with coherent units is straightforward since they involve just ratios or products of base units. The calculations break down into three steps:\n", "\n", "1. Recast all of the problem quantities in base or coherent derived units.\n", "2. Perform the numerical calculations.\n", "3. Using algebraic rules for the cancelation of terms, simplify and reduce units to units relevant to the context of the problem." ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "MGYOVZqwBG-N" }, "source": [ ">**Example:** The kinetic energy of a object with mass $m = 3\\ \\mbox{kg}$ traveling at velocity $v = 10 \\ \\mbox{m/s}$ is given by\n", ">\n", ">\\begin{align*}\n", "K.E. & = \\frac{1}{2} mv^2 \\\\\n", "& = \\frac{1}{2} \\left(3\\ \\mbox{kg}\\right)\\left( 10 \\frac{\\mbox{m}}{\\mbox{s}}\\right)^2 \\\\\n", "& = 150 \\ \\frac{\\mbox{kg}\\cdot\\mbox{m}^2}{\\mbox{s}^2}\n", "= 150 \\ \\mbox{N}\\cdot\\mbox{m}\n", "= \\fbox{150 J}\n", "\\end{align*}" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "FrtLVsgbBG-O" }, "source": [ "> **Example:** What is the mass of air in a spherical balloon with radius of 10 cm inflated to 1 atm at 25 degrees Celsius? Assume the molecular weight of air is 28.966 grams/mole, and that atmospheric pressure is 101,325 Pa.\n", ">\n", "> _Solution:_ Start by converting all of the quantities in the problem to base or derived units.\n", ">\n", "> $$MW_{air} = 28.966\\ \\frac{\\mbox{g}}{\\mbox{mol}} = 0.028966\\ \\frac{\\mbox{kg}}{\\mbox{mol}}$$\n", ">\n", "> $$P = 101,325\\ \\mbox{Pa} = 101,325\\ \\frac{\\mbox{N}}{\\mbox{m}^2} = 101,325\\ \\frac{\\mbox{kg}}{\\mbox{m}\\cdot\\mbox{s}^2}$$\n", ">\n", "> $$V = \\frac{4}{3}\\pi r^3 = \\frac{4}{3}\\pi \\left( 0.10\\ \\mbox{m}\\right)^3 = 0.004189\\ \\mbox{m}^3$$\n", ">\n", "> $$R = 8.314 \\frac{\\mbox{J}}{\\mbox{K}\\cdot\\mbox{mol}} = 8.314 \\frac{\\mbox{kg}\\cdot\\mbox{m}^2}{\\mbox{s}^2\\cdot\\mbox{K}\\cdot\\mbox{mol}}$$\n", ">\n", "> $$T = 25 + 273.15 = 298.15 K$$ \n", ">\n", "> Using molecular weight and the ideal gas law\n", ">\n", "> $$m_{air} = MW_{air} n_{air} = MW_{air}\\frac{PV}{RT}$$\n", "> \n", "> Substituting quantities into this expression for $m_{air}$\n", ">\n", "> \\begin{align*}\n", " m_{air} & = \\left(0.028966\\ \\frac{\\mbox{kg}}{\\mbox{mol}}\\right) \n", " \\frac{\\left(101,325\\ \\frac{\\mbox{kg}}{\\mbox{m}\\cdot\\mbox{s}^2}\\right)\\left(0.004189\\ \\mbox{m}^3\\right)}{\\left(8.314 \\frac{\\mbox{kg}\\cdot\\mbox{m}^2}{\\mbox{s}^2\\cdot\\mbox{K}\\cdot\\mbox{mol}}\\right)\\left(298.15\\ \\mbox{K}\\right)} \\\\\n", " & = \\frac{0.028966 \\cdot 101,325 \\cdot 0.004189}{8.314 \\cdot 298.15} \\times \\frac{\\frac{\\mbox{kg}}{\\mbox{mol}}\\cdot\\frac{\\mbox{kg}}{\\mbox{m}\\cdot\\mbox{s}^2}\\cdot\\mbox{m}^3}{\\frac{\\mbox{kg}\\cdot\\mbox{m}^2}{\\mbox{s}^2\\cdot\\mbox{K}\\cdot\\mbox{mol}} \\cdot \\mbox{K}}\\\\\n", " & = \\fbox{0.00496 kg}\n", " \\end{align*}" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "W5Guzcd4BG-P" }, "source": [ "### Non-Coherent Derived Units\n", "\n", "Coherent units are easy to work with because no numerical factors are required to express them in terms of the base units. On the other hand, working with such a limited set of units makes it difficult to express commonly quantities in easy-to-remember numbers or do back-of-the-envelop calculations. Having to write a multiple of 101,325 Pa to express commonly encountered pressures is just asking for computational errors.\n", "\n", "Non-coherent derived units are quantities that can be expressed in terms of a numerical factor and product or ratio of base units. Here are some common examples:" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "pHVfCSNnBG-Q" }, "source": [ "## Absolute versus Offset Scales\n", "\n", "For the purpose of applying the ideal gas law, what is the air pressure in this tire?\n", "\n", "![Tire_pressure_gauge.jpg](https://raw.githubusercontent.com/jckantor/CBE20255/master/notebooks/figures/Tire_pressure_gauge.jpg)\n", "\n", "The quantities used in most scientific calculations are measured on absolute scales, such as mass and length. On a absolute scale, a value of zero implies the absence of the underlying quantity. Something with zero mass has no mass, something with zero length means it has no length. \n", "\n", "Some common engineering measurements, however, are reported 'relative to' or 'offset from' a reference value. For example, degrees Celsius measures temperature relative to the melting point of ice; degrees Fahrenheit measures temperature relative to a brisk winter day. In the figure above, tire pressure is being measured relative to pressure of the surrounding air. This is called the 'gauge pressure' because that is what is being measured by the pressure gauge.\n", "\n", "The offsets result in numerical values convenient for common everyday use, but introduce an additional consideration (and source of errors!) for engineering calculations.\n", "\n", "Examples of offset scales include:\n", "\n", "* Degrees Celsius\n", "* Degrees Fahrenheit\n", "* Gauge Pressure (pressure relative to normal atmospheric pressure). \n", "* Enthalpy and Free Energy of Formation (energy required to form a substance relative to standard laboratory conditions.)\n", "* Calendar dates (days relative to start of the Common Era)\n", "\n", "Engineers sometimes distinguish absolute and gauge pressures by adding an explicit suffix. In particular, psia refers to 'pounds per square inch absolute', while psig refers to 'pounds per square inch gauge'. Non-engineers almost never make these distinction, so you need to be very careful when interpreting information given to you! It's always your responsibility to resolve any ambiguity in the data given to you for analysis.\n", "\n", "The misuse of pressure and temperature scales is a common source of errors in engineering calculations." ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "fUrJLX2YBG-Q" }, "source": [ "> **Example:** A football is inflated to 12.5 psig (pounds per square in gauge) at\n", "> 70 degrees F. The football is taken to play outdoors at 40 degrees F. Using the \n", "> gas law,\n", ">\n", "> $$P_2/T_2 = P_1/T_1$$\n", ">\n", "> what is the pressure of the football at playing conditions?\n", ">\n", "> _Solution:_ The ideal gas law assumes quantities are given in absolute units. \n", "> The problem statement, however, gives conditions in offset units. In this case,\n", "> 0 degrees Farhenheit is 459.67 in absolute (Rankine) units, and 0 psig is \n", "> 14.696 psia in absolute units. Incorporating the offsets the gas law reads\n", ">\n", "> $$\\frac{P_2 + 14.696}{40 + 459.67} = \\frac{12.5 + 14.696}{70 + 459.67}$$\n", ">\n", "> Solving for $P_2$\n", ">\n", "> $$P_2 = \\frac{40+459.67}{70+459.67}(12.5 + 14.696) - 14.696 = 10.96\\ \\mbox{psig}$$" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "OtTR70quBG-R" }, "source": [ "## Extensive versus Intensive Quantities\n", "\n", "An important distinction among measured quantities arises when we consider what happens when combining systems under consideration. For example, mixing two identical one-liter containers of an acidic solution yields two liters of the solution, twice the mass of solution, and twice the number of molecules of all types. If the solutions were at a high temperature, the result would have twice the thermal energy content. Quantities that _scale_ in direct proportion to the size of sytem are _extensive_ quantities. \n", "\n", "Other quantities, such as the temperature of the mixture, concentration of acid in the mixture, or vapor pressure are independent of the size of a system. Quantities that do not scale with the size are _intensive_ quantities.\n", "\n", "This distinction is fundamental to process modeling and thermodynamics. " ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "jx4vSYULBG-S" }, "source": [ "> **Exercise.** Catagorize the following quantities as either extensive or intensive variables: Concentration, density, electrical charge, electrical resistivity, length, material hardness, mass, moles, pH, pressure, specific volume, temperature, viscosity, volume." ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "uH03WVI1BG-T" }, "source": [ "## Ideal Gas Law Calculations\n", "\n", "The ideal gas law is a work horse of engineering calculations.\n", "\n", "\$$\n", "PV = nRT\n", "\$$\n", "\n", "Despite its simplicity and familiarity, misuse of units and scale for pressure $P$ and temperature $T$, and identifying correct values of the gas constant $R$, are common sources of errors in homework and exams. Taking time now to really master ideal gas law calculations will pay dividends down the road." ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "uH03WVI1BG-T" }, "source": [ "### Absolute Temperature\n", "\n", "| Reference | F | C | R | K |\n", "| :- | :-: | :-: | :-: | :-: |\n", "| Absolute Zero | -459.67 | -273.15 | 0 | 0 |\n", "| Normal Boiling point of $N_2$ | | \n", "| Dry Ice | -109.3 | -78.5 | | |\n", "| Boiling Point of Propane | -43.6 | -42 | | |\n", "| Freezing Point of Water | 32 | 0 | 491.67 | 273.15 |\n", "| STP | | | | |\n", "| Typical Room Temperature | 68 | 20 | | |\n", "| Pleasant Summer Day | 77 | 25 | | |\n", "| Human Body | | 37 | | |\n", "| Normal Boiling Point of Water | 212 | 100 | | | \n", "| 10 psig steam | | | | | \n", "| 70 psig steam | | | |\n", "| 400 psig steam | | | |" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "uH03WVI1BG-T" }, "source": [ "### Absolute versus Gauge Pressure\n", "\n", "Every engineer needs to know atmospheric pressure in common engineering and scientific units. If need to look up these numbers then you're doing it wrong. \n", "\n", "| Value | Unit |\n", "| :---: | :--: |\n", "| 1 | atm |\n", "| 14.696 | pounds per square inch (absolute), psia |\n", "| 0 | pounds per square inch (gauge), psig |\n", "| 101,325 | Newtons per square meter (Pascals) |\n", "| 101.325 | kiloPascals |\n", "| 1.01325 | bars |\n", "| 1013.25 | millibars |\n", "| 760 | mm Hg |\n", "| 760 | torr |\n", "| 29.92 | in Hg\n", "| 33.9 | feet of water |" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "uH03WVI1BG-T" }, "source": [ "### Units of Pressure (to be completed)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "uH03WVI1BG-T" }, "source": [ "### PV has units of Energy (to be completed)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "uH03WVI1BG-T" }, "source": [ "### Table of Values for $R$ (to be completed)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "XKgyUAzWBG-T" }, "source": [ "## Working with Units in Python using the pint library\n", "\n", "There are a number of python libraries that incorporate units into python calculations. Among these, [pint](http://pint.readthedocs.org/en/latest/) is a relatively new library that builds on experience with earlier attempts." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "VT3cZLoUBG-U", "outputId": "bba11745-3cf3-482e-93ca-733a5dd68cde" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: pint in /Users/jeff/anaconda/lib/python3.5/site-packages\n" ] } ], "source": [ "!pip install pint" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "WkYTCsEfBG-a" }, "source": [ "The core concept in pint is to work with a unit registry, which is created as follows" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "0LCzneTrBG-b" }, "outputs": [], "source": [ "from pint import UnitRegistry\n", "ur = UnitRegistry()" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "uNJ-VugyBG-d" }, "source": [ "### Assigning Multiplicative Units\n", "\n", "The unit registry provides a simple means to assign units using the multiplication operator. For example, here's how to compute the molarity of a sodium chloride solution in 58.44 grams of $NaCl$ (mw = 58.44) has been dissolved in water to form 3 liters of solution." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "4hUJ0BTGBG-e", "outputId": "7e653bbd-1304-41bc-b452-2ee8a25ed139" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.3333333333333333 mole / liter\n" ] } ], "source": [ "# problem data\n", "V = 3.0 * ur.liters\n", "m = 58.44 * ur.grams\n", "mw = 58.44 * ur.grams/ur.mol\n", "\n", "# compute molarity\n", "C = m/(mw*V)\n", "\n", "print(C)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "KKyhabFfBG-i" }, "source": [ "### Unit Conversion\n", "\n", "Each variable with units has to() and ito() methods for converting the quantity to a desired set of units. The to() method is used to create a new variable by converting an existing variable to the indicated units." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "XjIgBL4LBG-i", "outputId": "2b300eb3-455d-49a4-dc49-f11f71d6e1ea" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.5 kilogram / gallon\n", "132.08602617907425 gram / liter\n" ] } ], "source": [ "x = 0.5 * ur.kilograms/ur.gallon\n", "y = x.to(ur.grams/ur.liter)\n", "\n", "print(x)\n", "print(y)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "WK_YmUG8BG-l" }, "source": [ "The ito() method converts an existing variable 'in-place'. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "J1hawtqmBG-m", "outputId": "3349aaad-bfb4-477c-edad-9e378800b2c4" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "132.08602617907425 gram / liter\n" ] } ], "source": [ "x = 0.5 * ur.kilograms/ur.gallon\n", "x.ito(ur.grams/ur.liter)\n", "\n", "print(x)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "HyKtwbOSBG-p" }, "source": [ "For example, here's how to compute the molarity of a sodium chloride solution in which 0.5 pounds of NaCl (mw = 58.44) has been dissolved in water to form 2 gallons of solution. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "4ts8mGdKBG-q", "outputId": "2ce98249-2b00-4433-95c2-9f06a8145f50" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.0028519279032626055 mole * pound / gallon / gram\n", "0.3417363316133261 mole / liter\n", "1.2936127367100163 mole / gallon\n" ] } ], "source": [ "# problem data\n", "V = 3.0 * ur.gallons\n", "m = 0.5 * ur.lbs\n", "mw = 58.44 * ur.grams/ur.mol\n", "\n", "# compute concentration\n", "C = m/(mw*V)\n", "print(C)\n", "\n", "# convert to desired units and print\n", "C = C.to(ur.mol/ur.liter)\n", "print(C)\n", "\n", "# convert to moles per gallon\n", "C.ito(ur.mol/ur.gallon)\n", "print(C)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "kHgErVwVBG-t" }, "source": [ "Muratic Acid is concentrated hydrochloric acid (31.5% by weight) sold by the gallon in home improvement centers for cleaning brick and masonary surfaces. The density of the solution is typically about 1.15 grams/ml. What is the molar concentration of HCl?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "6Ln97-NdBG-u", "outputId": "b43c423a-c6d1-4744-d013-e2487feea782" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.009935545803620405 mole / milliliter\n", "9.935545803620405 mole / liter\n" ] } ], "source": [ "# molecular weight\n", "mwHCl = 36.46 * ur.grams/ur.mol\n", "\n", "# problem data\n", "rho = 1.15 * ur.grams/ur.ml\n", "wHCl = 0.315 * ur.grams/ur.gram\n", "\n", "# calculations\n", "massHCl = wHCl * rho # mass of HCl per volume\n", "moleHCl = massHCl/mwHCl # gmols of HCl per volume\n", "\n", "print(moleHCl)\n", "\n", "# convert to desired units\n", "moleHCl.ito(ur.mol/ur.liter)\n", "print(moleHCl)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "l5ght72SBG-w" }, "source": [ "### Mole and Mass Fractions" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "pGV5iEogBG-x", "outputId": "d9683179-6c11-4ec6-ca03-e959dd86bcf5" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.36108542899408286 dimensionless\n" ] } ], "source": [ "# molar weights \n", "mwBen = 78.11 * ur.grams/ur.liter\n", "mwTol = 92.14 * ur.grams/ur.liter\n", "\n", "xBen = 0.4 * ur.mol/ur.mol\n", "xTol = 0.6 * ur.mol/ur.mol\n", "\n", "wBen = mwBen*xBen / (mwBen*xBen + mwTol*xTol)\n", "\n", "print(wBen)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "pQKmFbbOBG-2" }, "source": [ "### Prefixes" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "Yn7fTodEBG-3", "outputId": "612d96f8-da43-41b6-c75f-c470812f3750" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "78.11 kilogram / kilomole\n", "0.07811 kilogram / mole\n" ] } ], "source": [ "mwBen = 78.11 * ur.kg/ur.kmol\n", "print(mwBen)\n", "\n", "mwBen.ito_base_units()\n", "print(mwBen)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "s4qtEnckBG-6" }, "source": [ "### Temperature and Other Offset (Non-multiplicative) Units\n", "\n", "Examples of non-multiplicative units are degrees Celsius, degrees Fahrenheit, and gauge pressure. For these units the zero of the measurement scale is offset from absolute zero of the underlying physical quantity. In these cases the units are assigned using the Quantity() function of the UnitRegistry module." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "M0ygOiaTBG-6", "outputId": "c2e704bf-735f-4e24-ba09-a6321f633227" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "25 degC = 77.00000039999996 degF\n" ] } ], "source": [ "T = ur.Quantity(25,ur.degC)\n", "\n", "print(T, \" = \", T.to(ur.degF))" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "_jsOI5GOBG--" }, "source": [ "There is an embedded ambiguity in working with non-multiplicative units. For example, given temperatures Ta = 10 and Tdelta = 25 in degrees C, should Ta + Tdelta give an answer of 35 degrees C, or the sum of the absolute temperatures which would correspond to 308.15 degrees C?\n", "\n", "Pint uses unit type called delta_degC for this situation." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "NhzHbiSFBG-_", "outputId": "11ed4a2f-674e-4edf-b79e-2054f79af8d4" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "35.0 degC\n" ] } ], "source": [ "Ta = ur.Quantity(10.0, ur.degC)\n", "Tdelta = 25.0 * ur.delta_degC\n", "\n", "print(Ta + Tdelta)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "R9z-XzZFBG_C", "outputId": "71e4148b-443e-423a-a06b-8e6f58542558" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "100.000 delta_degC\n", "180.000 delta_degF\n" ] } ], "source": [ "Tb = ur.Quantity(100.0, ur.degC)\n", "Tf = ur.Quantity(32.0, ur.degF)\n", "\n", "print(\"{0:6.3f}\".format(Tb-Tf))\n", "print(\"{0:6.3f}\".format((Tb-Tf).to(ur.delta_degF)))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "D_N5TVSQBG_H", "outputId": "edafc83f-b9a2-40ee-9744-3aa3d1c9a7fd" }, "outputs": [ { "data": { "text/html": [ "10.959644683262889 pound_force_per_square_inch" ], "text/latex": [ "$10.959644683262889\\ \\mathrm{pound_force_per_square_inch}$" ], "text/plain": [ "" ] }, "execution_count": 13, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "P1 = (12.5 + 14.696) * ur.psi\n", "\n", "T1 = ur.Quantity(70, ur.degF).to(ur.degR)\n", "T2 = ur.Quantity(40, ur.degF).to(ur.degR)\n", "\n", "P2 = (T2/T1)*P1 - 14.696 * ur.psi\n", "P2" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "gix_r1BBBG_J", "outputId": "8f609900-7918-44f9-8333-937763cb6070" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Volume = 4188.790204786391 centimeter ** 3\n", "Mass of Air = 4.95962584191983 gram\n" ] } ], "source": [ "import math\n", "pi = math.pi\n", "\n", "# constants\n", "R = 8.314 * ur.joule/(ur.mol*ur.degK)\n", "mw = 28.966 * ur.grams/ur.mol\n", "\n", "# problem data\n", "P = 1.0 * ur.atm\n", "T = ur.Quantity(25,ur.degC).to(ur.degK)\n", "r = 10 * ur.cm\n", "\n", "# calculations\n", "V = (4.0/3.0)*pi*r**3\n", "print(\"Volume = \", V)\n", "\n", "m = mw*P*V/(R*T)\n", "\n", "print(\"Mass of Air = \", m.to(ur.grams))" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "4QIwXPuzBG_L" }, "source": [ "## Exercises" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "qEaGvxAcBG_L" }, "source": [ "### Units of Refrigeration\n", "\n", "A hockey arena is equipped with a cooling system providing 200 tons of refrigeration. (Refrigeration capacity is measured in units of 'tons' that correspond to the rate of energy removal necessary to freeze one ton of ice in 24 hour. It is commonly assumed to be 12,000 British Thermal Units (BTU) per hour). It is proposed to add seating for 1,500 spectators. Assuming each spectator releases about 100 watts of power, how many additional tons of refrigeration will be required to maintain ice conditions?" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "jcKTlWeMBG_M" }, "source": [ "### Units of the Ideal Gas Law\n", "\n", "The ideal gas equation may be written as\n", "\n", "$$PV = nRT$$\n", "\n", "where $P$ is pressure, $V$ is volume, $n$ is the number of moles, and $T$ is temperature. Show that the units of $PV$ can be expressed as energy." ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "9fdZfVwVBG_M" }, "source": [ "### Deflategate\n", "\n", "NFL rules specify that footballs should inflated to between 12.5 and 13.5 pounds per square inch. In the so-called \"Deflategate\" controversy involving the AFC championship game of 2015, the New England Patriots were accused of underinflating the game balls in order to achieve an advantage. Independent estimates show the game balls were inflated to 11.5 pounds per square inch at the game day temperature of 51 degrees F. Suppose the balls were originally filled in a training room at 72 degrees F. Assuming the ideal gas law applies, did the balls meet NFL rules at the time they were filled?" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "_vYIjXNRBG_N" }, "source": [ "### Agricultural Chemical Calculations\n", "\n", "A farmer plans to plant 1 square mile of farmland as corn and needs to calculate how much nitrogen fertilizer to buy. Lab samples show the upper 6 inches of soil average 8 parts per million (ppm) of nitrogen by weight, and 4 ppm in the next 18 inches. The dry weight of the soil is 4 million pounds per acre-foot. The farmer is planning for a yield of 180 bushels/acre, and the local university agricultural department recommends a total of 1.2 pounds of nitrogen per bushel for the local soil conditions. \n", "\n", "Nitrogen is available to the farm in the form of urea (chemical formula $CH_4N_2O$) at a price of \\$592 per short ton, and as anhydrous ammonia (chemical formula$NH_3$) at a price of \\$847 per short ton.\n", "\n", "What type of fertilizer should the farmer buy, how much, and at what cost?" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "3w6vS9z6BG_N" }, "source": [ "### Units of Illumination\n", "\n", "A regional entreprenuer is proposing to develop an indoor hydroponics facility enclosing 1 acre of useable growing area. The proposal includes illuminating the growing area at 20,000 lux using led lamps capable of producing 80 lumens/watt and operating 18 hours/day. Local electricity prices are 8.5 cents per kilowatt-hour. What will be the annual cost of electricity for illumination?" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "MPvYLDEPBG_N" }, "source": [ "### Estimation\n", "\n", "Atmospheric pressure averages about 14.696 pounds per square inch which is equal to the weight of the corresponding air column at sea level. The current level of carbon dioxide ($CO_2$) in the atmosphere is about 400 ppm (by mass), and rising at a level of 2.1 ppm per year. How much $CO_2$ would have to be sequestered each year to maintain carbon dioxide at current atmospheric levels? Express your answer in giga-metric-tons, and giga-metric-ton-moles.\n", "\n", "If the density of air-dried wood is 0.53 grams/cm^3, is 20% water by weight, and the dry mass is 45% carbon, how many acre-feet of wood would be required to sequester the excess $CO_2$? Does that seem plausible?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "_buy-503BG_O" }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "JLAxNXJBBG_P" }, "source": [ "\n", "< [Units, Quantities, and Engineering Calculations](http://nbviewer.jupyter.org/github/jckantor/CBE20255/blob/master/notebooks/01.00-Units-Quantities-and-Engineering-Calculations.ipynb) | [Contents](toc.ipynb) | [Units and Conversions for Home Heating](http://nbviewer.jupyter.org/github/jckantor/CBE20255/blob/master/notebooks/01.02-Units-and-Conversions-for-Home-Heating.ipynb) >

" ] } ], "metadata": { "colab": { "name": "01.01-Units-and-Engineering-Calculations.ipynb", "provenance": [], "version": "0.3.2" }, "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.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }