Skip to content

Event handling for ME2 on consecutive simulations with different inputs #72

@dhblum

Description

@dhblum

I wanted to report an issue with simulating and ME2 FMU in consecutive steps without initialization between steps where the input changes from one step to the next. For example, initialize and simulate from 0 to 100 s with input u1 = 0, then simulate (without initialization) from 100 to 200 s with input u1 = 1. There seems to be a problem with identifying and accounting for events that may be triggered by this change in input from one step to the next.

I think I've identified a problem at line 345 of fmi_algorithms_drivers.py (here). Note that 346 performs an event check if the FMU is ME1, however, does not do this check if the FMU is ME2, thereby seemingly skipping this check altogether. My proposal is to insert the following code after line 349:

        elif isinstance(self.model, fmi.FMUModelME2):
            self.model.event_update()    

I created and attached to this comment a test Modelica model that can be compiled into an FMU and then simulated using the python script. The Modelica model looks like the following:

image

The results of running the Python script with and without the fix I propose looks like the following:

image

I am not sure if I am missing something that either makes this a non-issue or if there's more to be done to fix, but I wanted to report and see what the developers and community thought.

I tested using Python 2.7.17, pyfmi v2.5, on Ubuntu 18.04.5 LTS.

eventTest_mo.txt
eventTest_py.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions