The purpose of this Jupyter notebook is to get you started with units and engineering calculations.

Things to master:

- Unit systems
- Unit conversions
- Difference between mass and weight, and the difference between kg-m, kg-f, and lbm and lbf
- Concept of mole, and the difference between g-mol, kg-mol, and any other kind of mole
- Absolute versus Gauge Pressure
- Typical values of temperature and pressure in real-world applications
- Working with units in python using the
`pint`

library.

There are seven fundamental units in the Système International d'Unités (SI) system, all other unit can be generated from these.

Dimension | SI Units | CGS | English |
---|---|---|---|

Mass | kilogram (kg) | gram (g) | lb-mass, slug |

Length | meter (m) | centimeter (cm) | inch (in); foot (ft) |

Time | second (s) | second (s) | second (sec) |

Temperature | degree Kelvin (K) | degree Celsius (°C) | degree Rankine (°R) |

Quantity | mole (gmol) | mole (gmol) | mole (gmol) |

Current | Ampere (A) | abampere | |

Luminous Intensity | candela (cd) | stlib [luminance] | candlepower, etc. |

Exercise.Give an everyday example of something with about 1 SI unit of the corresonding dimension.

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.

Calculations with coherent units is straightforward since they involve just ratios or products of base units. The calculations break down into three steps:

- Recast all of the problem quantities in base or coherent derived units.
- Perform the numerical calculations.
- Using algebraic rules for the cancelation of terms, simplify and reduce units to units relevant to the context of the problem.

\begin{align*} K.E. & = \frac{1}{2} mv^2 \\ & = \frac{1}{2} \left(3\ \mbox{kg}\right)\left( 10 \frac{\mbox{m}}{\mbox{s}}\right)^2 \\ & = 150 \ \frac{\mbox{kg}\cdot\mbox{m}^2}{\mbox{s}^2} = 150 \ \mbox{N}\cdot\mbox{m} = \fbox{150 J} \end{align*}

Example:The kinetic energy of a object with mass $m = 3\ \mbox{kg}$ traveling at velocity $v = 10 \ \mbox{m/s}$ is given by

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.$$MW_{air} = 28.966\ \frac{\mbox{g}}{\mbox{mol}} = 0.028966\ \frac{\mbox{kg}}{\mbox{mol}}$$$$ P = 101,325\ \mbox{Pa} = 101,325\ \frac{\mbox{N}}{\mbox{m}^2} = 101,325\ \frac{\mbox{kg}}{\mbox{m}\cdot\mbox{s}^2}$$$$V = \frac{4}{3}\pi r^3 = \frac{4}{3}\pi \left( 0.10\ \mbox{m}\right)^3 = 0.004189\ \mbox{m}^3$$$$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}}$$$$T = 25 + 273.15 = 298.15 K$$

Solution:Start by converting all of the quantities in the problem to base or derived units.Using molecular weight and the ideal gas law

$$ m_{air} = MW_{air} n_{air} = MW_{air}\frac{PV}{RT} $$Substituting quantities into this expression for $m_{air}$

\begin{align*} m_{air} & = \left(0.028966\ \frac{\mbox{kg}}{\mbox{mol}}\right) \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)} \\ & = \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}}\\ & = \fbox{0.00496 kg} \end{align*}

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.

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:

For the purpose of applying the ideal gas law, what is the air pressure in this tire?

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.

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.

The offsets result in numerical values convenient for common everyday use, but introduce an additional consideration (and source of errors!) for engineering calculations.

Examples of offset scales include:

- Degrees Celsius
- Degrees Fahrenheit
- Gauge Pressure (pressure relative to normal atmospheric pressure).
- Enthalpy and Free Energy of Formation (energy required to form a substance relative to standard laboratory conditions.)
- Calendar dates (days relative to start of the Common Era)

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.

The misuse of pressure and temperature scales is a common source of errors in engineering calculations.

$$P_2/T_2 = P_1/T_1$$

Example:A football is inflated to 12.5 psig (pounds per square in gauge) at 70 degrees F. The football is taken to play outdoors at 40 degrees F. Using the gas law,what is the pressure of the football at playing conditions?

$$\frac{P_2 + 14.696}{40 + 459.67} = \frac{12.5 + 14.696}{70 + 459.67}$$

Solution:The ideal gas law assumes quantities are given in absolute units. The problem statement, however, gives conditions in offset units. In this case, 0 degrees Farhenheit is 459.67 in absolute (Rankine) units, and 0 psig is 14.696 psia in absolute units. Incorporating the offsets the gas law readsSolving for $P_2$

$$P_2 = \frac{40+459.67}{70+459.67}(12.5 + 14.696) - 14.696 = 10.96\ \mbox{psig}$$

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.

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.

This distinction is fundamental to process modeling and thermodynamics.

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.

The ideal gas law is a work horse of engineering calculations.

\begin{equation} PV = nRT \end{equation}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.

Reference | F | C | R | K |
---|---|---|---|---|

