Principles of Object-Oriented Modeling and Simulation with Modelica 3.3 - Peter Fritzson - E-Book

Principles of Object-Oriented Modeling and Simulation with Modelica 3.3 E-Book

Peter Fritzson

4,4
122,99 €

oder
-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Fritzson covers the Modelica language in impressive depth from the basic concepts such as cyber-physical, equation-base, object-oriented, system, model, and simulation, while also incorporating over a hundred exercises and their solutions for a tutorial, easy-to-read experience. * The only book with complete Modelica 3.3 coverage * Over one hundred exercises and solutions * Examines basic concepts such as cyber-physical, equation-based, object-oriented, system, model, and simulation

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 2317

Veröffentlichungsjahr: 2015

Bewertungen
4,4 (18 Bewertungen)
11
4
3
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Contents

Cover

Half Title page

Title page

Copyright page

Preface

About the Author

About this Book

Reading Guide

Acknowledgements

Contributions to Examples

Contributors to the Modelica Standard Library, Version 3.2.1

Contributors to the Modelica Standard Library, Versions 1.0 to 2.1

Contributors to the Modelica Language, Version 3.3 revision 1

Contributors to the Modelica Language, Version 3.3

Contributors to the Modelica Language, Version 3.2

Contributors to the Modelica Language, Version 3.0

Contributors to the Modelica Language, Version 2.0

Contributors to the Modelica Language, up to Version 1.3

Modelica Association Member Companies and Organizations 2013

Funding Contributions

Part I: Introduction

Chapter 1: Introduction to Modeling and Simulation

1.1 Systems and Experiments

1.2 The Model Concept

1.3 Simulation

1.4 Building Models

1.5 Analyzing Models

1.6 Kinds of Mathematical Models

1.7 Using Modeling and Simulation in Product Design

1.8 Examples of System Models

1.9 Summary

1.10 Literature

Chapter 2: A Quick Tour of Modelica

2.1 Getting Started with Modelica

2.2 Object-Oriented Mathematical Modeling

2.3 Classes and Instances

2.4 Inheritance

2.5 Generic Classes

2.6 Equations

2.7 Acausal Physical Modeling

2.8 The Modelica Software Component Model

2.9 Partial Classes

2.10 Component Library Design and Use

2.11 Example: Electrical Component Library

2.12 The Simple Circuit Model

2.13 Arrays

2.14 Algorithmic Constructs

2.15 Discrete-Event and Hybrid Modeling

2.16 Packages

2.17 Annotations

2.18 Naming Conventions

2.19 Modelica Standard Library

2.20 Implementation and Execution of Modelica

2.21 Tool Interoperability through Functional Mockup Interface

2.22 History

2.23 Summary

2.24 Literature

2.25 Exercises

Part II: The Modelica Language

Chapter 3: Classes, Types, Declarations, and Lookup

3.1 Contract between Class Designer and User

3.2 A Class and Instance Example

3.3 Variables

3.4 Behavior as Equations

3.5 Access Control

3.6 Simulating the Moon Landing Example

3.7 Short Classes and Nested Classes

3.8 Specialized Classes

3.9 Predefined Types/Classes

3.10 Structure of Variable Declarations

3.11 Declaration Prefixes

3.12 Variable Specifiers

3.13 Initial Values of Variables

3.14 Conditional Instance Declarations

3.15 Declaration Order and Use before Declaration

3.16 Introduction to Scoping and Name Lookup

3.17 Nested Lookup Procedure in Detail

3.18 The Concepts of Type and Subtype

3.19 Use of Subtyping and Type Compatibility

3.20 Summary of Type Concepts

3.21 Summary

3.22 Literature

3.23 Exercises

Chapter 4: Inheritance, Modifications, and Generics

4.1 Inheritance

4.2 Inheritance through Modification

4.3 Redeclaration

4.4 Parameterized Generic Classes

4.5 Designing a Class to Be Extended

4.6 Adapting and Extending Libraries by class extends

4.7 Summary

4.8 Literature

4.9 Exercises

Chapter 5: Components, Connectors, and Connections

5.1 Software Component Models

5.2 Connectors and Connector Classes

5.3 Connections

5.4 Connectors, Components, and Coordinate Systems

5.5 Design Guidelines for Connector Classes

5.6 Connecting Components from Multiple Domains

5.7 Detailed Connection Semantics

5.8 Implicit Connections with the inner/outer Construct

5.9 Expandable Connectors for Information Buses

5.10 Stream Connector Concept for Fluid Systems

5.11 Overconstrained Connection Graphs

5.12 Summary

5.13 Literature

5.14 Exercise

Chapter 6: Literals, Operators, and Expressions

6.1 Character Set

6.2 Comments

6.3 Identifiers, Names, and Keywords

6.4 Predefined Types

6.5 Literal Constants

6.6 Operator Precedence and Associativity

6.7 Order of Evaluation

6.8 Expression Type and Conversions

6.9 Variability of Expressions

6.10 Arithmetic Operators

6.11 Equality, Relational, and Logical Operators

6.12 Miscellaneous Operators

6.13 Built-in Intrinsic Mathematical Functions

6.14 Built-in Special Operators and Functions

6.15 Match-Expressions and Symbolic Programming

6.16 Summary

6.17 Literature

6.18 Exercises

Chapter 7: Arrays

7.1 Array Declarations and Types

7.2 General Array Construction

