Monte Carlo

Monte Carlo Simulation Improves Oxygen Consumption Estimation

Stop gambling! Use Monte Carlo simulation to accurately predict oxygen consumption in your biological reactor and assess the risk of oxygen supply failing to meet oxygen demand. With a spreadsheet add-in, you are no longer limited to using static, fixed values to calculate individual results. Spreadsheet models can be enhanced using Mont Carlo simulation to capture the changing, random behavior in, as well as the interactions between, the variables in a model. A range of values described by a probability distribution quantifies the model outcome, or result, allowing for an informed decision.

Opportunity Crudes

Industrial wastewater treatment systems are sometimes in a state of stress due to factors that can include highly variable flow rates, highly variable organic loading, pH extremes, elevated wastewater temperatures, and nutrient deficiencies (nitrogen and/or phosphorus). This is particularly true for wastewater systems in petrochemical plants due to the ever increasing ratio of “opportunity crude” to “sweet crude” oil production.

Opportunity crudes, compared to sweet crudes, generally have a higher concentration of one or more of the following: alcohols, amines, chloride salts, metals, phenols, solvents, sulfur compounds, surfactants, water, and numerous chemical additives to improve the viscosity, density, and corrosion characteristics of the crude oil, provide antifreeze protection, and sequester sulfur. These non-oil components are washed out of the crude in the desalter and represent the largest flow, contaminant, and five-day biochemical oxygen demand (BOD5) contributors to the wastewater plant. Too often, the result is an overloaded, oxygen-deficient, biologically stressed activated sludge system with solids that settle poorly in the secondary clarifier and an odorous environment that engages the community in a negative way.

So why use opportunity crudes as feedstock? The answer is one of economics: Opportunity crudes are cheaper, so the price differential between the crude oil purchase cost and the sell price for finished products (gasoline, diesel, jet fuel, home heating oil, etc.) is much greater, increasing the profitability of the refinery.

Impact on the Refinery Wastewater System

At many refineries, the wastewater system was designed to handle a relatively narrow range of flows and organics resulting from the processing of a reduced crude slate (range of crude oils). The aeration basin volume and the associated oxygen supply system were sized to satisfy mixing requirements and the oxygen uptake rate (OUR) of a bacterial population nourished on a predictable substrate. However, the increase in the production of opportunity crudes has resulted in several significant changes in wastewater quality and characteristics.

Flow rates to the wastewater plant are rising along with increases in both the solubility and concentration of the BOD5 entering the biological reactor, forcing the need for an elevated mixed liquor suspended solids concentration, pushing the mean cell residence time past design limits for a given activated sludge process, all of which boost oxygen demand. This raises the OUR without a corresponding hike in the oxygen supply. The result is easily predicted: Consistently low dissolved oxygen (DO) levels in the aeration basin; a decline in bacterial metabolism; a decrease in BOD5 removal rates; a reduction, or cessation, in nitrification rates for nitrifying plants; an increase in low-DO filamentous bacteria; and surging odor complaints.

Wastewater Plant Design and Loading

A simple process flow diagram of the wastewater system referenced in this analysis is shown in Figure 1. This is an industrial plant treating a refinery wastewater using equalization, dissolved air flotation to remove free and emulsified oil, and a plug-flow activated sludge system followed by secondary clarification. Waste activated sludge (WAS) is aerobically digested and the digested solids go to a belt filter press prior to being landfilled.

Figure 1: Wastewater Treatment Plant Process Flow Diagram

Wastewater plant layout example

The current oxygen supply system for the 5,678 m3 (1.5 mil gal or MG) aeration basin, per the original design, is 8,165 kg/d O2 (18,000 lb/d O2). This quantity of oxygen is no longer sufficient for the biological reactor, nor has it been for quite a while, as evidenced by the fact that the average DO concentration in the aeration basin outlet, based on continuous measurements spanning a three-year period, was 0.19 mg/L.

