Skip to main content

Open Access 2024 | Open Access | Buch

Buchtitelbild

Solving Ordinary Differential Equations in Python

insite
SUCHEN

Über dieses Buch

This open access volume explains the foundations of modern solvers for ordinary differential equations (ODEs). Formulating and solving ODEs is an essential part of mathematical modeling and computational science, and numerous solvers are available in commercial and open source software. However, no single ODE solver is the best choice for every single problem, and choosing the right solver requires fundamental insight into how the solvers work. This book will provide exactly that insight, to enable students and researchers to select the right solver for any ODE problem of interest, or implement their own solvers if needed. The presentation is compact and accessible, and focuses on the large and widely used class of solvers known as Runge-Kutta methods. Explicit and implicit methods are motivated and explained, as well as methods for error control and automatic time step selection, and all the solvers are implemented as a class hierarchy in Python.

Inhaltsverzeichnis

Frontmatter

Open Access

Chapter 1. Programming a Simple ODE Solver
Abstract
Ordinary differential equations (ODEs) are widely used in science and engineering, particularly when it comes to modeling dynamic processes. Although analytical methods can be employed to solve simple ODEs, nonlinear ODEs typically require numerical methods for solutions. In this chapter we demonstrate how to program general numerical solvers capable of handling any ODE. Initially we will focus on scalar ODEs, which consist of a single equation and a single unknown. Subsequently, in Section 1.3, we will extend these concepts to systems of coupled ODEs. Acquiring a solid grasp of the concepts presented in this chapter will not only help you with programming your own ODE solvers but also in using a diverse range of readily available, general-purpose ODE solvers in Python or other programming languages.
Joakim Sundnes

Open Access

Chapter 2. Improving the Accuracy
Abstract
As mentioned previously, the FE method derived in Chapter 1 is not the most sophisticated ODE solver. Although it provides sufficient accuracy for most of the applications covered in this book, there are alternative methods available that offer improved accuracy and stability, making them better suited for solving challenging ODE systems. In this chapter, we will focus on enhancing accuracy, and thus we will primarily explore explicit methods. Implicit methods, which exhibit superior stability properties and are better suited for solving stiff ODEs, will be discussed in Chapter 3.
Joakim Sundnes

Open Access

Chapter 3. Stable Solvers for Stiff ODE Systems
Abstract
In the previous chapter, we introduced explicit Runge-Kutta (ERK) methods and demonstrated how they can be implemented as a hierarchy of Python classes. For most ODE systems, replacing the simple forward Euler method with a higher-order ERK method will significantly reduce the number of time steps needed to reach a specified accuracy. Furthermore, it often leads to reduced computation time, since the additional cost per time step is outweighed by the reduced number of steps. However, there exists a class of ODEs known as stiff systems, where all the ERK methods require very small time steps, and any attempt to increase the time step leads to spurious oscillations and possible divergence of the solution. Stiff ODE systems pose a challenge for explicit methods, and they are better addressed by implicit solvers such as implicit Runge-Kutta (IRK) methods. IRK methods are well-suited for stiff problems and can offer substantial reductions in computation time when tackling challenging problems.
Joakim Sundnes

Open Access

Chapter 4. Adaptive Time Step Methods
Abstract
In practical computations, one seeks to achieve a desired accuracy with the minimum computational effort. For a given method, this requires finding the largest possible value of the time step Δt. In the previous chapters we kept the step size constant through the solution interval, but this is rarely the most efficient approach, since the error depends on the characteristics of the solution in addition to the step size. In smooth regions, larger time steps can be used without introducing significant error, while smaller time steps are needed in regions where the solution has rapid variations. This chapter extends the Runge-Kutta methods from the previous chapters to methods that select the time step automatically to control the error in the solution.
Joakim Sundnes

Open Access

Chapter 5. Modeling Infectious Diseases
Abstract
Throughout this book we have focused entirely on solving ODEs, without delving deeply into their origins or applications. In the present chapter we shift our attention to modeling with ODEs, by exploring a widely studied class of ODE models that describe the spread of infectious diseases. This group of models serves as a good example of how a complex phenomenon can be modeled using relatively simple systems of ODEs. We will derive these models based on a set of fundamental assumptions and discuss the limitations that arise from these assumptions. Although we consider a single application and a single class of models, the fundamental steps of the modeling process are applicable to a wide range of real-world phenomena.
Joakim Sundnes
Backmatter
Metadaten
Titel
Solving Ordinary Differential Equations in Python
verfasst von
Joakim Sundnes
Copyright-Jahr
2024
Electronic ISBN
978-3-031-46768-4
Print ISBN
978-3-031-46767-7
DOI
https://doi.org/10.1007/978-3-031-46768-4

Premium Partner