7.3 Array Concatenation and Construction

7.4 Array Indexing

7.5 Using Array Concatenation and Slices

7.6 Array Equality and Assignment

7.7 String Concatenation Array Operator

7.8 Arithmetic Array Operators and Elementwise Operators

7.9 Built-in Array Functions

7.10 Vectorization via Application of Scalar Functions to Arrays

7.11 Empty Arrays

7.12 Summary

7.13 Literature

7.14 Exercises

Chapter 8: Equations

8.1 General Equation Properties

8.2 Equations in Declarations

8.3 Equations in Equation Sections

8.4 Initialization and Initial Equation

8.5 Equation Operators for Overconstrained Connection-Based Equation Systems

8.6 Synchronous Clock-Based Equations

8.7 Equation Operators for Clocked State Machines

8.8 Special Operators for Enabling Equation System Solution

8.9 Balanced Model Equation Systems

8.10 Partial Differential Equations

8.11 Summary

8.12 Literature

8.13 Exercises

Chapter 9: Algorithms and Functions

9.1 Declarative versus Nondeclarative Constructs

9.2 Algorithms and Statements

9.3 Functions

9.4 External Functions

9.5 User-Defined Overloaded Operators and Constructor Functions

9.6 Summary

9.7 Literature

9.8 Exercises

Chapter 10: Packages

10.1 Packages as Abstract Data Types

10.2 Package Access

10.3 Package and Library Structuring

10.4 Package Variants and Operations

10.5 A Comparison Between Java and Modelica Packages

10.6 External Resources and Libraries

10.7 Summary

10.8 Literature

10.9 Exercises

Chapter 11: Annotations, Units, and Quantities

11.1 Standard Annotations

11.2 Annotation Syntax

11.3 Annotation Placement

11.4 Graphical Annotations

11.5 Annotations for Customizing Library GUIs

11.6 Annotations for Simulation Experiments

11.7 Annotation for Single Use of a Class

11.8 Annotations Influencing Code Generation

11.9 Documentation Annotations

11.10 Version Handling Annotations

11.11 Tool Specific Annotations

11.12 Annotations for Access Control to Protect Intellectual Property

11.13 Function Annotations

11.14 Annotations for External Libraries and Include Files

11.15 URI References to External Resources

11.16 Units and Quantities

11.17 Summary

11.18 Literature

11.19 Exercises

Part III: Modeling and Applications

Chapter 12: Cyber-Physical System Modeling Methodology

12.1 Building System Models

12.2 Modeling a Tank System

12.3 Modeling of a DC-Motor Servo from Predefined Components

12.4 Designing Interfaces—Connector Classes

12.5 Block Diagram Models

12.6 Categories of Variables and Constants in Mathematical Models

12.7 Types of Equations in Mathematical Models

12.8 Statespace Equations for Continuous Systems

12.9 Summary

12.10 Literature

12.11 Exercises

Chapter 13: Discrete Events and Hybrid and Embedded System Modeling

13.1 Real-Time and Reactive Systems

13.2 Events

13.3 Discrete Model Examples and Related Formalisms

13.4 Hybrid System Modeling and Simulation

13.5 Concurrent Access to Shared Resources

13.6 Clock-Based Modeling in Detail

13.7 Clocked State Machines in Detail

13.8 Summary

13.9 Literature

13.10 Exercises

Chapter 14: Basic Laws of Nature

14.1 Energy Conservation

14.2 Analog Electrical Circuits

14.3 Mechanical Translational 1D

14.4 Mechanical Rotational 1D

14.5 Flow Systems and Hydraulics

14.6 Thermal Systems

14.7 Thermodynamics

14.8 Multibody Systems

14.9 Summary

Chapter 15: Application Examples

15.1 Mechatronic Systems—A DC Motor

15.2 Thermodynamics—An Air-filled Control Volume Interacting with Subsystems

15.3 Chemical Reactions

15.4 Biological and Ecological Systems

15.5 Economic Systems

15.6 Packet-Switched Communication Networks

15.7 Design Optimization

15.8 Fourier Analysis of Simulation Data

15.9 Pressure Dynamics in 1D Ducts—Solving Wave Equations by Discretized PDEs

15.10 Mechanical Multibody Systems and the MBS Library

15.11 Mechanical CAD Model Simulation and Visualization

15.12 Summary

15.13 Literature

Chapter 16: Modelica Library Overview

16.1 Modelica.Constants Library

16.2 Modelica.Math Library

16.3 Modelica.ComplexMath Library

16.4 Modelica.Utilities Library

16.5 Modelica.SIUnits Library

16.6 Modelica.Electrical Library

16.7 Modelica.Electrical.Digital Library

16.8 Modelica.Blocks Library

16.9 Modelica_StateGraph2 Library

16.10 Modelica_Synchronous Library

16.11 Modelica.Mechanics Library

16.12 Modelica.FLuid Library

16.13 Modelica.Media Library

16.14 Modelica.Thermal Library

16.15 ThermoSysPro Library

16.16 ThermoPower Library

16.17 PowerSystems Library

16.18 PNLib—Extended Hybrid Petri Net (xHPN) Library

16.19 BioChem—Biochemical Pathway Library

16.20 OpenHydraulics Library

16.21 BondLib and the SystemDynamics Library World3 Model

16.22 Summary

16.23 Literature

Part IV: Technology and Tools

