A system of first‑order differential equations involves multiple dependent variables, each with its own derivative, coupled together. Many physical, biological, and engineering models naturally lead to such systems.
Examples:
Predator–prey dynamics(Lotka–Volterra)
Coupled oscillators
Chaotic systems(Lorenz attractor)
SepalSolver provides tools to solve these systems numerically using , just as with single ODEs, but the function signature changes to accept and return arrays.
The SIR model divides a population into three compartments: Susceptible (S), Infected (I), and Recovered (R). The model is defined by the following system of ODEs:
\begin{eqnarray}
\cfrac{dS}{dt} &= -\beta\cfrac{S I}{N} \\
\cfrac{dI}{dt} &= \beta\cfrac{S I}{N} - \gamma I \\
\cfrac{dR}{dt} &= \gamma I
\end{eqnarray}
Example 5C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Define the ODE as a function
double betaSIR = 0.3, gammaSIR = 0.1, N = 1000.0;
double[] dydt(double t, double[] y) => [
-betaSIR * y[0] * y[1] / N,
betaSIR * y[0] * y[1] / N - gammaSIR * y[1],
gammaSIR * y[1]];
// Initial condition
double[] y0 = [999.0, 1.0, 0.0];
// Time span
double[] tspan = [0, 160];
// Solve the ODE using Ode45
(ColVec T, Matrix Y) = Ode45(dydt, y0, tspan);
// Plot the results
Plot(T, Y, Linewidth: 2);
Legend(["S", "I", "R"], UpperLeft);
Title("SIR Epidemic Model");
Xlabel("t");
Ylabel("population");
SaveAs("SIR_Epidemic_Model.png");
OutputFrom the book
.. Admonition:: Example 5 : Brusselator Model
The brusselator is a theoretical model for a type of autocatalytic reaction. It is defined by the following system of ODEs:
.. Admonition:: Example 6 : Blasius Boundary Layer
The Blasius Boundary Layer refers to a boundary layer of fluid in the vicinity of a flat plate that moves steadily in its own plane.This concept was first introduced by German mathematician Heinrich Blasius. This solution is important in the field of fluid dynamics, particularly in the area of laminar flow.In this solution, the flow velocity outside the boundary layer is assumed to be uniform. Inside the boundary layer, the fluid's velocity changes from zero at the plate surface to the free stream velocity at the edge of the boundary layer. This concept plays a significant role in understanding and predicting the behavior of fluid flow in various engineering and scientific applications. The solutions to the Blasius equation provide valuable insights into the behavior of fluid flow near a boundary. For instance, it demonstrates that the boundary layer thickness grows as the square root of the distance along the plate. Also, it reveals that the shear stress at the plate surface is proportional to the square root of the free stream velocity, among other observations. The Blasius Boundary Layer solution, despite its simplifications, offers a good approximation for real-life engineering problems involving fluid flow over flat surfaces.This understanding is crucial in designing and optimizing various engineering systems, ranging from airfoils in aeronautics to heat exchangers in thermal power plants and thermal shield design on reusable rockets.
2f′′′+f′′f=0
This equation can be solved by transforming it into a system of 1st order differential equations. Let: y_1 = f, y_2 = f', y_3 = f'' hence
So, the system of first order differential equation is thus:
y1′y2′y3′===y2,y3,−0.5y3y1
Subject to the following initial and terminal conditions. y_1(0) = 0, y_2(0) = 0, y_2(\infty) = 1 To solve system of ordinary differential equation, you need the initial conditions, but when one of the initial conditions is missing, and we have a terminal condition instead, we can solve for the initial condition we do not have using the terminal condition we have, just like finding the root of a nonlinear function.But to evaluate the value of the function that you want to be zero, you have to perform the integration of the ode, using the guess given by the nonlinear solver and then return the function value which is the difference between the terminal value you obtained from the integration and the desired value.In this case the unknown value is y_3(0), and the function value is y_2(\infty) - 1.