OpenModelica Environment and Modelica Overview

Similar documents
Modelica Environments and OpenModelica

OpenModelica OMShell and OMNotebook Introduction and Exercises

OpenModelica Compiler (OMC) Overview

OpenModelica Compiler (OMC) Overview

The OpenModelica Modeling, Simulation, and Development Environment

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

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

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

Technical Overview of OpenModelica and its Development Environment

1st Annual OpenModelica Workshop Feb 2, 2009

Meta-Programming with Modelica. Model Transformations

OpenModelica User s Guide

What follows is a list of the OMC APIs with their syntax and examples.

OMEdit OpenModelica Connection Editor

CIM 2 Modelica Factory

Modelica Development Tooling for Eclipse

OMEdit. OpenModelica Connection Editor. User Manual Version April 2011

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

OpenModelica Eclipse Plugin and MetaModelica Exercises

Introduction to Java

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

Heat An Interactive Development Environment for Learning & Teaching Haskell

The current topic: Python. Announcements. Python. Python

Oriented Modeling and Simulation with Modelica

Modelica Change Proposal MCP-0019 Flattening (In Development) Proposed Changes to the Modelica Language Specification Version 3.

Introduction to Programming System Design CSCI 455x (4 Units)

ModelicaML: Getting Started Issue April 2012

Introduction to Python

JVA-103. Java Programming

Technical Overview of OpenModelica and its Development Environment

Institutionen för datavetenskap Department of Computer and Information Science

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

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

JAVA An overview for C++ programmers

Portland State University Maseeh College of Engineering and Computer Science. Proficiency Examination Process

Flask Web Development Course Catalog

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

Table of Contents EVALUATION COPY

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

Introduction p. 1 Basic Programming Introduction p. 7 Introduction to Python p. 7 Why Use Python? p. 10 Main Technical Features p.

Technical Overview of OpenModelica and its Development Environment

Soar IDE. Keith Knudsen, Mike Quist, Dave Ray & Bob Wray May 24, 2007

CS 253: Intro to Systems Programming 1/21

Today. Review. Unix as an OS case study Intro to Shell Scripting. What is an Operating System? What are its goals? How do we evaluate it?

Accelerating Information Technology Innovation

MEAP Edition Manning Early Access Program Get Programming with Java Version 1

Software Project. Lecturers: Ran Caneti, Gideon Dror Teaching assistants: Nathan Manor, Ben Riva

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

Generic Language Technology

IBM TPF Toolkit VisualAge TPF

Towards Unified System Modeling with the ModelicaML UML Profile

WA1278 Introduction to Java Using Eclipse

Integrated Software Environment. Part 2

Introduction to Java Programming

Programmiersprachen (Programming Languages)

Technical Overview of OpenModelica and its Development Environment

1.00 Lecture 2. What s an IDE?

Adding Functions to AMPL

Scientific Computing: Lecture 1

An OpenModelica Python Interface and its use in PySimulator

Formal editing: jedit-mmt. Narrative editing: LaTeX-MMT. Browsing: MMT web server. Building: MMT scripting language. The MMT API: A Generic MKM System

CPS221 Lecture: Operating System Functions

Laboratory Assignment #3 Eclipse CDT

Notes of the course - Advanced Programming. Barbara Russo

CSE 421 Course Overview and Introduction to Java

Accelerating Information Technology Innovation

Starting the System & Basic Erlang Exercises

News in RSA-RTE 10.0 updated for sprint Mattias Mohlin/Anders Ek, June 2016

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

Principles of Programming Languages. Lecture Outline

Dynamic Languages Toolkit. Presented by Andrey Tarantsov

Integrated Model-Driven Development Environments for Equation-Based Object-Oriented Languages

1 Lexical Considerations

What s new in CDT 4.0 and beyond. Doug Schaefer QNX Software Systems CDT Project Lead

Python Scripting for Computational Science

Fundamentals of Programming. By Budditha Hettige

HOW TO USE CODE::BLOCKS IDE FOR COMPUTER PROGRAMMING LABORATORY SESSIONS

Modelica3D. Platform Independent Simulation Visualization. Christoph Höger. Technische Universität Berlin Fraunhofer FIRST

CT 229. CT229 Lecture Notes. Labs. Tutorials. Lecture Notes. Programming II CT229. Objectives for CT229. IT Department NUI Galway

Professor Hugh C. Lauer CS-1004 Introduction to Programming for Non-Majors

PYTHON TRAINING COURSE CONTENT

