next up previous index
Next: Anatomy of a model Up: How to create a Previous: Algebraic Models   Index

Click for printer friendely version of this HowTo

Ordinary Differential Equations

Models can be built from words or from equations. We usually start with a word model, or qualitative model, just to get the central concepts organized. But qualitative models are difficult to explore and sooner or later, we find ourselves translating actions in our word models into equations that describe the quantitative results of these actions. Tools such as matlab and octave make quantitative models easy to explore. Simple command line tools, series and tf also give us a means for exploring algebraic models. series generates a sequence of numbers of length num_terms from begin to end This sequence of numbers can then be piped into tf, a tool for evaluating an algebraic expression and these results can be piped into a plot tool. Thus, a you can set up an easy pipeline with a shell command like this:
shell> series begin end num_terms | 
       tf "algebraic_expression" | plot
and the moral of the story is that numerical tools enable the model to be used as a simulation of the real phenomena and certain hypotheses can be tested against it. Word models, on the other hand, can describe a process, but are not so easily converted into computer programs and tested.

Differential equations come in all flavors and sizes. They basically have the form

$\displaystyle \frac{\textrm{d}y}{\textrm{d}t} = f(y,t),$    

where $ f(y,t)$ can be linear, nonlinear, have constant coefficients or variable coefficients. Often times $ y$ is a function of $ t$. That is, $ y = y(t)$. The highest order derivative in the equation determines the order of the differential equation. Differential equations with only a single independent variable are called Ordinary Differential Equations (ODEs). Those with more than one independent variable are called Partial Differential Equations (PDEs), due to the fact that the derivatives are partial derivatives. The solution to a differential equation is the unknown function $ y(t)$ that you have the derivative for. While this may seems backward, in nature, we can observe how something changes over time, and thus, we can fit a derivative to this data. From this derivative, we then try to determine the original function.

A differential equation describes changes in one variable relative to another variable, and as such, solutions to differential equations are functions that describe the ups and downs of a function. For example, $ y = \sin(t)$ or $ y = Ae^{-bt}$ where $ y$ is the dependent variable and $ t$ is the independent variable. The differential equation:

$\displaystyle \frac{\textrm{d}y}{\textrm{d}t}=-by$ (2.4.1)

is an equation that says the change in $ y(t)$ for a certain change in $ t$ is negatively proportional to the value of $ y(t)$. In other words, when $ y(t)$ is large, the slope of the solution (d$ y$/d$ t$) is negative and proportional to $ y(t)$ (the proportionality constant is $ b$). As $ y(t)$ becomes smaller, the slope becomes smaller.

The solution to Equation 2.4.1 is

$\displaystyle y(t) = Ae^{-bt },$ (2.4.2)

where the constant $ A$ is determined by the ``initial condition'', the value of $ y(t)$ when $ t=0$. If $ y(0) = 1$, then $ y(t) = e^{-bt}$; if $ y(0) = 100$, then $ y(t) = 100e^{-bt}$. The solution of the differential equation, produces a ``class'' of similar solutions, and a particular member of that class is identified by the initial condition.

Building an ODEno_title

Example (Building an ODE)  

Consider a simple chemical reaction. We have a substance, $ A$, that spontaneously converts to $ B$ with a rate, $ k$, while $ B$ spontaneously converts to $ A$ with a rate, $ l$. Schematically, we can notate this with the equation:

$\displaystyle A \underset{\emph{l}}{\overset{\emph{k}}{\rightleftharpoons}}B.$    

From this, we can describe the change in $ A$ as the proportion of $ B$ that converts into $ A$ minus the proportion of $ A$ that changes into $ B$. That is,

$\displaystyle \frac{\textrm{d}A}{\textrm{d}t} = \emph{l}B -\emph{k}A.$ (2.4.3)

If we enforce conservation of mass so that the combined mass of $ A$ and $ B$ is always constant, $ A + B = P_{\textrm{max}}$, we can now rewrite the Equation 2.4.3 as

