Difference between revisions of "Scilab/C4/ODE-Applications/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
PoojaMoolya (Talk | contribs) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 7: | Line 7: | ||
|- | |- | ||
| 00:01 | | 00:01 | ||
− | |Dear Friends, | + | |Dear Friends, Welcome to the Spoken Tutorial on '''Solving ODEs using Scilab ode function''' |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
Line 19: | Line 15: | ||
|- | |- | ||
|00:12 | |00:12 | ||
− | | | + | | Use Scilab ode function |
|- | |- | ||
|00:15 | |00:15 | ||
− | |Solve typical examples of '''ODEs''' and | + | | Solve typical examples of '''ODEs''' and |
|- | |- | ||
| 00:18 | | 00:18 | ||
− | |Plot the solution. | + | | Plot the solution. |
|- | |- | ||
Line 35: | Line 31: | ||
|- | |- | ||
| 00:24 | | 00:24 | ||
− | | | + | | Motion of '''simple pendulum''' |
|- | |- | ||
| 00:26 | | 00:26 | ||
− | | | + | | '''Van der Pol equation''' |
|- | |- | ||
|00:28 | |00:28 | ||
− | | | + | | and ''' Lorenz system'''. |
|- | |- | ||
Line 62: | Line 58: | ||
|- | |- | ||
− | |||
|00:45 | |00:45 | ||
− | |||
|and should know how to solve '''ODEs.''' | |and should know how to solve '''ODEs.''' | ||
|- | |- | ||
− | |||
|00:48 | |00:48 | ||
|To learn '''Scilab,''' please refer to the relevant tutorials available on the '''Spoken Tutorial''' website. | |To learn '''Scilab,''' please refer to the relevant tutorials available on the '''Spoken Tutorial''' website. | ||
|- | |- | ||
− | |||
| 00:56 | | 00:56 | ||
− | + | |The '''ode''' function is an '''ordinary differential equation solver'''. | |
− | |The '''ode''' function is an '''ordinary differential equation''' | + | |
|- | |- | ||
− | |||
| 01:01 | | 01:01 | ||
||The syntax is '''y equal to ode''' within parenthesis '''y zero, t zero, t''' and '''f'''. | ||The syntax is '''y equal to ode''' within parenthesis '''y zero, t zero, t''' and '''f'''. | ||
|- | |- | ||
− | |||
|01:10 | |01:10 | ||
− | |||
|| Here '''y zero''' is the initial condition of the '''ODEs''', | || Here '''y zero''' is the initial condition of the '''ODEs''', | ||
|- | |- | ||
− | |||
|01:15 | |01:15 | ||
− | |||
| '''t zero''' is the '''initial time''', | | '''t zero''' is the '''initial time''', | ||
Line 100: | Line 86: | ||
|- | |- | ||
− | |||
|01:19 | |01:19 | ||
− | |||
|and '''f''' is the '''function'''. | |and '''f''' is the '''function'''. | ||
|- | |- | ||
− | |||
|01:22 | |01:22 | ||
− | |||
||Consider the motion of '''simple pendulum.''' | ||Consider the motion of '''simple pendulum.''' | ||
Line 116: | Line 98: | ||
|- | |- | ||
− | |||
| 01:33 | | 01:33 | ||
|We are given the initial conditions- | |We are given the initial conditions- | ||
|- | |- | ||
− | |||
|01:36 | |01:36 | ||
− | + | |'''theta of zero''' is equal to '''pi by four''' and | |
− | |'''theta zero''' is equal to '''pi by four''' and | + | |
|- | |- | ||
− | |||
|01:39 | |01:39 | ||
− | |||
| '''theta dash of zero''' is equal to '''zero.''' | | '''theta dash of zero''' is equal to '''zero.''' | ||
|- | |- | ||
− | |||
|01:44 | |01:44 | ||
+ | | Then the position of the '''pendulum''' is given by: | ||
− | |||
|- | |- | ||
− | |||
| 01:47 | | 01:47 | ||
− | |||
|| '''theta double dash t minus g by l into sin of theta t equal to zero.''' | || '''theta double dash t minus g by l into sin of theta t equal to zero.''' | ||
Line 149: | Line 123: | ||
|- | |- | ||
|02:03 | |02:03 | ||
− | |''' l equal to zero point five meter''' is the | + | |''' l equal to zero point five meter''' is the length of the '''pendulum.''' |
|- | |- | ||
Line 165: | Line 139: | ||
|- | |- | ||
| 02:29 | | 02:29 | ||
− | |Open ''' | + | |Open '''Pendulum dot sci''' on '''Scilab editor.''' |
|- | |- | ||
Line 180: | Line 154: | ||
|- | |- | ||
− | |||
| 02:52 | | 02:52 | ||
− | |||
|We substitute the values of '''g''' and '''l''' . | |We substitute the values of '''g''' and '''l''' . | ||
|- | |- | ||
− | |||
| 02:56 | | 02:56 | ||
||Here we take '''y''' to be the given '''variable theta''' and '''y dash''' to be '''theta dash.''' | ||Here we take '''y''' to be the given '''variable theta''' and '''y dash''' to be '''theta dash.''' | ||
|- | |- | ||
− | |||
|03:03 | |03:03 | ||
− | + | |Then we call the '''ode''' function with arguments '''y zero, t zero, t''' and the function '''Pendulum.''' | |
− | |Then we call the '''ode | + | |
|- | |- | ||
− | |||
| 03:12 | | 03:12 | ||
− | | The solution to the | + | | The solution to the equation will be a '''matrix''' with two '''rows.''' |
|- | |- | ||
− | |||
| 03:17 | | 03:17 | ||
− | |||
| The first '''row''' will contain the values of '''y''' in the given '''time range.''' | | The first '''row''' will contain the values of '''y''' in the given '''time range.''' | ||
|- | |- | ||
− | |||
| 03:21 | | 03:21 | ||
− | |||
| The second '''row''' will contain the values of '''y dash ''' within the '''time range. ''' | | The second '''row''' will contain the values of '''y dash ''' within the '''time range. ''' | ||
|- | |- | ||
− | |||
|03:27 | |03:27 | ||
− | |||
|Hence we plot both the '''rows''' with respect to '''time. ''' | |Hence we plot both the '''rows''' with respect to '''time. ''' | ||
|- | |- | ||
− | |||
|03:31 | |03:31 | ||
− | |||
|Save and execute the file '''Pendulum dot sci'''. | |Save and execute the file '''Pendulum dot sci'''. | ||
|- | |- | ||
− | |||
| 03:37 | | 03:37 | ||
− | |||
|The plot shows how the values of '''y''' and '''y dash''' vary with '''time. ''' | |The plot shows how the values of '''y''' and '''y dash''' vary with '''time. ''' | ||
|- | |- | ||
− | |||
| 03:44 | | 03:44 | ||
− | |||
|Switch to '''Scilab console'''. | |Switch to '''Scilab console'''. | ||
|- | |- | ||
− | |||
| 03:47 | | 03:47 | ||
− | |||
| If you want to see the values of '''y,''' type '''y''' on the '''console''' and press '''Enter.''' | | If you want to see the values of '''y,''' type '''y''' on the '''console''' and press '''Enter.''' | ||
|- | |- | ||
− | |||
| 03:54 | | 03:54 | ||
− | |||
|The values of '''y''' and '''y dash''' are displayed. | |The values of '''y''' and '''y dash''' are displayed. | ||
|- | |- | ||
− | |||
| 03:58 | | 03:58 | ||
− | + | |Let us solve '''Van der Pol equation''' using the '''ode''' function. | |
− | |Let us solve '''Van der Pol equation''' using the '''ode | + | |
|- | |- | ||
− | |||
| 04:03 | | 04:03 | ||
− | |||
|We are given the '''equation '''- | |We are given the '''equation '''- | ||
|- | |- | ||
− | |||
| 04:06 | | 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.''' | |'''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 | | 04:20 | ||
− | + | |The initial conditions are '''v of two equal to one''' and '''v dash of two equal to zero. ''' | |
− | |The initial | + | |
|- | |- | ||
− | |||
| 04:28 | | 04:28 | ||
− | |||
|Assume '''epsilon is equal to zero point eight nine seven. ''' | |Assume '''epsilon is equal to zero point eight nine seven. ''' | ||
|- | |- | ||
− | |||
|04:32 | |04:32 | ||
− | |||
|We have to find the solution within the '''time range two less than t less than ten''' and then '''plot''' the solution. | |We have to find the solution within the '''time range two less than t less than ten''' and then '''plot''' the solution. | ||
|- | |- | ||
− | |||
| 04:42 | | 04:42 | ||
− | |||
|Let us look at the code for '''Van der Pol equation. ''' | |Let us look at the code for '''Van der Pol equation. ''' | ||
|- | |- | ||
− | |||
| 04:47 | | 04:47 | ||
− | + | | Switch to '''Scilab editor''' and open '''Vander pol dot sci.''' | |
− | | Switch to '''Scilab editor''' and open ''' | + | |
|- | |- | ||
− | |||
| 04:53 | | 04:53 | ||
− | |||
| We define the initial conditions of the '''ODEs''' and '''time''' and then define the '''time range. ''' | | We define the initial conditions of the '''ODEs''' and '''time''' and then define the '''time range. ''' | ||
|- | |- | ||
− | |||
| 05:01 | | 05:01 | ||
− | |||
|Since the '''inital time value''' is given as '''two''', we start the time range at two. | |Since the '''inital time value''' is given as '''two''', we start the time range at two. | ||
|- | |- | ||
| 05:07 | | 05:07 | ||
− | | Then we define the '''function | + | | Then we define the '''function Vander pol''' and construct a system of '''first order ODEs.''' |
|- | |- | ||
Line 317: | Line 249: | ||
|- | |- | ||
− | |||
| 05:21 | | 05:21 | ||
− | |||
|Here '''y''' refers to the '''voltage v.''' | |Here '''y''' refers to the '''voltage v.''' | ||
|- | |- | ||
− | |||
| 05:25 | | 05:25 | ||
− | + | | Then we call '''ode''' function and solve the system of '''equations.''' | |
− | | Then we call '''ode | + | |
|- | |- | ||
− | |||
| 05:30 | | 05:30 | ||
− | |||
| Finally we plot '''y''' and '''y dash versus t.''' | | Finally we plot '''y''' and '''y dash versus t.''' | ||
|- | |- | ||
− | |||
| 05:35 | | 05:35 | ||
− | + | | Save and execute the file '''Vander pol dot sci.''' | |
− | | Save and execute the file ''' | + | |
|- | |- | ||
− | |||
| 05:41 | | 05:41 | ||
− | |||
|The '''plot''' showing '''voltage versus time''' is shown. | |The '''plot''' showing '''voltage versus time''' is shown. | ||
|- | |- | ||
− | |||
| 05:45 | | 05:45 | ||
− | |||
|Let's move onto '''Lorenz system of equations.''' | |Let's move onto '''Lorenz system of equations.''' | ||
|- | |- | ||
− | |||
| 05:50 | | 05:50 | ||
− | |||
|The '''Lorenz system of equations''' is given by: | |The '''Lorenz system of equations''' is given by: | ||
|- | |- | ||
− | |||
| 05:53 | | 05:53 | ||
− | |||
|'''x one dash equal to sigma into x two minus x one''', | |'''x one dash equal to sigma into x two minus x one''', | ||
|- | |- | ||
− | |||
| 06:00 | | 06:00 | ||
− | |||
|'''x two dash equal to one plus r minus x three into x one minus x two''' and | |'''x two dash equal to one plus r minus x three into x one minus x two''' and | ||
|- | |- | ||
− | |||
| 06:08 | | 06:08 | ||
− | |||
|'''x three dash equal to x one into x two minus b into x three.''' | |'''x three dash equal to x one into x two minus b into x three.''' | ||
|- | |- | ||
− | |||
| 06:16 | | 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.''' | |
− | |The initial conditions are '''x one zero | + | |
|- | |- | ||
− | |||
| 06:29 | | 06:29 | ||
− | + | |Let '''sigma''' be equal to '''ten, r''' be equal to '''twenty eight''' and '''b''' equal to '''eight by three.''' | |
− | |Let '''sigma''' be equal to '''ten, r''' be equal to '''twenty eight and b''' equal to '''eight by three.''' | + | |
|- | |- | ||
− | |||
| 06:37 | | 06:37 | ||
− | |||
|Switch to '''Scilab editor''' and open '''Lorenz dot sci'''. | |Switch to '''Scilab editor''' and open '''Lorenz dot sci'''. | ||
|- | |- | ||
− | |||
| 06:44 | | 06:44 | ||
|We start by defining the initial conditions of the '''ODEs.''' | |We start by defining the initial conditions of the '''ODEs.''' | ||
|- | |- | ||
− | |||
| 06:48 | | 06:48 | ||
− | |||
|Since there are three different '''ODEs,''' there are three initial conditions. | |Since there are three different '''ODEs,''' there are three initial conditions. | ||
|- | |- | ||
− | |||
| 06:54 | | 06:54 | ||
− | |||
|Then we define the '''inital time''' condition and next the '''time range.''' | |Then we define the '''inital time''' condition and next the '''time range.''' | ||
|- | |- | ||
− | |||
| 07:00 | | 07:00 | ||
− | + | |We define the '''function Lorenz''' and then define the given constants '''sigma, r''' and '''b.''' | |
− | |We define the '''function Lorenz''' and then define the given constants '''sigma, r and b.''' | + | |
|- | |- | ||
− | |||
| 07:08 | | 07:08 | ||
− | |||
|Then we define the '''first order ODEs.''' | |Then we define the '''first order ODEs.''' | ||
|- | |- | ||
− | |||
| 07:12 | | 07:12 | ||
− | + | |Then we call the '''ode''' function to solve the '''Lorenz system of equations.''' | |
− | |Then we call the '''ode | + | |
|- | |- | ||
− | |||
| 07:18 | | 07:18 | ||
− | |||
|We equate the solution to '''x.''' | |We equate the solution to '''x.''' | ||
|- | |- | ||
− | |||
| 07:21 | | 07:21 | ||
− | |||
|Then we '''plot x one, x two''' and '''x three versus time.''' | |Then we '''plot x one, x two''' and '''x three versus time.''' | ||
|- | |- | ||
− | |||
| 07:28 | | 07:28 | ||
− | |||
|Save and execute the file '''Lorenz dot sci.''' | |Save and execute the file '''Lorenz dot sci.''' | ||
|- | |- | ||
− | |||
| 07:33 | | 07:33 | ||
− | |||
|The '''plot''' of '''x one, x two''' and '''x three versus time''' is shown. | |The '''plot''' of '''x one, x two''' and '''x three versus time''' is shown. | ||
|- | |- | ||
− | |||
| 07:39 | | 07:39 | ||
− | |||
|Let us summarize this tutorial. | |Let us summarize this tutorial. | ||
|- | |- | ||
− | |||
| 07:41 | | 07:41 | ||
− | |||
|In this tutorial we have learnt to develop '''Scilab code''' to solve an '''ODE''' using '''Scilab ode function'''. | |In this tutorial we have learnt to develop '''Scilab code''' to solve an '''ODE''' using '''Scilab ode function'''. | ||
|- | |- | ||
− | |||
| 07:50 | | 07:50 | ||
− | |||
|Then we have learnt to '''plot''' the solution. | |Then we have learnt to '''plot''' the solution. | ||
Line 476: | Line 357: | ||
|- | |- | ||
− | |||
| 07:56 | | 07:56 | ||
− | |||
| It summarizes the Spoken Tutorial project. | | It summarizes the Spoken Tutorial project. | ||
|- | |- | ||
− | |||
|07:59 | |07:59 | ||
− | |||
||If you do not have good bandwidth, you can download and watch it. | ||If you do not have good bandwidth, you can download and watch it. | ||
|- | |- | ||
− | |||
|08:04 | |08:04 | ||
− | |||
||The spoken tutorial project Team: | ||The spoken tutorial project Team: | ||
|- | |- | ||
− | |||
|08:06 | |08:06 | ||
− | |||
||Conducts workshops using spoken tutorials. | ||Conducts workshops using spoken tutorials. | ||
|- | |- | ||
− | |||
|08:09 | |08:09 | ||
− | |||
||Gives certificates to those who pass an online test. | ||Gives certificates to those who pass an online test. | ||
|- | |- | ||
− | |||
|08:13 | |08:13 | ||
− | |||
||For more details, please write to contact@spoken-tutorial.org. | ||For more details, please write to contact@spoken-tutorial.org. | ||
|- | |- | ||
− | |||
|08:20 | |08:20 | ||
− | |||
|Spoken Tutorial Project is a part of the Talk to a Teacher project. | |Spoken Tutorial Project is a part of the Talk to a Teacher project. | ||
|- | |- | ||
− | |||
| 08:23 | | 08:23 | ||
− | |||
| It is supported by the National Mission on Eduction through ICT, MHRD, Government of India. | | It is supported by the National Mission on Eduction through ICT, MHRD, Government of India. | ||
|- | |- | ||
− | |||
| 08:31 | | 08:31 | ||
− | |||
|More information on this mission is available at the link shown below. | |More information on this mission is available at the link shown below. | ||
|- | |- | ||
− | |||
| 08:36 | | 08:36 | ||
− | |||
|This is Ashwini Patil, signing off. | |This is Ashwini Patil, signing off. | ||
|- | |- | ||
− | |||
|08:38 | |08:38 | ||
− | |||
| Thank you for joining. | | Thank you for joining. |
Latest revision as of 11:11, 10 March 2017
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. |