Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT,...

30
Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland Tamara.Beltrame@vtt .fi Conference 2006 François E. Cellier Inst. of Computational Science ETH Zurich 8092 Zurich, Switzerland [email protected]
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    216
  • download

    0

Transcript of Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT,...

Page 1: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

Quantized State System Simulation in Dymola/Modelica

Using the DEVS Formalism

Tamara Beltrame

VTT, Industrial Systems

PO Box 1000, VM3

02150 Espoo, Finland

[email protected]

Conference 2006

François E. Cellier

Inst. of Computational Science

ETH Zurich

8092 Zurich, Switzerland

[email protected]

Page 2: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 2

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

• A tool has been created for the simulation of highly discontinuous models in Dymola/Modelica that is based on Zeigler’s DEVS (Discrete Event Systems) formalism.

• ModelicaDEVS provides a reimplementation of the PowerDEVS software, a tool developed for the simulation of physical systems that is based on Kofman’s QSS (Quantized State Systems) algorithms.

Abstract

Page 3: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 3

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

• Motivation• The DEVS Formalism• Quantized State Systems• ModelicaDEVS• Simulation Results• Conclusions

Overview

Page 4: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 4

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

• When simulating continuous models on a digital computer, a quantization must take place, as digital computers can only perform a finite number of computations within any finite time span.

• Usually, it is the time axis that is being discretized, i.e., we are asking ourselves: given the current state at time t*, what value shall the state vector assume at time t* + h ?

• Yet, it is also possible to discretize the state axes, i.e., we can ask the question: given the current value of the quantized state variable qi , what is the earliest time when the variable will assume a value of qi ± Δqi ?

Motivation

Page 5: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 5

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

• Numerical simulation algorithms can be based on either paradigm.

• Whereas almost all simulation algorithms currently on the market are based on the former approach, the QSS techniques are based on the latter.

• The QSS approach has some distinct advantages:– The method is naturally asynchronous.– QSS simulations can be more easily combined with discrete events.– Most state events turn into time events in QSS.– A QSS simulation of an analytically stable system is always stable.– QSS offers a global error bound.– It is possible to design “implicit” algorithms that are not truly implicit.

Motivation 2

Page 6: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 6

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

• DEVS was introduced by B. Zeigler in 1976.

• DEVS is one among several discrete-event simulation methodologies. Other discrete-event techniques include: Petri nets, finite state machines, Markov chains, ...

• Specialty: DEVS models work with an infinite number of states. This is useful for numerical integration.

The DEVS Formalism

Page 7: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 7

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The DEVS Formalism 2

• Accept an input trajectory (external event), generate an output trajectory.

• Definition: M = <X, Y, S, δint, δext, λ, ta>– X = set of inputs– S = set of possible states– Y = set of outputs– δext = external transition– ta = time-advance function, often represented by σ– δint = internal transition– λ = output function

Atomic Models

Page 8: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 8

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The DEVS Formalism 3

Atomic Models (cont.)

Example:

Page 9: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 9

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The DEVS Formalism 4

• DEVS is closed under coupling.

• Useful to split a complex model into simpler models.

• The dynamics of the coupled model N:1. Evaluate the atomic model d* that is the next one to execute an internal

transition. Let tn be the time when the transition has to take place.2. Advance the simulation time to t = tn and let d* execute the internal

transition.3. Forward the output of d* to all connected atomic models and let them

execute their external transitions.

Coupled Models

Page 10: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 10

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The DEVS Formalism 5

• Reuse of coupled models as atomic models.

• The actual task of N is to wrap Ma and Mb, in order to make them look like they were one single model.

• The coupled model N features the same transitions as an atomic model, but the transitions of N depend on the transitions of its sub-models.

Hierarchical Models

Page 11: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 11

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

• QSS operate on piecewise constant input and output trajectories.

• Systems with piecewise constant trajectories can be simulated using the DEVS formalism.

• QSS use a quantization function to transform a continuous system into a system with piecewise constant input and output trajectories.

• The quantization function is hysteretic in order to avoid illegitimate models.– Illegitimate models perform an infinite number of transitions in a finite

time interval.

Quantized State Systems (QSS)

Page 12: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 12

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

Quantized State Systems 2

• A quantization function maps real numbers x(t) into a discrete set of real values q(t).– Problem: x(t) = −sign(q(t))

• A hysteretic quantization function prevents infinite oscillations from occurring within a single time step.

Hysteretic Quantization Function

.

Page 13: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 13

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

Quantized State Systems 3

• Conventional continuous system: x(t) = f(x(t), u(t), t)• Quantized continuous system: ξ(t) = f(q(t), u(t), t)

• Example: x(t) = −x(t) + 10·ε(t − 1.76)Used quantization function: q(t) = floor(ξ(t))