$\displaystyle \frac{\textrm{d}A}{\textrm{d}t} = l(P_{\textrm{max}} - A) -kA.$ (2.4.4)

Without explicitly finding a solution to Equation 2.4.4, we can determine what it will be when it is at equilibrium. That is to say, we can determine what proportion of $ P_{\textrm{max}}$ needs to be comprised of $ A$ such that the amount of $ B$ converting to $ A$ is the same as the amount of $ A$ converting to $ B$, or $ kA = l(P_{\textrm{max}} - A)$. We do this by setting the slope of $ A$ to zero and solving for $ A$:

$\displaystyle l(P_{\textrm{max}} - A) - k A$ $\displaystyle = 0$    
$\displaystyle lP_{\textrm{max}} - lA - k A$ $\displaystyle =$    
$\displaystyle lP_{\textrm{max}} - A(l + k)$ $\displaystyle =$    
$\displaystyle A(l + k)$ $\displaystyle = lP_{\textrm{max}}$    
$\displaystyle A$ $\displaystyle = \frac{lP_{\textrm{max}}}{(l+k)}$    
$\displaystyle A$ $\displaystyle = \frac{P_{\textrm{max}}}{(1+\frac{k}{l})}.$    

Thus, if

$\displaystyle A = \frac{P_{\textrm{max}}}{(1+\frac{k}{l})},$    

then the amounts of $ A$ and $ B$ will not change.

Now that we know what the equilibrium is, it is interesting to look at the general solution to Equation 2.4.4 because the equilibrium plays a large role in it. Equation 2.4.4 can be solved using various methods. In Example we show how to use an integrating factor to solve for $ A(t)$ and the result is:

$\displaystyle A(t) = \frac{P_{\textrm{max}}}{(1+\frac{k}{l})} - \left[\frac{P_{\textrm{max}}}{(1+\frac{k}{l})} - A(0)\right]e^{-(l+k)t}.$    

Notice what happens as $ t$ gets larger and larger. If we take the limit, we get

$\displaystyle \lim_{t \to \infty} A(t) = \frac{P_{\textrm{max}}}{(1+\frac{k}{l})},$    

and thus, the system converges on the equilibrium. The exponential term simply causes the difference between the initial condition, the amount of $ A$ at time $ t=0$, or $ A(0)$, the equilibrium to become smaller and smaller as time passes. $ \vert\boldsymbol{\vert}$

Two Componants as Oneno_title

Example (Two Componants as One)  

Now, consider a two component reaction,

$\displaystyle A + B \underset{l}{\overset{k}{\rightleftharpoons}} C.$    

This is called a second order reaction because the reaction rate depends on the concentration of two components, $ A$ and $ B$. However, under certain conditions, it can be treated as a first order reaction, like in Example When the concentration of $ A$ or $ B$ is essentially infinite, and there is a small concentration of the other component, then we have a pseudo first order reaction. Here we will show how this is possible from the differential equation.

We start with a 2nd order equation where the rate of formation is determined by the concentration of [$ A$] and [$ B$],

$\displaystyle \frac{\textrm{d}C}{\textrm{d}t} = kAB - lC.$    

We assume that $ A$s collide with $ B$s at a rate determined by the temperature of the reaction and that a certain fraction of the collisions will result in making a $ C$. If the availability of $ A$ is infinite so that its concentration never changes, the rate constant $ k$ can be rewritten as a pseudo rate constant $ k_p = kA$:

$\displaystyle \frac{\textrm{d}C}{\textrm{d}t} = k_{p}B - lC,$    

and this allows us to treat the second order reaction as if it were first order. This assumption, that $ A$ is infinite, is often reasonable when $ A$ is some sort of drug compound and $ B$ is a cellular receptor for this compound. $ \vert\boldsymbol{\vert}$

next up previous index
Next: Anatomy of a model Up: How to create a Previous: Algebraic Models   Index

Click for printer friendely version of this HowTo

Frank Starmer 2004-05-19