This is a problem I noticed when trying to answer this question. Just consider the following toy example:
test = ParametricNDSolveValue[{x'[t] == 1, x[0] == a, WhenEvent[t == 1, Sow@a]},
x, {t, 0, 2}, a];
test@1; // Reap
(* {Null, {{a$224638}}} *)
This behavior becomes annoying when one wants to group the extracted value using the parameter a
as a tag i.e. the 2nd argument of Sow
.
How to understand this behavior? Is it possible to Sow
the parameter value inside WhenEvent
? If not, what's the best workaround for it?
test@1
is executed, at some point aFunction
is constructed and it appears the argumenta$224638
is rewritten in the standard way by adding$
; namely the new argument isa$224638$
. Thus the value ofa
fails to be injected intoSow[a$224638]
. WRI might consider it a bug, if you report it. $\endgroup$