Difference between revisions of "OpenModelica/C3/Block-Component-Modeling/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
|- | |- | ||
|| 00:01 | || 00:01 | ||
− | || Welcome to the spoken tutorial on '''Block component modeling'''. | + | || Welcome to the '''spoken tutorial''' on '''Block component modeling'''. |
|- | |- | ||
|| 00:06 | || 00:06 | ||
− | || In this tutorial, we are going to learn: | + | || In this tutorial, we are going to learn: |
+ | how to define a '''block''', | ||
|- | |- | ||
|| 00:12 | || 00:12 | ||
− | || | + | ||how to connect '''blocks''', |
|- | |- | ||
|| 00:15 | || 00:15 | ||
− | || | + | ||how to use blocks from '''Modelica Library'''. |
|- | |- | ||
|| 00:19 | || 00:19 | ||
− | || To record this tutorial, I am using: | + | || To record this tutorial, I am using: '''OpenModelica version 1.9.2''' |
|- | |- | ||
Line 29: | Line 30: | ||
|- | |- | ||
|| 00:30 | || 00:30 | ||
− | || To understand and practice this tutorial, you need | + | || To understand and practice this tutorial, you need knowledge of '''component oriented modeling''' in '''Modelica'''. |
|- | |- | ||
Line 45: | Line 46: | ||
|- | |- | ||
||00:52 | ||00:52 | ||
− | || It is useful in control | + | || It is useful in '''control application'''s. |
|- | |- | ||
Line 53: | Line 54: | ||
|- | |- | ||
||01:08 | ||01:08 | ||
− | || | + | ||Variables of a block class must have fixed causality, either '''input''' or '''output'''. |
|- | |- | ||
Line 69: | Line 70: | ||
|- | |- | ||
||01:28 | ||01:28 | ||
− | ||They are used to model | + | ||They are used to model input and output signals. |
|- | |- | ||
Line 81: | Line 82: | ||
|- | |- | ||
||01:47 | ||01:47 | ||
− | ||Let us write a class that uses | + | ||Let us write a class that uses '''block'''s to perform the following operations: |
+ | Take two time varying signals as input and output their sum. | ||
|- | |- | ||
Line 101: | Line 103: | ||
|- | |- | ||
||02:26 | ||02:26 | ||
− | ||Let signal | + | ||Let signal 2 be '''2 times t squared'''. |
|- | |- | ||
Line 109: | Line 111: | ||
|- | |- | ||
||02:35 | ||02:35 | ||
− | ||It is similar to the previous case with two | + | ||It is similar to the previous case with two inputs and one output. |
|- | |- | ||
||02:41 | ||02:41 | ||
− | ||Let us choose one | + | ||Let us choose one input to be our '''signal'''. |
|- | |- | ||
||02:46 | ||02:46 | ||
− | ||Let the other | + | ||Let the other input i.e. '''signal 2''' be a constant '''K''' by which to amplify the signal. |
|- | |- | ||
||02:54 | ||02:54 | ||
− | ||The product of these two | + | ||The product of these two inputs is the output required. |
|- | |- | ||
Line 129: | Line 131: | ||
|- | |- | ||
|| 03:06 | || 03:06 | ||
− | || Notice that both the | + | || Notice that both the sum of signals and amplification require a block with '''2''' inputs and '''1''' output. |
|- | |- | ||
Line 169: | Line 171: | ||
|- | |- | ||
||04:08 | ||04:08 | ||
− | ||Create | + | ||Create '''instance'''s of '''Sum''' and '''Product''' blocks in the '''main''' class. |
|- | |- | ||
||04:14 | ||04:14 | ||
− | ||Lastly, program the necessary equations related to | + | ||Lastly, program the necessary equations related to input and output variables. |
|- | |- | ||
Line 224: | Line 226: | ||
|- | |- | ||
− | || | + | ||C5:39 |
− | ||Double | + | ||Double click on '''MISO'''. |
|- | |- | ||
||05:43 | ||05:43 | ||
− | ||Interfaces package also has several other | + | ||'''Interfaces''' package also has several other '''block'''s which are similar to '''MISO''' in functionality. |
|- | |- | ||
|| 05:51 | || 05:51 | ||
− | || Now let me shift '''OMEdit''' window to the left for better visibility. | + | || Now, let me shift '''OMEdit''' window to the left for better visibility. |
|- | |- | ||
Line 269: | Line 271: | ||
|- | |- | ||
|| 06:43 | || 06:43 | ||
− | || It | + | || It '''inherit'''s '''Block class'''. |
|- | |- | ||
||06:46 | ||06:46 | ||
− | ||You may locate this in '''Modelica library''' using the path shown. | + | ||You may locate this in '''Modelica library''' using the '''path''' shown. |
|- | |- | ||
Line 289: | Line 291: | ||
|- | |- | ||
|| 07:08 | || 07:08 | ||
− | || '''RealInput''' is a connector which evidently represents a '''real''' input signal. | + | || '''RealInput''' is a '''connector''' which evidently represents a '''real''' input signal. |
|- | |- | ||
Line 297: | Line 299: | ||
|- | |- | ||
|| 07:20 | || 07:20 | ||
− | || Similarly, '''RealOutput''' is a connector which represents a '''real''' output signal. | + | || Similarly, '''RealOutput''' is a '''connector''' which represents a '''real''' output signal. |
|- | |- | ||
Line 321: | Line 323: | ||
|- | |- | ||
|| 07:52 | || 07:52 | ||
− | || Variables '''y''' and '''u''' are a part of this block since it | + | || Variables '''y''' and '''u''' are a part of this block since it '''inherit'''s '''MISO'''. |
|- | |- | ||
Line 357: | Line 359: | ||
|- | |- | ||
||08:39 | ||08:39 | ||
− | || These statements indicate the instantiation of '''Sum''' and '''Product''' blocks. | + | || These statements indicate the '''instantiation''' of '''Sum''' and '''Product''' blocks. |
|- | |- | ||
Line 389: | Line 391: | ||
|- | |- | ||
||09:33 | ||09:33 | ||
− | ||Close the pop up window. | + | ||Close the pop-up window. |
|- | |- | ||
Line 397: | Line 399: | ||
|- | |- | ||
||09:43 | ||09:43 | ||
− | ||Note that this generates a plot that is in accordance with the values of signal provided. | + | ||Note that this generates a '''plot''' that is in accordance with the values of signal provided. |
|- | |- | ||
Line 421: | Line 423: | ||
|- | |- | ||
|| 10:21 | || 10:21 | ||
− | || Watch the video available at the following link: http://spoken-tutorial.org/ | + | || Watch the video available at the following link: |
+ | http://spoken-tutorial.org/What_is_a_Spoken_Tutorial | ||
+ | |||
+ | It summarizes the '''Spoken Tutorial''' project. | ||
|- | |- | ||
|| 10:27 | || 10:27 | ||
− | || We | + | || We conduct workshops using '''spoken tutorials''', give certificates. Please contact us. |
|- | |- |
Latest revision as of 20:23, 21 August 2018
Time | Narration |
00:01 | Welcome to the spoken tutorial on Block component modeling. |
00:06 | In this tutorial, we are going to learn:
how to define a block, |
00:12 | how to connect blocks, |
00:15 | how to use blocks from Modelica Library. |
00:19 | To record this tutorial, I am using: OpenModelica version 1.9.2 |
00:26 | You may use any of the following operating systems. |
00:30 | To understand and practice this tutorial, you need knowledge of component oriented modeling in Modelica. |
00:38 | Prerequisite tutorials are mentioned on our website. Please go through them. |
00:44 | Let us now learn more about blocks. |
00:48 | block is a specialized class in Modelica. |
00:52 | It is useful in control applications. |
00:56 | For example, Modelica Library has blocks for PI and PID controllers which are frequently seen in chemical engineering control applications. |
01:08 | Variables of a block class must have fixed causality, either input or output. |
01:15 | blocks can be connected using connect statements. |
01:19 | We have learnt about connect statements in previous tutorials. |
01:24 | Connectors acts as interface between blocks. |
01:28 | They are used to model input and output signals. |
01:33 | For example, this is declaration for a block connector that models real input signals. |
01:41 | Let us now try to understand block component modeling through an example. |
01:47 | Let us write a class that uses blocks to perform the following operations:
Take two time varying signals as input and output their sum. |
01:59 | Take a time varying signal as input and amplify it by a constant. |
02:05 | Let us define this problem statement in detail using schematics. |
02:11 | This figure shows a schematic for block that takes two signals as input and returns their sum. |
02:19 | To make things simpler, let us choose signal 1 to be t which represents time. |
02:26 | Let signal 2 be 2 times t squared. |
02:31 | This is schematic for amplification of a signal. |
02:35 | It is similar to the previous case with two inputs and one output. |
02:41 | Let us choose one input to be our signal. |
02:46 | Let the other input i.e. signal 2 be a constant K by which to amplify the signal. |
02:54 | The product of these two inputs is the output required. |
02:59 | We have chosen the signal 2 i.e. K to be 5 units. |
03:06 | Notice that both the sum of signals and amplification require a block with 2 inputs and 1 output. |
03:16 | Modelica library already has a block named MISO that stands for Multiple Input Single Output. |
03:24 | It is available in Modelica.Interfaces.Block package. |
03:30 | The input to this block u is a vector since it can accept multiple signals as input. |
03:38 | y is the output which is a scalar. |
03:42 | Let us now discuss how to solve our problem using OMEdit. |
03:48 | Extend MISO block to create a block named Sum. |
03:53 | We have learnt about extending a class in previous tutorials. |
03:59 | Extend MISO to create a block named Product. |
04:04 | Create a class named main. |
04:08 | Create instances of Sum and Product blocks in the main class. |
04:14 | Lastly, program the necessary equations related to input and output variables. |
04:22 | Note that Sum corresponds to the Sum of signals whereas Product corresponds to the amplification of signal. |
04:32 | I have already created the necessary blocks and packaged them into a file named arithmeticOperationsUsingBlocks. |
04:42 | You may locate this file on our website and download it. |
04:46 | Let me now switch to OMEdit. |
04:49 | I shall first demonstrate the package arithmeticOperationsUsingBlocks and then demonstrate the syntax of MISO block. |
04:59 | I have already opened the package arithmeticOperationsUsingBlocks in OMEdit. |
05:06 | Let me expand it in the Libraries Browser. |
05:10 | Note that the package has blocks named Sum, Product and a main class. |
05:18 | Double-click on all three of them. |
05:24 | Let me also open MISO block from Modelica Library. |
05:29 | Expand Modelica library. |
05:32 | Go to Blocks → Interfaces. Scroll down a bit. |
C5:39 | Double click on MISO. |
05:43 | Interfaces package also has several other blocks which are similar to MISO in functionality. |
05:51 | Now, let me shift OMEdit window to the left for better visibility. |
05:57 | Let us first look into Sum block. |
06:01 | Switch to Text View if it opens in Diagram View. |
06:05 | This is the syntax for declaring a block. |
06:10 | This statement is used to inherit MISO block from its location in Modelica library. |
06:16 | We have learnt about Class inheritance or Class extension in previous tutorials. |
06:23 | Let me now take a step back for a moment and demonstrate MISO block. |
06:29 | Go to MISO tab. Switch to Text View. |
06:35 | MISO is a partial block which means that it can only be inherited but not instantiated. |
06:43 | It inherits Block class. |
06:46 | You may locate this in Modelica library using the path shown. |
06:51 | This class is used here only for the sake of its Diagram View and hence need not be discussed. |
06:58 | nin represents the number of inputs. |
07:02 | This parameter may be changed when the block is inherited. |
07:08 | RealInput is a connector which evidently represents a real input signal. |
07:14 | In this case, the input is a vector u as we already discussed. |
07:20 | Similarly, RealOutput is a connector which represents a real output signal. |
07:27 | Here, y is the real-valued output signal. |
07:31 | RealInput and RealOutput are present in the same package of Modelica Library as MISO. |
07:38 | Please look into them. |
07:41 | Now, let me show you how the Diagram View of MISO block looks like. |
07:46 | Let us now go back to Sum block and continue from where we left off. |
07:52 | Variables y and u are a part of this block since it inherits MISO. |
07:59 | As we have learnt in previous tutorials, Sum is an array function. |
08:05 | It takes an array as input and returns the sum of its elements. |
08:11 | Let me switch to Product block. Switch to Text View. |
08:17 | This block inherits MISO as well. |
08:21 | As we have seen in previous tutorials, Product is an array function that takes an array as input. |
08:29 | It returns the product of its elements. |
08:33 | Let me now switch to main class. |
08:37 | Switch to Text View. |
08:39 | These statements indicate the instantiation of Sum and Product blocks. |
08:44 | These instances can also be created using the drag and drop functionality of OMEdit. |
08:51 | We discussed this feature in previous tutorials. |
08:56 | nin is a parameter for dimension of input vector u in MISO. |
09:03 | We assign a value of 2 to this parameter. |
09:07 | This equation indicates the values of signal 1 and signal 2 for Sum of signals which we discussed in slides. |
09:17 | Similarly, this indicates the values of Signal 1 and Signal 2 for amplification of signal as we already discussed. |
09:29 | Let me now simulate this class. Click on Simulate button. |
09:33 | Close the pop-up window. |
09:36 | Expand mySum in Libraries Browser. Select y. |
09:43 | Note that this generates a plot that is in accordance with the values of signal provided. |
09:51 | This brings us to the end of this tutorial. |
09:54 | As an assignment, look into the codes for RealInput, RealOutput, SI, SO and MIMO blocks. |
10:04 | You can find them in Modelica.Blocks.Interfaces package. |
10:10 | RealInputand RealOutput are connectors which are used quite frequently. |
10:17 | Hence it is necessary to understand them. |
10:21 | Watch the video available at the following link:
http://spoken-tutorial.org/What_is_a_Spoken_Tutorial It summarizes the Spoken Tutorial project. |
10:27 | We conduct workshops using spoken tutorials, give certificates. Please contact us. |
10:33 | If you have questions in this spoken tutorial, please visit the webpage mentioned. |
10:40 | We coordinate coding of solved examples from popular books. We give honorarium to contributors. Please visit our website. |
10:50 | We help migrate labs from commercial simulators to OpenModelica. |
10:56 | Spoken Tutorial Project is supported by NMEICT, MHRD, Government of India. |
11:03 | We thank the development team of OpenModelica for their support. |
11:09 | I would like to thank you for joining me in this tutorial. Good bye. |