The mean BOD5 concentration entering the aeration basin, for the three-year period being analyzed, was 229 g/m3 with a maximum value of 659 g/m3. The mean influent flow rate during this period was 15,171 m3/d (4.0 mgd) with a peak flow of 25,741 m3/d (6.8 mgd). Using the mean values, the quantity of BOD5 entering the biological reactor was, on average, 3,469 kg/d (7,642 lb/d BOD5). The carbonaceous oxygen demand for this BOD5 loading is estimated with Equation 1, the “standard form” of the equation that uses a BOD conversion factor of 0.68, explained in detail below. This equation takes into account the solids removed through sludge wasting and deducts the oxygen demand of those solids. Nitrogenous oxygen demand was not considered given this plant’s inability to nitrify while this analysis was underway.

Equation 1: Calculation of Carbonaceous Oxygen Demand

Calculation of oxygen demand equation


  • Q is the influent flow rate in units of m3/d (mgd or mil gal per day).
  • BODinf is the biological reactor influent BOD5 concentration in units of g/m3 (mg/L).
  • BODeff is the secondary clarifier effluent BOD5 concentration, arbitrarily set to a low value of 10 g/m3 (mg/L) to be conservative in the estimation of carbonaceous oxygen demand.
  • Unit conversion = 10-3 kg/g (8.34 lb/gal)
  • Conversion factor for converting all carbonaceous BOD5 to end products (CO2 and H2O) is 0.68 for municipal wastewater plants, ≤0.20 to 0.68 for industrial wastewater plants with lower values directly correlated with an increasing percentage of refractory compounds.
  • 1.42 represents the stoichiometric relationship between bacterial cells (C5H7NO2) and the oxygen required to stabilize organic substrate (1.42 g O2/g biodegradable solids).
  • WASkg  is the quantity of waste activated sludge, kg/d (lb/d).

The daily waste activated sludge quantity is calculated using Equation 2. This equation uses the observed yield coefficient, Yobs, which was derived from plant operating data. For municipal wastewater plants, the typical value of Y ranges from 0.5 to 0.7 g MLVSS/g BOD5 removed. In the stressed environment of an industrial wastewater system, the value of Y is much smaller, with the mean of Yobs = 0.239 for this particular plant.

Equation 2: Calculation of Waste Activated Sludge Quantity

Calculation of waste activated sludge equation


  • QWAS is the waste activated sludge flow rate in units of m3/d (mil gal per day).
  • RASTSS is the return activated sludge concentration, g/m3.
  • Yobs is the observed yield coefficient that directly reflects the net sludge production.

BOD Conversion Factor Applied to an Industrial System

The required oxygen supply to a biological reactor is determined using the ultimate BOD (BODu), rather than the five-day BOD. The BODu includes the oxygen demand associated with carbonaceous oxidation plus the oxygen demand related to endogenous respiration. For domestic wastewater, the ultimate BOD is estimated as being equal to the BOD5 multiplied by a conversion factor in the range of 1.2 to 1.6 with the typical value for BODu/BOD5 equal to 1.46 (von Sperling). The reciprocal of the BOD5 conversion factor (1/1.46) is 0.6849, rounded to 0.68 in the denominator of Equation 1. This value represents the percentage of organic matter that is stabilized by the fifth day of the BOD test and accounts for 68% of the total oxygen consumption at day five.

Industrial wastewater plants, with highly variable organic concentrations, use chemical oxygen demand (COD), instead of BOD, for process control purposes because the COD test can be completed in approximately two hours. But another, and perhaps more important, reason for using COD in an industrial wastewater environment is because the COD test measures the majority of organic matter, including refractory, or slowly biodegradable (as well as non-biodegradable), organic compounds in the sample. In comparison, the BOD5 test only measures the oxygen used for oxidation of non-refractory, soluble organic matter. Of the two test procedures, COD is considered to provide a better measurement of the oxygen demand of the wastewater than BOD5. Because the COD measurement represents the oxygen demand for biodegradable, slowly biodegradable, and non-biodegradable organic compounds, it is always higher than the BOD5 value for the same sample. In the absence of refractory compounds, the typical ratio of COD to BOD is 2.13. In the presence of refractory compounds, the COD/BOD5 ratio is highly variable.

The mean COD/BOD5 ratio for this data set was 4.02, with a minimum value of 2.14 and a maximum of 11.73, indicating a significant amount of refractory compounds in the wastewater at different times. As the COD/BOD5 ratio increases, there is a corresponding decrease in the BOD conversion value, calculated using Equation 3. Because the BOD conversion value is in the denominator of Equation 1, as it decreases, the oxygen consumption increases. Therefore, a failure to adjust the conversion factor to account for an increase in the COD/BOD5 ratio would significantly underestimate the oxygen demand. As a function of the COD/BOD5 ratio, the BOD conversion factor (BOD5/BODu) is adjusted (Equation 3) with COD/BOD5 ≥ 2.1317 (when BODu/BOD5 is set equal to 1.46).