→ ξ(t) = −floor(ξ(t)) + 10·ε(t − 1.76) → ξ(t) = −q(t) + 10·ε(t − 1.76)

• q(t) is a piecewise constant, linear or quadratic function.QSS1 → uses constant function.QSS2 → uses linear function.QSS3 → uses quadratic function.

Discretization of a Continuous System

.

.

.

.

.

Page 14: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 14

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

Quantized State Systems 4

Discretization of a Continuous System (cont.)

Page 15: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 15

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The PowerDEVS Simulator

• PowerDEVS is written in C++ → sequential variable updates.

• The software employs a hierarchical simulation scheme.

• Coordinators represent coupled models, simulators represent atomic models.

• Coordinators contain simulators or other coordinators.

• Coordinators control the interaction between their children. → Components on the same level do not communicate with each other, but only with their parent coordinator.

Page 16: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 16

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The ModelicaDEVS Simulator

• ModelicaDEVS operates on the synchronous data flow principle.

• All equations are constantly monitored.

• Whether a variable gets updated or not must be determined by Boolean variables.

Page 17: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 17

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

Atomic Models in ModelicaDEVS

• ModelicaDEVS models have one or more input ports and one output port.

• ModelicaDEVS signals/events consist of the following values:– Coefficients of Taylor series up to second order of the current function

value.– Boolean value. Indicates the creation of an event.

• Input event: uVal[1], uVal[2], uVal[3] and uEvent.• Output event: yVal[1], yVal[2], yVal[3] and yEvent.

• Components have two Boolean variables dint and dext ...– dint = true → execute internal transition.– dext = true → execute external transition.

• … and two real-valued variables lastTime and sigma.– lastTime stores the time of the last event.– sigma stores the amount of time that has to elapse before the next internal

transition takes place.

Page 18: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 18

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

Coupled Models in ModelicaDEVS

• Communication between blocks:

• When block A executes its internal transition (dint = true), it sends an output to block B (yEvent = true).

• When block B receives an event (uEvent = true), it executes its external transition.

Page 19: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 19

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

Coupled Models in ModelicaDEVS 2

• Benefits of the Dymola simulator:

– The dynamics of coupled models are still determined by their sub-models.

– Performs the same loop as defined by the DEVS formalism ...

– ... but the evaluation of d* is done implicitly by Modelica’s concept of simultaneous equation evaluation.

• Coupled models are handled implicitly by the Dymola Simulator.

Page 20: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 20

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

Hierarchic Models in ModelicaDEVS

• A hierarchic model contains a component that consists of other components (sub-models).

• Sub-models just add a number of equations to the model equation “pool” → no special treatment required.

• Hierarchic models are handled implicitly by the Dymola Simulator.

Page 21: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 21

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The Flyback Converter

Page 22: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 22

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The Flyback Converter 2

Page 23: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 23

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The Flyback Converter 3

Page 24: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 24

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The Flyback Converter 4

Page 25: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 25

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The Flyback Converter 5

Page 26: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 26

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

Mixed Systems

Page 27: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 27

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

The Flyback Converter 6

Page 28: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 28

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

• A new Dymola/Modelica library implementing a number of Quantized State System (QSS) simulation algorithms has been presented. ModelicaDEVS duplicates the capabilities of PowerDEVS. The graphical user interfaces of both tools are practically identical. However, the underlying simulators are very different. Whereas PowerDEVS implements Zeigler’s hierarchical DEVS simulator, ModelicaDEVS operates on simultaneous equations and synchronous information flows.

• The embedding of ModelicaDEVS within the Dymola/ Modelica environment enables users to mix DEVS models with other modeling methodologies that are supported by Dymola and for which Dymola offers software libraries.

Conclusions

Page 29: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

© Tamara Beltrame, September 2006, Slide 29

ETH ZürichDepartment of Computer ScienceInstitute of Computational Science

• Unfortunately, ModelicaDEVS is much less efficient in run-time performance than PowerDEVS. The loss of run-time efficiency is probably caused by Dymola’s event handling algorithms that have been designed for optimal robustness in the context of hybrid system simulation rather than run-time efficiency in the context of pure discrete-event system simulation.

• Although ModelicaDEVS offers a full implementation of a DEVS kernel and can therefore be used for the simulation of arbitrary discrete-event systems, the modeling blocks that have been made available so far in ModelicaDEVS are geared towards the simulation of continuous systems using QSS algorithms.

Conclusions 2

Page 30: Quantized State System Simulation in Dymola/Modelica Using the DEVS Formalism Tamara Beltrame VTT, Industrial Systems PO Box 1000, VM3 02150 Espoo, Finland.

The End