Software tutorial/Integration of ODEs

From Process Model Formulation and Solution: 3E4
Jump to navigation Jump to search

In our course we have learned several ways of integrating a single equation \(\displaystyle \frac{dy(t)}{dt} = f(t, y) \) with a given initial condition \(y(t=0)=y_0\); and we have shown that systems of ODE's can also be integrated: \[ \displaystyle \frac{d{\bf y}(t)}{dt} = {\bf f}(t, {\bf y}) \]given a set of initial conditions \({\bf y}(t=0) = {\bf y}_0\). We learned about Euler's method, Heun's method and Runge-Kutta methods.

However, we only coded Euler's method (because it was simple!), but not the others. These other methods have been (reliably) coded up by others and sophisticated error correction tools built into their algorithms. You should always use these toolbox functions to integration your differential equation models. In this section we will show how to use MATLAB and Python's built-in functions to integrate:

  • a single differential equation
  • a system of differential and algebraic equations.

We will only look at initial value problems (IVPs) in this tutorial.

MATLAB Python