Semantics of Co-simulation Algorithms with Simulator Contracts
Integration of simulators for co-simulation algorithms, including techniques for combining simulators to achieve ideal solutions. Dive into case studies and challenges faced in co-simulation environments. Discover strategies for master algorithm control and handling reactivity mismatches.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Semantics of Co-simulation Algorithms with Simulator Contracts Cl udio Gomes, Levi L cio, Hans Vangheluwe
Co-sim: Objective Overture Env. [3] [1] Controller [2] [4] Body Max acceleration? Collision? Battery performance? A technique to combine simulators to approximate ideal solution [5]. [1] Case Study by Kristof Berx , Davy Maes, and Klaas Gadeyne, from Flanders Make [2] http://www.blensor.org/ [3] http://overturetool.org/ [4] https://nl.mathworks.com/products/simulink.html [5] K bler, R., and W. Schiehlen. 2000. Two Methods of Simulator Coupling. Mathematical and Computer Modelling of Dynamical Systems 6 (2): 93 113. https://doi.org/10.1076/1387-3954(200006)6:2;1-M;FT093. 2
Co-sim: Interfaces Overture Env. Controller Body Env. Simulator Control Simulator Body Simulator Solver Solver Model Model Solver Model Env. Body Controller setIn( ) getOut ( ) doStep( , H) 3
Co-sim: Master Algorithm Control Simulator Env. Simulator Env. Master Controller Body Body Simulator 4
Env. Co-sim: Main Challenge Controller Body Ctrl. A Env. A Master A Body. A Ctrl. A Env. A MasterB Body. A Ctrl. B Env. B Master A Body. B 5
Issue 1: Reactivity Match FMU1 FMU1 FMU2 getOut( ) setIn( )doStep( , H) doStep( , H) Master S2 S1 getOut( ) setIn( ) t->t+H t t->t+H t doStep(FMU1, ) getOut(FMU1, ) setIn(FMU2, ) doStep(FMU2, ) getOut(FMU2, ) setIn(FMU1, ) FMU2 t-H t t+H 6
Issue 1: Reactivity Mismatch FMU1 FMU1 FMU2 doStep( , H) doStep( , H) getOut( ) setIn( ) Master S2 S1 getOut( ) setIn( ) t->t+H t t->t+H t getOut(FMU1, ) setIn(FMU2, ) getOut(FMU2, ) setIn(FMU1, ) doStep(FMU1, ) doStep(FMU2, ) FMU2 t-H t t+H 7
Issue 2: Feedthrough Match FMU1 FMU2 doStep( , H) doStep( , H) setIn( ) getOut( ) setIn( ) getOut( ) ?1 ?1 ?1 ?1 ?2 ?2 ?2 ?2 setIn( ) getOut( ) setIn( ) getOut( ) t +H t +H doStep(FMU1, ) doStep(FMU2, ) getOut(FMU1, y2, ) setIn(FMU2, u2, ) getOut(FMU2, y2, ) setIn(FMU1, u2, ) getOut(FMU2, y1, ) setIn(FMU1, u1, ) getOut(FMU1, y1, ) setIn(FMU2, u1, ) ?(? + ?) = ? ? ? ,? ? |?(? + ? ?(?) = ?(?(?),?(?)) 8
Issue 2: Feedthrough Mismatch doStep( , H) doStep( , H) getOut( ) ?1 ?1 ?1 ?1 ?2 ?2 ?2 ?2 t +H t +H doStep(FMU1, ) doStep(FMU2, ) getOut(FMU1, y1, ) ?(? + ?) = ? ? ? ,? ? |?(? + ? ?(?) = ?(?(?),?(?)) ?(? + ?) = ?(?(? + ?),?(?)) 9
Problem doStep(FMU1, ) doStep(FMU2, ) getOut(FMU1, y2, ) setIn(FMU2, u2, ) getOut(FMU2, y2, ) setIn(FMU1, u2, ) getOut(FMU2, y1, ) setIn(FMU1, u1, ) getOut(FMU1, y1, ) setIn(FMU2, u1, ) Does satisfy Reactive Input Reactive Input Delayed Input FMU1 FMU2 ?1 ?1 ?1 ?1 ?2 ?2 ?2 ?2
Approach 1. Formalize feed-through, reactivity contracts, and cosim scenario 2. Define operational semantics of master algorithms w.r.t 1. 3. Does a given master algorithm satisfy a given scenario? 1. Bonus: generate a master 11
Contract Representation Delayed Input Feedthrough ?? ?? d ? ? r ?? ?? Reactive Input 13
Symbolic State Representation Timestamp 0,?,? + ? Defined ???,?? ?? ? ?? ? + ? ? ? + ? d ? ? ?+H ? r ?? ?? Defined ???,?? Timestamp 0,?,? + ? 14
Generic MA and Symbolic State ?? 0 ?? 0 0 0 d ? ? 0 0 r ?? ?? 15
Generic MA and Symbolic State ?? ? +? ?? +? +? ? ? +? ? d ? ? +? ? ? +? r ?? ?? 16
Example Symbolic Execution ?? ? +? ?? +? ? +? +? ? ? d ? ? ? +? ? +? r ?? ?? ???????(?) ????(??) ????(??) ???????(?) ????(??) ????(??) 17
Scenario Formalization ?? ?? ? d ? r ?? ?? 18
State Formalization ? ?? ?? d ? r ?? ?? 19
GetOut Operation ? ?? ?? ? d ?? ?? r Example: 20
DoStep Operation ? ?? ?? ? d ?? r ?? Example: 22
Master Algorithm ? ?? ?? ? d Example: ?? r ?? 23
Industrial Case Controller runs at ? = 10 6? Plant and Load are connected by a power bond. 24
New FMU Old FMU Example Behaviors Adaptation Fixed-step Jacobi, step size 1st-order input interpolations, step size Combination of: 1st-order input interpolations, causality preservation, and energy conservation, in selected signals 25 Benedikt, M, D Watzenig, J Zehetner, and A Hofer. 2013. NEPCE-A Nearly Energy Preserving Coupling Element for Weak-Coupled Problems and Co-Simulation. In IV International Conference on Computational Methods for Coupled Problems in Science and Engineering, Coupled Problems, 1 12. Ibiza, Spain.
Conclusions 1. Formalized feed-through, reactivity contracts, and cosim scenario 2. Defined operational semantics of master algorithms w.r.t 1. 3. Limitations: 1. Not considered generating all master algorithms 1. There s an infinite # of them, but only finitely many interesting ones 2. Not all are equal w.r.t. performance, etc. 26
Q&A Thank you! 27
Appendix 28
End of Co-sim Step. setIn( ) doStep( , H) getOut( ) Control Simulator Env. Simulator doStep( , H) getOut( ) getOut( ) getOut( ) setIn( ) Start of new step Env. Master Controller Body setIn( ) getOut( ) Body Simulator doStep( , H) 29
CosimStep = (set|get|doStep)+ Master = CosimStep+ getOut( ) Control Simulator Env. Simulator Env. Master Controller Body Body Simulator 30
Env. Co-sim: Main Challenge Controller Body Ctrl. A Env. A Master A Body. A Ctrl. A Env. A MasterB Body. A Ctrl. B Env. B Master A Body. B 31
Interactions with FMU FMU1 FMU2 doStep( , H) doStep( , H) getOut( ) setIn( ) getOut( ) setIn( ) t->t+H t t->t+H t doStep(FMU1, ) getOut(FMU1, ) setIn(FMU2, ) doStep(FMU2, ) getOut(FMU2, ) setIn(FMU2, ) 32
Interactions with FMU FMU1 FMU2 doStep( , H) doStep( , H) getOut( ) setIn( ) getOut( ) setIn( ) t->t+H t t->t+H t getOut(FMU1, ) setIn(FMU2, ) getOut(FMU2, ) setIn(FMU2, ) doStep(FMU1, ) doStep(FMU2, ) 33
Interactions with FMU getOut( ) setIn( ) t t doStep( , H) getOut( ) setIn( ) t->t+H t t 34
Interaction Mismatch Example Master assumes interpolation FMU implements interpolation Master assumes extrapolation FMU implements interpolation 35
Problem Statement FMUs, developed by independent suppliers, can impose constraints on interactions. We need a schedule that satisfies these. 36
Our Solution Modelled everything: Model constraints Model composition of constrained FMUs Model orchestrator execution (SOS) At the right level of abstraction: Symbolic orchestration execution With the most appropriate formalism: Tried Petri-nets, failed. Settled for Prolog 37
Example Operational Semantics getOut(F1, y1), setIn(F2, u2), getOut(F2, y2), setIn(F1, u1), doStep(F1), (u2, undefined, t) (y1, undefined, t) (F1, defined, t) (F2, defined, t) (y2, undefined, t) (u1, undefined, t) 38
Example Operational Semantics getOut(F1, y1), setIn(F2, u2), getOut(F2, y2), setIn(F1, u1), doStep(F1), (u2, undefined, t) (y1, defined, t) (F1, defined, t) (F2, defined, t) (y2, undefined, t) (u1, undefined, t) 39
Example Operational Semantics getOut(F1, y1), setIn(F2, u2), getOut(F2, y2), setIn(F1, u1), doStep(F1), (u2, defined, t) (y1, defined, t) (F1, defined, t) (F2, defined, t) (y2, undefined, t) (u1, undefined, t) 40
Example Operational Semantics getOut(F1, y1), setIn(F2, u2), getOut(F2, y2), setIn(F1, u1), doStep(F1), (u2, defined, t) (y1, defined, t) (F1, defined, t) (F2, defined, t) (y2, defined, t) (u1, undefined, t) 41
Example Operational Semantics getOut(F1, y1), setIn(F2, u2), getOut(F2, y2), setIn(F1, u1), doStep(F1), (u2, defined, t) (y1, defined, t) (F1, defined, t) (F2, defined, t) (y2, defined, t) (u1, defined, t) 42
Example Operational Semantics getOut(F1, y1), setIn(F2, u2), getOut(F2, y2), setIn(F1, u1), doStep(F1), (u2, defined, t) (y1, undefined, tH) (F1, defined, tH) (F2, defined, t) (y2, defined, t) (u1, defined, t) 43
Example Operational Semantics ,getOut(s1, y1), setIn(s2, u2), doStep(s2), getOut(s2, y2), setIn(s1, u1) (u2, defined, t) (y1, defined, tH) (F1, defined, tH) (F2, defined, t) (y2, defined, t) (u1, defined, t) 44
Example Operational Semantics ,getOut(s1, y1), setIn(s2, u2), doStep(s2), getOut(s2, y2), setIn(s1, u1) (u2, defined, tH) (y1, defined, tH) (F1, defined, tH) (F2, defined, t) (y2, defined, t) (u1, defined, t) 45
Example Operational Semantics ,getOut(s1, y1), setIn(s2, u2), doStep(s2), getOut(s2, y2), setIn(s1, u1) (u2, defined, tH) (y1, defined, tH) (F1, defined, tH) (F2, defined, tH) (y2, undefined, tH) (u1, defined, t) 46
Example Operational Semantics ,getOut(s1, y1), setIn(s2, u2), doStep(s2), getOut(s2, y2), setIn(s1, u1) (u2, defined, tH) (y1, defined, tH) (F1, defined, tH) (F2, defined, tH) (y2, defined, tH) (u1, defined, t) 47
Example Operational Semantics ,getOut(s1, y1), setIn(s2, u2), doStep(s2), getOut(s2, y2), setIn(s1, u1) (u2, defined, tH) (y1, defined, tH) (F1, defined, tH) (F2, defined, tH) (y2, defined, tH) (u1, defined, tH) 48
Conclusions We built a symbolic operational semantics for Co-simulation. Given a set of constrained FMUs, we can: Decide if a schedule is valid, and Compute a valid schedule. In the future, we intend to: Derive FMU constraints, given an intended schedule Useful for OEM/Supplier relations. 49