OpenModelica OMShell and OMNotebook Introduction and Exercises

Similar documents
OpenModelica Environment and Modelica Overview

Modelica Environments and OpenModelica

The OpenModelica Modeling, Simulation, and Development Environment

High Level Mathematical Modeling and Parallel/GRID Computing with Modelica. Peter Fritzson

Modelica Language Concepts. Classes and Inheritance

OpenModelica Compiler (OMC) Overview

INTRODUCTION TO OBJECT-ORIENTED MODELING AND SIMULATION WITH MODELICA USING THE OPENMODELICA ENVIRONMENT

OpenModelica Compiler (OMC) Overview

Oriented Modeling and Simulation with Modelica

OpenModelica User s Guide

OpenModelica Development Environment with Eclipse Integration for Browsing, Modeling, and Debugging

CIM 2 Modelica Factory

OMEdit. OpenModelica Connection Editor. User Manual Version April 2011

OMEdit OpenModelica Connection Editor

The following are brief descriptions of the scripting commands available in the OpenModelica environment.

Modeling Technical Systems [ ] Mag MA MA Schweiger Gerald TU Graz Spring 2017

Wolfram SystemModeler. Getting Started

Simulation and Benchmarking of Modelica Models on Multi-core Architectures with Explicit Parallel Algorithmic Language Extensions

Analysis and Design Optimisation of Electronic Circuits using Oscad and OpenModelica

Institutionen för datavetenskap Department of Computer and Information Science

AUTOMATIC PARALLELIZATION OF OBJECT ORIENTED MODELS ACROSS METHOD AND SYSTEM

OpenModelica Eclipse Plugin and MetaModelica Exercises

Automatic Parallelization of Mathematical Models Solved with Inlined Runge-Kutta Solvers

Modelica Based Parser Generator with Good Error Handling

1st Annual OpenModelica Workshop Feb 2, 2009

Technical Overview of OpenModelica and its Development Environment

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

Lab #1: A Quick Introduction to the Eclipse IDE

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit

Introduction to Object Introduction to Object--Oriented Oriented Modeling, Simulation and Control with Modelica T torial Tut Tu or o ia i l for

Chapter 4: Programming with MATLAB

Text Editors for Programmers. Dr. Prasad Kulkarni Michael Jantz Jamie Robinson

Installation Manual and Quickstart Guide

Eclipse CDT Tutorial. Eclipse CDT Homepage: Tutorial written by: James D Aniello

CS 253: Intro to Systems Programming 1/21

12.620J / 6.946J / 8.351J / Classical Mechanics: A Computational Approach

2 Copyright Open Source Modelica Consortium. September pages. Wiley IEEE Press. 4 Copyright Open Source Modelica Consortium.

Parallel Code Generation in MathModelica / An Object Oriented Component Based Simulation Environment

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

Desktop Command window

Installation Manual and Quickstart Guide

1.00 Lecture 2. What s an IDE?

Programming with Mathematica

An Eclipse-based Integrated Environment for Developing Executable Structural Operational Semantics Specifications

Introduction to Minitab 1

Parsing Scheme (+ (* 2 3) 1) * 1

ENGR 1181 MATLAB 05: Input and Output

Institutionen för datavetenskap Department of Computer and Information Science

Introduction to Object-Oriented Modeling, Simulation, Debugging and Dynamic Optimization with Modelica using OpenModelica

27-Sep CSCI 2132 Software Development Lecture 10: Formatted Input and Output. Faculty of Computer Science, Dalhousie University. Lecture 10 p.

Graphical User Interface. GUI in MATLAB. Eng. Banan Ahmad Allaqta

Create a custom tab using Visual Basic

Algorithms & Datastructures Laboratory Exercise Sheet 1

Research in Model-Based Product Development at PELAB in the MODPROD Center

The parametric equation below represents a ball being thrown straight up. x(t) = 3 y(t) = 96t! 16t 2

