Search code examples
modelicaintegral

integrate Modelica variable without influencing state selection


I want to integrate a Modelica variable over time, just for convenience in plotting and post-processing. The variable I want to integrate over time is the power of a compressor so that I get the total energy. The first idea would be to add these lines:

Modelica.Units.SI.Power P_comp;
Modelica.Units.SI.Energy E_comp;
equation
P_comp = der(E_comp);

Is that the recommended way, or are there (better?) alternatives? Is it expected to influence the selection of dynamic states?


Solution

  • Assuming that those two lines are the only ones using E_comp that should work.

    Basically E_comp will be part of its own separate state-selection block and changes there shouldn't influence anything else.

    However, state selection consists of a number of algorithms and heuristics so it is difficult to formally guarantee that any change does not influence it. I could imagine some strange possibilities that would break this, but I don't think anyone has implemented them - and I don't see a use-case for them (except to mess up cases like this).

    And if you instead of integrating want to differentiate a signal it is a lot messier.