OpenModelica/C2/Examples-through-OMEdit/English

From Script | Spoken-Tutorial
Jump to: navigation, search
Visual Cue Narration
Slide Number 1

Title Slide

Welcome to this spoken tutorial on Examples through OMEdit.
Slide Number 2

Learning Objective

In this tutorial, we will learn,
  • to open and simulate different Modelica library classes.
Slide Number 3

System Requirements

To record this tutorial, I am using
  • OpenModelica version 1.9.5 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 should have OMEdit installed on your system.

You should also know how to work on the OMEdit window.

If not, please go through the previous OpenModelica tutorials on this website.

/* Switch to OMEdit */ Let us switch to the OMEdit window.
Switch to Libraries Browser On the left side of OMEdit window, we see the Libraries Browser.

Here we can see a list of libraries.

Hover the mouse on the Libraries.

/* Expand Modelica Library */

Let us expand the Modelica library.

To do this, click on the arrow head to the left of the Modelica library.

Now I will demonstrate an example from the Electrical library.
/* Expand Electrical Library */

Expand Electrical library >> Expand Analog library

Expand the Electrical library.

Click on the arrow head to the left of Electrical library.

Under Electrical, we find Analog library.

Let's expand the Analog library.

/* Expand Example Library */ Once again, we see many different libraries displayed.

Now, let’s expand the Example library.

Here we can see different examples of Analog.

/* Opening Rectifier Class in Example Library */

Right click Rectifier >> Open Class

Next, we will open the class named Rectifier.

Right-click on Rectifier and select Open Class.

We can also double-click on the class name to open the class.

Switch to Modeling Perspective window

Switch to Diagram View.

Now we are in the Modeling Perspective window.

By default, the class opens in Diagram View.

I have already demonstrated how to switch between different views earlier in this series.

/* Switch to Text View */

Click on Text View button next to Diagram View.

Now let's switch to the Text View by clicking on the Text View icon.

Here we can see the Modelica code pertaining to the Rectifier class.

/* Checking a Class */ Before simulating a model, we need to check for the correctness of the model.
Click green button with white coloured double tick To do this, first locate Check All Models button on the toolbar.

This button has white coloured double ticks on it.

Click on it.

Getting error messages in Messages Browser.

Cursor on the Messages Browser.

Immediately, the Messages Browser opens at the bottom of the window.

This will show messages pertaining to the Modelica class.

/* Simulating a Class */ Now, let’s try to simulate the model.
Click green coloured arrow button On the toolbar, click on the green coloured arrow button.

This is the Simulate button which is used to simulate the model.

We can also press Ctrl and B keys to simulate the model.

/* Switching to Simulation Output Window */ On simulating, a new window opens.
Hover the mouse on simulation output window. It shows the compilation process of the class.
Point to the success message. Once the compilation is successful, the output window displays the message:

Simulation process finished successfully.

Close this window.

/* Switching to Plotting Perspective */ By default, the Plotting Perspective should now open in the OMEdit window.

If it does not open, click the Plotting button at the bottom right.

We can also press Ctrl and F3 keys to open the Plotting Perspective.

Here we can see the simulation results of the Modelica class.
Switch to Variables Browser. At the right of the Plotting Perspective, look at the Variables Browser window.
Point to Variables Browser. Under Variables Browser:

we will learn to change input variable values of a Modelica class.

Point to IDC and Losses. By default, IDC = 500, Losses = 2890.26

Change the value of IDC and see how the values of Losses change.

Change IDC value to 250. Let us change the value of IDC from 500 to 250.

and press Enter.

Click Re-simulate button. Go to the top right corner of the window.

Click Re-simulate button.

Point to the message >> Close the window The success message window will open.

Close this window.

Point to the changes. Once the simulation is completed, note the changes.

Losses = 1756.77

Cursor on the plot window. Now let me demonstrate how to generate a plot.

We will generate a plot between Losses and Time.

Click on check box against Losses variable. Click on the check box against the Losses variable.
Point to the plot, Losses on Y-axis and time on X-axis. We can see a plot between Time on the X-axis and Losses on the Y-axis.

This plot describes the power losses for the diode bridge varying with time.

/* Simulation Setup Window */

Change Simulation Interval

Point to X-axis from 0 to 0.1 unit.

By default, the simulation runs from 0 to 0.1 unit time.

We can vary this interval using the Simulation Setup option.

Go to Modeling Perspective. To do this, go to the Modeling Perspective.

Click on the Modeling button.