LAB 03: The Equations of Uniform Motion

The current topic: Python. Announcements. Python. Python

SolidWorks Motion Study Tutorial

Towards Run-time Debugging of Equation-based Object-oriented Languages

Introduction to Programming for Biology Research

MEDIA COMPUTATION DRJAVA. Lecture 11.3 November 7, 2008

Towards Modelica 4 Meta-Programming and Language Modeling with MetaModelica 2.0

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

A Modular. OpenModelica. Compiler Backend

Introduction to Programming (Java) 2/12

Vice Chairman of Modelica Association Director of Open Source Modelica Consortium

Identifiers. Identifiers are the words a programmer uses in a program Some identifiers are already defined. Some are made up by the programmer:

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

SIMULINK FOR BEGINNERS:

On Academic Dishonesty. Declarative Computation Model. Single assignment store. Single assignment store (2) Single assignment store (3)

Lab 3a Using the vi editor

Getting started with Hugs on Linux

Module Road Map. 7. Version Control with Subversion Introduction Terminology

Perl (5 Days Content)

A Portable Debugger for Algorithmic Modelica Code

To Measure a Constant Velocity. Enter.

Lecture 2 Operating System Structures (chapter 2)

Lab 4 Projectile Motion

Introduction: Equipment: Getting Started Collecting the data:

TDDC88 Lab 4 Software Configuration Management

How to make a "hello world" program in Java with Eclipse *

emacs Know your tools emacs keys Minimal number of key commands for emacs GNU Emacs is an extensible, customisable text editor-and more

Installation Manual and Quickstart Guide

Simple Java Programming Constructs 4

Scientific Computing: Lecture 1

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edit9on

Getting Started (1.8.7) 9/2/2009

Chapter 8. Classes and Objects

Mend for Eclipse quick start guide local analysis

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

Learning objectives. The Java Environment. Java timeline (cont d) Java timeline. Understand the basic features of Java

Components, Connectors and Connections. 1 Peter Fritzson Copyright Open Source Modelica Consortium

Often, more information is required when designing system call Information varies according to OS and types of system call

Compile and Run WordCount via Command Line

Integration of OpenModelica in Ptolemy II

The Thomas Hardye School Summer Preparation Task Computer Science AS

Introduction to Lab Sessions

Projectile Trajectory Scenarios

An OpenModelica Python Interface and its use in PySimulator

HW #7 Solution Due Thursday, November 14, 2002

Transcription:

OpenModelica OMShell and OMNotebook Introduction and Exercises, Adrian Pop, Peter Aronsson OpenModelica Course at INRIA, 2006 06 08 1 OMShell and OMNotebook OpenModelica End- User Subsystems OMShell interactive session handler for Modelica scripting OMNotebook interactive electronic notebook for Modelica teaching (with DrModelica), scripting, and documentation OpenModelica Compiler (OMC) compiles and executes/simulates Modelica models ptplot package (from Berkeley) make plots 2

OpenModelica Environment Architecture Eclipse Plugin Editor/Browser Emacs Editor/Browser OMShell Interact. session handler Graphical Model Editor/Browser Textual Model Editor DrModelica OMNoteBook Model Editor Execution Modelica Compiler Modelica Debugger 3 Interactive Session Handler on dcmotor Example (Session handler called OMShell OpenModelica Shell) >>simulate(dcmotor,starttime=0.0,stoptime=10.0) >>plot({load.w,load.phi}) model dcmotor Modelica.Electrical.Analog.Basic.Resistor r1(r=10); Modelica.Electrical.Analog.Basic.Inductor i1; Modelica.Electrical.Analog.Basic.EMF emf1; Modelica.Mechanics.Rotational.Inertia load; Modelica.Electrical.Analog.Basic.Ground g; Modelica.Electrical.Analog.Sources.ConstantVoltage v; connect(v.p,r1.p); connect(v.n,g.p); connect(r1.n,i1.p); connect(i1.n,emf1.p); connect(emf1.n,g.p); connect(emf1.flange_b,load.flange_a); end dcmotor; 4

