Describe spatialDistribution as event triggering#3795
Describe spatialDistribution as event triggering#3795henrikt-ma wants to merge 4 commits intomodelica:masterfrom
Conversation
|
Note that this will take some time, due to the need to check the implementations (which are more complicated than for delay). |
|
I had the impression that we already had the necessary test implementations in some tools? @casella, @gkurzbach? |
Well, at least it will take more time for me to check (including checking whether we have a test-implementation). Specifically for the test-implementations it would be good to understand exactly which events are propagated (just discrete-time expressions? any change? any minimum discontinuity to avoid events bouncing back and forth and generating more and more events?) |
Just like However, I realize that
I'd say we should specify this with the same level of detail as for
|
80a8fab to
68d5382
Compare
|
I notice that it was now generalized to non-Reals. I can to some extent see that it makes sense, but I'm not sure if I have seen any use-case for it - and I don't know how much extra issues it brings. It may be easier to skip that part.
I don't know the consequence of this. I think I get the point that non-events for positiveVelocity imply that the spatialDistribution doesn't generate events and thus isn't discrete-time, even if you send in non-Reals; but there might be additional subtle issues. |
Yes, I found it best to put everything on the table. Based on my experience with implementing |
At least I have tried to separate the concerns of event generation within |
|
@MarkusOlssonModelon and @gkurzbach state that implemented in Modelon Impact and SimulationX. |
| The expressions \lstinline!in0!, \lstinline!in1!, \lstinline!out0!, and \lstinline!out1! shall all be subtypes of a common type $T$, where $T$ is either \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, or an enumeration type. | ||
| Further, \lstinline!x! shall be a subtype of \lstinline!Real!, \lstinline!positiveVelocity! is a \lstinline!Boolean!, and \lstinline!initialPoints! and \lstinline!initialValues! are arrays of subtypes of $T$ and \lstinline!Real!, respectively. |
There was a problem hiding this comment.
| The expressions \lstinline!in0!, \lstinline!in1!, \lstinline!out0!, and \lstinline!out1! shall all be subtypes of a common type $T$, where $T$ is either \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, or an enumeration type. | |
| Further, \lstinline!x! shall be a subtype of \lstinline!Real!, \lstinline!positiveVelocity! is a \lstinline!Boolean!, and \lstinline!initialPoints! and \lstinline!initialValues! are arrays of subtypes of $T$ and \lstinline!Real!, respectively. | |
| The expressions \lstinline!in0!, \lstinline!in1!, \lstinline!out0!, and \lstinline!out1! shall all be subtypes of\lstinline!Real!. | |
| Further, \lstinline!x! shall be a subtype of \lstinline!Real!, \lstinline!positiveVelocity! is a \lstinline!Boolean!, and \lstinline!initialPoints! and \lstinline!initialValues! are arrays of subtypes of \lstinline!Real!. |
I should have realized this earlier, but non-Real spatialDistribution will cause problems for the initialValues.
Basically we normally interpolate between the initial points, but that doesn't work if the values are non-Reals.
I'm sure that it could be handled in some way, but I'm not confident that we will find all the issues before the release - and since there wasn't that much push for non-Real spatialDistribution I think it can wait.
| Further, when a \lstinline!spatialDistribution!-expression is non-discrete-time and event generation is enabled (not appearing inside \lstinline!noEvent!), discontinuities in \lstinline!in0! and \lstinline!in1! may be preserved in the distribution $z$, and trigger events when appearing in any of the operator outputs. | ||
| It is a quality of implementation to avoid excessive generation of events by only preserving significant discontinuities. | ||
|
|
||
| Disregarding the event-triggering handling of discontinuities, \lstinline!spatialDistribution! for $T$ being \lstinline!Real! can be described in terms of the pseudo-code given as a block: |
There was a problem hiding this comment.
| Disregarding the event-triggering handling of discontinuities, \lstinline!spatialDistribution! for $T$ being \lstinline!Real! can be described in terms of the pseudo-code given as a block: | |
| Disregarding the event-triggering handling of discontinuities, \lstinline!spatialDistribution! can be described in terms of the pseudo-code given as a block: |
Similarly.
HansOlsson
left a comment
There was a problem hiding this comment.
Overall good, but some issue with non-Real initial values.
Since that case seems a bit esoteric I think it is better to delay that and get the other changes.
| This allows the direct computation of the solution based on interpolating the boundary conditions. | ||
|
|
||
| When a \lstinline!spatialDistribution!-expression is discrete-time (see \cref{discrete-time-expressions}), events will be generated in order to allow the value to change at the correct points in time, and it is an error if both \lstinline!x! and \lstinline!in0! or \lstinline!in1! change at the same event. | ||
| Further, when a \lstinline!spatialDistribution!-expression is non-discrete-time and event generation is enabled (not appearing inside \lstinline!noEvent!), discontinuities in \lstinline!in0! and \lstinline!in1! may be preserved in the distribution $z$, and trigger events when appearing in any of the operator outputs. |
There was a problem hiding this comment.
I also realized that this line suggest that one can write:
(, out1) = noEvent(spatialDistribution(in0, 0, x, true, {0,1}, {0,0}));
to disable event generation for spatialDistribution, similarly as for other operators.
That makes sense, but two points:
- That should preferably be clarified, as
noEventwas previously described for "expressions", but multi-returning functions aren't really "expressions". - If
in0is an integer expression it would seem that we generate a non-discrete-time integer - is that intentional? This might indicate that there might be additional problems for non-RealspatialDistribution.
We decided to make both
delayandspatialDistributionevent triggering operators, but so far the specification has only been updated fordelay. This PR does it also forspatialDistribution.At least to me, trying to capture the intricacies of event triggering in the pseudo-code for
spatialDistributiondoesn't sound like a good idea. Instead, I'd like us to consider the option of throwing out the pseudo-code, now that it is becoming even more remote from an actual implementation.Note that we haven't test-implemented this in System Modeler, so I am counting on others to verify that the few things I have added regarding event triggering is in agreement with what has already been "test-implemented" in other tools.