Difference between revisions of "OpenModelica/C3/Annotations--in-Modelica/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "{| border=1 ||'''Visual Cue''' ||'''Narration''' |- ||'''Slide Number 1''' '''Title Slide''' || Welcome to the spoken tutorial on '''Annotation'''. |- || Slide: '''Learning...")
 
 
(6 intermediate revisions by one other user not shown)
Line 6: Line 6:
  
 
'''Title Slide'''
 
'''Title Slide'''
|| Welcome to the spoken tutorial on '''Annotation'''.
+
|| Welcome to the spoken tutorial on '''Annotations'''.
  
 
|-
 
|-
Line 24: Line 24:
  
 
* '''OpenModelica 1.9.2'''  
 
* '''OpenModelica 1.9.2'''  
* You may use any of the following operating systems. '''Linux, Windows, Mac OS X''' or '''FOSSEE OS'''
+
* You may use any of the following operating systems to practice this tutorial.
  
 
|-
 
|-
Line 40: Line 40:
 
||''' Annotations''' can appear at multiple locations in a '''class'''.
 
||''' Annotations''' can appear at multiple locations in a '''class'''.
  
'''Annotations''' can be used to:
+
They may be used to:
  
 
* change simulation settings
 
* change simulation settings
* add supporting '''documentation'''
+
* to add supporting '''documentation''' and
* add '''icon and diagram views''' to a '''class'''
+
* to add '''icon and diagram views''' to a '''class'''
  
 
|-
 
|-
Line 56: Line 56:
 
* '''Start Time'''
 
* '''Start Time'''
 
* '''Stop Time'''
 
* '''Stop Time'''
* '''Tolerance'''
+
* '''Tolerance''' and
 
* '''Interval'''
 
* '''Interval'''
  
Line 65: Line 65:
  
 
Syntax for '''experiment'''
 
Syntax for '''experiment'''
|| Shown here is an an example demonstrating the syntax of '''experiment''' annotation.
+
|| Shown here is an example demonstrating the syntax of '''experiment''' annotation.
  
 
|-
 
|-
||  
+
|| Switch to '''OMEdit'''
|| Now, we shall understand '''experiment''' annotation through a class named '''bouncingBallWithAnnotations'''.  
+
|| Now, we shall understand '''experiment''' annotation through a '''class''' named '''bouncingBallWithAnnotations'''.  
  
 
Let me switch to '''OMEdit'''.  
 
Let me switch to '''OMEdit'''.  
  
 
|-
 
|-
||  
+
|| Press '''Ctrl+O''' >> go to the location >> select the files.
 
|| Please download all the files available on our website.
 
|| Please download all the files available on our website.
  
I have opened all the necessary files in '''OMEdit'''.  
+
Let me open the necessary model files for this tutorial.  
  
Note that the following files are now open in '''OMEdit''':
+
Press '''Ctrl+O'''.
  
'''bouncingBallWithAnnotations''' and  
+
Go to the appropriate location on your Desktop and select '''color.mo''' and '''bouncingBallWithAnnotations'''.
  
'''color'''.
+
These files are now open in '''OMEdit'''.
  
 
|-
 
|-
Line 94: Line 94:
  
 
|-
 
|-
||  
+
|| Double-click on '''bouncingBallWithAnnotations''' in '''Libraries Browser''' >> shift the window
 
|| Double-click on '''bouncingBallWithAnnotations''' in '''Libraries Browser'''.  
 
|| Double-click on '''bouncingBallWithAnnotations''' in '''Libraries Browser'''.  
  
Let me shift OMEdit window to the left for better visibility
+
Let me shift '''OMEdit''' window to the left for better visibility.
  
 
|-
 
|-
Line 103: Line 103:
  
 
// '''experiment(StartTime=0,StopTime=5)''' //
 
// '''experiment(StartTime=0,StopTime=5)''' //
|| Switch to '''text view''' if the class opens in '''Icon/Diagram View'''.  
+
|| Switch to '''text view''' if the class opens in either '''Icon/Diagram View'''.
  
 +
The model is now open in '''Text View'''.
  
Let me scroll down a little bit.  
+
|-
 +
||Scroll down.
 +
||Let me scroll down a little bit.  
  
Here, we use '''experiment''' annotation to set '''startTime''' to '''0''' and '''stopTime''' to '''5''' units.  
+
Here, we use the '''experiment''' annotation to set '''startTime''' to '''0''' and '''stopTime''' to '''5''' units.  
  
 
'''experiment''' annotation serves the same purpose as '''Simulation Setup''' toolbox.  
 
'''experiment''' annotation serves the same purpose as '''Simulation Setup''' toolbox.  
 
Watch the prerequisite tutorials for more information on '''Simulation Setup''' toolbox.
 
  
 
|-
 
|-
 
|| Click on '''Simulation Setup'''.
 
|| Click on '''Simulation Setup'''.
|| Click on '''Simulation Setup''' button in toolbar.  
+
|| Click on '''Simulation Setup''' button in the toolbar.  
  
You can see the same '''stopTime''' and '''startTime''' fields here.  
+
|-
 +
||Point to '''stopTime''' and '''startTime''' fields
 +
||You can see the same '''stopTime''' and '''startTime''' fields here.  
  
 
We changed the values of these fields using '''experiment''' annotation.  
 
We changed the values of these fields using '''experiment''' annotation.  
  
Let’s simulate the model now.
+
Let us simulate the model now.
  
 
|-
 
|-
|| Click on '''Simulate''' icon.
+
|| Click on '''Simulate'''.
 
|| Click on '''Simulate''' button.
 
|| Click on '''Simulate''' button.
  
Line 131: Line 134:
 
|| /* Plotting perspective */
 
|| /* Plotting perspective */
  
Click on '''h''' in '''variables browser'''.
+
Select '''h''' in '''variables browser'''.
|| The model has now simulated.  
+
|| Select '''h''' in '''variables browser'''.  
  
Click on '''h''' in '''variables browser'''.  
+
Note that the simulation interval is '''5''' units.  
  
Note that the simulation interval is '''5''' seconds.
+
This is due to '''startTime''' and ‘'''StopTime''' fields of '''experiment''' annotation.  
 
+
This is due to '''startTime''' and ‘'''topTime''' fields of '''experiment''' annotation.  
+
  
 
|-
 
|-
||  
+
|| De-select '''h''' >> delete the result
|| De-select '''h''' and delete the result.
+
|| Now de-select '''h''' and delete the result.
  
 
|-
 
|-
Line 163: Line 164:
 
|-
 
|-
 
|| Click on '''Documentation View''' button
 
|| Click on '''Documentation View''' button
|| Go to the top left of modeling area.  
+
|| Go to the top left of '''modeling''' area.  
  
 
Click on fourth button which is '''Documentation View'''.
 
Click on fourth button which is '''Documentation View'''.
Line 176: Line 177:
  
 
|-
 
|-
||  
+
|| Close '''Documentation''' Browser >>  Back to the slides
|| Close '''Documentation''' Browser and go back to the slides.
+
|| Close '''Documentation''' Browser.
 +
 
 +
Let me go back to the slides.
  
 
|-
 
|-
Line 183: Line 186:
  
 
'''record'''
 
'''record'''
|| '''Record''' is a specialized class used to define a '''record''' data structure
+
|| '''Record''' is a specialized '''class''' used to define a '''record''' data structure.
 
+
 
+
For example, bank accounts have records with person’s name, age etc., as fields
+
 
+
  
'''Records''' can only contain '''variables'''
+
For example, bank accounts have records with person’s name, age etc.. as fields.
  
 +
'''Records''' can only contain '''variables'''.
  
'''Records''' may not contain '''equations'''
+
They may not contain '''equations'''.
  
 
|-
 
|-
Line 203: Line 203:
  
 
|-
 
|-
||  
+
|| Switch to '''OMEdit''' >> shift window to the right
|| Let me switch to '''OMEdit''' to demonstrate '''record''' definition.
+
|| Let me switch to '''OMEdit''' to demonstrate record definition.
  
 +
Let me shift '''OMEdit''' window to the right.
  
We will now use the file named '''Color'''.
+
|-
 
+
||
To open it in '''Textview''', let me shift '''OMEdit''' window to the right.
+
||We will now use the file named '''Color'''.  
  
 
|-
 
|-
||  
+
|| Double-click on '''color'''
|| Double-click on '''color''' icon in '''Libraries''' Browser.
+
|| To open it in '''Textview''', double-click on '''color''' icon in '''Libraries Browser'''.
  
 
|-
 
|-
|| record color
+
|| '''record color'''
 
+
Real red;
+
 
+
Real blue;
+
 
+
Real green;
+
  
end color;
+
'''Real red''';
  
'''Highlight each one of them separately.'''
+
'''Real blue''';
|| This record has three variables '''red''', '''blue''' and '''green'''.
+
  
 +
'''Real green''';
  
 +
'''end color''';
  
 +
Highlight each one of them separately.
 +
|| This '''record''' has three variables named '''red, blue''' and '''green'''.
  
 
|-
 
|-
 
|| Hover over '''Simulate'''
 
|| Hover over '''Simulate'''
|| You can see that '''simulate''' button doesn’t appear.  
+
|| You may see that '''Simulate''' button doesn’t appear in the toolbar.  
  
This means that '''records''' are not meant to be simulated.  
+
This indicates that records are not meant to be simulated.  
  
 
|-
 
|-
 
||  
 
||  
|| Let me go back to slides.
+
|| Now let me go back to slides.
  
 
|-
 
|-
Line 248: Line 246:
 
|| It is easier to understand annotation elements as records.
 
|| It is easier to understand annotation elements as records.
  
For example, '''experiment''' can be considered as a record with '''StartTime''', '''StopTime''', '''Tolerance''' and '''Interval''' as fields.
+
For example, '''experiment''' annotation can be considered as a '''record''' with '''StartTime, StopTime, Interval''' and '''Tolerance''' as its fields.
 +
 
 +
Graphical elements can be interpreted similarly.
 +
 
 +
We will understand more about the interpretation of annotations as records when we discuss '''icon and diagram views'''.
 +
 
 +
|-
 +
|| Slide:
 +
'''Assignment'''
 +
||As an assignment,  
 +
 
 +
Vary the stop time for simulation of '''bouncingBallWithAnnotations class''' from '''10''' to '''20''' units.
 +
 +
Use '''experiment annotation''' for this purpose.  
  
Graphical elements can be similarly interpreted.  
+
Simulate the '''class''' after this change.  
  
We will understand more about the interpretation of '''annotations''' as '''records''' when we discuss '''icon and diagram views'''.
+
Plot '''h''' vs '''time''' and notice the change in simulation stop time.
  
 
|-
 
|-
Line 264: Line 275:
 
|| Watch the video available at the following link.  
 
|| Watch the video available at the following link.  
  
It summarises spoken tutorial project.
+
It summarises '''spoken tutorial''' project.
  
 
|-
 
|-
Line 270: Line 281:
  
 
'''Spoken Tutorial''' Workshops
 
'''Spoken Tutorial''' Workshops
|| We conduct workshops using spoken tutorials.  
+
|| We conduct workshops using '''spoken tutorials''' .  
  
 
We give certificates to those who pass an online test.  
 
We give certificates to those who pass an online test.  
Line 280: Line 291:
  
 
'''Forum to answer questions'''
 
'''Forum to answer questions'''
|| If you have questions from this tutorial,  
+
|| If you have questions from this spoken tutorial,  
  
 
Please visit the following website.
 
Please visit the following website.
Line 306: Line 317:
  
 
'''Acknowledgements'''
 
'''Acknowledgements'''
|| '''Spoken Tutorial Project''' is funded by '''NMEICT, MHRD''', Government of India
+
|| '''Spoken Tutorial Project''' is funded by '''NMEICT, MHRD''', Government of India.
  
 
|-
 
|-

Latest revision as of 14:22, 5 April 2016

Visual Cue Narration
Slide Number 1

Title Slide

Welcome to the spoken tutorial on Annotations.
Slide:

Learning Objectives

In this tutorial, we are going to learn:
  • How to specify an annotation and
  • How to define a record
Slide:

System Requirements

To record this tutorial, I am using:
  • OpenModelica 1.9.2
  • You may use any of the following operating systems to practice this tutorial.
Slide:

Prerequisites

To understand and practice this tutorial, you need knowledge of class definition in Modelica.

Please watch the prerequisite tutorials available on our website.

Slide:

Annotations

Annotations can appear at multiple locations in a class.

They may be used to:

  • change simulation settings
  • to add supporting documentation and
  • to add icon and diagram views to a class
Slide:

experiment

In the previous tutorials, we used SimulationSetup button in the toolbar to vary simulation settings.

experiment is a model annotation that may be used to vary the following:

  • Start Time
  • Stop Time
  • Tolerance and
  • Interval

Discussion of Tolerance and Interval are beyond the scope of this tutorial series.

Slide:

Syntax for experiment

Shown here is an example demonstrating the syntax of experiment annotation.
Switch to OMEdit Now, we shall understand experiment annotation through a class named bouncingBallWithAnnotations.

Let me switch to OMEdit.

Press Ctrl+O >> go to the location >> select the files. Please download all the files available on our website.

Let me open the necessary model files for this tutorial.

Press Ctrl+O.

Go to the appropriate location on your Desktop and select color.mo and bouncingBallWithAnnotations.

These files are now open in OMEdit.

We will first look into bouncingBallWithAnnotations.

This model is an extension of the bouncingBall model which we discussed in previous tutorials.

Please watch the prerequisite tutorials for more information on this model.

Double-click on bouncingBallWithAnnotations in Libraries Browser >> shift the window Double-click on bouncingBallWithAnnotations in Libraries Browser.

Let me shift OMEdit window to the left for better visibility.

Highlight

// experiment(StartTime=0,StopTime=5) //

Switch to text view if the class opens in either Icon/Diagram View.

The model is now open in Text View.

Scroll down. Let me scroll down a little bit.

Here, we use the experiment annotation to set startTime to 0 and stopTime to 5 units.

experiment annotation serves the same purpose as Simulation Setup toolbox.

Click on Simulation Setup. Click on Simulation Setup button in the toolbar.
Point to stopTime and startTime fields You can see the same stopTime and startTime fields here.

We changed the values of these fields using experiment annotation.

Let us simulate the model now.

Click on Simulate. Click on Simulate button.
/* Plotting perspective */

Select h in variables browser.

Select h in variables browser.

Note that the simulation interval is 5 units.

This is due to startTime and ‘StopTime fields of experiment annotation.

De-select h >> delete the result Now de-select h and delete the result.
Click on Modeling button Click on Modeling button at bottom right.
Now, let us learn more about adding documentation to a model using annotations.
/* bouncingBallWithAnnotations */


Documentation(info = "This is a bouncing ball model with annotations")

The highlighted text appears in Documentation annotation.

Now, let me show an application of Documentation annotation.

Click on Documentation View button Go to the top left of modeling area.

Click on fourth button which is Documentation View.

/* Documentation View */

Highlight // This is a bouncing ball model with annotations //

You can view the text typed in Documentation annotation in the browser.

This functionality allows us to add useful information for larger models which require documentation.

Close Documentation Browser >> Back to the slides Close Documentation Browser.

Let me go back to the slides.

Slide:

record

Record is a specialized class used to define a record data structure.

For example, bank accounts have records with person’s name, age etc.. as fields.

Records can only contain variables.

They may not contain equations.

Slide:

Example of record

Shown here is an example record named Person.

It has name and age as its fields.

Switch to OMEdit >> shift window to the right Let me switch to OMEdit to demonstrate record definition.

Let me shift OMEdit window to the right.

We will now use the file named Color.
Double-click on color To open it in Textview, double-click on color icon in Libraries Browser.
record color

Real red;

Real blue;

Real green;

end color;

Highlight each one of them separately.

This record has three variables named red, blue and green.
Hover over Simulate You may see that Simulate button doesn’t appear in the toolbar.

This indicates that records are not meant to be simulated.

Now let me go back to slides.
Slide:

Records in annotations

It is easier to understand annotation elements as records.

For example, experiment annotation can be considered as a record with StartTime, StopTime, Interval and Tolerance as its fields.

Graphical elements can be interpreted similarly.

We will understand more about the interpretation of annotations as records when we discuss icon and diagram views.

Slide:

Assignment

As an assignment,

Vary the stop time for simulation of bouncingBallWithAnnotations class from 10 to 20 units.

Use experiment annotation for this purpose.

Simulate the class after this change.

Plot h vs time and notice the change in simulation stop time.

This brings us to the end of this tutorial.
Slide:

About the Spoken Tutorial project

Watch the video available at the following link.

It summarises spoken tutorial project.

Slide:

Spoken Tutorial Workshops

We conduct workshops using spoken tutorials .

We give certificates to those who pass an online test.

Please contact us.

Slide:

Forum to answer questions

If you have questions from this spoken tutorial,

Please visit the following website.

Slide:

Textbook Companion Project

We coordinate coding of solved examples from popular books.

Please visit the following website.

Slide:

Lab Migration Project

We help migrate commercial simulator labs to OpenModelica.

We give honorarium and certificates to those who do this.

Please contact us.

Slide:

Acknowledgements

Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
Slide:

Thanks

We thank the development team of OpenModelica for their support.

Thank you for joining me in this tutorial.

Contributors and Content Editors

Kaushik Datta, Nancyvarkey