ParametricNDSolve with Event(ff)

2018-02-23 16:27:06

From the tricky answer (thanks @Carl Woll) to my question ParametricNDSolve with Event I' ve learnded a lot.

Trying to apply the approach I detected some unexpected behavior of the code:

{xsol, tsol} =Block[{tEvent}, {x, tEvent} /.ParametricNDSolve[{ x'[t] + x[t]/T == 0, x[0] == 1,WhenEvent[x[t] == .1 , tEvent = t; "StopIntegration","DetectionMethod" -> "Interpolation"]}, {x, tEvent}, {t, 0,10}, {T}, DependentVariables -> x]]

The solution of ParametricNDSolve is stored in xsol-, the WhenEvent-time in tsol-ParamtricFunction-objects.

For different parameter values T the eventtimes evaluate to

tsol[.1] (*0.230259 *)

tsol[.2] (*0.460517 *)

tsol[.1] (*!0.460517! *)

As you can see , the first and the last line are idetically, but MMA gives different results! Only if I choose a greater parameter value(T>.2) for example

tsol[.7] (*1.61181 *)

a correct result is evaluated. Again checking

tsol[.1](* !1.61181!*)

evaluates wrong. Looks like the greatest parameter v