Difference between revisions of "OpenModelica/C2/OpenModelica-Connectors/English"
Nancyvarkey (Talk | contribs) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 28: | Line 28: | ||
| | To record this tutorial, I am using | | | To record this tutorial, I am using | ||
− | * '''OpenModelica version 1. | + | * '''OpenModelica version 1.11.0''' and |
* '''Ubuntu Linux OS 14.04''' | * '''Ubuntu Linux OS 14.04''' | ||
Line 51: | Line 51: | ||
'''Code Files''' | '''Code Files''' | ||
− | | | '''RLC_Circuit '''file used in the tutorial is provided as code | + | | | '''RLC_Circuit '''file used in the tutorial is provided as a code file on our site. |
Download the files from '''Code Files''' link. | Download the files from '''Code Files''' link. | ||
Line 68: | Line 68: | ||
First we will create a new '''class.''' | First we will create a new '''class.''' | ||
− | So go to '''File''' menu and select '''New Modelica Class'''. | + | So go to the '''File''' menu and select '''New Modelica Class'''. |
|- | |- | ||
Line 103: | Line 103: | ||
|- | |- | ||
− | | | | + | | | Right click on '''Sample'''>> '''Save''' |
| | Now we will save this class. | | | Now we will save this class. | ||
− | For this, | + | For this, right-click on '''Sample class''' and click on '''Save'''. |
Choose an appropriate location to save this file. | Choose an appropriate location to save this file. | ||
− | |||
− | |||
|- | |- | ||
Line 139: | Line 137: | ||
|- | |- | ||
− | || | + | | | Select '''RLC_Circuit.mo''' >> '''Open''' |
− | | | Select the desired file you wish to open | + | | | Select the desired file you wish to open. |
+ | |||
+ | I will choose '''RLC_Circuit.mo''' file downloaded earlier from '''Code files'''. | ||
+ | |||
+ | Click on the '''Open '''button. | ||
|- | |- | ||
Line 167: | Line 169: | ||
| | Next, we will learn to connect '''classes'''. | | | Next, we will learn to connect '''classes'''. | ||
− | For this I will use '''RLC_Circuit''' file which we | + | For this, I will use '''RLC_Circuit''' file which we opened earlier. |
|- | |- | ||
| | Point to different classes in the package. | | | Point to different classes in the package. | ||
− | | | '''RLC_Circuit''' is a '''Modelica''' | + | | | '''RLC_Circuit''' is a '''Modelica package''' containing different '''classes'''. |
− | Let’s expand the package. | + | Let’s expand the '''package'''. |
|- | |- | ||
| | Point to all the models in the package. | | | Point to all the models in the package. | ||
− | | | Here we can see various '''classes''' namely, | + | | | Here we can see various '''classes,''' namely, |
* '''Ground''' | * '''Ground''' | ||
Line 190: | Line 192: | ||
|- | |- | ||
− | || Move the cursor on '''circuit''' | + | || Move the cursor on '''circuit class'''. |
Point to the class. | Point to the class. | ||
Line 196: | Line 198: | ||
Move the cursor over to all the blocks. | Move the cursor over to all the blocks. | ||
− | || This package also contains a '''circuit''' | + | || This '''package''' also contains a '''circuit class.''' |
Double-click on the '''circuit '''file and go to the '''Text view'''. | Double-click on the '''circuit '''file and go to the '''Text view'''. | ||
− | Here we can see that the '''class ''' | + | Here we can see that the '''class '''does not contain any code. |
|- | |- | ||
| | Go to the '''Diagram View'''. | | | Go to the '''Diagram View'''. | ||
− | | | Now go to | + | | | Now go to '''Diagram View'''. |
|- | |- | ||
Line 213: | Line 215: | ||
| | Let us place all the '''blocks/components''' in the grid area. | | | Let us place all the '''blocks/components''' in the grid area. | ||
− | + | Then we will connect them. | |
|- | |- | ||
− | | | | + | | | Click on '''Resistor''' |
− | | | | + | | | Click on '''Resistor''' and drag and drop it into the grid space. |
− | + | |- | |
+ | | | '''Component Name''' >> '''Resistor''' >> '''R''' | ||
+ | | | We get a message, '''Enter Component Name.''' | ||
+ | |||
+ | In the '''Name''' field, enter the component name as '''R''' and click '''OK'''. | ||
|- | |- | ||
− | | | | + | | | Click on '''Inductor''' |
+ | |||
+ | '''Resistor''' >> '''Inductor''' | ||
+ | |||
+ | '''Component Name''' >> '''Resistor''' >> '''L''' | ||
− | + | | | Click on '''Inductor''' | |
− | + | Drag and drop it into the grid space and place it next to the '''Resistor''' | |
− | + | Enter the component name as '''L''' and click '''OK'''. | |
+ | |||
+ | |- | ||
+ | | | Click on '''Capacitor''' | ||
+ | |||
+ | '''Inductor''' >> '''Capacitor''' | ||
+ | |||
+ | '''Component Name''' >> '''Capacitor''' >> '''C''' | ||
+ | |||
+ | | | Click on '''Capacitor''' | ||
+ | |||
+ | Drag and drop it into the grid space and place it next to the '''Inductor''' | ||
+ | |||
+ | Enter the component name as '''C''' and click '''OK'''. | ||
+ | |||
+ | |- | ||
+ | | | Click on '''VoltageSource''' | ||
+ | |||
+ | Point the position of '''VoltageSource'''ter | ||
+ | |||
+ | '''Component Name''' >> '''VoltageSource''' >> '''ACVoltage''' | ||
+ | |||
+ | | | Next, click on '''VoltageSource''' and drag and drop it into the grid space. | ||
+ | |||
+ | Place it above the '''R, L''' and '''C''' which are placed in series. | ||
+ | |||
+ | Enter the component name as '''ACVoltage'''. | ||
+ | |||
+ | |- | ||
+ | | | Point to '''ACVoltage''' | ||
+ | | | Note that, please do not put any space in the component name field. | ||
+ | |||
+ | It will give translation error at the time of simulation. | ||
+ | |||
+ | Now click '''OK'''. | ||
+ | |||
+ | |- | ||
+ | | | Click on '''Ground''' | ||
+ | |||
+ | Point the position of '''Ground''' | ||
+ | |||
+ | Point to all the components in the '''RLC Circuit'''. | ||
+ | |||
+ | '''Component Name''' >> '''Ground''' >> '''G''' | ||
+ | |||
+ | | |Next, click on '''Ground''' and drag and drop it into the grid space. | ||
+ | |||
+ | Place it below the '''R, L''' and '''C''' components in series. | ||
+ | |||
+ | Enter the component name as '''G''' and click '''OK'''. | ||
+ | |||
+ | Now we have all the required components to construct the '''RLC Circuit''' in series. | ||
+ | |||
+ | |- | ||
+ | | | /* Connecting the components to complete the circuit */ | ||
+ | | | Let's connect these '''components'''. | ||
+ | |||
+ | |- | ||
+ | | | Hover the mouse to the left part of component. | ||
+ | |||
+ | Hover the mouse to the right part of component. | ||
+ | |||
+ | | | Hover the mouse to the left part of component. | ||
+ | |||
+ | A pop up '''RLC underscore Circuit dot pin p''' appears. | ||
+ | |||
+ | This represents '''positive pin'''. | ||
+ | |||
+ | Similarly, the right part of component shows a pop up as '''RLC underscore Circuit dot pin n'''. | ||
+ | |||
+ | This represents '''negative pin'''. | ||
|- | |- | ||
Line 235: | Line 315: | ||
Point to '''+''' sign. | Point to '''+''' sign. | ||
− | | | Place the cursor over the '''negative ''' | + | | | Place the cursor over the '''negative pin''' of the '''Resistor'''. |
− | We can see a ''''+'''' sign when the cursor is placed over '''n''' | + | We can see a ''''+'''' sign when the cursor is placed over '''n pin'''. |
|- | |- | ||
|| Click on the pin>> hold >> drag it to the '''p''' pin of '''Inductor.''' | || Click on the pin>> hold >> drag it to the '''p''' pin of '''Inductor.''' | ||
− | | | Click on the pin. | + | | | Click on the '''pin'''. |
− | Hold and drag it to the '''p''' | + | Hold and drag it to the '''p pin''' of the '''Inductor.''' |
|- | |- | ||
| | Click on its '''p''' pin | | | Click on its '''p''' pin | ||
− | | | Click on | + | | | Click on '''Inductor's p pin '''and then release the cursor. |
|- | |- | ||
− | | | Point to | + | | | Point to '''Indicator''' and '''Capacitor'''. |
Click on '''n''' pin of '''Inductor>>''' hold >> drag top pin of '''Capacitor.''' | Click on '''n''' pin of '''Inductor>>''' hold >> drag top pin of '''Capacitor.''' | ||
− | | | Next, we will connect '''n''' | + | | | Next, we will connect '''n pin''' of the '''Inductor''' with the '''p pin '''of the '''Capacitor.''' |
− | Click on the '''n''' | + | Click on the '''n pin''' of the '''Inductor.''' |
− | Hold and drag it to the '''p''' | + | Hold and drag it to the '''p pin''' of the '''Capacitor.''' |
|- | |- | ||
Line 266: | Line 346: | ||
Point to the connection. | Point to the connection. | ||
− | | | Click on the '''p''' | + | | | Click on the '''p pin''' of the '''Capacitor.''' |
− | Now we have connected the '''Resistor, Inductor '''and''' Capacitor''' in series. | + | Now we have connected the '''Resistor, Inductor''' and''' Capacitor''' in series. |
|- | |- | ||
− | || Click on '''p''' pin of '''Resistor>>''' hold >>drag to '''p''' pin of '''VoltageSource'''. | + | || Click on '''p''' pin of '''Resistor>>''' hold >> drag to '''p''' pin of '''VoltageSource'''. |
| | Next step is to provide the '''VoltageSource.''' | | | Next step is to provide the '''VoltageSource.''' | ||
− | Click on the '''p''' | + | Click on the '''p pin''' of the '''Resistor.''' |
− | Hold and drag it to the '''p''' | + | Hold and drag it to the '''p pin''' of the '''VoltageSource'''. |
|- | |- | ||
| | Point to the pin. | | | Point to the pin. | ||
+ | |||
+ | Click on n pin of '''Capacitor'''>> hold>> drag to '''n''' pin of ''VoltageSource'''. | ||
Click on it. | Click on it. | ||
− | |||
+ | | | Similarly, we will connect the '''n pin''' of the '''Capacitor''' with the '''n pin''' of the '''VoltageSource.''' | ||
+ | |||
+ | Click on the '''n pin''' of the '''Capacitor'''. | ||
+ | |||
+ | Hold and drag it to the '''n pin''' of the '''VoltageSource'''. | ||
+ | |||
+ | Click on the '''n pin''' and release the cursor. | ||
|- | |- | ||
− | | | Click on '''n''' pin of '''VoltageSource | + | | | Click on '''n''' pin of '''VoltageSource'''>>hold >> drag to '''p''' pin of '''Ground'''. |
Click on it. | Click on it. | ||
Point to the completed circuit. | Point to the completed circuit. | ||
− | |||
− | |||
|| Next step is to '''Ground''' the circuit. | || Next step is to '''Ground''' the circuit. | ||
− | Click on the '''n''' | + | Click on the '''n pin''' of the '''VoltageSource'''. |
+ | |||
+ | Hold and drag it to the '''Ground'''. | ||
− | + | Note that '''Ground''' has got only one '''pin''' which is the '''p pin.''' | |
Click on it and release the cursor. | Click on it and release the cursor. | ||
− | Now | + | Now the circuit is complete. |
− | + | ||
|- | |- | ||
| | | | | | ||
Line 309: | Line 396: | ||
|- | |- | ||
− | | | Press '''CTRL | + | | | Press '''CTRL S''' |
− | | | Press '''CTRL | + | | | Press '''CTRL S''' to save the '''class'''. |
|- | |- | ||
Line 316: | Line 403: | ||
Click on '''Check All Models''' button. | Click on '''Check All Models''' button. | ||
+ | |||
| | Now we will check for the correctness of the '''class'''. | | | Now we will check for the correctness of the '''class'''. | ||
Line 337: | Line 425: | ||
Point to the window. | Point to the window. | ||
+ | |||
| | Click on the '''Simulate''' button. | | | Click on the '''Simulate''' button. | ||
Line 348: | Line 437: | ||
|| <center>/* Generating plot for the Model */</center> | || <center>/* Generating plot for the Model */</center> | ||
− | Expand ''' | + | Expand '''R''' >> click on '''Ir''' to get plot between '''Ir''' and '''time.''' |
− | | | Expand ''' | + | | | Expand '''R''' and click on '''Ir''' to get the plot between '''Ir''' and '''time.''' |
We will learn about '''Equations''' and '''Variables''' in the upcoming tutorials. | We will learn about '''Equations''' and '''Variables''' in the upcoming tutorials. | ||
Line 356: | Line 445: | ||
|- | |- | ||
|| | || | ||
− | | | That's all for this tutorial. | + | | | That's all for this tutorial. Let's summarize. |
− | + | ||
− | Let's summarize. | + | |
|- | |- | ||
Line 381: | Line 468: | ||
Construct a '''RLC Circuit''' where: | Construct a '''RLC Circuit''' where: | ||
− | '''Resistor | + | '''Resistor, Inductor''' and '''Capacitor '''are in '''parallel''' connection. |
− | Use the same '''classes''' and ''' | + | Use the same '''classes''' and '''connector''' available in the '''RLC_Circuit package'''. |
This is the diagram of the circuit which needs to be constructed. | This is the diagram of the circuit which needs to be constructed. | ||
Line 410: | Line 497: | ||
* Conducts workshops using spoken tutorials | * Conducts workshops using spoken tutorials | ||
* Gives certificates to those who pass an online test | * Gives certificates to those who pass an online test | ||
− | * For more details, please write to | + | * For more details, please write to us. |
|- | |- | ||
Line 457: | Line 544: | ||
'''Acknowledgements''' | '''Acknowledgements''' | ||
− | | | '''Spoken Tutorial''' and '''FOSSEE''' projects are funded by NMEICT, MHRD, Government of India. | + | | | '''Spoken Tutorial''' and '''FOSSEE''' projects are funded by '''NMEICT, MHRD''', Government of India. |
|- | |- |
Latest revision as of 06:53, 20 February 2017
Visual Cue | Narration |
Slide Number 1
Title Slide |
Welcome to this spoken tutorial on OpenModelica Connectors. |
Slide Number 2
Learning Objectives |
In this tutorial, we will learn to:
|
Slide Number 3
System Requirements |
To record this tutorial, I am using
But, the process demonstrated in this tutorial is identical in other OS such as-
|
Slide Number 4
Pre-requisites spoken-tutorial.org |
To practice this tutorial, you need to know about OMEdit.
The Prerequisite tutorials are mentioned on our website. |
Slide Number 5
Code Files |
RLC_Circuit file used in the tutorial is provided as a code file on our site.
Download the files from Code Files link. |
I have already opened the OMEdit window. | |
/* Creating a new class file and switching views */
Click on File >> New Modelica Class. |
Now we will discuss how to create a new model.
First we will create a new class. So go to the File menu and select New Modelica Class. |
Point to Create New Modelica Class window. | Create New Modelica Class window appears. |
Point to Name field.
Place the cursor in the Name field. |
In the Name field, enter the name of the class which we want to create.
I will enter the name as Sample. |
Point to Specialization field and the classes.
Point to the Class. |
In the Specialization field, select the type of class you wish to create.
I will choose Class. |
Click on OK. | Then click on OK. |
Point to the new class | A new class will be created with the given name.
We will learn more about classes in the upcoming tutorials. |
Right click on Sample>> Save | Now we will save this class.
For this, right-click on Sample class and click on Save. Choose an appropriate location to save this file. |
Right click on Sample and select Unload.
Click Yes in the conformation dialog box that appears. |
Let's close the Sample file.
Right-click on Sample and select Unload. Click Yes in the confirmation dialog box that appears. |
<<PAUSE>> | |
/* Opening a new class file and switching views */
Go to File >> Click to Open Model/Library File |
Now we shall learn how to open an existing class.
To open a class, go to the File menu. Then click on Open Model/Library File. |
Select RLC_Circuit.mo >> Open | Select the desired file you wish to open.
I will choose RLC_Circuit.mo file downloaded earlier from Code files. Click on the Open button. |
Slide Number 6
Connectors |
Now we will learn about Connectors.
A Connector is a way for one model to exchange information with another model. |
Slide Number 7
|
Use of Connectors:
Connectors are used in:
|
Point to RLC_Circuit file | Next, we will learn to connect classes.
For this, I will use RLC_Circuit file which we opened earlier. |
Point to different classes in the package. | RLC_Circuit is a Modelica package containing different classes.
Let’s expand the package. |
Point to all the models in the package. | Here we can see various classes, namely,
and also a connector named Pin We will learn more about classes and connectors in upcoming tutorials in this series. |
Move the cursor on circuit class.
Point to the class. Move the cursor over to all the blocks. |
This package also contains a circuit class.
Double-click on the circuit file and go to the Text view. Here we can see that the class does not contain any code. |
Go to the Diagram View. | Now go to Diagram View. |
/* Placing all the components in the Grid */
Point to all the blocks/components in the grid area. |
Let us place all the blocks/components in the grid area.
Then we will connect them. |
Click on Resistor | Click on Resistor and drag and drop it into the grid space. |
Component Name >> Resistor >> R | We get a message, Enter Component Name.
In the Name field, enter the component name as R and click OK. |
Click on Inductor
Resistor >> Inductor Component Name >> Resistor >> L |
Click on Inductor
Drag and drop it into the grid space and place it next to the Resistor Enter the component name as L and click OK. |
Click on Capacitor
Inductor >> Capacitor Component Name >> Capacitor >> C |
Click on Capacitor
Drag and drop it into the grid space and place it next to the Inductor Enter the component name as C and click OK. |
Click on VoltageSource
Point the position of VoltageSourceter Component Name >> VoltageSource >> ACVoltage |
Next, click on VoltageSource and drag and drop it into the grid space.
Place it above the R, L and C which are placed in series. Enter the component name as ACVoltage. |
Point to ACVoltage | Note that, please do not put any space in the component name field.
It will give translation error at the time of simulation. Now click OK. |
Click on Ground
Point the position of Ground Point to all the components in the RLC Circuit. Component Name >> Ground >> G |
Next, click on Ground and drag and drop it into the grid space.
Place it below the R, L and C components in series. Enter the component name as G and click OK. Now we have all the required components to construct the RLC Circuit in series. |
/* Connecting the components to complete the circuit */ | Let's connect these components. |
Hover the mouse to the left part of component.
Hover the mouse to the right part of component. |
Hover the mouse to the left part of component.
A pop up RLC underscore Circuit dot pin p appears. This represents positive pin. Similarly, the right part of component shows a pop up as RLC underscore Circuit dot pin n. This represents negative pin. |
Move the mouse to negative pin of resistor.
Point to + sign. |
Place the cursor over the negative pin of the Resistor.
We can see a '+' sign when the cursor is placed over n pin. |
Click on the pin>> hold >> drag it to the p pin of Inductor. | Click on the pin.
Hold and drag it to the p pin of the Inductor. |
Click on its p pin | Click on Inductor's p pin and then release the cursor. |
Point to Indicator and Capacitor.
Click on n pin of Inductor>> hold >> drag top pin of Capacitor. |
Next, we will connect n pin of the Inductor with the p pin of the Capacitor.
Click on the n pin of the Inductor. Hold and drag it to the p pin of the Capacitor. |
Click on the p pin.
Point to the connection. |
Click on the p pin of the Capacitor.
Now we have connected the Resistor, Inductor and Capacitor in series. |
Click on p pin of Resistor>> hold >> drag to p pin of VoltageSource. | Next step is to provide the VoltageSource.
Click on the p pin of the Resistor. Hold and drag it to the p pin of the VoltageSource. |
Point to the pin.
Click on n pin of Capacitor'>> hold>> drag to n pin of VoltageSource. Click on it. |
Similarly, we will connect the n pin of the Capacitor with the n pin of the VoltageSource.
Click on the n pin of the Capacitor. Hold and drag it to the n pin of the VoltageSource. Click on the n pin and release the cursor. |
Click on n pin of VoltageSource>>hold >> drag to p pin of Ground.
Click on it. Point to the completed circuit. |
Next step is to Ground the circuit.
Click on the n pin of the VoltageSource. Hold and drag it to the Ground. Note that Ground has got only one pin which is the p pin. Click on it and release the cursor. Now the circuit is complete. |
Pause the tutorial and check that your circuit looks like mine. | |
Press CTRL S | Press CTRL S to save the class. |
/* Check the Model */
Click on Check All Models button. |
Now we will check for the correctness of the class.
Click on Check All Models button. |
Point to the message.
Point to equations and variables. |
Observe the Messages Browser.
It shows the number of equations and the number of variables. Model will be ready to simulate if both of them are equal. |
/* Simulate the Model */
Click on Simulate button. Point to the window. |
Click on the Simulate button.
A new window appears. |
Point to the window. | This output window displays the success message. |
Expand R >> click on Ir to get plot between Ir and time. |
Expand R and click on Ir to get the plot between Ir and time.
We will learn about Equations and Variables in the upcoming tutorials. |
That's all for this tutorial. Let's summarize. | |
Slide Number 8
Summary |
In this tutorial, we have learnt to,
|
Slide Number 9
Assignment |
As an assignment-
Construct a RLC Circuit where: Resistor, Inductor and Capacitor are in parallel connection. Use the same classes and connector available in the RLC_Circuit package. This is the diagram of the circuit which needs to be constructed. [[Image:]] |
Slide Number 10
About the Spoken Tutorial Project |
Watch the video available at the following link.
It summarizes the Spoken Tutorial project. |
Slide Number 11
|
The Spoken Tutorial Project Team
|
Slide Number 12
Forum slide Do you have questions in this Spoken Tutorial?
Choose the minute and second where you have the question. Explain your question briefly. Someone from the FOSSEE team will answer them. |
Please post your times queries in this forum. |
Slide Number 13
|
The FOSSEE team coordinates coding of solved examples of popular books.
We give honorarium and certificates for those who do this. For more details, please visit this site. |
Slide Number 14
Lab Migration Project |
The FOSSEE team helps migrate commercial simulator labs to OpenModelica.
We give honorarium and certificates for those who do this. For more details, please visit this site. |
Slide Number 15
Acknowledgements |
Spoken Tutorial and FOSSEE projects are funded by NMEICT, MHRD, Government of India. |
Slide Number 16
Thanks |
This tutorial is contributed by Kaushik Datta and Priyam Nayak.
Thanks you for joining. |