Absolute Zero | -459.67 | -273.15 | 0 | 0 |

Normal Boiling point of $N_2$ | ||||

Dry Ice | -109.3 | -78.5 | ||

Boiling Point of Propane | -43.6 | -42 | ||

Freezing Point of Water | 32 | 0 | 491.67 | 273.15 |

STP | ||||

Typical Room Temperature | 68 | 20 | ||

Pleasant Summer Day | 77 | 25 | ||

Human Body | 37 | |||

Normal Boiling Point of Water | 212 | 100 | ||

10 psig steam | ||||

70 psig steam | ||||

400 psig steam |

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.

Value | Unit |
---|---|

1 | atm |

14.696 | pounds per square inch (absolute), psia |

0 | pounds per square inch (gauge), psig |

101,325 | Newtons per square meter (Pascals) |

101.325 | kiloPascals |

1.01325 | bars |

1013.25 | millibars |

760 | mm Hg |

760 | torr |

29.92 | in Hg |

33.9 | feet of water |

In [ ]:

```
!pip install pint
```

The core concept in pint is to work with a `unit registry`

, which is created as follows

In [ ]:

```
from pint import UnitRegistry
ur = UnitRegistry()
```

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.

In [ ]:

```
# problem data
V = 3.0 * ur.liters
m = 58.44 * ur.grams
mw = 58.44 * ur.grams/ur.mol
# compute molarity
C = m/(mw*V)
print(C)
```

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.

In [ ]:

```
x = 0.5 * ur.kilograms/ur.gallon
y = x.to(ur.grams/ur.liter)
print(x)
print(y)
```

The `ito()`

method converts an existing variable 'in-place'.

In [ ]:

```
x = 0.5 * ur.kilograms/ur.gallon
x.ito(ur.grams/ur.liter)
print(x)
```

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.

In [ ]:

```
# problem data
V = 3.0 * ur.gallons
m = 0.5 * ur.lbs
mw = 58.44 * ur.grams/ur.mol
# compute concentration
C = m/(mw*V)
print(C)
# convert to desired units and print
C = C.to(ur.mol/ur.liter)
print(C)
# convert to moles per gallon
C.ito(ur.mol/ur.gallon)
print(C)
```

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?

In [ ]:

```
# molecular weight
mwHCl = 36.46 * ur.grams/ur.mol
# problem data
rho = 1.15 * ur.grams/ur.ml
wHCl = 0.315 * ur.grams/ur.gram
# calculations
massHCl = wHCl * rho # mass of HCl per volume
moleHCl = massHCl/mwHCl # gmols of HCl per volume
print(moleHCl)
# convert to desired units
moleHCl.ito(ur.mol/ur.liter)
print(moleHCl)
```

In [ ]:

```
# molar weights
mwBen = 78.11 * ur.grams/ur.liter
mwTol = 92.14 * ur.grams/ur.liter
xBen = 0.4 * ur.mol/ur.mol
xTol = 0.6 * ur.mol/ur.mol
wBen = mwBen*xBen / (mwBen*xBen + mwTol*xTol)
print(wBen)
```

In [ ]:

```
mwBen = 78.11 * ur.kg/ur.kmol
print(mwBen)
mwBen.ito_base_units()
print(mwBen)
```

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.

In [ ]:

```
T = ur.Quantity(25,ur.degC)
print(T, " = ", T.to(ur.degF))
```

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?

Pint uses unit type called `delta_degC`

for this situation.

In [ ]:

```
Ta = ur.Quantity(10.0, ur.degC)
Tdelta = 25.0 * ur.delta_degC
print(Ta + Tdelta)
```

In [ ]:

```
Tb = ur.Quantity(100.0, ur.degC)
Tf = ur.Quantity(32.0, ur.degF)
print("{0:6.3f}".format(Tb-Tf))
print("{0:6.3f}".format((Tb-Tf).to(ur.delta_degF)))
```

In [ ]:

```
P1 = (12.5 + 14.696) * ur.psi
T1 = ur.Quantity(70, ur.degF).to(ur.degR)
T2 = ur.Quantity(40, ur.degF).to(ur.degR)
P2 = (T2/T1)*P1 - 14.696 * ur.psi
P2
```

Out[ ]:

In [ ]:

```
import math
pi = math.pi
# constants
R = 8.314 * ur.joule/(ur.mol*ur.degK)
mw = 28.966 * ur.grams/ur.mol
# problem data
P = 1.0 * ur.atm
T = ur.Quantity(25,ur.degC).to(ur.degK)
r = 10 * ur.cm
# calculations
V = (4.0/3.0)*pi*r**3
print("Volume = ", V)
m = mw*P*V/(R*T)
print("Mass of Air = ", m.to(ur.grams))
```

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?

The ideal gas equation may be written as

$$ PV = nRT$$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.

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?

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.

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.

What type of fertilizer should the farmer buy, how much, and at what cost?

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?

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.

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?

In [ ]:

```
```