Closed ceraolo closed 3 weeks ago
It seems to me that no final solution was found.
It actually is available since end of 2017: See https://github.com/modelica/ModelicaStandardLibrary/discussions/4381 for an alternative to the derivative-based or sample-based implementations.
I've had a look at the link.
It seems to me that is shows something different than this ticket's proposal: I see in the comment: here is one drawback, too: LastLib is not tool-agnostic and requires a tool-specific redeclaration of LastLib.Last for the imported FMU.
My implementation, instead, is tool-agnostic, does not require any lib, and is totally unrelated to FMI. It would offer two very simple blocks directly inside MSL. And, looking at the several discussions out there, its seems there is much need for them.
It seems to me that is shows something different than this ticket's proposal
I am afraid I cannot follow. It seems to me that you did not check the references given by #4381. #4381 is a showcase to compensate the drawbacks of the existing sample-based implementation of Modelica.Blocks.Math.SignalExtrema (many artificial time-events) or derivative-based implementation of Modelica.Blocks.Math.ContinuousSignalExtrema (artificial state variable or need for approximation).
Closing in favour of the available blocks or alternatives:
Finding minimum and maximum of a signal over time has been discussed along the time, see: https://github.com/modelica/ModelicaSpecification/issues/109 and https://stackoverflow.com/questions/30732774/modelica-compute-minimum-maximum-of-continuous-variable-over-time.
It seems to me that no final solution was found. In particular It results to me that all solutions proposed in the above stackoverflow ticket do not work in OpenModelica, because of being ill-conditioned or invalid Modelica code.
I think the two models I propose below for min(t) and max(t) work well. I've checked them with Dymola and Openmodelica: they simulate very fast and do not show any sign of numerical difficulties.
In case it is agreed upon, I could create a PR to insert them somewhere in MSL Blocks.
The following tiny package contains the two blocks TimeMin and TimeMax, and a "Test" model, to show their behaviour. The following screenshot clarifies.