OpenModelica/C3/Component-oriented-modeling/English-timed

From Script | Spoken-Tutorial
Revision as of 17:35, 10 October 2017 by Jyotisolanki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time Narration
00:01 Welcome to the spoken tutorial on Component oriented modeling.
00:06 In this tutorial, we are going to learn: How to instantiate a model.
00:12 How to define connector class and How to develop model of a simple electric circuit using component models.
00:21 To record this tutorial, I am using: OpenModelica 1.9.2. Ubuntu Operating System version 14.04.
00:31 But this process is identical to any of the following operating systems.
00:39 To understand and practice this tutorial, you need to know how to define a class in Modelica.
00:45 you need to know how to define a package and Icon and Diagram Views.
00:51 Prerequisite tutorials are mentioned on our website. Please go through them.
00:57 Now let us learn more about Class Instantiation.
01:02 Modelica classes can be instantiated.
01:06 For example, an individual can be considered an instance of human being class. Instance of a class has the same variables and equations as the class itself.
01:20 The syntax for Class Instantiation is as shown.
01:25 Now, let us understand this through an example. Please download and save all the files available on our website.
01:34 Let me switch to OMEdit. The following files are already open in OMEdit: classInstantiationExample and simpleCircuit.
01:48 Double-click on classInstantiationExample. Let us discuss more about this class now.
01:56 Let me shift OMEdit window to the left for better visibility.
02:02 Here, I have instantiated the bouncingBall class to create two objects named object1 and object2.
02:12 Note that each instance has different start values for the height variable h.
02:20 Please refer prerequisite tutorials for more information on the bouncingBall model.
02:27 Let us simulate this class now.
02:30 Click on Simulate button in the toolbar.
02:34 The class did not simulate and it threw up an error.
02:39 This is because bouncingBall class is not open in OMEdit.
02:45 Open bouncingBall class which you downloaded from the website.
02:50 Now, simulate this class once again. Close the pop up window.
02:56 Note that the class simulates successfully this time around.
03:01 This exercise demonstrates that a class should be open in OMEdit to be instantiated.
03:09 Expand object1 variables in the variables browser.
03:14 Note that the variables listed here are declared in bouncingBall class.
03:20 These variables are also a part of object1 and object2 since the adjust instances of the bouncingBall class.
03:30 Now delete the result and go back to the slides.
03:37 Component orientation sets Modelica apart from other modeling and simulation softwares.
03:43 It is the single most important feature of Modelica.
03:48 component models represent single physical phenomenon.
03:53 They can be instantiated and connected to produce desired effect.
03:59 For example, an RLC circuit could be developed from resistor, inductor and capacitor models.
04:08 Acausal connectors serve as the interface between component instances.
04:15 They are defined using connector class. For example, pins can be used as connectors for electrical components.
04:24 We will learn more about this when we try to simulate the example for an electric circuit.
04:30 Connectors content across and flow variables and they cannot contain equations.
04:38 Now, let us simulate this Electric Circuit shown in the slide.
04:43 The voltage of battery is given by {VoSin(2pift)}, where Vo is 10 Volts, f is 1 Hz and the resistance is 5 ohm.
04:59 Let us take a look at the Solution Methodology to model the electric circuit shown in previous slide: Note that any Resistor and Voltage Source have two pins: Positive and Negative.
05:14 Hence, define a connector named pin.
05:18 Define a class named Ground with one instance of pin connector.
05:24 Define a class named Resistor.
05:28 The Resistor class should have two instances of the pin connector: Positive pin and the Negative pin.
05:36 Define a class named VoltageSource with two instances of pin connector as we have seen in the case of resistor class.
05:46 Define a class named simpleCircuit. simpleCircuit should have instances of Resistor and VoltageSource.
05:56 Connect the respective pins of Resistor, ground and the VoltageSource.
06:02 The component models required have already been programmed.
06:07 Hence, I shall demonstrate only the last two steps of Solution Methodology.
06:13 Let me switch to OMEdit. Go back to the Modeling perspective.
06:19 Let me shift OMEdit window to the right.
06:23 Expand simpleElectricCircuitpackage in the Libraries Browser.
06:29 Note that this package has five classes named: pin, Ground, Resistor, Voltage Source and circuit.
06:40 Double-click on simpleElectricCircuit. Close ClassinstantiationExample.
06:48 Let me shift OMEdit window to the left once again for better visibility.
06:54 Modelica.SIunits package has been imported in the package simpleElectricCircuit.
07:02 Hence, type definitions in that package, can be used without reference to their full names.
07:10 Let us try to understand pin connector. Scroll down a little bit.
07:17 Pin is defined using connector class.
07:21 Voltage and current are the variables that a pin exchanges with its surroundings.
07:27 Potential at the pin is defined by v. Voltage and Current are types defined in SIunits package of Modelica library.
07:40 Voltage across a component causes a current to flow through it.
07:44 Hence, current is a flow variable and is defined using flow keyword.
07:50 pin connector also has an Icon view specified by annotations as shown.
07:57 Now let us discuss a little about Resistor class. Scroll down a little more.
08:04 As discussed in the Solution Methodology, Resistor class has two instances of pin connector.
08:12 p stands for positive pin and n stands for negative pin.
08:18 Now, let me show you how to instantiate a class using the drag and drop functionality of OMEdit.
08:26 To demonstrate that, let me open a new class using Ctrl + N.
08:32 Name this class example1 and press Ok. Shift OMEdit window to the right.
08:41 Go to Diagram View if the class opens in Text View.
08:46 Now let me instantiate pin class.
08:51 Left-click on pin icon in Libraries Browser.
08:55 Hold and drag the icon to the diagram layer. Drop it at any location on the canvas.
09:04 We have now created an instance of pin class.
09:09 You may also change the dimensions and location after dropping it, as shown.
09:16 Now let us see how this class is instantiated in Text View. Go to Text View.
09:22 Notice the command for instantiation of class pin and an annotation based on its placement in Diagram View.
09:33 Hence, creating an instance of a class in Diagram View automatically reflects in the Text View. Now let me close example1 tab.
09:45 Let us learn how to model electric circuit that we saw in the slides.
09:51 Double-click on Circuit icon which is also a part of simpleElectricCircuit package.
09:58 This class already has our circuit of interest assembled, as can be seen in its Diagram View. It is ready to be simulated.
10:09 But let us build the same circuit in a new file.
10:14 We shall use drag and drop functionality that we have just learnt about.
10:19 Press Ctrl + N. Name this file circuit(underscore)construction. Press OK.
10:28 Switch to Diagram View, if it opens in Text View.
10:32 Select, drag and drop the VoltageSource icon from Libraries Browser. You may change its dimensions as you wish.
10:43 Similarly, select, drag and drop the Resistor icon from Libraries Browser.
10:50 Do the same with Ground class.
10:54 Now, we need to connect the respective pins of each component.
11:00 Let us first connect the positive pin of Voltage Source to the positive pin of Resistor.
11:07 Hover over the left pin of Voltage Source.
11:11 The text that appears indicates that, this is the positive pin p.
11:17 Left click on this pin and drag the cursor closer to the left pin of Resistor.
11:24 Leave the mouse when the appearance of cursor changes to cross from an arrow.
11:30 Similarly, connect the negative pin of resistor to the negative pin of voltage source.
11:38 We have not mentioned the connections with Ground in the circuit diagram.
11:44 But, we need to connect the negative pins of Resistor and Voltage Source to Ground individually.
11:51 This ensures a reference point for potential in the circuit.
11:57 Now, this class is complete. Save the class by pressing Ctrl + S.
12:04 Click on Simulate button. Close the pop up window.
12:10 The class has simulated successfully.
12:14 Let me shift OMEdit window to the left for better visibility of Variables browser.
12:20 Expand Resistor column in the Variables Browser and select Ir.
12:28 Note that the profile is sinusoidal as expected.
12:33 Since the Voltage Source is an AC source instead of DC.
12:38 Hence, we have created a model from its component parts and simulated it.
12:44 We shall learn more about the Resistor and Voltage Source classes that we used here in the next tutorial.
12:52 Let me switch to the slides.
12:55 This brings us to the end of this tutorial.
12:59 As an assignment, construct an electric circuit with two resistors in series, with one Voltage Source.
13:07 Use the component models for Voltage source and Resistor provided in simple electric circuit package.
13:15 Watch the video available at the following link: org /What\_is\_a\_Spoken\_Tutorial It summarises Spoken Tutorial project.
13:21 We conduct workshops using spoken tutorials. Please contact us.
13:26 If you have questions from this tutorial, please visit the website mentioned below.
13:32 We coordinate coding of solved examples of popular books. Please visit our website.
13:38 We help migrate commercial simulator labs to OpenModelica. Please visit the following website for more information.
13:47 Spoken Tutorial Project is funded by NMEICT, MHRD Government of India.
13:54 We thank the development team of OpenModelica for their support. Thank you.

Contributors and Content Editors

Jyotisolanki, Sandhya.np14