**R Programming – Thomas Bryce Kelly**, and kindly contributed to R-bloggers)

The so-called residence time of a system is both an immensely useful and highly intuitive conception which provides a relevant timescale for processes. For example, the residence time of nutrients flowing into a pond would be the average ‘lifetime’ of the nutrients before being taking up by the pond creatures. If it is a small number, then the nutrients are taken up very quickly compared to if is a large number.

Here is the “traditional” formula for calculating residency time of a conservative tracer:

The more mass that’s in the system the longer the residence time becomes; and on the flip side, the greater the flux the shorter the time becomes. While both simple and widely used, this formula requires knowledge of both the Mass of the system and the flux rate of either the input or output (depends on the system and/or whether it is at steady state). For the microlayer we have annual input fluxes but we do not have the mass of trace-metals within the microlayer (there are many reasons for this). So we need a new way to estimate the residence time.

Residence Time Distribution (RTD) theory was developed by and subsequently been used in industry for a number of processes including reaction vessels in chemical engineering,^{(1)}Zacca, J. J., Debling, J. A., & Ray, W. H. (1996). REACTOR RESIDENCE TIME DISTRIBUTION EFFECTS ON THE MULTISTAGE POLYMERIZATION OF OLEFINS–I . BASIC PRINCIPLES AND ILLUSTRATIVE EXAMPLES, POLYPROPYLENE. *Chemical Engineering Science*, *51*(21), 4859–4886. processing and packaging of cereals,^{(2)}Engineering : Residence Time Distribution IV. (2009), 2009. and in all sorts of general mixing research.^{(3)}Wolf, D., & Resnick, W. (1963). Residence Time Distribution in Real Systems. *I&Ec Fundamentals*, *2*(4), 287–293. http://doi.org/10.1021/i160008a008 The mathematics are quite simple and we’ll take just a minute to go over the major points before generalizing it for our uses.

A RTD is nothing more than a distribution plot that shows how many particles of each residence time there are. Just like a histogram of heights will tell us what percentage of the population is 5′ 8″, so too can the RTD with regards to residence time.

Therefore the residence time of the entire ensemble of particles is then given by this integral (same as the average value of our histogram).

And while all of this works quite well, we are missing one piece. These formulae are restricted to conservative tracers and in many systems, including the one we’re working on, tracers are reactive and thus non-conservative. Let’s fix this.

## Generalization

The current formulation assumed a “bomb” type addition of particles into the system, or for the more mathematically inclined a Dirac delta function. Once the particles are added, the formula assumes that the number of particles is conservative so they cannot simply disappear over time. To adapt this framework for a non-instantaneous addition of particles, I’ve come up with this conceptual model. Currently we’re calculating how *old* the particles are when they leave the system, yet the residence time doesn’t have to be equal to this. For a “bomb” style release then these two aspects are true, but in our more general formulation we want to know how much have the particles *aged* while in the system.

Therefore we have:

Applying this concept to our existing formula we arrive at this,

While this equation still requires the assumption of conservation (no loss term), there would be ways to extend it for such a system. For our needs, this equation is perfect and allows for the calculation of a residence time which is scale invariant and for a reactive tracer. Perhaps most importantly, this formula moves us away from the assumption of steady state which plagues most environmental research. Not only is the steady state condition rarely confirmed (evidence please?) but it is also probably not true in general. By basing work off of the SS assumption, all conclusions are contingent on it, and that is not a good place to be.

Notes

1. | ↑ | Zacca, J. J., Debling, J. A., & Ray, W. H. (1996). REACTOR RESIDENCE TIME DISTRIBUTION EFFECTS ON THE MULTISTAGE POLYMERIZATION OF OLEFINS–I . BASIC PRINCIPLES AND ILLUSTRATIVE EXAMPLES, POLYPROPYLENE. Chemical Engineering Science, 51(21), 4859–4886. |

2. | ↑ | Engineering : Residence Time Distribution IV. (2009), 2009. |

3. | ↑ | Wolf, D., & Resnick, W. (1963). Residence Time Distribution in Real Systems. I&Ec Fundamentals, 2(4), 287–293. http://doi.org/10.1021/i160008a008 |

**leave a comment**for the author, please follow the link and comment on their blog:

**R Programming – Thomas Bryce Kelly**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...