Problem solving ODE equations with Runge-Kutta (order 2 or 4)

55 Views Asked by At

I've been tasked to solve two equations that model Penicillin growth in batches using Heun's method and Runge-Kutta 4 method. The model consists of two equations, one modelling the general concentration of cellular mass and the other the concentration of Penicillin itself. The equations are (respectively):

\begin{align} \frac{dy(t)}{dt} &=13.1\cdot y(t) - 13.94\cdot y(t)^2 \\ \frac{dx(t)}{dt} &= 1.71\cdot y(t), \end{align}

subject to $y(0) = 0.03$ and $x(0)=0$, $0\leq t\leq 1$ and $h = 0.1$.

I've already solved the first one but the problem I'm having is that I don't know how to apply the algorithm into the second one. I've found the following about the Heun's:

\begin{align} k_1 &= h\cdot f(t_n, x_n) \\ k_2 &= h\cdot f(t_{n+1}, x_n + k_1) \\ x_{n+1} &= x_n + \frac{1}{2}\cdot (k_1 + k_2) \end{align}

Just as an example for the first two values, $y(0) = 0.03$ and $y(0.1)=0.09$ and therefore I believe that for $x_1$, $k_1 = 0.1\cdot 1.71\cdot 0.09 = 0.154$, here I get stuck trying to find an expression for $k_2$.

1

There are 1 best solutions below

3
On BEST ANSWER

In your model $y$ does not depends on $x$ and it was numerically solved giving as result $y(t_n)$ for a generic $0 \le t_n \le 1$

Now for $x$ with $f(t_n,x_n) = \alpha y(t_n) = f(t_n)$ we have the recurrences

$$ \cases{ k_1 = h \alpha y(t_k)\\ k_2 = h \alpha y(t_{k+1})\\ x_{k+1} = x_k + \frac 12(k_1+ k_2)\\ t_{k+1} = t_k + h } $$

with $x_0 = 0$

NOTE

For Runge-Kutta order 4 we have regarding $x$

$$ \cases{ k_1 = h\alpha y(t_k)\\ k_2 = h\alpha y(t_k + \frac 12 h)\\ k_3 = h\alpha y(t_k+\frac 12 h)\\ k_4 = h\alpha y(t_{k+1})\\ x_{k+1} = x_k +\frac 16(k_1+2k_2+2k_3+k_4)\\ t_{k+1} = t_k + h } $$