This time I would like to present another example of use Scilab/Scicos environment to solve numerically a differential equation. Today we will deal with the following mathematical relation
\[y'= 1-y^2, \]
where \(y(x)\) is uknown function of intependent variable \(x\). The equation already is in the form of algebraic solutions with respect of its highest derivative, so one can construct diagram. It may look as follows
where there were used the following blocks taken from the Pallette browser: INTEGRAL_m, EXPRESSION, CSCOPE and CLOCK_c. The block EXPRESSION computes derivative \(y'\) of unknown function \(y\) and sends the result to the input of the block INTEGRAL_m, which integrates signal and on its output appears the function \(y(x)\). This signal is then sent to the input of the block EXPRESSION, forming a kind of feedback in this mathematical system. The results are observed by the use of block CSCOPE, which is controlled by the signal from CLOCK_c.
In the block EXPRESSION we set the number of inputs as 1 and build the expression representing the differential equation:
where u1 denotes the first input (in this case the only one), i.e. the unknown function \(y\).
In the next block INTEGRAL_m we set the following parameters:
i.e. Initial Condition, which denotes initial value of its output signal \(y\). In this case we have assumed \(y(0)=-0.9\).
In the block CLOCK_c one can set the following parameters
that is the Period equal to 0.01 and Initialisation Time equal to 0. This means that there will be produced events with a period of 0.01 starting at instance 0. These events will control the block CSCOPE, which will show results exactly at the corresponding instances.
In the block CSCOPE we have set Ymin and Ymax, as well as Refresh period and buffer size parameters in the following way
These parameters should be set manually in a way corresponding to the range of the numerical simulation observed.
Finally we choose Simulation and Setup in the project window menu, and then set Final integration time as 10. Here we should note that the simulation time in this case means independent variable \(x\) in our differential equation.
Now we should save our model and then we can start simulation. You can expect to see the following plot:
Now it is time to try simulations with other initial conditions!
Original examples of use of Scilab/Scicos environment in modelling, simulation and analysis of dynamical physical processes
Subscribe to:
Post Comments (Atom)
Plotting a function in Scilab
Suppose we want to plot the graph of a function. This can be done as shown in the following script: x = 0 : 0.01 : 15 ; ...
-
Let us assume that one has a text file "data.txt" with data, for example two columns of numbers corresponding to time and displace...
-
Today I will present a way of dealing with the next example of a system of ordinary differential equations using Scicos - the toolbox of S...
No comments:
Post a Comment