Difference between revisions of "OpenModelica/C2/OpenModelica-Connectors/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 28: Line 28:
 
| | To record this tutorial, I am using
 
| | To record this tutorial, I am using
  
* '''OpenModelica version 1.9.5''' and  
+
* '''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 files on our site.
+
| | '''RLC_Circuit '''file used in the tutorial is provided as a code files 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:
  
 
|-
 
|-
| | Click on '''File'''>> '''Save'''
+
| | Right click on '''Sample'''>> '''Save'''
| | Now we will save this '''class'''.
+
| | Now we will save this class.
  
For this, go to '''File''' menu and click on '''Save'''.
+
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.
 
Click on '''Save'''.
 
  
 
|-
 
|-
Line 139: Line 137:
  
 
|-
 
|-
|| Click on''' Open.'''
+
|| Select '''RLC_Circuit.mo''' >> '''Open'''
| | Select the desired file you wish to open and click on the '''Open '''button.
+
| | 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 downloaded earlier.
+
For this I will use '''RLC_Circuit''' file which we opened earlier.
  
 
|-
 
|-
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 class'''.
+
|| 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'''.
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.
  
Click on components and drag and drop it into the grid space.  
+
Then we will connect them.
  
 
|-
 
|-
| | /* Connecting the components to complete the circuit */
+
| | Click on '''Resistor'''
| | Now we have all the required components to construct the '''RLC Circuit''' in series.
+
| | Click on '''Resistor''' and drag and drop it into the grid space.
  
Let's connect these '''components'''.
+
|-
 +
| | '''Component Name''' >> '''Resistor''' >> '''R'''
 +
| | We get a message, '''Enter Component Name'''
 +
 
 +
In the '''Name''' field, enter the component name as '''R''' and click '''OK'''.
  
 
|-
 
|-
| | Point to the left part of the component.
+
| | Click on '''Inductor'''
 +
 
 +
'''Resistor''' >> '''Inductor'''
 +
 
 +
'''Component Name''' >> '''Resistor''' >> '''L'''
  
Point to the left part of the component.
+
| |  Click on '''Inductor'''
  
| | The left part of the '''components '''represents '''p (positive)''' pin.
+
Drag and drop it into the grid space and place it next to the '''Resistor'''
  
And the right part represents the '''n (negative)''' pin.
+
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 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_Circuit.pin p appears.
 +
 
 +
This represents positive pin.
 +
 
 +
Similarly, the right part of component shows a pop up as RLC_Circuit.pin n.
 +
 
 +
This represents negative pin.
  
 
|-
 
|-
Line 248: Line 328:
 
|-
 
|-
 
| | Click on its '''p''' pin
 
| | Click on its '''p''' pin
| | Click on the '''Inductor's p '''pin and then release the cursor.
+
| | Click on '''Inductor's p '''pin and then release the cursor.
  
 
|-
 
|-
| | Point to indicator and capacitor.
+
| | 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.'''
Line 268: Line 348:
 
| | Click on the '''p''' pin of the '''Capacitor.'''
 
| | 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.'''
  
Line 280: Line 360:
 
|-
 
|-
 
| | 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.'''
 
| | 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 it to the '''Ground.'''
+
| | Click on n pin of VoltageSource>>hold >> drag to p pin of Ground.
  
|| Next step is to '''Ground''' the circuit.
+
Click on it.
  
Click on the '''n''' pin of the '''VoltageSource.'''
+
Point to the completed circuit.
  
Hold and drag it to the '''Ground.'''
+
|| Next step is to Ground the circuit.
  
|-
+
Click on the n pin of the VoltageSource.
| |Click on it.
+
 
| |Click on it and release the cursor.
+
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.
  
|-
 
| |Point to the completed circuit.
 
| |Now, the circuit is complete.
 
  
 
|-
 
|-
Line 313: Line 405:
  
 
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 334: Line 427:
  
 
Point to the window.
 
Point to the window.
 +
 
| | Click on the '''Simulate''' button.
 
| | Click on the '''Simulate''' button.
  
Line 345: Line 439:
 
|| <center>/* Generating plot for the Model */</center>
 
|| <center>/* Generating plot for the Model */</center>
  
Expand '''resistor1''' >> click on '''Ir''' to get plot between '''Ir''' and '''time.'''
+
Expand '''R''' >> click on '''Ir''' to get plot between '''Ir''' and '''time.'''
  
| | Expand '''resistor1''' and click on '''Ir''' to get the 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.  
 
We will learn about '''Equations''' and '''Variables''' in the upcoming tutorials.  
Line 353: Line 447:
 
|-
 
|-
 
||  
 
||  
| | That's all for this tutorial.  
+
| | That's all for this tutorial. Let's summarize.
 
+
Let's summarize.
+
  
 
|-
 
|-
Line 378: Line 470:
 
Construct a '''RLC Circuit''' where:
 
Construct a '''RLC Circuit''' where:
  
'''Resistor''', '''Inductor''' and '''Capacitor '''are in '''parellel''' connection.
+
'''Resistor''', '''Inductor''' and '''Capacitor '''are in '''parallel''' connection.
  
Use the same '''classes''' and '''connectors''' available in the '''RLC_Circuit '''package.
+
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 407: Line 499:
 
* 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 [mailto:contact@spoken-tutorial.org contact@spoken-tutorial.org]
+
* For more details, please write to us. contact@spoken-tutorial.org
  
 
|-
 
|-

Revision as of 11:23, 14 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:
  • Create a new class
  • Open an existing class
  • Connect different classes
  • Build a model and
  • Simulate the model
Slide Number 3

System Requirements

To record this tutorial, I am using
  • OpenModelica version 1.11.0 and
  • Ubuntu Linux OS 14.04

But, the process demonstrated in this tutorial is identical in other OS such as-

  • Windows,
  • Mac OS X or
  • FOSSEE OS on ARM
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 files 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

Use of Connectors:

Connectors are used in:

  • Connections
  • Communication
  • Coupling between component and outside world.
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,
  • Ground
  • VoltageSource
  • Resistor
  • Capacitor and
  • Inductor

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 doesn’t contain any code.

Go to the Diagram View. Now go to the 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 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_Circuit.pin p appears.

This represents positive pin.

Similarly, the right part of component shows a pop up as RLC_Circuit.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.
/* Generating plot for the Model */

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,
  • Create a new class
  • Open an existing class
  • Connect different classes
  • Build a Model and
  • Simulate the Model
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.

http://spoken-tutorial.org/

It summarizes the Spoken Tutorial project.

Slide Number 11


Spoken Tutorial Workshop

The Spoken Tutorial Project Team
  • Conducts workshops using spoken tutorials
  • Gives certificates to those who pass an online test
  • For more details, please write to us. contact@spoken-tutorial.org
Slide Number 12

Forum slide

Do you have questions in this Spoken Tutorial?


Please visit this site

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


Textbook Companion Project

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.

Contributors and Content Editors

Kaushik Datta, Nancyvarkey