Event Handling by OpenModelica BouncingBall >>simulate(bouncingball, stoptime=3.0); >>plot({h,flying}); model BouncingBall parameter Real e=0.7 "coefficient of restitution"; parameter Real g=9.81 "gravity acceleration"; Real h(start=1) "height of ball"; Real v "velocity of ball"; Boolean flying(start=true) "true, if ball is flying"; Boolean impact; Real v_new; impact=h <= 0.0; der(v)=if flying then -g else 0; der(h)=v; when {h <= 0.0 and v <= 0.0,impact} then v_new=if edge(impact) then -e*pre(v) else 0; flying=v_new > 0; reinit(v, v_new); end when; end BouncingBall; 5 Run Scripts in OpenModelica RunScript command interprets a.mos file.mos means MOdelica Script file Example: >> runscript("sim_bouncingball.mos") The file sim_bouncingball.mos : loadfile("bouncingball.mo"); simulate(bouncingball, stoptime=3.0); plot({h,flying}); 6

Some OMShell Exercises Start OMShell (e.g. from the start menu) Look at the examples in the OpenModelicaUsersGuide. Try evaluating a small expression, e.g. 2+3, push return type help() try command completion, e.g. type loadm followed by tab fill in Modelica (i.e. loadmodel(modelica)) Use the file menu->loadmodel and load the dcmotor (../testmodels) type sim followed by tab; fill in dcmotor type plot followed by tab; fill in some variable(s) to plot (look at the users guide) type in a small function and call it 7 OpenModelica OMNotebook Electronic Notebook with DrModelica Primarily for teaching Interactive electronic book Platform independent OMNotebook Does not need Mathematica 8

Interactive Contents in DrModelica Contains Examples and Exercises from Modelica Book Recent Book, 2004: 9 Cells with both Text and Graphics Java must be installed for plotting to work 10

Exercises and Answers in OMNotebook DrModelica 11 Some OMNotebook Commands (see also OpenModelica Users Guide) Shift-return (evaluated a cell) File Menu (open, close, etc.) Text Cursor (vertical), Cell cursor (horisontal) Cell types: text cells & executable code cells Copy, paste, group cells Copy, pase, group text Command Completion (shift-tab) 12

Simplest Model Hello World! A Modelica Hello World model Equation: x = - x Initial condition: x(0) = 1 class HelloWorld "A simple " Real x(start=1); der(x)= -x; end HelloWorld; Simulation in OpenModelica environment 1 0.8 0.6 simulate(helloworld, stoptime = 2) plot(x) 0.4 0.2 0.5 1 1.5 2 13 Example class: Van der Pol Oscillator class VanDerPol "Van der Pol oscillator model" Real x(start = 1) "Descriptive string for x"; // x starts at 1 Real y(start = 1) "y coordinate"; // y starts at 1 parameter Real lambda = 0.3; der(x) = y; // This is the 1st diff // der(y) = -x + lambda*(1 - x*x)*y; /* This is the 2nd diff */ end VanDerPol; simulate(vanderpol,stoptime = 25) plotparametric(x,y) 2 1-2 -1 1 2-1 -2 14

Small OMNotebook Exercise Locate the HelloWorld model in DrModelica using OMNotebook! Simulate and plot the example. Do a slight change in the model, re-simulate and re-plot. class HelloWorld "A simple " Real x(start=1); der(x)= -x; end HelloWorld; simulate(helloworld, stoptime = 2) plot(x) Locate the VanDerPol model in DrModelica and try it! Do some change and re-simulate 15 Small OMNotebook Exercises cont. Select and copy a cell (tree to the right) Position the horizontal cell cursor: first click between cells; then click once more on top of the horizontal line Paste the cell Note: You can find most Users Guide examples in the UsersGuideExamples.onb in the testmodels directory 16