**Narration**
1
00:00:01 --> 00:00:08
Dear Friends, Welcome to the Spoken Tutorial on **Solving ODEs using Scilab ode function**
2
00:00:09 --> 00:00:11
At the end of this tutorial, you will learn how to:
3
00:00:12 --> 00:00:14
Use Scilab ode function
4
00:00:15 --> 00:00:17
Solve typical examples of **ODEs** and
5
00:00:18 --> 00:00:20
Plot the solution.
6
00:00:21 --> 00:00:23
The typical examples will be:
7
00:00:24 --> 00:00:25
Motion of **simple pendulum**
8
00:00:26 --> 00:00:27
**Van der Pol equation**
9
00:00:28 --> 00:00:29
and ** Lorenz system**.
10
00:00:30 --> 00:00:32
To record this tutorial, I am using
11
00:00:33 --> 00:00:35
**Ubuntu 12.04** as the operating system
12
00:00:36 --> 00:00:39
and **Scilab 5.3.3** version.
13
00:00:40 --> 00:00:44
To practice this tutorial, a learner should have basic knowledge of **Scilab**
14
00:00:45 --> 00:00:47
and should know how to solve **ODEs.**
15
00:00:48 --> 00:00:55
To learn **Scilab,** please refer to the relevant tutorials available on the **Spoken Tutorial** website.
16
00:00:56 --> 00:01:00
The **ode** function is an **ordinary differential equation solver**.
17
00:01:01 --> 00:01:09
The syntax is **y equal to ode** within parenthesis **y zero, t zero, t** and **f**.
18
00:01:10 --> 00:01:14
Here **y zero** is the initial condition of the **ODEs**,
19
00:01:15 --> 00:01:16
**t zero** is the **initial time**,
20
00:01:17 --> 00:01:18
**t** is the **time range**,
21
00:01:19 --> 00:01:21
and **f** is the **function**.
22
00:01:22 --> 00:01:24
Consider the motion of **simple pendulum.**
23
00:01:25 --> 00:01:32
Let **theta t** be the angle made by the **pendulum** with the **vertical** at time **t.**
24
00:01:33 --> 00:01:35
We are given the initial conditions-
25
00:01:36 --> 00:01:38
**theta of zero** is equal to **pi by four** and
26
00:01:39 --> 00:01:43
**theta dash of zero** is equal to **zero.**
27
00:01:44 --> 00:01:46
Then the position of the **pendulum** is given by:
28
00:01:47 --> 00:01:55
**theta double dash t minus g by l into sin of theta t equal to zero.**
29
00:01:56 --> 00:02:02
Here **g equal to 9.8 m per second square** is the **acceleration due to gravity** and
30
00:02:03 --> 00:02:10
** l equal to zero point five meter** is the length of the **pendulum.**
31
00:02:11 --> 00:02:21
For the given initial conditions, we have to solve the **ODE** within the **time range zero less than equal to t less than equal to five.**
32
00:02:22 --> 00:02:24
We also have to **plot** the solution.
33
00:02:25 --> 00:02:28
Let us look at the code for solving this problem.
34
00:02:29 --> 00:02:33
Open **Pendulum dot sci** on **Scilab editor.**
35
00:02:34 --> 00:02:39
The first line of the code defines the initial conditions of the **ODE.**
36
00:02:40 --> 00:02:45
Then we define the intial time value. And we provide the **time range.**
37
00:02:46 --> 00:02:51
Next, we convert the given equation to a system of **first order ODEs.**
38
00:02:52 --> 00:02:55
We substitute the values of **g** and **l** .
39
00:02:56 --> 00:03:02
Here we take **y** to be the given **variable theta** and **y dash** to be **theta dash.**
40
00:03:03 --> 00:03:11
Then we call the **ode** function with arguments **y zero, t zero, t** and the function **Pendulum.**
41
00:03:12 --> 00:03:16
The solution to the equation will be a **matrix** with two **rows.**
42
00:03:17 --> 00:03:20
The first **row** will contain the values of **y** in the given **time range.**
43
00:03:21 --> 00:03:26
The second **row** will contain the values of **y dash ** within the **time range. **
44
00:03:27 --> 00:03:30
Hence we plot both the **rows** with respect to **time. **
45
00:03:31 --> 00:03:36
Save and execute the file **Pendulum dot sci**.
46
00:03:37 --> 00:03:43
The plot shows how the values of **y** and **y dash** vary with **time. **
47
00:03:44 --> 00:03:46
Switch to **Scilab console**.
48
00:03:47 --> 00:03:53
If you want to see the values of **y,** type **y** on the **console** and press **Enter.**
49
00:03:54 --> 00:03:57
The values of **y** and **y dash** are displayed.
50
00:03:58 --> 00:04:02
Let us solve **Van der Pol equation** using the **ode** function.
51
00:04:03 --> 00:04:05
We are given the **equation **-
52
00:04:06 --> 00:04:19
**v double dash of t plus epsilon into v of t square minus one into v dash of t plus v of t equal to zero.**
53
00:04:20 --> 00:04:27
The initial conditions are **v of two equal to one** and **v dash of two equal to zero. **
54
00:04:28 --> 00:04:31
Assume **epsilon is equal to zero point eight nine seven. **
55
00:04:32 --> 00:04:41
We have to find the solution within the **time range two less than t less than ten** and then **plot** the solution.
56
00:04:42 --> 00:04:46
Let us look at the code for **Van der Pol equation. **
57
00:04:47 --> 00:04:52
Switch to **Scilab editor** and open **Vander pol dot sci.**
58
00:04:53 --> 00:05:00
We define the initial conditions of the **ODEs** and **time** and then define the **time range. **
59
00:05:01 --> 00:05:06
Since the **inital time value** is given as **two**, we start the time range at two.
60
00:05:07 --> 00:05:14
Then we define the **function Vander pol** and construct a system of **first order ODEs.**
61
00:05:15 --> 00:05:20
We substitute the value of **epsilon** with **zero point eight nine seven. **
62
00:05:21 --> 00:05:24
Here **y** refers to the **voltage v.**
63
00:05:25 --> 00:05:29
Then we call **ode** function and solve the system of **equations.**
64
00:05:30 --> 00:05:34
Finally we plot **y** and **y dash versus t.**
65
00:05:35 --> 00:05:40
Save and execute the file **Vander pol dot sci.**
66
00:05:41 --> 00:05:44
The **plot** showing **voltage versus time** is shown.
67
00:05:45 --> 00:05:49
Let's move onto **Lorenz system of equations.**
68
00:05:50 --> 00:05:52
The **Lorenz system of equations** is given by:
69
00:05:53 --> 00:05:59
**x one dash equal to sigma into x two minus x one**,
70
00:06:00 --> 00:06:07
**x two dash equal to one plus r minus x three into x one minus x two** and
71
00:06:08 --> 00:06:15
**x three dash equal to x one into x two minus b into x three.**
72
00:06:16 --> 00:06:28
The initial conditions are **x one zero equal to minus ten**, **x two zero equal to ten** and **x three zero equal to twenty five.**
73
00:06:29 --> 00:06:36
Let **sigma** be equal to **ten, r** be equal to **twenty eight** and **b** equal to **eight by three.**
74
00:06:37 --> 00:06:43
Switch to **Scilab editor** and open **Lorenz dot sci**.
75
00:06:44 --> 00:06:47
We start by defining the initial conditions of the **ODEs.**
76
00:06:48 --> 00:06:53
Since there are three different **ODEs,** there are three initial conditions.
77
00:06:54 --> 00:06:59
Then we define the **inital time** condition and next the **time range.**
78
00:07:00 --> 00:07:07
We define the **function Lorenz** and then define the given constants **sigma, r** and **b.**
79
00:07:08 --> 00:07:11
Then we define the **first order ODEs.**
80
00:07:12 --> 00:07:17
Then we call the **ode** function to solve the **Lorenz system of equations.**
81
00:07:18 --> 00:07:20
We equate the solution to **x.**
82
00:07:21 --> 00:07:27
Then we **plot x one, x two** and **x three versus time.**
83
00:07:28 --> 00:07:32
Save and execute the file **Lorenz dot sci.**
84
00:07:33 --> 00:07:38
The **plot** of **x one, x two** and **x three versus time** is shown.
85
00:07:39 --> 00:07:40
Let us summarize this tutorial.
86
00:07:41 --> 00:07:49
In this tutorial we have learnt to develop **Scilab code** to solve an **ODE** using **Scilab ode function**.
87
00:07:50 --> 00:07:52
Then we have learnt to **plot** the solution.
88
00:07:53 --> 00:07:55
Watch the video available at the link shown below.
89
00:07:56 --> 00:07:58
It summarizes the Spoken Tutorial project.
90
00:07:59 --> 00:08:03
If you do not have good bandwidth, you can download and watch it.
91
00:08:04 --> 00:08:05
The spoken tutorial project Team:
92
00:08:06 --> 00:08:08
Conducts workshops using spoken tutorials.
93
00:08:09 --> 00:08:12
Gives certificates to those who pass an online test.
94
00:08:13 --> 00:08:19
For more details, please write to contact@spoken-tutorial.org.
95
00:08:20 --> 00:08:22
Spoken Tutorial Project is a part of the Talk to a Teacher project.
96
00:08:23 --> 00:08:30
It is supported by the National Mission on Eduction through ICT, MHRD, Government of India.
97
00:08:31 --> 00:08:35
More information on this mission is available at the link shown below.
98
00:08:36 --> 00:08:37
This is Ashwini Patil, signing off.
99
00:08:38 --> 00:08:43
Thank you for joining.