Why study Programming Language Concepts? Chapter One. Language Evaluation Criteria. Programming Domains. Readability Writability Reliability Cost

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, November 2017

OS PORTING AND ABSTRACTION LAB USER MANUAL

And Parallelism. Parallelism in Prolog. OR Parallelism

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

AUTOMATIC PARALLELIZATION OF OBJECT ORIENTED MODELS ACROSS METHOD AND SYSTEM

CS 415 Midterm Exam Spring 2002

JavaScript CS 4640 Programming Languages for Web Applications

Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of

CS 11 java track: lecture 1

CS A331 Programming Language Concepts

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, January 2018

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

CUDA Development Using NVIDIA Nsight, Eclipse Edition. David Goodwin

History Installing & Running Python Names & Assignment Sequences types: Lists, Tuples, and Strings Mutability

IBM C Rational Functional Tester for Java. Download Full Version :

IBM. IBM WebSphere Application Server Migration Toolkit. WebSphere Application Server. Version 9.0 Release

Transcription:

OpenModelica Environment and Modelica Overview, Adrian Pop OpenModelica Course, 2007 03 19 1 OpenModelica Goal: comprehensive modeling and simulation environment for research, teaching, and industrial usage Free, open-source for both academic and commercial use Available under Berkley New BSD open source license The OpenModelica compiler (OMC) now implemented in MetaModelica Invitation for open-source cooperation around OpenModelica, tools, and applications 2

The OpenModelica Environment 3 OpenModelica End-Users vs. Developers OpenModelica End-Users People who use OpenModelica for modeling and simulation OpenModelica Developers People who develop/contribute to parts in the OpenModelica environment including the OpenModelica compiler 4

OpenModelica End-User Subsystems OpenModelica End-User Subsystems a pre-packaged kit containing tools needed for modeling, simulation, teaching OpenModelica Compiler (OMC) compiles and executes/simulates Modelica models OMShell interactive session handler for Modelica scripting OMNotebook interactive electronic notebook for Modelica teaching (with DrModelica), scripting, and documentation OpenModelica MDT Eclipse Plugin (Modelica Development Tooling), e.g. for library development (c.f. JDT Java, CDT,) Graphic Model Editor from MathCore (only binary, but free for university usage) 5 6 OpenModelica Development Toolkit (OMDev) to Simplify Open Source Development OMDev is a pre-packaged pre-compiled kit containing all tools needed for OpenModelica development. Just unpack and start working on your platform. (Windows, (Linux)) MetaModelica Compiler (MMC) for developing OMC OpenModelica Compiler (OMC) for browsing support Eclipse plugin MDT (Modelica Development Tooling), e.g. for compiler (OMC) development Pre-compiled Corba (MICO) for tool communication Packaged Gnu compiler (Mingw version for Windows) Emacs mode Online (web) Subversion for version handling Online (web) Bugzilla for bug reporting Automatic regression testing using a test suite (Soon: release of interactive debugger)

OpenModelica Environment Architecture Eclipse Plugin Editor/Browser Emacs Editor/Browser Interactive session handler Graphical Model Editor/Browser Textual Model Editor DrModelica OMNoteBook Model Editor Execution Modelica Compiler Modelica Debugger 7 OpenModelica Client-Server Architecture Server: Main Program Including Compiler, Interpreter, etc. Parse Corba Client: Graphic Model Editor Client: OMShell Interactive Session Handler SCode Inst Ceval Interactive system Untyped API Typed Checked Command API plot etc. Client: Eclipse Plugin MDT 8

Released in OpenModelica 1.4.3 OpenModelica compiler/interpreter OMC Interactive session handler OMShell OpenModelica Notebook with DrModelica OMNotebook OpenModelica Eclipse plugin MDT Available: MathModelica Lite graphic editor (not part of OpenModelica) Preliminary versions: Debugger soon released, beta version being improved 9 OpenModelica Compiler/Interpreter New version (1.4.3) soon released March, 2007 Currently implemented in 120 000 lines of MetaModelica Includes code generation, BLT-transformation, index reduction, connection to DASSL, etc. Most of the Modelica language including classes, functions, inheritance, modifications, import, etc. Hybrid/Discrete event support 10