Chapter 17: A Mathematical Representation for Modelica Models

17.1 Defining Hybrid DAEs—a Hybrid Mathematical Representation

17.2 Summary

17.3 Literature

Chapter 18: Techniques and Research

18.1 Overview of the Process of Simulating Modelica Models

18.2 Simulation Techniques—Solving Equation Systems

18.3 Selected Modelica-Related Research and Language Design

18.4 Literature

Chapter 19: Environments

19.1 General Background

19.2 Common Characteristics

19.3 OpenModelica

19.4 Wolfram SystemModeler

19.5 The Dymola Environment

19.6 Summary

19.7 Literature

Appendix A: Glossary

Literature

Appendix B: Modelica Formal Syntax

B.1 Lexical Conventions

B.2 Modelica Grammar

B.3 MetaModelica 2.0 Grammar Extensions

B.4 Optimization Grammar Extensions

B.5 ParModelica Grammar Extensions

Appendix C: Solutions to Exercises

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Appendix D: Modelica Standard Library Samples

Modelica.Constants

Modelica.SIunits

Modelica.SIunits.Conversions

Modelica.SIunits.Conversions.to_degC

Modelica.SIunits.Converslons.from_degC

Modelica.Math

Modelica.Math.Random

Modelica.Blocks

Modelica.Blocks.Interfaces

Modelica.Blocks.Continuous

Modelica.Blocks.Nonlinear

Modelica.Blocks.Math

Modelica.Blocks.Sources

Modelica.Electrical

Modelica.Electrical.Analog

Modelica.Electrical.Analog.Interfaces

Modelica.Electrical.Analog.Basic

Modelica.Electrical.Analog.Ideal

Modelica.Electrical.Analog.Sensors

Modelica.Electrical.Analog.Sources

Modelica.Electrical.Analog.Lines

Modelica.Electrical.Analog.-Semiconductors

Modelica.Electrical.Analog.Examples

Appendix E: Modelica and Python Scripting

E.1 OpenModelica Modelica Scripting Commands

E.2 OpenModelica Python Scripting Commands

E.3 Wolfram SystemModeler Scripting Commands

E.4 Dymola Scripting Commands

Appendix F: Related Equation-Based, Object-Oriented Modeling Languages

F.1 Language Developments Behind Modelica

F.2 Related Languages

F.3 Literature

Appendix G: FMI—Functional Mockup Interface

G.1 Summary

G.2 Overview

G.3 FMI for Model Exchange

G.4 FMI for Co-Simulation

G.5 Literature

References

Index

Wiley End User License Agreement

Principles of Object Oriented Modeling and Simulation with Modelica 3.3

IEEE Press445 Hoes LanePiscataway, NJ 08854

IEEE Press Editorial BoardTariq Samad, Editor in Chief

George W. Arnold                Mary Lanzerotti            Linda Shafer      
Dmitry Goldgof                    Pui-In Mak                     MengChu Zhou
Ekram Hossain                      Ray Perez                       George Zobrist  

Kenneth Moore, Director of IEEE Book and Information Services (BIS)

For further information visit: the book web page http://www.DrModelica.org, the Modelica Association web page http://www.modelica.org, the authors research page http://www.ida.liu.se/labs/pelab/modelica, or email the author at [email protected]

Copyright © 2015 by the Institute of Electrical and Electronics Engineers, Inc. All rights reserved.

All rights reserved. Reproduction or use of editorial or pictorial content in any manner is prohibited without express permission. No patent liability is assumed with respect to the use of information contained herein. While every precaution has been taken in the preparation of this book the publisher assumes no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of information contained herein.

Certain material from the Modelica Tutorial and the Modelica Language Specification available at http://www.modelica.org has been reproduced in this book with permission the from the Modelica Association.

Documentation from the commercial libraries HyLib and PneuLib has been reproduced with permission from the author.

Documentation and code from the Modelica libraries available at http?www.modelica.org has been reproduced with permission in this book according to the following license:

The Modelica License (Version 1.1 of June 30, 2000)

Redistribution and use in source and binary forms, with or without modification are permitted, provided that the following conditions are met:

1. The author and copyright notices in the source files, these license conditions and the disclaimer below are (a) retained and (b) reproduced in the documentation provided with the distribution.
2. Modifications of the original source files are allowed, provided that a prominent notice is inserted in each changed file and the accompanying documentation, stating how and when the file was modified, and provided that the conditions under (1) are met.
3. It is not allowed to charge a fee for the original version or a modified version of the software, besides a reasonable fee for distribution and support. Distribution in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution is permitted, provided that it is not advertised as a product of your own.

Modelica License DisclaimerThe software (sources, binaries, etc) in its original or in a modified form are provided “as is” and the copyright holders assume no responsibility for its contents what so ever. Any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright holders, or any party who modify and/or redistribute the package, be liable for any direct, indirect, incidental, special, exemplary, or consequential damages, arising in any way out of the use of this software, even if advised of the possibility of such damage.

TrademarksModelica® is a registered trademark of the Modelica Association. MathModelica® and MathCode® are registered trademarks of MathCore Engineering AB. Dymola® is a registered trademark of Dynasim AB. MATLAB® and Simulink® are registered trademarks of Math Works Inc. JavaTM is a trademark of Sun MicroSystems AB. Mathematica® is a registered trademark of Wolfram Research Inc.

