Scilab/C4/ODE-Applications/English-timed

From Script | Spoken-Tutorial
Revision as of 11:11, 10 March 2017 by PoojaMoolya (Talk | contribs)

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

Contributors and Content Editors

Gaurav, PoojaMoolya, Sandhya.np14