Equation 3: Adjustment of BOD Conversion Factor

Static Spreadsheet Model

Equation 1 has been entered into a spreadsheet model as shown in Figure 2. The model takes several input values or variables (flow, BOD, etc.) to compute the desired outputs (Oxygen Consumption or Net Oxygen in Reactor). Using the mean value for each input, it can be seen that, on average, there is an excess of oxygen (net oxygen) in the biological reactor of 864 kg/d O2 (1,906 lb/d O2). Figure 2 represents a static model that only changes when an input value is changed. A change can be made to one or another input to answer a range of “what-if” questions but this is a cumbersome and time-consuming method of analysis.

Figure 2: Excel Spreadsheet Entries to Calculate Oxygen Demand

Excel spreadsheet to calculate oxygen demand

Table 1 is a frequency table providing a detailed breakdown of the aeration tank outlet DO concentration, using 0.10 mg/L increments. This table shows that 85.6% of the time the aeration outlet DO was less than 0.10 mg/L. Yet the spreadsheet model estimates a significant oxygen surplus of 864 kg/d O2 indicating that, of the available oxygen supply, only 89.4% is required for oxidation and endogenous respiration, with the remainder contributing to what should be a significant DO residual, certainly much greater than an average value of 0.19 mg/L. The spreadsheet model is unable to predict, or even hint at, the possibility of the low DO concentration so predominate in the aeration tank.

Table 1: Frequency Table of Dissolved Oxygen Concentrations

Frequency table of DO concentrations

Use of Monte Carlo Simulation

Monte Carlo simulation is a sampling experiment with the purpose of estimating the distribution of an outcome variable that depends on the probability distributions of several input variables. For any variable, its probability distribution is defined by a minimum and maximum value, whether known or estimated, and the likelihood of occurrence, or the probability of being sampled during a simulation, for each value within the range. Monte Carlo simulation can also be used to determine risk, as in the probability of not having some minimum oxygen level in the aeration basin, below which treatment will be less than optimal and odor generation potential will increase.

The oxygen consumption estimation approach used in the spreadsheet model portrayed in Figure 2 made use of the mean value, a point estimate, for each input variable. However, each input variable is experiencing constant, random change that a point estimate does not capture. For example, Figure 3 is a histogram that shows the spread or variability in the influent BOD5 concentration with a probability distribution fit to the data. An estimate of the uncertainty in the data is given where we can state that the influent BOD5 concentration, 87.8% of the time, will be varying between the range of 136 to 341 g/m3. With Monte Carlo simulation, the inherent uncertainty in each variable is captured, in the form of a probability distribution, and that distribution is then used to more accurately estimate an output which, in this example, is oxygen consumption.

Figure 3: Histogram of Influent 5-day BOD

Histogram of Influent BOD

Probability distributions were fit to each of the five input variables: 1) influent flow, 2) influent BOD5 concentration, 3) BOD conversion factor, 4) observed yield coefficient, and 5) WAS quantity. By applying a probability distribution to each variable, Monte Carlo simulation can be used to run thousands of iterations where each variable is randomly changing within the constraints defined by the probability distribution associated with it. The output variable of interest, oxygen consumption, is also changing throughout the simulation, in response to changes in, and the interactions between, the input variables, with the result being a range of values and associated probabilities rather than a single value.

Figure 4 shows the output, a probability distribution for oxygen consumption, generated from a simulation run where each input variable was randomly sampled 10,000 times. The probability distribution estimates that 37.5% of the time the oxygen consumption will exceed 8,165 kg/d O2 (18,000 lb/d O2), the maximum quantity of oxygen that can be supplied to the aeration basin. In other words, the expected DO concentration in the aeration tank outlet, 37.5% of the time, would be at or near 0 g/m3. The spreadsheet model has no way to provide this kind of insight, returning as it did a single value, a result that indicated an oxygen surplus was to be expected.

Figure 4: Distribution of Oxygen Consumption Values

