modelica / fmi-standard

Specification of the Functional Mock-up Interface (FMI)
https://fmi-standard.org/
Other
262 stars 85 forks source link

Usage of FMI for steady state simulation #1920

Open christian-wolf-eks opened 8 months ago

christian-wolf-eks commented 8 months ago

After make a rather small research-based market analysis/statistics, it became apparent that the process industry is not directly needing dynamic models. Their typical workflow is twofold:

  1. The components of a chemical reactor needs to be selected according to the requirements of various kinds. In order to do so, they claimed to rely on steady state calculations and optimize these for the aimed operation point.
  2. Generation of local models and deriving controller algorithms (like MPC) to stabilize the plants in the steady states.

The plant construction process is characterized by selection of pre-existing components and combining these in a smart fashion. Thus, it would make sense to ship simulation model(s) with these components by the vendors. That would allow to create both simulations in a component-based way (think SSP), ideally based on FMI.

For the dynamic models (2. above) this was possible in general. The steady state simulation models (number 1 above) however is not really possible to be handled in the current way. The only option to calculate the steady state was to use the model exchange models and optimize the state such that the derivatives vanish. However, this is more of a hack than the desired application of the FMU interface.

Thus, it might be desirable to extend the scope and add considerations for such steady state calculations either to the standard/an extension or by declaring the existing restrictions and boundary conditions in the documentation.

This issue was created after the discussion in Sindelfinden in Nov, 2023 at Akkodis related to possible extensions and user requirements. I recreated this issue here as I put it initially in the wrong repository.

chrbertsch commented 8 months ago

@hubertus65 : Does Modelon use FMI in the context of steady-state simulation?

chrbertsch commented 7 months ago

Discussion at design web-meeting:

chrbertsch commented 7 months ago

@ tool vendors: Do you already use FMI for steady state simulation?
Do you solve this in initialization mode? What is missing?

KarlWernersson commented 7 months ago

You can do this in Dymola by adding equations for the FMU's derivative and modify the fixed attribute to false on some state (that has a fixed initial value) to balance out the equations.

The FMU test package containing Modelica models made for testing FMI 2 capabilities that created by DLR for the FMI 2 release contains two simple test cases for this. FMITest.Initialization.LinearSystems.SimpleSteadyState FMITest.Initialization.LinearSystems.SimpleSteadyState2

Edit: Needs to be model exchange FMU for it to work in Dymola as the States and state derivatives are not exposed in that way for our co-simulation import, but should fully possible to solve for CS as well as long as we don't want to affect the derivatives after initialization and the FMU has exposed the derivatives in modelStructure

chrbertsch commented 7 months ago

FMI Design Meeting: Klaus: is this all done in initialization? Christian W.: in the above use cases: intitialization --> control engineering --> calculate once again Klaus: Each FMU can calculate its steady state. For connected FMUs one has to solve it. Karl: For connected FMUs more complicated. Klaus: We have the initial "approx" and "exact" to help for the solution Christian B: Shall we explain this and provide examples in the implementer's guide? Torsten S: Do we state in the spec, that the FMU has to support this? Karl: Yes: Klaus: but many FMUs do not support this. Torsten S: for GRT code from Simulink this is not supported Klaus: we cannot enforce this. the initializiation equation could be "every output is zero". Karl: for efficient implementation you need the dependencies and directional derivatives. Klaus: We do partial derivatives numerically, but use the structure. (this was faster, some years ago) Christian: could "Steady state calculation" be a "feature" of FMUs in the "feature list"? And describe it in the implementers' guide? Torsten: should there be a capability flag? Klaus: It is more a hint. you can already give structural information for the initial equation. (e.g. no dependency on inputs). But often the FMUs do not provide dependency information. Torsten: the difference between empty string and not having the attribute is very important. Should be mentioned in the implementers' guide. Klaus: Avoiding initialization requires user intervention. Klaus: I think we already have non normative text. Torsten: We should have explanations in the implementers' guide. Karl: in FMI the initialization is not realtime capable. Christian W: Could we create a minimal example? Klaus: you need several FMUs or an FMU with a feedback loop. Christian: we should have some description Klaus: we have a section on "artificial vs. real algebraic loops", which is similar.

chrbertsch commented 7 months ago

Klaus: The pseudo-code in https://fmi-standard.org/docs/3.0.1/#algebraic-loops already contains a fixed-point iteration The steady state calculation is a use case, that could be handled with the exisiting mechanisms