Assignment 1 - 2010 - Solution
Due date(s): | 27 September 2010 |
(PDF) | Assignment questions |
(PDF) | Assignment solutions |
<rst> <rst-options: 'toc' = False/> <rst-options: 'reset-figures' = False/>
.. rubric:: The solutions were prepared by both TA's: Ali and Elliot.
Question 1 [1]
==
.. note::
Distillation tray modelling.
The distillation column is a common unit operation in refineries, air-separation, and fine-chemical processes. The figure, taken from Wikipedia, shows a cross-section of two trays in a distillation column.
.. figure:: ../che3e4/Assignments/Assignment-1/images/Bubble_Cap_Trays.png :scale: 70 :align: center
*Source*: http://en.wikipedia.org/wiki/File:Bubble_Cap_Trays.PNG
- . Redraw the figure, and add to it a boundary you would use to write the mass and energy balance equations for a single tray.
- . Which physical phenomena would you need to consider for an accurate model?
- . Which reasonable simplifying assumptions would you make to reduce the complexity of your model?
Solution
- . The following boundary would be a good basis for energy and mass balances on a single tray:
.. figure:: ../che3e4/Assignments/Assignment-1/images/Bubble_Cap_Trays_With_Boundary.png :scale: 70 :align: center
- . In order to construct the mass balances you would need to account for:
* Liquid mass flow (both bulk and of :math:`n-1` individual components) into the tray's downcomer from the tray above. * Liquid mass flow (both bulk and of :math:`n-1` individual components) out of the tray into the next tray's downcomer. * Vapour mass flow (both bulk and of :math:`n-1` individual components) into the bottom of the tray from the tray below (condensation through the bubble caps). * Vapour mass flow (both bulk and of :math:`n-1` individual components) off the top of the tray (evaporation). * Either a form of thermodynamic equilibrium calculation to calculate the steady state vapour to liquid ratios or a form of calculation (likely empirical) to calculate the dynamic vapour flow rates from each tray. * In the more complicated case, thermodynamic relations to calculate mixture properties within each tray.
In order to construct an energy balance you would need to account for:
* Convective flow of energy in via liquid flow into the tray's downcomer from the tray above. * Convective flow of energy out via liquid flow out of the tray into the next tray's downcomer. * Convective flow of energy in via vapour flow into the bottom of the tray from the tray below (condensation through the bubble caps). * Convective flow of energy out via vapour flow off the top of the tray (evaporation). * Thermodynamic relations to calculate the relative energy of the liquid and vapour mixtures at the internal conditions. * Depending on how complicated the model is desired to be one could also account for convective heat loss off of the sides of the column. * Radiative transfer between trays.
- . In order to simplify the model one could make any of the following assumptions (whether these assumptions are reasonable depends on the system being modelled):
* Perfect mixing of liquid resulting in uniform temperature and concentration at each tray. * 100% condensation of vapour entering the bottom of each tray. * All vapour leaving a tray enters the next tray (i.e. no condensation and backflow in the vapour transfer area). * All vapour transmission occurs over the active tray area. * No vapour transfer within the downcomer regions. * The vapour and liquid of each tray are at equilibrium. * Perfectly insulated column (i.e. no radiative losses). * Negligible radiative transfer between trays. * The components and mixtures are non-reactive. * The effects of mixing are negligible.
.. raw:: latex
\newpage
Question 2 [2]
===
.. note::
This question will slowly build up the equations and assumptions for solving a common chemical engineering problem: heat loss from a pipe.
Our final goal is to be able to predict the temperature profile, along the length of a tube. Such tubes could occur, for example, in a shell and tube heat exchanger, as shown in the figure below from the Wikipedia article.
.. figure:: ../che3e4/Assignments/Assignment-1/images/U-tube_heat_exchanger.png :alt: ../che3e4/Assignments/Assignment-1/images/U-tube_heat_exchanger.png :scale: 70 :align: center
*Source*: http://en.wikipedia.org/wiki/Shell_and_tube_heat_exchanger
- . Write down all the possible controlling mechanisms you might consider for a high-accuracy model of this shell and tube heat exchanger.
- . Now let's start simple, and consider only the fluid flow in the pipe. What would the cross-sectional profile for the flow look like under (a) laminar flow and (b) turbulent flow?
- . Consider a short cross-sectional segment, of width :math:`\Delta z`, where the temperature is :math:`T(z)` at the entry and :math:`T(z + \Delta z)` at the exit. The figure below contains the boundary region already drawn, in green.
.. image:: ../che3e4/Assignments/Assignment-1/images/pipe-heat-balance.png :alt: ../che3e4/Assignments/Assignment-1/images/pipe-heat-balance.svg :scale: 60 :align: center
A. Which specific assumption do you have to invoke so that the temperature in the radial direction is constant?
B. Assuming this assumption is true, write down the average temperature within the segment, and define it as :math:`\overline{T}(z)`.
C. What is the surface area of the pipe in this segment?
D. Finally, using Newton's law of cooling, write down the rate of energy loss, :math:`Q`, to the outside environment, where the wall temperature is defined as :math:`T_\text{wall}`. What are the units of the heat transfer coefficient, and the units of :math:`Q`?
- . Now perform an energy balance over this segment.
* Heat in = * Heat out = * Heat generated = * Overall heat balance, assuming steady-state:
- . Lastly, divide this steady-state equation by :math:`\Delta z` and take limits so that :math:`\Delta z \rightarrow 0`. This allows you to reach our goal and write an equation that predicts the temperature profile along the length of a tube.
Recall from calculus that:
.. math::
\lim_{\Delta z \rightarrow 0} \frac{T(z + \Delta z) - T}{\Delta z} = \frac{dT}{dz}
Solution
- . A shell and tube heat exchanger operates by transferring heat from the hot stream to the cold stream through conduction. Therefore one controlling mechanism is *heat conduction*. Other controlling mechanisms include:
* Fluid flow: which exists in the tube and shell sides
* Evaporation: Some heat exchangers involve phase changes. For example, the cold fluid evaporates (e.g. reboilers), or a vapour fluid condenses (e.g. the condenser in a refrigerator cycle). In such cases, the phase change must be considered.
* Reaction: Many industrial packed-bed reactors have a shell and tube design where the reaction occurs in the tube side. The shell side acts as a cooling or heating medium by transferring heat from or to the tube side (reaction medium).
* Radiation: Heat transfer via thermal radiation from the body of the heat exchanger to ambient or *vice versa*.
- . In laminar flow, the cross-sectional profile for the velocity is parabolic where the maximum velocity occurs in the centre of the pipe. Laminar flow occurs at low Reynolds numbers (:math:`\text{Re}<2100` for pipes). In turbulent flow, however, the radial distribution of velocity is noticeable only within a thin layer adjacent to the wall. Turbulent flow occurs at high Reynolds numbers (:math:`\text{Re}>2100` for pipes).
- . Considering a segment of width :math:`\Delta z`:
A. We assume that we have a *plug flow* through the pipe, which means that the velocity is constant in the radial direction. Note that the plug flow assumption requires a turbulent flow where the boundary layer adjacent to the wall of the pipe is negligible.
B. The average temperature can be obtained from the temperatures at the two ends of the segment as :math:`\overline{T} = \displaystyle\frac{T(z)+T(z+\Delta z)}{2}`
C. The surface area of the cylindrical segment is :math:`A = 2\pi R \Delta z=\pi D\Delta z \qquad (D=2R)`.
D. Newton's law of cooling states that the rate of the heat transferred through the wall (:math:`Q`) is proportional to the difference between the fluid's temperature and the wall temperature. We choose the proportional constant as :math:`(\pi D \Delta z) h` where :math:`h` is positive and is the heat transfer coefficient. Therefore, :math:`Q = \left(\pi D \Delta z\right) h\left(\overline{T}-T_{wall}\right)`, where :math:`\overline{T}` is the fluid's temperature inside the segment. The unit of :math:`Q` is energy per time (e.g. :math:`J s^{-1}`). As a result, the unit of the constant :math:`h` will be :math:`J s^{-1} m^{-2} K`.
- . The energy balance at steady state is
.. math::
0=\dot{m}c_p\left(T(z)-T(z+\Delta z)\right)-Q
where :math:`\dot{m}` is the mass flowrate inside the pipe, and :math:`Q` is the heat transferred through the wall. Substituting :math:`Q` from Newton's law gives :math:`0=\dot{m}c_p(T(z)-T(z+\Delta z))-(\pi D \Delta z) h(\overline{T}-T_{wall})`.
Then rearranging, and dividing both sides by :math:`\dot{m}c_p\Delta z` yields :math:`\displaystyle\frac{T(z+\Delta z)-T(z)}{\Delta z}=-\displaystyle\frac{(\pi D) h}{\dot{m}c_p}(\overline{T}-T_{wall})`.
The term :math:`\displaystyle\frac{T(z+\Delta z)-T(z)}{\Delta z}` will represent the derivative of :math:`T` with respect to :math:`z` as :math:`\Delta z\rightarrow 0`. Also, :math:`T=\overline{T}` when :math:`\Delta z\rightarrow 0`. Let us define :math:`\lambda=\displaystyle\frac{(\pi D) h}{\dot{m}c_p}`. Therefore, the following equation results:
.. math::
\frac{dT}{dz}=-\lambda(T-T_{wall})
This is a differential equation that predicts the fluid's temperature versus the length of the pipe, at steady state.
Question 3 [1.5]
====
Consider a CSTR where an irreversible, first-order endothermic reaction of the form :math:`A\stackrel{k}{\rightarrow} B` takes place. Let :math:`C_{A}` denote the concentration of the species A in the reactor, :math:`T_R` and :math:`T_{in}` denote the temperatures of the reactor and of the inlet stream, respectively, :math:`Q`, is the heat added to/removed from the reactor, :math:`C_{A0}` is the concentration of A in the inlet stream, :math:`V` is the volume of the reactor, :math:`k_{0}, E, \Delta H` are the pre-exponential constant, the activation energy, and the enthalpy of the reaction and :math:`C_{p}` and :math:`\rho` are the heat capacity and fluid density in the reactor.
Develop a model that describes the evolution of the concentration and temperature in the reactor, using a systematic modelling approach that also outlines all assumptions made.
Solution
We start by generating a diagram of the system to aid in visualizing the set up and constructing the mass and energy balances:
.. figure:: ../che3e4/Assignments/Assignment-1/images/Q2_Reactor.png :scale: 40 :align: center
In order to simplify the modelling process we make the following reasonable assumptions (based on the implications of the problem statement):
- Either the reagents A and B have similar heat capacities and densities/ mixture densities or the reagents are in dilute enough concentration that the heat capacity and density of the carrier fluid is dominant (i.e. Cp and rho are constant)
- The reactor is perfectly mixed
- Shaft work is negligible
- Kinetic and potential energies are negligible
- The reactor is sealed (i.e. convective and evaporative losses are negligible)
- All physical properties are temperature independent
- Effects of mixing may be neglected (i.e. ideal mixtures)
- The system has a constant volume (i.e. :math:`F_{\text{in}} = F_{\text{out}} = F`)
- There is no reagent B in the inlet
Moving to the modelling of the concentration of A and B in the reactor. It is important to note that a proper mass/molar balance deals with absolute quantities, not concentration. The only reason we can separate :math:`C_{a}/C_{b}` and :math:`V_{R}` in such a nice way is because we assumed a constant reactor volume. In the more complicated case we would need to consider the chain rule, which would result in a :math:`\frac{dV_{R}}{dt}` term (In actuality we have used the chain rule below but since :math:`V_{R}` is assumed constant the term :math:`\frac{dV_{R}}{dt}` simply cancels to 0).
.. math:: \frac{dn_{a}}{dt} &= \frac{dC_{a}V_{R}}{dt} = \frac{dC_{a}}{dt}V_{R} = \underbrace{\sum_{i}\left(C_{a0,i} \times F_{in,i}\right)}_{\text{inlet}} - \underbrace{\sum_{i}\left(C_{a} \times F_{out,i}\right)}_{\text{outlet}} + \text{Generation} - \text{Consumption} \\ \frac{dn_{b}}{dt} &= \frac{dC_{b}V_{R}}{dt} = \frac{dC_{b}}{dt}V_{R} = \underbrace{\sum_{i}\left(C_{b0,i} \times F_{in,i}\right)}_{\text{inlet}} - \underbrace{\sum_{i}\left(C_{b} \times F_{out,i}\right)}_{\text{outlet}} + \text{Generation} - \text{Consumption}
We know that there is no generation of A and no consumption of B in the reactor and we know there is only one inlet and outlet stream. Therefore:
.. math::
\frac{dC_{a}}{dt} &= C_{a0}\frac{F}{V_{R}} - C_{a}\frac{F}{V_{R}} - k_{0}e^{\displaystyle-\frac{E}{RT_{R}}}C_{a} \\ \frac{dC_{b}}{dt} &= - C_{b}\frac{F}{V_{R}} - k_{0}e^{\displaystyle-\frac{E}{RT_{R}}}C_{a}
Moving to the energy balance (we again take note that the only reason the :math:`\frac{dE}{dt}` may be whittled down to :math:`\frac{dT}{dt}` is because all other terms are assumed constant). Note that "other sources" refers to things such as shaft work, kinetic/potential energy, *etc*.:
.. math:: \frac{dE}{dt} = \sum_{i}\left(\text{Convective flow in}\right) - \sum_{i}\left(\text{Convective flow out}\right) - \text{Heat of reaction} + Q + \text{other sources}
.. math::
\displaystyle \frac{d\left(C_{p} \rho V_{R}\left(T_{R}-T_{\text{ref}}\right)\right)}{dt} &= \frac{d\left(C_{p} \rho V_{R} T_{R}\right)}{dt} - \frac{d\left(C_{p} \rho V_{R} T_{\text{ref}}\right)}{dt} = \frac{d\left(C_{p} \rho V_{R} T_{R}\right)}{dt} - \left(0\right) \\ \displaystyle \frac{d\left(C_{p} \rho V_{R} T_{R}\right)}{dt} &= \left(C_{p} \rho F\left(T_{\text{in}}-T_{\text{ref}}\right)\right) - \left(C_{p} \rho F\left(T_{R}-T_{\text{ref}}\right)\right) - \Delta H k_{0}V_{R}e^{-\frac{E}{RT_{R}}}C_{a} + Q + (0)
Simplifying:
.. math:: \frac{dT_{R}}{dt} = \left(\frac{F}{V_{R}}\right)\left(T_{\text{in}}-T_{R}\right) - \left(\frac{\Delta H k_{0}}{C_{p} \rho}\right)C_{a}e^{ -\frac{E}{RT_{R}}} + \frac{Q}{C_{p} \rho V_{R}}
It is very important to note that :math:`T_{\text{ref}}` was used to calculate each enthalpy term. In this specific case the :math:`T_{\text{ref}}` cancels out due to the assumption made at the start of the solution (specifically the assumptions of equal inlet and outlet flow rates and an equal and constant density and heat capacity over the entire mixture). A reference temperature **must always be used when calculating enthalpies**. **There is no such thing as an absolute enthalpy**. As the current state of thermodynamics stands it is theoretically impossible to calculate absolute enthalpy (who knows what the future will bring...). As standard practice you should always start with :math:`T_{\text{ref}}` in your energy balances and if it cancels out then all the better for your solution.
Question 4 [1.5]
====
The simplest example of biological wastewater treatment involves removing a single nutrient, :math:`\sf N`, from a liquid waste stream and converting it to (solid) biomass, :math:`\sf B`. This process is used, for example, by pop manufacturers to treat liquid waste from their processes, where :math:`\sf N` would be sugar (e.g. fructose). The microorganisms absorb :math:`\sf N` from the wastewater and use it to grow more and more biomass.
- . Draw a simple CSTR where this liquid stream enters, containing :math:`\sf N_\text{in}` [mg/L] and the stream leaving the reactor contains both liquid and solid fractions. The solids in the outlet stream can be separated, and the remaining liquid would contain much less :math:`\sf N`, allowing the company to discharge that liquid to municipal wastewater treatment systems.
Draw the boundaries you will consider on your diagram as well.
- . Write an overall mass balance, where the flows, :math:`q`, are expressed in units of litres per day, typically being in the order of megalitres per day.
- . Write a dynamic mass balance for :math:`\sf N` and :math:`\sf B`, where their units are expressed in mg/L. Assume there is no biomass in the inlet stream. The reaction rate for converting :math:`\sf N \longrightarrow B` is given by :math:`r_B` in units of mg/(L.day).
- . Write the two equations for the steady-state values of :math:`\sf N` and :math:`\sf B` if :math:`r_B = \mu_\text{max} \displaystyle \frac{\sf N}{\sf K + N} \sf B`, where :math:`\sf K` [mg/L] and :math:`\mu_\text{max}` [1/day] are constants from the Monod rate expression. Note that :math:`r_N = \displaystyle - \frac{1}{Y_B} r_B`, where :math:`Y_B` is the yield of :math:`\sf B` from :math:`\sf N`.
- . Are these equations solvable by hand if you are given the constants such as :math:`\sf N_\text{in}, K`, :math:`\mu_\text{max}`, *etc* in your equations?
Solution
- . A diagram of the process is provided below. The boundary that will be used for the component and overall mass balances has also been depicted and labelled (essentially the system will be the liquid contents of the reactor).
.. figure:: ../che3e4/Assignments/Assignment-1/images/Q3_Reactor.png :scale: 50 :align: center
In order to simplify the modelling process we make the following reasonable assumptions:
* The overall density of the mixture is roughly constant and equal to that of water (This may seem like a huge leap at first but you must consider the fact that :math:`\sf N` is likely dilute, otherwise the company would try to reclaim these resources, and the organisms being grown are mostly water and so the density of the overall mixture will likely be close to that of water, the carrier fluid). In practice this assumption leads to reasonably good results. * The reactor is perfectly mixed. * The reactor is sealed (i.e. convective and evaporative losses are negligible). This assumption has a few caveats. You cannot assume this for general biological systems and in reality even this system will have gaseous loses but we are not modelling these components. Waste decomposition processes (ex. activated sludge, anaerobic digestion) will almost always convert at least a portion of :math:`\sf N` to some gaseous component (ex. :math:`CO_{2}`, :math:`CH_{4}`, etc.). But since we are not modelling these components we can simply forget about gas loss terms. It is also possible that in a real system evaporative losses of water would occur over time but these would likely be negligible in comparison to the relative size of the reactors. * All physical properties are temperature independent. * Effects of mixing may be neglected (i.e. ideal mixtures). * The system has a constant volume (i.e. :math:`F_{\text{in}} = F_{\text{out}} = F`). * The inlet stream is sterile (i.e. no active organisms). Again this assumption is context sensitive. In activated sludge plants, for example, there will almost always be a recycle stream to reuse organisms ("bugs" are resources too). For the purposes of this question we will assume no recycling and no organisms in the inlet stream in general (the waste stream could be contaminated...) * Endogenous decay (i.e. bacteria death) is negligible.
- . In writing the overall mass balance we recall that volume **is not a conserved quantity in realistic cases**. We must always start with either mass or mole balances. These quantities are always conserved (omitting nuclear reactions of course...). What you will find though is that in ideal cases, such as when density is assumed constant, mass balances can break down to volume balances, which makes life simpler. Just be careful that you don't start with a volume balance.
.. math:: \frac{M_{\text{total}}}{dt} = \sum_{i}(M_{\text{in},i}) - \sum_{i}(M_{\text{out},i})
Dividing through by the average constant density:
.. math::
\frac{1}{\rho} \cdot \frac{M_{\text{total}}}{dt}&= \frac{1}{\rho} \cdot \left(\sum_{i}(M_{\text{in},i}) - \sum_{i}(M_{\text{out},i}) \right)\\ \frac{V_{R}}{dt} &= \sum_{i}(F_{\text{in},i}) - \sum_{i}(F_{\text{out},i})
Naturally, with only one inlet and one outlet, this relation breaks down to our previous assumption of equal flow at steady state.
.. math:: \frac{V_{R}}{dt} &= \sum_{i}(F_{in,i}) - \sum_{i}(F_{out,i})\\ (0) &= F_{in} - F_{out}\\ F &= F_{in} = F_{out}
- . The construction of the mass balances for :math:`\sf N` and :math:`\sf B` follow the exact same logic used in question 3. Since we have a constant reactor volume:
.. math::
\frac{dM_{N}}{dt} &= \frac{dNV_{R}}{dt} = \frac{dN}{dt}V_{R} = \underbrace{\sum_{i}\left(N_{0,i}F_{\text{in},i}\right)}_{\text{inlet}} - \underbrace{\sum_{i}\left({N} F_{\text{out},i}\right)}_{\text{outlet}} + \,\text{Generation} - \text{Consumption} \\ \frac{dM_{B}}{dt} &= \frac{dBV_{R}}{dt} = \frac{B}{dt}V_{R} = \underbrace{\sum_{i}\left(B_{0,i}F_{\text{in},i}\right)}_{\text{inlet}} - \underbrace{\sum_{i}\left({B} F_{\text{out},i}\right)}_{\text{outlet}} + \,\text{Generation} - \text{Consumption}
We have assumed there is no generation of :math:`\sf N` and no consumption of :math:`{\sf B}` (i.e. bacterial death, also known as endogenous decay) in the reactor and we have assumed we have only one inlet and outlet stream and that the inlet stream is sterile. Therefore:
.. math:: \frac{dN}{dt} = N_{0}\frac{F}{V_{R}} - N\frac{F}{V_{R}} - \left(\frac{1}{Y_{B}}\right)\left(\mu_{\text{max}}\frac{N}{K+N}\right)B
.. math:: \frac{dB}{dt} = - B\frac{F}{V_{R}} + \left(\mu_{\text{max}}\frac{N}{K+N}\right)B
(As a quick little extra bit of information, the factor :math:`\displaystyle \frac{F}{V_{R}}` is commonly referred to as the "dilution rate" in bioreactor engineering and is a very important design factor)
- . When considering the steady state of bioreactors it is often best to start with the organism balances (this is because they are more likely to not contain an inlet term and so are simpler to work with). This is also because the organism balances will be your source for determining if the steady state substrate values are directly calculable.
If you cannot explicitly write all of the substrate concentrations from the steady state organism balances then there is no need to derive the rest of the steady state balances in the hopes of an analytical solution. Simply skip to numerically determining the steady state.
.. math:: \displaystyle \frac{dB}{dt} &= - B\frac{F}{V_{R}} + \left(\mu_{\text{max}}\frac{N}{K+N}\right)B \\ (0) &= - \overline{B}\frac{F}{V_{R}} + \left(\mu_{\text{max}}\frac{\overline{N}}{K+\overline{N}}\right)\overline{B} \\ \overline{B}\frac{F}{V_{R}} &= \left(\mu_{\text{max}}\frac{\overline{N}}{K+\overline{N}}\right)\overline{B} \\ \frac{F}{V_{R}} &= \left(\mu_{\text{max}}\frac{\overline{N}}{K+\overline{N}}\right) \\ \frac{F}{V_{R}}\left(K+\overline{N}\right) &= \mu_{\text{max}}\overline{N} \\ \left(\mu_{\text{max}}-\frac{F}{V_{R}}\right)\overline{N} &= \frac{F}{V_{R}}K \\ \overline{N} &= \left(\frac{\frac{F}{V_{R}}K}{\left(\mu_{\text{max}}-\frac{F}{V_{R}}\right)}\right)
and
.. math::
\displaystyle \frac{dN}{dt} &= N_{0}\frac{F}{V_{R}} - N\frac{F}{V_{R}} - \left(\frac{1}{Y_{B}}\right)\left(\mu_{\text{max}}\frac{N}{K+N}\right)B \\ (0) &= \frac{F}{V_{R}}\left(N_{0} - \overline{N}\right) - \left(\frac{1}{Y_{B}}\right)\left(\mu_{\text{max}}\frac{\overline{N}}{K+\overline{N}}\right)\overline{B} \\ \left(\frac{1}{Y_{B}}\right)\left(\mu_{\text{max}}\frac{\overline{N}}{K+\overline{N}}\right)\overline{B} &= \frac{F}{V_{R}}\left(N_{0} - \overline{N}\right) \\ \overline{B} &= \frac{\frac{F}{V_{R}}\left(N_{0} - \overline{N}\right)}{\left(\frac{1}{Y_{B}}\right)\left(\mu_{\text{max}}\frac{\overline{N}}{K+\overline{N}}\right)}
- . As was seen in the previous part of the solution, the steady states are indeed directly calculable if given values for :math:`F`, :math:`V_{R}`, :math:`N_{0}`, :math:`K`, :math:`\mu_{\text{max}}`, and :math:`Y_{B}`. It is also interesting to note that the theoretical maximum for the dilution rate is set by the denominator of the steady state version of the organism balance and is equal to the maximum specific growth rate (:math:`\mu_{\text{max}}`). When you think about it this makes perfect sense. If you are putting in flow faster than your organisms can grow then they will simply be washed out.
While less obvious, it can also be shown that :math:`\overline{N}` will approach the inlet concentration of :math:`N_{0}` as the dilution rate approaches :math:`\mu_{\text{max}}` (This makes intuitive sense because if you are feeding the reactor at a rate that is almost washing out the bacteria then there concentration will be lower and so most of your substrate will exit the reactor). Obviously if your goal is to digest :math:`\sf N` then you would want to make your reactor as large as possible, but realistically after a certain point there would be diminishing returns for increasing the reactor size. Therefore space, cost, and legal constraints usually set the reactor size.
As an aside, it is interesting to note that if your goal was to grow as much bacteria as possible (this could happen in specialty chemicals for example), and assuming your inlet substrate concentration is much larger than the half saturation constant (I will not go into why this requirement is needed...) then you would actually want to operate the reactor as a close as possible to wash out. This is because while the reactor concentration of the bacteria would likely be smaller, the substrate concentration would be much higher and so the overall production rate would be higher.
Question 5 [2]
====
.. note:: To review and practice material related to number systems and round-off errors.
- . Convert the following binary numbers to base-10:
* :math:`\sf 01010111` * :math:`\sf 1110.0001`
- . Convert the following hexadecimal numbers to base-10:
* :math:`\sf 9A8B7C6D` * :math:`\sf DEADB0EF`
- . In either MATLAB or Python: write a short function that returns the smallest positive number used on your computer. In other words your computer will be unable to reliably distinguish between zero and a quantity smaller than this number.
- . How does your value (above) compare to what MATLAB or Python reports?
* **MATLAB**:
.. code-block:: matlab
>> help eps % read what this command does >> eps
* **Python**:
.. code-block:: python
>>> np.finfo(np.double).eps
Solution
- . :math:`(01010111)_2=0\times 2^7 +1\times 2^6 +0\times 2^5 +1\times 2^4 +0\times 2^3 +1\times 2^2 +1\times 2^1 +1\times 2^0=87`
:math:`(1110.0001)_2=1\times 2^3 +1\times 2^2 +1\times 2^1 +0\times 2^0 +0\times 2^{-1} +0\times 2^{-2} +0\times 2^{-3} +1\times 2^{-4}=14.0625`
- . The conversion from hexadecimal to decimal is done similarly to the conversion from binary to decimal. The difference is that the base is 16 here. Also, the letters :math:`A-F` represent integer numbers :math:`10-15` respectively.
:math:`(\sf{9A8B7C6D})_{16}=9\times 16^7 +(10)\times 16^6 + 8\times 16^5 +(11)\times 16^4+7\times 16^3 +(12)\times 16^2 +6\times 16^1 +(13)\times 16^0` = 259 283 2621
:math:`(\sf{DEADB0EF})_{16}=13\times 16^7 +14\times 16^6 + 10\times 16^5 +13\times 16^4+11\times 16^3 +0\times 16^2 +14\times 16^1 +15\times 16^0` = 3 735 924 975
- . The following code obtains the smallest positive number.
.. twocolumncode:: :code1: ../che3e4/Assignments/Assignment-1/code/myepsilon.m :language1: matlab :header1: MATLAB code :code2: ../che3e4/Assignments/Assignment-1/code/myepsilon.py :language2: python :header2: Python code
Recall that most computers internally convert base 10 input values to binary, base 2 values before performing any calculations. Therefore, the initial value of *number* in the above code is approximated to the nearest binary representation in the computer. Then the division of that binary representation by two will always have an exact binary representation. Therefore, unlike the initial value of *number* which may not be finitely representable in binary, its subsequent values obtained through the while loop are divisible by two and thus exactly representable in binary. That is why, the variable "epsilon" must eventually reach the smallest positive number :math:`.0000...0001 \times 2^{-111...111}`.
The code keeps dividing *number* by two in order to make it closer and closer to zero. At some point, the current value of *number* cannot be distinguished from zero (the condition in the while loop). This is where the algorithm stops. We report the value right before the current one as the smallest positive number that can be distinguished from zero. This previous value is always stored as ``epsilon`` in the above code.
The epsilon value around 0.0 returned by MATLAB matches that computed by our code. Notice that this value is not explicitly classified as the smallest *normalized* representation (in computers, binary numbers are normalized to have a lead digit of 1). This is because some computers allow for "gradual underflow". This means that some computers allow the mantissa to become denormalized (i.e. have 0 as a lead digit) once the exponent has reached its smallest allowable value (thereby making the gap between 0 and the epsilon smaller). As an aside, note that your solution will likely equal ``realmin()*eps()``. There is a very logical reason for this (left to you as an exercise to see why!).
.. raw:: latex
\vspace{0.5cm} \hrule \begin{center}END\end{center}
</rst>