Click on Simulation Setup option on the toolbar. Click on the Simulation Setup option on the toolbar.
Point to Simulation Setup window. The Simulation Setup window opens.
Change Start Time to 0.01 unit. Here, change the Start Time to 0.01 unit.
Ensure that Simulate check box is checked. Ensure that Simulate check box is checked.
Click Ok. And then click on Ok.
Point to the success message window. Immediately we see the success message window.
Close this window. Close this window.
Point to the simulation The class is re-simulated with a simulation interval of 0.01 to 0.1 unit time.
/* Delete Result in Variables Browser*/

Right Click on Rectifier >> select Delete Result

Let's delete these results.

To do so, right-click on Rectifier and then click on Delete Result.

The result has now been deleted.

Hover the mouse on the Libraries. Now I will demonstrate an example from Mechanics library.
* Expand Mechanics Library */

Expand Mechanics library >> Expand Multibody library

First we will expand the Mechanics library.

Under Mechanics, we find Multibody library.

Let's expand the Multibody library also.

/* Expand Example Library */

Point to different examples

After this, let's expand the Example library.

Here we can see different examples of Multibody Mechanics.

/* Expand Elementary Library */ Next, we will expand the Elementary library.
/* Opening DoublePendulum Class in Example Library */

Right click DoublePendulum >> Open Class

Let us open the class named DoublePendulum.

To do this, right-click on DoublePendulum and select Open Class.

Switch to Diagram View The class opens in Text view.
/* Checking a Class */

Click green button with white coloured double tick.

Now, click on Check All Models button on the toolbar.
Cursor on the Messages Browser. Observe the Messages Browser.

This will show messages pertaining to the Modelica class.

/* Simulating a Class */

Click green colored arrow button

Now, let’s try to simulate the model.

To do so, click on the Simulate button on the toolbar.

Once the compilation is successful,

the Plotting Perspective opens in the OMEdit window.

Point to Variables Browser >> Point to damper variable Under the Variables Browser, let’s expand the damper variable.
Point to the default values By default, d = 0.1,

relative angular acceleration(a_rel) = 11.567 and

relative rotational angle [der(phi_rel)] = 4.1

Change d value to 0.05. Let us change the value of d from 0.1 to 0.05.

and press Enter.

Click Re-simulate button. Then click Re-simulate button.
Point to the changes. After completion of the simulation, observe the changes.

relative angular acceleration (a_rel) = 15.449 and

relative rotational angle [der(phi_rel)] = 4.359

Cursor on the plot window. Now, we will generate a plot between relative angular acceleration and Time.
Click on check box against a_rel variable. Click on the check box against a_rel variable.
Point to the plot, Time on the X-axis and a_rel on the Y-axis. We see a plot between Time on the X-axis and a_rel on the Y-axis.

This plot describes the relative angular acceleration varying with Time.

/* Simulation Setup Window */

Change Simulation Interval

Point to X-axis from 0 to 3 unit.

By default, the simulation runs from 0 to 3 unit time.

Let's change this interval.

Go to Modeling Perspective. To do this, go to the Modeling Perspective.
Click on Simulation Setup option on the toolbar. Click on Simulation Setup option on the toolbar.
Point to Simulation Setup window. The Simulation Setup window opens.
Change Start Time to 1 unit and Stop Time to 5 unit. Here change the Start Time to 1 unit and the Stop Time to 5 units.
Ensure that Simulate check box is checked. Ensure that Simulate check box is checked.
Click Ok. then click on Ok.
Point to the success message window. We get the success message window.
Close this window. Close this window.
Point to the simulation. The class is re-simulated with a simulation interval of 1 to 5 unit time.
/* Delete Result in Variables Browser*/ Once the necessary plot is generated, we can delete the results.
Right Click on DoublePendulum >> select Delete Result In the Variable Browser, right click on DoublePendulum.

Select Delete Result.

The result has now been deleted.

Let's summarize.
Slide Number 5

Summery

In this tutorial, we have learnt,
  • to open and simulate different Modelica library classes.
Slide Number 6

Assignment

As an assignment:
  • Expand Magnetic library in Modelica
  • Simulate SaturatedInductor class in FluxTubes library
  • Change the values of a few input variables and re-simulate
  • Generate a Parametric plot between i and LossPower of variable r.
Slide Number 7

About the Spoken Tutorial Project

Watch the video available at the following link.

It summarizes the Spoken Tutorial project.

Slide Number 8

Spoken Tutorial Workshops

The Spoken Tutorial Project Team:
  • conduct workshops.
  • Gives certificates to those who pass an online test.

For more details, please write to us.

Slide Number 9

Forum slide

Do you have questions in this Spoken Tutorial?

Please visit this site.

Slide Number 10

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 11

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 12

Acknowledgements

Spoken Tutorial and FOSSEE projects are funded by NMEICT, MHRD, Government of India.
Slide Number 13

Thanks

This tutorial is contributed by Kaushik Datta and Priyam Nayak.

Thanks you for joining.

Contributors and Content Editors

Kaushik Datta