-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a block (based on time events) to calculate the extrema of a signal #3762
Conversation
Based on an old discussion ([Modelica Trac modelica#109](https://trac.modelica.org/Modelica/ticket/109)) and now triggered again via @tinrabuzin. The implementation is based on `Modelica.Blocks.Math.Mean`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some comments:
I don't understand why there is both y_min_last
and y_min
(etc) to me they could be the same variable.
And I would add two warnings as comments:
- The extrema will be approximate as it only return the extremas at the sampling points.
- The sampling will generate many events which may slow down the simulation.
I've added some more documentation. and removed the intermediate discrete variables. Basically I was orienting myself on the implementation of the |
I guess since it has already gone through one review it can probably get elevated from the draft status. Still open to suggestion regarding the name. |
I am very much in favor of the proposed min / max block. However, before adding my review here, I want to make to additional feature requests which are open for discussion:
|
This was done inside the when clause so does not add additional crossover events.
I've added two additional discrete variables @christiankral As for your other request number 2, I really like to keep this block in the way the other blocks work and also keep it simple, I can understand that the functionality you are looking for might come in handy but is probably quite special to your applications. So I'm reluctant to add this to this more simple block. Also this implementation is rather slow due to the sampling nature. So if you want a more sophisticated solution you might also look at https://github.com/beutlich/LastLib which does not generate ANY time events is hence much faster but depends on using the provided FMU (since the functionality was never accepted in Modelica Spec but is part of FMI spec). |
@dietmarw I fully understand your argument. That's OK with me. |
Alternative name proposal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
I don't think the name |
To be honest: The basic definitions of RMS and similar are sampled per basic period. |
Well I know that's the best solution we have (since we have no "continuous" implementation). |
…rating usage with correct setting of sampling frequency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me!
What's wrong with the CI/syntax_checks? |
Sorry when adding comparisonSignals.txt, I realized that's not reasonable using random signals. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after adapting the example, it's fine for me.
It seems the file starts with a UTF8-Byte Order Mark and the CI-check doesn't like that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now.
Nice example @AHaumer. With this example we can actually remove the test one I had added to ModelicaTest. No point in maintaining two models. So I will remove that one again . |
We have now a normal example inside MSL for this block.
Also fine by me now. One of the library officers should merge this then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Sorry for merging... I'm not a library officer. |
@AHaumer Have a look at the FMU-based solution See also https://tinyurl.com/lastlibfmu for some background information and the necessary tool-specific workarounds. The FMU (called Last.fmu) was recently reimplemented (FMI 1,0 ME) and is successfully used for parameter optimization tasks. |
@dietmarw I have two questions:
As we also have a a continuous and a discrete implementation of the models it would also make sense to have |
@christiankral Thanks for the feedback. I had not considered putting this block inside As for the future perspective of one day having a non-sampled version of MinMax (as demonstrated by https://github.com/beutlich/LastLib) I think we also have the problem of clearly establishing what goes into |
Based on an old discussion MO#109 and now triggered again via @tinrabuzin.
The implementation is based on
Modelica.Blocks.Math.Mean
I specifically put this into draft mode and like to discuss this first.
Some notes:
Mean
MinMax
but that one is taken although one could argue that that block really should be placed underBlocks.Routing