Corba Client-Server API Simple text-based (string) communication in Modelica Syntax API supporting model structure query and update Example Calls: Calls fulfill the normal Modelica function call syntax.: savemodel("myresistorfile.mo",myresistor) will save the model MyResistor into the file MyResistorFile.mo. For creating new models it is most practical to send a model, e.g.: model Foo end Foo; or, e.g., connector Port end Port; 11 Some of the Corba API functions savemodel(a1<string>,a2<cref>) loadfile(a1<string>) loadmodel(a1<cref>) deleteclass(a1<cref>) addcomponent(a1<ident>,a2<cref>, A3<cref>,annotate=<expr>) deletecomponent(a1<ident>, A2<cref>) updatecomponent(a1<ident>, A2<cref>, A3<cref>,annotate=<expr>) addclassannotation(a1<cref>, annotate=<expr>) getcomponents(a1<cref>) getcomponentannotations(a1<cref>) getcomponentcount(a1<cref>) getnthcomponent(a1<cref>,a2<int>) getnthcomponentannotation( A1<cref>,A2<int>) getnthcomponentmodification( A1<cref>,A2<int>)?? getinheritancecount(a1<cref>) 12 getnthinheritedclass(a1<cref>, Saves the model (A2) in a file given by a string (A1). This call is also in typed API. Loads all models in the file. Also in typed API. Returns list of names of top level classes in the loaded files. Loads the model (A1) by looking up the correct file to load in $MODELICAPATH. Loads all models in that file into the symbol table. Deletes the class from the symbol table. Adds a component with name (A1), type (A2), and class (A3) as arguments. Optional annotations are given with the named argument annotate. Deletes a component (A1) within a class (A2). Updates an already existing component with name (A1), type (A2), and class (A3) as arguments. Optional annotations are given with the named argument annotate. Adds annotation given by A2( in the form annotate= classmod(...)) to the model definition referenced by A1. Should be used to add Icon Diagram and Documentation annotations. Returns a list of the component declarations within class A1: {{Atype,varidA, commenta },{Btype,varidB, commentb }, {...}} Returns a list {...} of all annotations of all components in A1, in the same order as the components, one annotation per component. Returns the number (as a string) of components in a class, e.g return 2 if there are 2 components. Returns the belonging class, component name and type name of the nth component of a class, e.g. A.B.C,R2,Resistor, where the first component is numbered 1. Returns the flattened annotation record of the nth component (A2) (the first is has no 1) within class/component A1. Consists of a comma separated string of 15 values, see Annotations in Section 2.4.4 below, e.g false,10,30,... Returns the modification of the nth component (A2) where the first has no 1) of class/component A1. Returns the number (as a string) of inherited classes of a class. Returns the type name of the nth inherited class of a class. The first class has number 1.

Platforms All OpenModelica GUI tools (OMShell, OMNotebook,...) are developed on the Qt4 GUI library, portable between Windows, Linux, Mac Both compilers (OMC, MMC) are portable between the three platforms Windows currently main development and release platform Linux available Mac (Berkeley) Unix planned 13 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; equation 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; 14

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; equation 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; 15 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}); 16

OpenModelica MDT Eclipse Plugin Browsing of packages, classes, functions Automatic building of executables; separate compilation Syntax highlighting Code completion, Code query support for developers Automatic Indentation Debugger (Prel. version for algorithmic subset) 17 OpenModelica Eclipse Plugin Usage Example Code Assistance on function calling. 18

OpenModelica Eclipse Plugin Goto Definition 19 Graphic Model Editor MathModelica Lite (From MathCore Engineering AB) Runs with OpenModelica Not part of OpenModelica Free university usage 20

OMNotebook OpenModelica Electronic Notebook Primarily for teaching DrModelica Tutorial Document for learning Modelica OMNotebook is also free software 21 Interactive Contents in DrModelica Contains Examples and Exercises from Modelica Book Book, 2004: 22

OpenModelica Algorithmic Code Debugger (prel.) 23 Meta-Modelica Modelica Compiler (MMC) Supports extended subset of Modelica Used for development of OMC Some MetaModelica Language properties: Modelica syntax and base semantics Pattern matching (named/positional) Local equations (local within expression) Recursive tree data structures Lists and tuples Garbage collection of heap-allocated data Arrays (with local update as in standard Modelica) Polymorphic functions Function parameters to functions Simple builtin exception (failure) handling mechanism 24

Conclusions Recent OpenModelica version 1.4.3 planned release March, 2007 (Beta version now) Speeded up name analysis when-statements, inner-outer OpenModelica MDT Eclipse plugin, improved version Graphic model editor Lite available MetaModelica debugger Cooperation and feedback welcome! www.ida.liu.se/projects/openmodelica Download OpenModelica www.mathcore.com/drmodelica Modelica book page www.modelica.org Modelica Association Emails: {petfr,adrpo}@ida.liu.se, OpenModelicaInterest@ida.liu.se 25