Distribution of oxygen consumption

With the simulation results, what-if analysis can easily be conducted to answer questions. For example, if the oxygen supply system (mechanical aerators, diffused air, etc.) was increased to supply an additional 2,268 kg/d O2 (5,000 lb/d O2), to bring the total oxygen generation capacity to 10,433 kg/d O2 (23,000 lb/d O2), what percentage of time would the oxygen supply not meet oxygen demand? In Figure 5, the upper limit was adjusted to 10,433 kg/d O2 (23,000 lb/d O2) and the probability of oxygen demand exceeding supply was reduced from 37.5 to 22.0 percent.

Figure 5: Oxygen Supply Increased

Oxygen supply increased

At 22%, this percentage is still considered to represent too great a risk of being oxygen deficient and likely to generate odors. Therefore, the what-if scenario became one of wanting to know how much additional oxygen would be required to lower the risk of not meeting demand to 5 percent. Because the Monte Carlo simulation results are interactive, this can be determined simply by adjusting the upper limit to the 5% mark as shown in Figure 6. As the probability distribution shows, it would take an oxygen supply capacity of 17,082 kg/d O2 (37,659 lb/d O2), representing an increase in capacity of 109%, to reduce the risk level to 5 percent.

Figure 6: Oxygen Supplied to Minimize Risk

Oxygen supplied to minimize risk

Evaluation of Simulation Input Variables

Five input variables, with five different probability distributions derived directly from an extensive plant operating data set, were used to calculate the oxygen consumption using Monte Carlo simulation. Sensitivity analysis can be performed to determine which variable had the most influence on the output. Intuitively, the most likely candidates would be the combination of influent flow and influent BOD used to calculate the BOD loading on the biological reactor. From Figure 7, though, we can see that the ratio of the five-day BOD to the ultimate BOD (BOD5/BODu), which is the BOD conversion factor, was most influential, followed closely by the influent BOD5 concentration itself.

Figure 7: Influence of Input Variables on Oxygen Consumption

Influential variables

Had the analysis been conducted on a municipal wastewater plant, with little industrial contribution, the major influence of the BOD conversion factor would be a surprising, and suspicious, result, bringing into question the validity of the model. However, the analysis is on a refinery wastewater, with a highly variable COD, in terms of both concentration and the percentage of refractory compounds present. With such a wide range in the COD/BOD5 ratio, from 2.14 to 11.73, with an elevated mean value of 4.09, compared to a typical value of 2.13, the significant influence of the BOD conversion factor makes a lot of sense, lending support to the validity of the model.

Concluding Remarks

Monte Carlo simulation was performed in the presence of stakeholders and decision makers so they could see firsthand how this type of model is developed and the ways in which conclusions can be drawn. Results from simulations can be portrayed and communicated in numerous ways to suit any audience and to answer most questions. The primary focus of this analysis was on oxygen demand vs. oxygen supply. A common problem in chemical and petrochemical wastewater systems is insufficient oxygen supply to the biological reactor. At this North American refinery, Monte Carlo simulation was used to not only model oxygen utilization, it was also used to model key activated sludge process control parameters such as the food-to-mass ratio and mean cell residence time (MCRT).

In each case, when using point estimates to generate results, the static spreadsheet model failed to identify operating problems (insufficient DO, MCRT out of range, etc.) at the wastewater plant. By capturing and modeling the random variability in a comprehensive data set, problem areas were quickly revealed and quantified. With the probability of achieving a desired outcome known, the decision was made to increase the oxygen supply as part of an expansion to the biological treatment system.

When the expanded biological system was put into operation, going from a single-stage to a two-stage activated sludge system, the results were both immediate and stunning! Low DO was no longer an issue and the odor environment improved, effectively eliminating odor complaints. Solids settling in the secondary clarifiers improved. And the refinery is no longer constrained in its use of opportunity crudes due to high concentrations of ammonia (amines) entering the wastewater plant because the nitrification rate, previously stifled due to a lack of oxygen, literally took off, providing ammonia reduction far greater than required by the plant’s NPDES permit.


von Sperling, Marcos. Activated Sludge and Aerobic Biofilm Reactors. London: IWA Publishing, 2007.

Home   Activated Sludge   Oxygen Consumption   Monte Carlo   Polymer