synchronous events in the openmodelica compiler with a
play

Synchronous Events in the OpenModelica Compiler with a Petri Net - PowerPoint PPT Presentation

Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Synchronous Events in the OpenModelica Compiler with a Petri Net Library Application Simulation hybrid systems in Modelica Willi Braun, Bernhard Bachmann


  1. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Synchronous Events in the OpenModelica Compiler with a Petri Net Library Application Simulation hybrid systems in Modelica Willi Braun, Bernhard Bachmann and Sabrina Pross Department of Applied Mathematics University of Applied Sciences Bielefeld 33609 Bielefeld, Germany 2010-10-03 1 / 19

  2. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Outline Hybrid models in Modelica 1 Implementation in OpenModelica 2 Examples and results 3 2 / 19

  3. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Hybrid modeling Hybrid Mixed systems with continuous and discrete components Simulation needs handling with events and discontinuities Applications Switched electric circuits Controlled systems Petri Nets 3 / 19

  4. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Hybrid Petri Net Elements of a Petri Net P 2 P 1 Fundamental items are places and transitions 1 2 Directed arcs connect items T 1 5 P 3 1 1 T 3 T 2 2 3 P 5 P 4 4 / 19

  5. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Hybrid Petri Net Elements of a Petri Net P 2 P 1 Fundamental items are places and transitions 1 2 Directed arcs connect items T 1 5 P 3 1 1 T 3 T 2 2 3 P 5 P 4 4 / 19

  6. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Hybrid Petri Net Elements of a Petri Net P 2 5 12 . 5 P 1 Fundamental items are places and 1 2 P 1 transitions 4 P 2 1 Directed arcs connect items T 1 5 Modifications The fireing speed can be discribed by P 3 0 differential equations for continuous 1 1 behaviour T 3 T 2 Transistions may have a stochastic delay 2 3 Edges may have weightings, threshold and inhibition P 5 0 3 . 1 P 4 4 / 19

  7. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Hybrid Petri Net Elements of a Petri Net P 2 P 1 12 . 5 Fundamental items are places and transitions 3 P 1 1 Directed arcs connect items T 1 5 Modifications P 3 1 The fireing speed can be discribed by differential equations for continuous 2 P 4 1 behaviour T 3 T 2 Transistions may have a stochastic delay 2 1 Edges may have weightings, threshold and inhibition P 5 0 P 4 ⇒ Hybrid models 4 / 19

  8. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Petri Nets in OpenModelica Library in OpenModelica Continuous, discrete and stochastic Figure: Elements of the places and transitions can be PetriNet-Library combined Combined Petri Nets are versatile applicable For example: production or biological processes Problems in OpenModelica “ when equations ”were not treated synchronously Figure: Example network 5 / 19

  9. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Modelling events with Modelica e x a m p l e i f model input Real u ; y ; Real equation y = i f u > 0 then 1 − 1; e l s e end e x a m p l e i f ; Conditional expressions like u > 0 trigger events. If events occurs the value is stored twice. In this example y is the right limit and pre(y) is the left limit. 6 / 19

  10. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Hybrid Modelica DAE-System Flatten Modelica model: 0 = F ( ˙ x ( t ) , x ( t ) , y ( t ) , u ( t ) , q ( t e ) , q pre ( t e ) , c ( t e ) , p , t ) ↓ matching and sorting algorithm transform to f ( x ( t ) , u ( t ) , q pre ( t e ) , c ( t e ) , p , t )     x ( t ) ˙  = g ( x ( t ) , u ( t ) , q pre ( t e ) , c ( t e ) , p , t ) z = y ( t )    q ( t e ) h ( x ( t ) , u ( t ) , q pre ( t e ) , c ( t e ) , p , t ) 7 / 19

  11. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Synchronous Data-flow principle Sorting of when equations Incidence-Matrix //known V a r i a b l e : u when y2 > 2 then y 1 y 2 y 3 y 4 y 5 y3 = f1 ( y4 ) ;   y 3 = f 1( y 4) 0 1 1 1 0 end when ; y4 = f2 ( y5 ) ; y 4 = f 2( y 5) 0 0 0 1 1   when y1 > 0 then   y 5 = f 3( u ) 1 0 0 0 1 y5 = f3 ( u ) ;   y2 = f4 ( y4 ) ;   y 2 = f 4( y 4) 1 1 0 1 0   end when ; y 1 = f 5( u ) 1 0 0 0 0 y1 = f5 ( u ) ; 8 / 19

  12. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Synchronous Data-flow principle Incidence-Matrix Sorting of when equations //known V a r i a b l e : u y 1 y 5 y 4 y 2 y 3 y1 = f5 ( u ) ; when y1 > 0 then   y 1 = f 5( u ) 0 0 0 0 1 y5 = f2 ( u ) ; y 5 = f 3( u ) 1 0 0 0 1 end when ;   y4 = f3 ( y5 ) ;   y 4 = f 3( y 5) 0 1 0 0 1   when y1 > 0 then   y 2 = f 4( y 4) 1 0 1 0 1 y2 = f4 ( y4 ) ;   end when ; y 3 = f 1( y 4) 0 0 1 1 1 when y2 > 2 then y3 = f1 ( y4 ) ; end when ; 9 / 19

  13. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Synchronous Data-flow principle Incidence-Matrix Sorting of when equations //known V a r i a b l e : u y 1 y 5 y 4 y 2 y 3 y1 = f5 ( u ) ; when y1 > 0 then   y 1 = f 5( u ) 0 0 0 0 1 y5 = f2 ( u ) ; y 5 = f 3( u ) 1 0 0 0 1 end when ;   y4 = f3 ( y5 ) ;   y 4 = f 3( y 5) 0 1 0 0 1   when y1 > 0 then   y 2 = f 4( y 4) 1 0 1 0 1 y2 = f4 ( y4 ) ;   end when ; y 3 = f 1( y 4) 0 0 1 1 1 when y2 > 2 then y3 = f1 ( y4 ) ; end when ; Sorting equations Sorting is based on all equations due to the correct order of evaluation at all time points. 9 / 19

  14. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Hybrid Modelica DAE-System Flatten Modelica model: 0 = F ( ˙ x ( t ) , x ( t ) , y ( t ) , u ( t ) , q ( t e ) , q pre ( t e ) , c ( t e ) , p , t ) ↓ matching and sorting algorithm transform to f ( x ( t ) , u ( t ) , q pre ( t e ) , c ( t e ) , p , t )     x ( t ) ˙  = g ( x ( t ) , u ( t ) , q pre ( t e ) , c ( t e ) , p , t ) z = y ( t )    q ( t e ) h ( x ( t ) , u ( t ) , q pre ( t e ) , c ( t e ) , p , t ) 10 / 19

  15. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Hybrid models Hybrid Modelica DAE-System Flatten Modelica model: 0 = F ( ˙ x ( t ) , x ( t ) , y ( t ) , u ( t ) , q ( t e ) , q pre ( t e ) , c ( t e ) , p , t ) ↓ matching and sorting algorithm transform to f ( x ( t ) , u ( t ) , q pre ( t e ) , c ( t e ) , p , t )     x ( t ) ˙  = g ( x ( t ) , u ( t ) , q pre ( t e ) , c ( t e ) , p , t ) z = y ( t )    q ( t e ) h ( x ( t ) , u ( t ) , q pre ( t e ) , c ( t e ) , p , t ) We get four blocks: continuous f and g → derivative states and algebraic variables discrete h → discrete algebraic variables all z → all three block together An additional block to manage the conditions for events: c ( t ) → Zero Crossing functions 10 / 19

  16. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Implementation in OpenModelica Approach to simulate hybrid models 11 / 19

  17. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Implementation in OpenModelica Approach to simulate hybrid models Intial Step Initial-value problem is solved by a simplex-method Initial Zero-crossing functions and check for initial events 11 / 19

  18. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Implementation in OpenModelica Continuous integration Integration step Integration method: x i +1 = Φ( x i ) Calculate for the next step t i +1 the new state vector x ( t i +1 ) Evaluate continuous blocks f and g x ( t i +1 ) = f ( x ( t i +1 ) , q ( t i ) , q pre ( t i ) , c ( t i +1 ) , t ) ˙ y ( t i +1 ) = g ( x ( t i +1 ) , q ( t i ) , q pre ( t i ) , c ( t i +1 ) , t ) 12 / 19

  19. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Implementation in OpenModelica Check for event conditions Check for zero-crossing Conditions are converted into zero-crossing functions x < 2 changes from false to true when x − 2 crosses zero If any zero-crossing becomes true an event is fired 13 / 19

  20. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Implementation in OpenModelica Find event time Root-finding method Find root in interval [ t i ; t i +1 ] as event time t e Bisection is a simple and robust method, but it is also relative slowly All methods approximate the root by setting limits on each side of t e Additional we have t e − ǫ and t e + ǫ 14 / 19

  21. Hybrid models in Modelica Implementation in OpenModelica Examples and results Summary Implementation in OpenModelica Handle event Handle event Determine states at t e − ǫ with 1 interpolation Determine continuous blocks by using 2 functions f and g Save all variables as values for pre() 3 and emit them to result file x ( t e − ǫ ) = f ( x ( t e − ǫ ) , q ( t i ) , q pre ( t i ) , c ( t e − ǫ ) , t ) ˙ y ( t e − ǫ ) = g ( x ( t e − ǫ ) , q ( t i ) , q pre ( t i ) , c ( t e − ǫ ) , t ) 15 / 19

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend