Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

12 - More ODEs

Non-steady state scenarios occur all around us: heating up your cold hands, warming up your food, filling your washing machine, among a myriad of other examples. There’s also many non-steady state scenarios in chemical engineering: filling a tank, heating up a reactor, cooling down a reactor, etc. In this lecture, we will get more practice setting up problems and estimating a solution.

You should further understand at the end of this discussion that if you have an expression for the derivative, you can integrate that numerically to determine the system parameters as a function of time.

First Example: Predators and Prey

We know that predators and prey are related. If there are more prey, there will be more predators. If there are more predators, there will be less prey. This is a classic example of a coupled system. We can write a differential equation for the number of prey and predators as:

dPdt=aP−bPCdCdt=−cC+bPC\begin{align} \frac{dP}{dt} &= aP - bPC \\ \frac{dC}{dt} &= -cC + bPC \end{align}

where PP is the number of prey, CC is the number of predators, aa is the growth rate of prey, bb is a coupling parameter, and cc is the death rate of predators.

<Figure size 640x480 with 1 Axes>

Do you see that oscillatory pattern between predators and prey in nature?

Second Example: Solving the Lorenz Equations

The Lorenz equations are a set of three coupled, non-linear differential equations. They are used to model convection in the atmosphere and were developed by Edward Lorenz in 1963. Below is an example implementation of one solution to the Lorenz equations which are:

dxdt=σ(y−x)dydt=x(ρ−z)−ydzdt=xy−βz\begin{align} \frac{dx}{dt} &= \sigma(y-x) \\ \frac{dy}{dt} &= x(\rho-z)-y \\ \frac{dz}{dt} &= xy-\beta z \end{align}

where σ\sigma, ρ\rho, and β\beta are constants and are proportional to the Prandtl number, Rayleigh number, and other dimensional specific relations. xx is proportional to the convection rate, yy the horizontal temperature variation, and zz the vertical temperature variation.

<Figure size 1000x1000 with 1 Axes>

Third Example: Carbon Dioxide Concentration

Carbon dioxide (CO2CO_2) is produced by decaying organic matter. CO2CO_2 is consumed by photosynthesis processes. Below is a photo of a sealed terrarium.

If there are no plants in the terrarium, the CO2CO_2 concentration will increase over time. One estimate is it will increase at a constant rate according to the following differential equation:

dCCO2dt=k\frac{dC_{CO_2}}{dt} = k

where CCO2C_{CO_2} is the concentration of CO2CO_2 in the terrarium (ppm) and kk is the rate constant (1/time unit). This is a zero-order differential equation. The rate constant is proportion to the amount of soil decaying in the terrarium.

Given the above differential equation: dCCO2/dt=kdC_{CO_2}/dt = k, we can integrate both sides to obtain the concentration as a function of time easily by doing the integration analytically to yield:

∫C0CCO2dCCO2=∫0tkdtCCO2=kt+C0\begin{align} \int_{C_0}^{C_{CO_2}} dC_{CO_2} &= \int_0^t k dt \\ C_{CO_2} &= kt + C_0 \end{align}

where C0C_0 is the initial concentration of CO2CO_2 in the terrarium.

Now we’ll compare that linearly increasing predicted rate to a real scenario of carbon dioxide concentration inside a small terrarium. The atmosphere of the terrarium is first blown out with air and then it is completely closed with no plants present. Data was collected with a Bluetooth CO2 SCD30 monitor and an ESP32 microcontroller.

Loading...
Epoch_UTC 1687880366.8 Local_Date_Time 2023-06-27T09:39:26.827185 T 25.801 RH 92.05 CO₂ 2627.0 DP 24.41 AH 22.113 HI 26.84 MR 19.572 min 0.0 Name: 60870, dtype: object
<Figure size 640x480 with 1 Axes>

As can be seen above, our initial linear estimate isn’t very accurate. It appears that the production rate of CO2 is is initially at a constant rate and then at a certain concentration, it changes to a different rate. Perhaps a more accurate model would be:

dCCO2dt=k1−k2CCO2\frac{dC_{CO_2}}{dt} = k_1 - k_2C_{CO_2}
Loading...
<Figure size 640x480 with 1 Axes>

From this, it looks like the the dependenc of the rate of CO2 production is dependent on the concentration of CO2 in the terrarium but perhaps it’s not as strong as a first order relationship. Maybe a better approximation is:

dCCO2dt=k1−k2CCO20.5\frac{dC_{CO_2}}{dt} = k_1 - k_2C_{CO_2}^{0.5}

You can see if that’s a better fit to the data in a similar way I did above.

The above plot shows that the non-linear estimate (with parameters that were manually adjusted to better fit the data) is close to the actual data. Instead of manually adjusting the parameters, how could we estimate the parameters automatically? We could use a least squares approach to estimate the parameters. We’ll discuss that in the next lecture.