Library of Congress Cataloging-in-Publication Data:

Fritzson, Peter A., 1952- Principles of object oriented modeling and simulation with Modelica 3.3:a cyber-physical approach / Peter Fritzson.— 2nd edition. ISBN: 9781118859124      pages cm  Includes bibliographical references and index.1. Object-oriented methods (Computer science) 2. Computer simulation. 3. Modelica, I. Title. QA76.64.F758 2015 005.1’17–dc23

2014022271

Preface

The Modelica modeling language and technology is being warmly received by the world community in modeling and simulation with major applications in virtual prototyping of complex cyber-physical systems, which mix physical system dynamics with software (cyber) and networks. It is bringing about a revolution in this area, based on its ease of use, visual design of models with combination of lego-like predefined model building blocks, its ability to define model libraries with reusable components, its support for modeling and simulation of complex applications involving parts from several application domains, and many more useful facilities. To draw an analogy—Modelica is currently in a similar phase as Java early on, before the language became well known, but for virtual prototyping instead of Internet programming.

About the Author

Peter Fritzson, PhD, is Professor and Research Director of the Programming Environment Laboratory within Department of Computer and Information Science, Linköping University, Sweden. Prof. Fritzson is also Director of the Open Source Modelica Consortium, Director of the MODPROD Center for Model-Based Product Development, and Vice Chairman of the Modelica Association, all organizations he helped to establish. Previously, he has served as Chairman of the Scandinavian Simulation Society, Secretary of EuroSim, and a Project Leader at Sun MicroSystems California. Prof. Fritzson is one of the world’s leading experts on object-oriented equation-based modeling and simulation technology, and is one of the founding fathers of Modelica..

About this Book

This book teaches modeling and simulation of cyber-physical systems and gives an introduction and complete overview of the Modelica language to people who are familiar with basic programming concepts. It gives a basic introduction to the concepts of cyber-physical systems, modeling and simulation, equation-based object-oriented modeling, as well as the basics of object-oriented component-based modeling for the novice, and a comprehensive overview of modeling and simulation in a number of application areas. In fact, the book has several goals:

Being a useful textbook in introductory courses on modeling and simulation of cyber-physical systems.

Being easily accessible for people who do not previously have a background in modeling, simulation and object orientation.

Introducing the concepts of cyber-physical modeling, object-oriented modeling, and component-based modeling.

Providing a complete yet informal reference for the Modelica 3.3 language including the new synchronous features for embedded system modeling.

Demonstrating modeling examples from a wide range of application areas.

Being a reference guide for the most commonly used Modelica libraries.

Introducing requirement driven model-based system design and verification.

Giving an introduction to numeric and symbolic techniques used in current Modelica tools.

The book contains many examples of models in different application domains, as well as examples combining several domains. However, it is not primarily intended for the advanced modeler who, for example, needs additional insight into modeling within very specific application domains, or the person who constructs very complex models where special tricks may be needed.

All examples and exercises in this book are available in an electronic self-teaching material called DrModelica, based on this book, which gradually guides the reader from simple introductory examples and exercises to more advanced ones. All of this teaching material can be freely downloaded from the book web site within www.openmodelica.org. This site also includes the downloadable free open source tool OpenModelica for modeling and simulation, which is the tool primarily used in this book.

Moreover, the web site contains additional (teaching) material related to this book. The Modelica Standard Library 3.2.1 release August 2013 is used for the examples in this book. The main web site for the Modelica and Modelica libraries, including the most recent versions, is the Modelica Association website, www.Modelica.org.

This second edition describes improvements and updates of the Modelica language up to Modelica 3.3. revision 1, including synchronous clocked constructs, examines basic concepts of cyber-physical, equation-based, object-oriented system modeling and simulation. The Modelica class concept and its use in graphical and textual modeling is introduced together with several hundred examples from many application areas and explores modeling methodology for continuous, discrete, and hybrid systems; and more.

Reading Guide

This book is a combination of a textbook for teaching modeling and simulation of cyber-physical systems, a textbook and reference guide for learning how to model and program using Modelica, and an application guide on how to do physical modeling in a number of application areas. The book can be read sequentially from the beginning to the end, but this will probably not be the typical reading pattern. Here are some suggestions:

Very quick introduction to modeling and simulation of cyber-physical systems – an object-oriented approach: Chapters 1 and 2.

Basic introduction to the Modelica language: Chapter 2 and first part of Chapter 13.

Full Modelica language course: Chapters 1–13.

Emphasis on cyber-physical system modeling: Chapter 12 and Chapter 13.

Application-oriented course: Chapter 1, and 2, most of Chapter 5, Chapters 12–15. Use Chapters 3–11 as a language reference, and Chapter 16 and appendices as a library reference.

Teaching object orientation in modeling: Chapters 2–4, first part of Chapter 12.

Introduction to mathematical equation representations, as well as numeric and symbolic techniques, Chapters 17–18.

Modelica environments, with three example tools, Chapter 19.

An interactive computer-based self-teaching course material called DrModelica is available as electronic live notebooks at www.openmodelica.org. This material includes all the examples and exercises with solutions from the book, and is designed to be used in parallel when reading the book, with page references, etc.

The reading diagram below is yet another reading guideline, giving a combination of important language concepts together with modeling methodology and application examples of your choice. The selection is of necessity somewhat arbitrary – you should also take a look at the table of contents of other chapters and part of chapters so that you do not miss something important according to your own interest.

