2 Ordinary Differential Equations
Total Page:16
File Type:pdf, Size:1020Kb
Technical University of Munich Department of Informatics Bachelor’s Thesis in Informatics Robust Development with Continuous Integration in TIDOWA Robuste Entwicklung mit Kontinuierlicher Integration in TIDOWA Author: Hoang-Trieu Tong Supervisor: Prof. Dr. rer. nat. Martin Schulz Advisor: Dr. rer. nat. Martin Schreiber Submission Date: 15.04.2021 I confirm that this bachelor’s thesis is my own work and I have documented all sources and material used. Place, Date Hoang-Trieu Tong Abstract As software projects grow, the respective source code will become more complex and the number of developers that work simultaneously on the project will increase. Unfortunately, the same applies for the probability of errors occurring during the period of developing such a software. Thus, some countermeasures are required to minimize the probability of major errors and to detect software bugs in the project. Continuous integration (CI) and CI environments represent possible countermeasures. This thesis reports on CI and various implementations of CI applied to TIDOWA, a recently developed software program that is able to compute the approximate solution of initial value problems by means of time integration methods. In addition, a test framework is developed and implemented to verify the validity of TIDOWA’s implementations especially the validity regarding the convergence behavior of the implemented time integration methods. The CI environment in combination with the test framework represents a step towards creating a software development environment that allows better cooperation of developers and improves the quality of the software. i Contents Contents 1 Motivation 1 2 Ordinary Differential Equations 3 2.1 Introduction . 3 2.2 Initial Value Problems . 4 2.3 Examples . 7 2.3.1 System of Linear Oscillating Equations . 7 2.3.2 Model of the Circadian Clock . 7 2.4 Numerical Solution of IVPs . 8 2.4.1 Introduction . 8 2.4.2 Explicit Euler Method . 9 2.4.3 Heun Method . 9 2.4.4 Runge-Kutta Method of Order 4 . 10 2.4.5 Implicit Time Integration Method . 12 2.5 Concept of Convergence . 12 3 TIDOWA 15 4 Continuous Integration (CI) 17 4.1 Definition and Examination of CI . 17 4.2 Common Practices . 19 4.3 Overview of CI Implementations . 20 5 CI-Oriented Changes and Extensions in TIDOWA 27 5.1 Preliminaries . 27 5.2 Restructuring of TIDOWA . 27 5.3 Integration of Python Setuptools and Virtual Environment . 30 5.4 Test Framework . 31 5.5 Further Extensions . 31 ii 6 Continuous Integration in TIDOWA 32 6.1 Introduction . 32 6.2 Implementation of the Test Framework . 32 6.2.1 System Design: Essential Requirements and Design of the Test Framework 32 6.2.2 Implementation: Introduction . 38 6.2.3 Implementation: Preliminaries . 40 6.2.4 Implementation: Modules - The Core Four . 42 6.2.5 Implementation: Connectors - Data Transfer between Modules . 47 6.2.6 Implementation: Administrative Structure - Unification into One Program 49 6.3 Integration of CI Environment . 54 6.3.1 System Design: Selection and Essential Requirements of the CI Environment 54 6.3.2 Implementation: Preliminaries . 55 6.3.3 Implementation: Integration of Test Framework . 56 7 Case Study: Usage of Test Framework 59 7.1 Structure of Tests . 59 7.2 Interaction with Tests . 60 7.3 Test Execution in Local Environment . 60 8 Conclusion and Outlook 61 Bibliography 63 iii 1 Motivation Ordinary differential equations are often used in the field of physics, biology, medicine or even warfare to model complex correlations, e.g. the behavior of a pendulum or the ratio of two species over a certain period of time. What is more interesting than creating a model to certain problems is to find a way to solve them and thus predict events that may occur. One possible approach with which one may solve ordinary differential equations is the numeric approach that applies numerical methods onto these equations to derive an approximation of the solution. As some of the methods were developed by mathematicians who lived back then before the digital age, it is possible to use these procedures manually without any computational assistance. However, using this approach for models and problems that contain hundreds or thousands of equations takes a fair amount of time. Fortunately, with the digital revolution it is possible to hand such tasks over to computers with suitable programs. A program that is capable of this is TIDOWA. TIDOWA, developed at the Technical University Munich (TUM), provides implementations of different numerical methods that can be used to approximate the solution of ordinary differential equations. The software already offers a variety of numerical methods, nonetheless the project still is in its early stages. As the program grows and new functionalities are added, it is essential that the parts implemented so far are correct. This is important as future extensions might be based on old functionality. If older parts are erroneous, future developers will encounter lots of trouble and require much effort to fix parts of the software for which they are not responsible for and with which they are not familiar with. As this should not be the fate of every successive developer, it is time to take TIDOWA to the next level and introduce an environment that continuously tests the software and detects incorrect implementations, thus allowing developers to fix them in a timely manner. This thesis reports on the introduction of an environment to TIDOWA that continuously reviews the state of the software to detect possible errors as early as possible. In this context, it also covers the implementation of a test framework for TIDOWA that allows developers to 1 1 Motivation verify certain attributes concerning the behavior of implemented numerical methods. Chapter 2 discusses the fundamental concepts of ordinary differential equations that are used in TIDOWA. It introduces the theory and terminology necessary to further develop the software. Chapter 3 summarizes the history and the current state of the program. It also depicts the way how TIDOWA works and the interaction of the individual modules and stages within the software. Chapter 4 examines the subject of continuous integration from a theoretical standpoint. Additionally the chapter presents and compares various existing implementations of continu- ous integration environments. Chapter 5 presents the changes that were introduced to the software to integrate it into a continuous integration environment and to simplify its development for future developers. Chapter 6 discusses the two components that were newly introduced with the work of this thesis, them being the continuous integration environment and the test framework. First, the theory behind both is examined, which includes the selection process of the continuous integration environment and the design of the test framework. Afterwards, the details con- cerning both implementations are described. Chapter 7 describes the usage of the test framework. The chapter displays how tests are structured, added, removed and further executed inside a local environment. 2 2 Ordinary Differential Equations This chapter discusses the fundamentals regarding ordinary differential equations (ODEs), initial value problems (IVPs), time integration (TI) methods and convergence. It briefly introduces important concepts and terms that are included in TIDOWA. The following explanations and descriptions in Chapter 2.1 are based on [1, 2, 3, 4]. 2.1 Introduction Ordinary differential equations (ODEs) are equations that connect: • y(t), an unknown function with t being a variable, often used to identify the varying aspect time and • derivatives of this unknown function that are displayed with e.g. y0(t), y0, y(1)(t) or y(1) for the first derivative of y(t). In this context, y is referred to as dependent variable and t as independent variable. There are two important terms regarding ODEs: order and degree. The order of an ODE is equal to the “order of the highest derivative that appears in the”[1] ODE. Furthermore, the degree of an ODE is identical to the exponent of the highest derivative. If we consider the following exemplary ODE, it has an order of 4 and a degree of 1. y0(t)6 + 5y00(t)2 − 3y000(t)5 − 2y0000(t) = 0 One way of presenting ODEs is the so called standard form or normal form of the ODE. The standard form or normal form of a general ODE of order n is as follows: y(n)(t) = f(t, y(t), y(2)(t), ..., y(n−1)(t)) where f depicts a given functional relationship of y and t. The function s(t) is a solution of the ODE, defined in the interval I ⊆ R, if the follow- ing conditions apply: 3 2 Ordinary Differential Equations • the function s(t) is differentiable in I • functional identity: If y(t) and its derivatives y(i)(t) can be replaced by s(t) and its derivatives s(i)(t), with ∀t ∈ I, so that the equation is still satisfied, it is called functional identity We consider the following ODE as an example: 0 + y (t) = 4y(t) t ∈ R The solution of this example is the function s(t) = e4t. When y(t) and y0(t) are replaced with s(t) and s0(t) = 4e4t, the equation is still satisfied with: 4e4t = 4e4t. Thus, the functional + identity is fulfilled. In addition, s(t) is differentiable in R . It should be noted that in general an ODE has not only one but infinite solutions. The whole set of solutions is referred to as general solution or complete solution. In general we deal with systems of ODEs that consist of multiple ordinary differential equa- tions rather than individual equations. Examples for such systems are examined in Chapter 2.3. For the sake of completeness it should be mentioned that other types of differential equations such as partial differential equations exist as well.