MetaModelica A Unified Equation-Based Semantical and Mathematical Modeling Language Adrian Pop and Peter Fritzson Programming Environment Laboratory Department.

Slides:



Advertisements
Similar presentations
Model Driven Generative Programming Reza Azimi February 6, 2003 ECE1770: Trends in Middleware Systems.
Advertisements

Visual Scripting of XML
IAAnalyzer: Towards a Model-Driven Modeling and Analysis Framework for C ONNECT(ors) Massimo Tivoli, University of L’Aquila (UNIVAQ)
Start of presentation Mathematical Modeling of Physical Systems © Prof. Dr. François E. Cellier September 20, 2012 Object Oriented Modeling The aim of.
Debugging Natural Semantics Specifications Adrian Pop and Peter Fritzson Programming Environment Laboratory Department of Computer and Information Science.
Peter Fritzson 1 MetaModelica for Meta-Modeling and Model Transformations Peter Fritzson, Adrian Pop, Peter Aronsson OpenModelica Course at INRIA, 2006.
AUTOMATIC GENERATION OF CODE OPTIMIZERS FROM FORMAL SPECIFICATIONS Vineeth Kumar Paleri Regional Engineering College, calicut Kerala, India. (Currently,
The Dymola Bond Graph Library
{kajny, GridModelica: Modeling and Simulating on the Grid Håkan Mattsson, Christoph W. Kessler, Kaj Nyström, Peter Fritzson Programming.
Dirk Zimmer François E. Cellier Institute of Computational Science Department of Computer Science ETH Zürich A bondgraphic modeling tool and its application.
ModelicaXML A Modelica XML representation with Applications Adrian Pop, Peter Fritzson Programming Environments Laboratory Linköping University.
Composition of XML Dialects A ModelicaXML case study Adrian Pop, Ilie Savga, Uwe Aßmann, Peter Fritzson Programming Environments Laboratory Linköping University.
An Eclipse-based Integrated Environment for Developing Executable Structural Operational Semantics Specifications Adrian Pop and Peter Fritzson Programming.
A Portable Debugger for Algorithmic Modelica Code Adrian Pop, Peter Fritzson Programming Environments Laboratory (PELAB) Department of Computer and Information.
An framework for model-driven product design and development using Modelica Adrian Pop, Olof Johansson, Peter Fritzson Programming Environments Laboratory.
Natural Semantics Based Tools for Semantic Web with Application to Product Models Adrian Pop Programming Environments Laboratory (PELAB) Department of.
UML CASE Tool. ABSTRACT Domain analysis enables identifying families of applications and capturing their terminology in order to assist and guide system.
Programming Languages Structure
1 Ivan Lanese Computer Science Department University of Bologna Italy Concurrent and located synchronizations in π-calculus.
1 Dan Quinlan, Markus Schordan, Qing Yi Center for Applied Scientific Computing Lawrence Livermore National Laboratory Semantic-Driven Parallelization.
End-to-End Design of Embedded Real-Time Systems Kang G. Shin Real-Time Computing Laboratory EECS Department The University of Michigan Ann Arbor, MI
OpenModelica Development Environment with Eclipse Integration Adrian Pop, Peter Fritzson, Andreas Remar, Elmir Jagudin, David Akhvlediani Programming Environment.
Contributions to Meta-Modeling Tools and Methods Adrian Pop Programming Environments Laboratory.
ME 270 Final Project Presentation Operational Amplifiers.
Basic Concepts The Unified Modeling Language (UML) SYSC System Analysis and Design.
02/06/05 “Investigating a Finite–State Machine Notation for Discrete–Event Systems” Nikolay Stoimenov.
An Information Theory based Modeling of DSMLs Zekai Demirezen 1, Barrett Bryant 1, Murat M. Tanik 2 1 Department of Computer and Information Sciences,
Xactium xDSLs Run Models Not Code Tony Clark
1 April 2005, Siemens Industrial Turbomachinery AB Copyright © Copyright © 2005 Peter Fritzson Modelica Classes and Inheritance.
Requirements Expression and Modelling
Towards a Text Generation Template Language for Modelica Peter Fritzson *, Pavol Privitzer +, Martin Sjölund *, Adrian Pop * + Institute of Pathological.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Parser-Driven Games Tool programming © Allan C. Milne Abertay University v
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
Building Tools by Model Transformations in Eclipse Oskars Vilitis, Audris Kalnins, Edgars Celms, Elina Kalnina, Agris Sostaks, Janis Barzdins Institute.
MathCore Engineering AB Experts in Modeling & Simulation WTC.
Validated Model Transformation Tihamér Levendovszky Budapest University of Technology and Economics Department of Automation and Applied Informatics Applied.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Chapter 6 Programming Languages (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
MECHATRONICS Lecture 02 Slovak University of Technology Faculty of Material Science and Technology in Trnava.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
CPS 506 Comparative Programming Languages Syntax Specification.
Introduction Lecture 1 Wed, Jan 12, The Stages of Compilation Lexical analysis. Syntactic analysis. Semantic analysis. Intermediate code generation.
New possibilities 1. EBI data pack – database modules for main databases supported by EBI: Ensembl, UniProt, ChEBI,Reactome, IntAct, GO, BioModels, SBO.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
Systems Biology Markup Language Ranjit Randhawa Department of Computer Science Virginia Tech.
THE IMPORTANCE OF DISCRETE MATHEMATICS IN COMPUTER TECHNOLOGY.
LanguageLab A Meta-modelling Environment Terje Gjøsæter and Andreas Prinz, University of Agder, Norway SDL Forum 2015, Berlin, Germany.
The Hashemite University Computer Engineering Department
Concepts and Realization of a Diagram Editor Generator Based on Hypergraph Transformation Author: Mark Minas Presenter: Song Gu.
CONFIDENTIAL © 2007 Maplesoft, a division of Waterloo Maple Inc. Confidential MapleSim Pilot Test Program.
CS223: Software Engineering
2000 Research Overview Dr. Kim Mens Programming Technology Lab Vrije Universiteit Brussel.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
SysML-Modelica Transformation Specification (SE DSIG Meeting, Jacksonville, 3/22/2010) Chris Paredis Georgia Tech On behalf of the SysML-Modelica Working.
Systems Realization Laboratory SysML-based Reference Models for Fluid Power Components Chris Paredis, Raphael Kobi Product & Systems Lifecycle Management.
SysML and Modelica Integration Working Group Meeting 3/11/09 Peter Fritzson Wladimir Schamai.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
Bootstrapping a Modelica Compiler Martin Sjölund, Peter Fritzson, Adrian Pop Linköping University th International Modelica Conference Dresden,
SysML-Modelica Integration Working Group Report (SE DSIG meeting, Washington DC 3/24/2009) Chris Paredis Georgia Tech 1.
Functional Programming
Chapter 2: The Visual Studio .NET Development Environment
Chapter 1 Introduction.
Validating Reconfigurations of Reo Circuits
SysML v2 Formalism: Requirements & Benefits
SOFTWARE DESIGN AND ARCHITECTURE
Chapter 1 Introduction.
Subject: Language Processor
On behalf of the SysML-Modelica Working Group
Presentation transcript:

MetaModelica A Unified Equation-Based Semantical and Mathematical Modeling Language Adrian Pop and Peter Fritzson Programming Environment Laboratory Department of Computer and Information Science Linköping University JMLC’2006, September 13-15, Oxford, UK

2 Outline  Modelica  Introduction  Language properties  Example  MetaModelica  Motivation  MetaModelica extensions to Modelica  Example  Future Work  Conclusions

3 Modelica – General Formalism to Model Complex Systems  Robotics  Automotive  Aircrafts  Satellites  Biomechanics  Power plants  Hardware-in-the-loop, real-time simulation  etc

4 Modelica – The Next Generation Modeling Language  Declarative language  Equations and mathematical functions allow acausal modeling, high level specification, increased correctness  Multi-domain modeling  Combine electrical, mechanical, thermodynamic, hydraulic, biological, control, event, real-time, etc...  Everything is a class  Strongly typed object-oriented language with a general class concept, Java & Matlab like syntax  Visual component programming  Hierarchical system architecture capabilities  Efficient, nonproprietary  Efficiency comparable to C; advanced equation compilation, e.g equations

5 Modelica Language Properties  Declarative and Object-Oriented  Equation-based; continuous and discrete equations  Parallel process modeling of concurrent applications, according to synchronous data flow principle  Functions with algorithms without global side-effects (but local data updates allowed)  Type system inspired by Abadi/Cardelli (Theory of Objects)  Everything is a class – Real, Integer, models, functions, packages, parameterized classes....

6 The Form - Equations Equations were used in the third millenium B.C. Equality sign was introduced by Robert Recorde in 1557 Newton (Principia, vol. 1, 1686) still wrote text: “The change of motion is proportional to the motive force impressed;...” CSSL (1967) introduced special form of “equation”: variable = expression v = INTEG(F) / m Programming languages usually do not allow equations Modelica Background

7 Modelica Acausal Modeling Semantics What is acausal modeling/design? Why does it increase reuse? The acausality makes Modelica classes more reusable than traditional classes containing assignment statements where the input-output causality is fixed. Example: a resistor equation: R*i = v; can be used in three ways: i := v/R; v := R*i; R := v/i;

8 Modelica - Reusable Class Libraries

9 Graphical Modeling - Drag and Drop Composition

10 Srel = n*n' + (identity(3) - n*n')*cos(q) - skew(n)*sin(q); wrela = n*qd; zrela = n*qdd; Sb = Sa*Srel'; r0b = r0a; vb = Srel*va; wb = Srel*(wa + wrela); ab = Srel*aa; zb = Srel*(za + zrela + cross(wa, wrela)); fa = Srel'*fb; ta = Srel'*tb; Hierarchical Composition Diagram for a Model of a Robot

11 Multi-Domain Modelica Model - DCMotor  A DC motor can be thought of as an electrical circuit which also contains an electromechanical component. model DCMotor Resistor R(R=100); Inductor L(L=100); VsourceDC DC(f=10); Ground G; ElectroMechanicalElement EM(k=10,J=10, b=2); Inertia load; equation connect(DC.p,R.n); connect(R.p,L.n); connect(L.p, EM.n); connect(EM.p, DC.n); connect(DC.n,G.p); connect(EM.flange,load.flange); end DCMotor

12 Modelica compilation stages

13 Corresponding DCMotor Model Equations The following equations are automatically derived from the Modelica model: ( load component not included)

14 Connector Classes, Components and Connections Keyword flow indicates that currents of connected pins sums to zero. A connect statement in Modelica corresponds to connector Pin Voltage v; flow Current i; end Pin; connect(Pin1,Pin2) Connection between Pin1 and Pin2 Pin1.v = Pin2.v Pin1.i + Pin2.i = 0

15 Common Component Structure as SuperClass model TwoPin ”Superclass of elements with two electrical pins” Pin p,n; Voltage v; Current i; equation v = p.v – n.v; 0 = p.i + n.i; i = p.i; end TwoPin;

16 Electrical Components Reuse TwoPin SuperClass model Inductor ”Ideal electrical inductor” extends TwoPin; parameter Real L ”Inductance”; equation L*der(i) = u end Inductor; model Resistor ”Ideal electrical resistor” extends TwoPin; parameter Real R ”Resistance”; equation R*i = u end Resistor;

17 Corresponding DCMotor Model Equations The following equations are automatically derived from the Modelica model: ( load component not included)

18 MetaModelica - Context  Syntax - there are many efficient parser generator tools  lex (flex), yacc (bison), ANTLR, Coco, etc.  Semantics:  there are no standard efficient and easy to use compiler-compiler tools

19 MetaModelica - Motivation  Can we adapt the Modelica equation-based style to define semantics of programming languages?  Answer: Yes!  MetaModelica is just a part of the answer  executable language specification based on  a model (abstract syntax tree)  semantic functions over the model  elaboration and typechecking  translation  meta-programming  transformation  etc.  Further improvement – more reuse of language specification parts when building specifications for a new language (Future Work)

20 MetaModelica - Idea  We started from  The Relational Meta-Language (RML)  A system for building executable natural semantics specifications  Used to specify Java, Pascal-subset, C-subset, Mini-ML, etc.  The OpenModelica compiler for Modelica specified in RML  Idea: integrate RML meta-modeling and meta- programming facilities within OpenModelica by extending the Modelica language. The notion of equation is used as the unifying feature  Now we have  The MetaModelica language  The Modelica executable language specification (OpenModelica compiler) in MetaModelica (~ lines of code)  Meta-programming facilities for Modelica

21 MetaModelica extensions to Modelica (I)  Modelica  classes, models, records, functions, packages  behaviour is defined by equations or/and functions  equations  differential equations  algebraic equations  partial differential equations  difference equations  conditional equations  MetaModelica extensions  local equations  pattern equations  match expressions  lists, tuples, option and uniontypes

22 MetaModelica extensions to Modelica (II)  pattern equations  unbound variables get their value by unification Env.BOOLVAL(x,y) = eval_something(env, e);  match expressions  pattern matching  case rules pattern := match expression optional-local-declarations case pattern-expression opt-local-declarations optional-local-equations then value-expression; case else optional-local-declarations optional-local-equations then value-expression; end match;

23 MetaModelica – Example (I) package ExpressionEvaluator // abstract syntax declarations... // semantic functions... end ExpressionEvaluator;

24 package ExpressionEvaluator // abstract syntax declarations // semantic functions... end ExpressionEvaluator; MetaModelica – Example (II) uniontype Exp record RCONST Real x1; end RCONST; record PLUS Exp x1; Exp x2; end PLUS; record SUB Exp x1; Exp x2; end SUB; record MUL Exp x1; Exp x2; end MUL; record DIV Exp x1; Exp x2; end DIV; record NEG Exp x1; end NEG; end Exp; Expression: 12+5*13 Representation: PLUS( RCONST(12), MUL( RCONST(5), RCONST(13) ) PLUS MUL RCONST

25 MetaModelica – Example (III) package ExpressionEvaluator // abstract syntax declarations... // semantic functions function eval input Exp in_exp; output Real out_real; algorithm out_real := match in_exp local Real v1,v2,v3; Exp e1,e2; case RCONST(v1) then v1; case ADD(e1,e2) equation v1 = eval(e1); v2 = eval(e2); v3 = v1 + v2; then v3; case SUB(e1,e2) equation v1 = eval(e1); v2 = eval(e2); v3 = v1 - v2; then v3; case MUL(e1,e2) equation v1 = eval(e1); v2 = eval(e2); v3 = v1 * v2; then v3; case DIV(e1,e2) equation v1 = eval(e1); v2 = eval(e2); v3 = v1 / v2; then v3; case NEG(e1) equation v1 = eval(e1); v2 = -v1; then v2; end match; end eval; end ExpressionEvaluator;

26 Modelica/MetaModelica Development Tooling (MDT)  Supports textual editing of Modelica/MetaModelica code as an Eclipse plugin  Was created to ease the development of the OpenModelica development ( lines of code) and to support advanced Modelica library development  It has most of the functionality expected from a Development Environment  code browsing  code assistance  code indentation  code highlighting  error detection  automated build of Modelica/MetaModelica projects  debugging

27 Modelica/MetaModelica Development Tooling Code Assistance on function calling.

28 Conclusions and Future Work  MetaModelica a language that integrates modeling of  physical systems  programming language semantics  at the equation level  MetaModelica is a step towards reusable libraries of specifications for programming language semantics  Future Work  How do devise a suitable component model for the specification of a programming language semantics in terms of reusable components.  Tools to support such language modeling.

29 End Thank you! Questions?