Acknowledgements

The members of the Modelica Association created the Modelica language, and contributed have many examples of Modelica code in the Modelica Language Rationale and Modelica Language Specification (see http://www.modelica.org), some of which are used in this book. The members who contributed to various versions of Modelica are mentioned further below.

First, thanks to my wife, Anita, who has supported and endured me during this writing effort.

Very special thanks to Peter Bunus for help with model examples, some figures, Microsoft Word formatting, and for many inspiring discussions. Without your help this project might have been too hard, especially considering the damage to my hands from too much typing on computer keyboards.

Many thanks to Hilding Elmqvist for sharing the vision about a declarative modeling language, for starting off the Modelica design effort by inviting people to form a design group, for serving as the first chairman of Modelica Association, and for enthusiasm and many design contributions including pushing for a unified class concept. Also thanks for inspiration regarding presentation material including finding historical examples of equations.

Many thanks to Martin Otter for serving as the second chairman of the Modelica Association, for enthusiasm and energy, design and Modelica library contributions, as well as inspiration regarding presentation material.

Many thanks to Eva-Lena Lengquist Sandelin and Susanna Monemar for help with the first version of the exercises, for help with preparing certain appendices, and for preparing the first version of the DrModelica interactive notebook teaching material which makes the examples in this book more accessible for interactive learning and experimentation.

Thanks to Peter Aronsson, Bernhard Bachmann, Peter Beater, Jan Brugård, Dag Brück, Brian Elmegaard, Hilding Elmqvist, Vadim Engelson, Rüdiger Franke, Dag Fritzson, Torkel Glad, Pavel Grozman, Daniel Hedberg, Andreas Idebrant, Mats Jirstrand, Olof Johansson, Emma Larsdotter Nilsson, Håkan Lundvall, Sven-Erik Mattsson, Iakov Nakhimovski, Hans Olsson, Adrian Pop, Per Sahlin, Levon Saldamli, Hubertus Tummescheit, and Hans-Jürg Wiesmann for constructive comments on the first edition, and in some cases other help, on parts of the book, and to Peter Bunus for help in making Microsoft Word more cooperative.

Thanks to Hans Olsson and Dag Brück, who edited several versions of the Modelica Specification, and to Michael Tiller for sharing my interest in programming tools and demonstrating that it is indeed possible to write a Modelica book.

Thanks to Bodil Mattsson-Kihlström for handling many administrative chores at the Programming Environment Laboratory while I have been focusing on the first edition book writing, to Ulf Nässén for inspiration and encouragement, and to Uwe Assmann for encouragement and sharing common experiences on the hard task of writing books.

Thanks to all members of PELAB and employees of MathCore Engineering, who have given comments and feedback.

Thanks to the staff at Vårdnäs Stiftgård, who have provided a pleasant atmosphere for important parts of this writing effort.

Approximately 95 per cent of the running text of the first edition this book has been entered by voice using Dragon Naturally Speaking. This is usually slower than typing, but still quite useful for a person like me, who has acquired RSI (Repetitive Strain Injury) due to too much typing. Fortunately, I could still do limited typing and drawing, e.g., for corrections, examples, and figures. All Modelica examples are hand-typed, but often with the help of others. All figures except the curve diagrams are, of course, hand drawn.

The first version of this book “Principles of Object-Oriented Modeling and Simulation with Modelica 2.1” was finalized in September 2003.

The second edition, titled “Principles of Modeling and Simulation with Modelica 3.3: A Cyber-Physical Approach” has been updated to Modelica 3.3 rev 1 and extended with more aspects covering modeling of cyber-physical systems with integrated hardware-software and the new clocked synchronous features in Modelica 3.3 especially suitable for embedded systems modeling. A description of stream connectors including several examples has been added, as well as a description of expandable connectors. The chapter on the Modelica standard library and some other open source libraries has been updated to the current status. Moreover, some additional material has been included such as requirements-driven modeling and verification of cyber-physical software/hardware products, meta-modeling with MetaModelica, and a short introduction to FMI – the Functional Mockup Interface for model exchange and/or co-simulation.

Regarding the second edition many people have contributed with feedback—there is a risk of forgetting somebody here. I would especially like to thank Per Östlund for very detailed and expert feedback on nine of the chapters, Bernhard Thiele for detailed feedback regarding the new sections about the clocked synchronous constructs in Chapter 13, Francesco Casella for feedback on stream connectors and modeling style, Rüdiger Franke regarding application models and help to convert the thermodynamic examples in Chapter 15 to stream connector style, Alachew Shitahun for help with updating library and scripting appendices, Arunkumar Palanisamy for help with the grammar appendix update, Adeel Asghar for feedback regarding graphical annotations and the graphical editor. Also thanks to Dirk Zimmer, Elena Shmoylova, Martin Otter, Hilding Elmqvist, and Bernt Lie for feedback. Many thanks to Adrian Pop, Per Östlund, Martin Sjölund, Adeel Asghar, Willi Braun, Lennart Ochel, Vitalij Ruge, and all other developers in the OpenModelica project for support and help when needed. Thanks to Lena Buffoni for additional exercises and collaboration in teaching our Modelica course. Thanks to Adrian Pop and Martin Sjölund regarding MetaModelica and compiler bootstrapping work, and to Wladimir Schamai regarding feedback and collaboration on ModelicaML, requirement verification, and state charts semantics.

The updates for this edition were possible for me to type without voice input. My hands have become better with frequent crawl swimming exercises and a work position using a thin laptop on my lap.

Linköping, July 2014

Peter Fritzson

Contributions to Examples

Many people contributed to the original versions of some of the Modelica examples presented in this book. Most examples have been significantly revised compared to the originals. A number of individuals are acknowledged below with the risk of accidental omission due to oversight. If the original version of an example is from the Modelica Tutorial or the Modelica Specification on the Modelica Association web sites, the contributors usually are the members of the Modelica Association, but in some cases individuals are mentioned also in this case. In addition to the examples mentioned in this table, there are also numerous small example fragments from the Modelica Tutorial and Specification used in original or modified form in the text, which is indicated to some extent in the reference section of each chapter.

   

Example Models

   

Individuals

VanDerPol

in Section 2.1.1

Andreas Karström

SimpleCircuit

in Section 2.7.1

Members of the Modelica Association.

PolynomialEvaluator

in Section 2.14.3

Members of the Modelica Association.

LeastSquares

in Section 2.14.4

Mikael Adlers

Diode

and

BouncingBall

in Section 2.15

Members of the Modelica Association.

SimpleCircuit expansion

in Section 2.20.1

Martin Otter

Rocket

in Section 3.5

Peter Bunus

MoonLanding

in Section 3.5

Peter Bunus

BoardExample

in Section 3.17.5

Members of the Modelica Association.

BaseClassExtendsConflict

in Section 4.1.6

Per Östlund

LowPassFilter

in Section 4.2.10

Members of the Modelica Association.

FrictionFunction, KindOfController

Sec 4.3.12

Members of the Modelica Association.

Tank

in Section 4.4.5

Peter Bunus

Oscillator, Mass, Rigid

in Section 5.4.4

Martin Otter

SpringDamper

of

Figure 5-22

in Section 5.4.5 5.4.4

Dirk Zimmer

RealInput, RealoutPut, MISO

in Section 5.5.2

Martin Otter

MatrixGain, CrossProduct

in Section 5.7.5

Members of the Modelica Association.

Environment

in Section 5.8.1

Members of the Modelica Association.

CircuitBoard

in Section 5.8.2

Members of the Modelica Association.

uniformGravity, pointGravity

in Section 5.8.3

Members of the Modelica Association.

ParticleSystem

in Section 5.8.3

Members of the Modelica Association.

Volume

in Section 5.10.4.1

Rüdiger Franke, Francesco Casella, Martin Otter, Michael Sielemann, Hilding Elmqvist, Sven-Erik Mattsson, Hans Olsson

WaterVolumeConstant

in Section 5.10.4.1

Per Östlund

WaterVolumeCompressible

in Section 5.10.4.1

Francesco Casella

IsoenthalpicFlow

in Section 5.10.4.25.10.4.1

Rüdiger Franke, Francesco Casella, Martin Otter, Michael Sielemann, Hilding Elmqvist, Sven-Erik Mattsson, Hans Olsson

WaterVolumeConstant

in Section 5.10.4.1

Per Östlund

WaterVolumeCompressible

in Section 5.10.4.1

Francesco Casella

IsoenthalpicFlow

in Section 5.10.4.25.10.4.1

Rüdiger Franke, Francesco Casella, Martin Otter, Michael Sielemann, Hilding Elmqvist, Sven-Erik Mattsson, Hans Olsson

TemperatureSensor

in Section 5.10.4.3

Rüdiger Franke, Francesco Casella, Martin Otter, Michael Sielemann, Hilding Elmqvist, Sven-Erik Mattsson, Hans Olsson

TimeEventTest, mySinNoTime

in Section 5.10.4.36.3.3

Per Östlund

PendulumImplicitL, readParameterData

in Section 8.4.4

Sven-Erik Mattsson, Hilding Elmqvist, Martin Otter, Hans Olsson

ProcessControl1, ProcessControl2, ProcessCcntrol3, ProcessControl4

in Section 8.4.6

Sven-Erik Mattsson, Hilding Elmqvist, Martin Otter, Hans Olsson

HeatRectangle2D

in Section 8.10.1.4

Levon Saldamli

Material to

Figure 8-13

on 2D heat flow using FEM.

Levon Saldamli

FieldDomainOperators1D

in Section 8.10.5.

Hilding Elmqvist, Jonas Jonasson

DifferentialOperators1D

in Section 8.10.5.

Jonas Jonasson, Hilding Elmqvist

HeadDiffusion1D

in Section 8.10.5.

Jonas Jonasson, Hilding Elmqvist

Diff22D

in Section 8.10.5.1

Hilding Elmqvist

FourBarl

example in Section 8.5.1.

Martin Otter

Orientation

in Section 8.5.1.

Martin Otter, Hilding Elmqvist, Sven-Erik Mattsson.

FixedTranslation

in Section 8.5.3

Martin Otter, Hilding Elmqvist, Sven-Erik Mattsson.

Material to

Figure 8-5

on cutting branches in virtual connection graph.

Martin Otter, Hilding Elmqvist, Sven-Erik Mattsson.

findElement

in Section 9.2.7

Peter Aronsson

FilterBlock1

in Section 8.3.6

Members of the Modelica Association.

realToString

in Section 9.3.2.1

Members of the Modelica Association.

eigen

in Section 9.3.2.3

Martin Otter

findMatrixElement

in Section 9.3.2.6

Peter Aronsson

Record2

in Section 9.3.3

Members of the Modelica Association.

bilinearSampling

in Section 9.4.3

Members of the Modelica Association.

MyTable, interpolateMyTable

in Section 9.4.8

Members of the Modelica Association.

Mechanics

in Section 10.3.2.2

Members of the Modelica Association.

Placement, Transformation

in Section 11.4.4

Members of the Modelica Association.

Line, Polygon

, etc. in Section 11.4.5

Members of the Modelica Association.

Resistor, FrictionFunction

in Section 11.5.8.2

Members of the Modelica Association.

h0,h1,h2

in Section 11.10.1

Members of the Modelica Association.

FlatTank

in Section 12.2.1.1

Peter Bunus

TankPI, Tank, LiquidSource

in Section 12.2.3

Peter Bunus

PIContinuousController

in Section 12.2.3

Peter Bunus

TankPID, PIContinuousController

Section 12.2.4

Peter Bunus

DC-Motor Servo

in Section 12.3

Mats Jirstrand

SmoothAndEvents

in Section 13.2.5.11

Members of the Modelica Association.

CountingStateMachinel

in Section 13.3.2.1

Hilding Elmqvist, Fabien Gaucher, Sven Erik Mattsson, Francois Dupont

ClockedVarWhen

in Section 13.2.6.4

Bernhard Thiele

PreVsPrevious

in Section Section 13.2.5.14

Bernhard Thiele

WatchDogSystem

in Section 13.3.2.4

Peter Bunus

WatchDogSystemStateMachinePack

in Section 13.3.2.5

Bernhard Thiele

CustomerGeneration

in Section 13.3.4.2

Peter Bunus

ServerWithQueue

in Section 13.3.4.2

Peter Bunus

BasicDEVSTwoPort

in Section 13.3.5

Peter Bunus

SimpleDEVSServer

in Section 13.3.5

Peter Bunus

Place, Transition

in Section 13.3.6.5

Hilding Elmqvist, Peter Bunus

GameOfLife, nextGeneration

in Section 13.3.3.1

Peter Bunus

PIdiscreteController

in Section 13.4.1

Peter Bunus

TankHybridPI

in Section 13.4.1

Peter Bunus

SimpleElastoBacklash

in Section 13.4.2

Peter Bunus

DCMotorCircultBacklash

in Section 13.4.2

Peter Bunus

ElastoBacklash

in Section 13.4.2

Martin Otter

Philosophers, DiningTable

in Section 13.5.1

Håkan Lundvall

MassWithSpringDamper

in Section 13.6.1

Hilding Elmqvist, Sven-Erik Mattsson, Martin Otter, Bernhard Thiele

SpeedControlP_MassWithSpringDamper

in Section 13.6.1

Hilding Elmqvist, Sven-Erik Mattsson, Martin Otter, Bernhard Thiele

ClockedPiEx

in Section 13.6.5

Hilding Elmqvist, Martin Otter, Sven-Erik Mattsson

BackSampleEx1

in Section 13.6.9.4

Hilding Elmqvist, Martin Otter, Sven-Erik Mattsson

NoClockVsSampleHold

in Section 13.6.9.5

Bernhard Thiele

BaseClockPartitionEx

in Section 13.6.13.1

Hilding Elmqvist, Martin Otter, Sven-Erik Mattsson

ControlledMass

in Section 13.6.13.2

Hilding Elmqvist, Sven-Erik Mattsson, Martin Otter, Bernhard Thiele

SolverMethodClockedPI

in Section 13.6.15.3

Hilding Elmqvist, Sven-Erik Mattsson, Martin Otter, Bernhard Thiele

ClockTicks

in Section 13.6.16

Hilding Elmqvist, Martin Otter, Sven-Erik Mattsson

ClockTicksWithModelica32

in Section 13.6.16

Hilding Elmqvist, Martin Otter, Sven-Erik Mattsson

StateMachineSemantics

in Section 13.7.4.4

Hilding Elmqvist, Fabien Gaucher, Sven Erik Mattsson, Francois Dupont

HierarchicalAndParallelStateMachine1

in Section 13.7.5

Hilding Elmqvist, Fabien Gaucher, Sven Erik Mattsson, Francois Dupont

HierarchicalAndParallelStateMachine2

in Section 13.7.5

Hilding Elmqvist, Fabien Gaucher, Sven Erik Mattsson, Francois Dupont

BasicVolume

in Section 15.2.2

Mats Jirstrand

BasicVolume

in Section 15.2.3

Mats Jirstrand

BasicVolume

in Section 15.2.4

Mats Jirstrand

BasicVolume

in Section 15.2.4.2

Johan Gunnarsson

FlowConnectorIn

in Section 15.2.5.1

Francesco Casella

FlowConnectorOut

in Section 15.2.5.1

Francesco Casella

FlowConnector

in Section 15.2.5.1

Rüdiger Franke

IdealGas

in Section 15.2.5.2

Mats Jirstrand, Hubertus Tummescheit

BasicVolumeFirst

in Section 15.2.5.2

Mats Jirstrand, Hubertus Tummescheit

BasicVolume

in Section 15.2.5.2

Mats Jirstrand, Hubertus Tummescheit, Rüdiger Franke

PressureEnthalpySource

in Section 15.2.5.3

Mats Jirstrand

PressureEnthalpyBoundary

in Section 15.2.5.3

Rüdiger Franke

SimpleValveFlow

in Section 15.2.5.4

Mats Jirstrand

ValveFlowFirst

in Section 15.2.5.5

Mats Jirstrand

ValveFlow

in Section 15.2.5.5

Mats Jirstrand, Rüdiger Franke

ControlledValveFlowFirst

in Section 15.2.5.6

Mats Jirstrand

ControlledValveFlow

in Section 15.2.5.6

Mats Jirstrand, Rüdiger Franke

CtrlFlowSystem

in Section 15.2.5.6

Mats Jirstrand, Rüdiger Franke

PneumaticCylinderVolume

in Section 15.2.5.7

Hubertus Tummescheit

PneumaticCylinderVolume

in Section 15.2.5.8

Hubertus Tummescheit

RoomWithFan

in Section 15.2.6

Hubertus Tummescheit

RoomInEnvironment

in Section 15.2.6

Hubertus Tummescheit

HydrogenIodide

in Section 15.3.1

Emma Larsdotter Nilsson

LotkaVolterra

in Section 15.4.1

Emma Larsdotter Nilsson

HandyBase

in Section 15.4.2.2

Rodrigo Castro

HandyEgalitarianBase

in Section 15.4.2.4

Rodrigo Castro

HandyEquitableBase

in Section 15.4.2.5

Rodrigo Castro

HandyUnEquitableBase

in Section 15.4.2.6

Rodrigo Castro

World3

in Section 15.4.2.7

Francois Cellier

WillowForest

in Section 15.4.3

Emma Larsdotter Nilsson

TCPSender, Loss_link_queue

in Section 15.6.3

Daniel Fämquist et. al., Peter Bunus

Router21, TCPSackvsTCPWostWood

in Section 15.6

Daniel Fämquist et. al., Peter Bunus

LinearActuator

in Section 15.7

Mats Jirstrand, Jan Brugård

WeakAxis

in Section 15.8

Mats Jirstrand, Jan Brugård

WaveEquationSample

in Section 15.9

Jan Brugård, Mats Jirstrand

FreeFlyingBody

in Section 15.10.2

Vadim Engelson

doublePendulumNoGeometry

in Section 15.10.7

Vadim Engelson

doublePendulumCylinders

in Section 15.10.6.2

Vadim Engelson

PenduluraLoop2D

in Section 15.10.7

Vadim Engelson

ExtForcePendulum

in Section 15.10.9.1

Vadim Engelson

PendulumRotationalSteering

in Section 15.10.9.3

Vadim Engelson

PendulumWithPDController

in Section 15.10.9.4

Vadim Engelson

TripleSprings

in Section TripleSprings 5.4.3.2

Martin Otter

EngineV6

in Section 15.10.10

Martin Otter

Generator

in Section 17.1.6

Peter Bunus

Material to

Figure 17-4

,

Figure 17-5

, and

Figure 17-6

Bernhard Bachmann

Contributors to the Modelica Standard Library, Version 3.2.1

Person

Affiliation

Marcus Baur

DLR Institute of System Dynamics and Control, Oberpfaffenhofen, Germany

Thomas Beutlich

ITI GmbH, Dresden, Germany

Thomas Bödrich

Technical University of Dresden, Dresden, Germany

Francesco Casella

Politecnico di Milano, Milano, Italy

Christoph Clauß

Fraunhofer Institute for Integrated Circuits, Dresden, Germany

Rüdiger Franke

ABB AG, Mannheim, Germany

Leo Gall

Bausch-Gall GmbH, Munich, Germany

Peter Harmann

CyDesign Ltd., Coventry, U.K.

Anton Haumer

Technical Consulting & Electrical Engineering, St.Andrae-Woerdern, Austria

Andreas Heckmann

DLR Institute of System Dynamics and Control, Oberpfaffenhofen, Germany

Daniel Hedberg

Wolfram MathCore AB, Linköping, Sweden

Philipp Jordan

Technical University of Hamburg-Harburg, Hamburg, Germany

Christian Kral

AIT Austrian Institute of Technology, Vienna, Germany

Kristin Majetta

Fraunhofer Institute for Integrated Circuits, Dresden, Germany

Jesper Mattsson

Modelon AB, Lund, Sweden

Hans Olsson

Dassault Systèmes AB, Lund Sweden

Martin Otter

DLR Institute of System Dynamics and Control, Oberpfaffenhofen, Germany

Bruno Scaglioni

Consorzio MUSP, Piacenza, Italy

Michael Sielemann

DLR Institute of System Dynamics and Control, Oberpfaffenhofen, Germany

Martin Sjölund

Linköpings University, Linköping, Sweden

Bernhard Thiele

DLR Institute of System Dynamics and Control, Oberpfaffenhofen, Germany

Jakub Tobolar

DLR Institute of System Dynamics and Control, Oberpfaffenhofen, Germany

Hubertus Tummescheit

Modelon AB, Lund Sweden

Michael Wetter

Lawrence Berkeley National Laboratory, Berkeley, U.S.A.

Dietmar Winkler

Telemark University College, Porsgrunn, Norway

Stefan Wischhusen

XRG Simulation GmbH, Hamburg, Germany

Johannes Ziske

Technical University of Dresden, Dresden, Germany

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!