OpenModelica/C2/OpenModelica-Connectors/English

From Script | Spoken-Tutorial
Revision as of 01:23, 20 February 2017 by Nancyvarkey (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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 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

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 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.
/* 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.
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