0
$\begingroup$

I'm working with the function NDSolve. I give it the time of integration, the time I want it to evaluate my differential equations. Sometimes, it crashes before the end of its attribuated time ; For example, I want to evaluate between 0 and 2000 seconds, but for a reason, it crashed at 1877.99325.... or something.

The fact that it crashed or stopped because a predicted event happened doesn't interest me here. I would like to know if there is a way to extract that time and put it in a variable, like that :

    NDSolve[...]
    (*output of NDSolve*){{f1[x]->InterpolatingFunction[{{0.,1877.99325 (*it's this value that I want !*)}},<>][x],f2[x]->InterpolatingFunction[{{0.,1877.99325 (*it's this value that I want !*)}},<>][x]}}
    t=a way or an other to extract my value
    timecrash=t

How could I do that ? Any help would be great !

EDIT : ... OK, so my answer was deleted and transformed as a comment, and now I can't comment my own answer (which was supposed to be a comment, by the way). But I can't comment the first comments neither because I still need 50 rep (..??) I tried the "Domain" solution, but it doesn't work so far. I tried these lines :

    f["Domain"]/.sol(*this "sol" comes from sol=NDSolve[...]*)//Last

The output is : f[Domain] Another shot : f["Domain"]//Last The output is : Domain

$\endgroup$
10
  • 2
    $\begingroup$ Letting f be any one of your InterpolatingFunction[]s, try f["Domain"] // Last. $\endgroup$ – J. M.'s torpor Jul 9 '15 at 14:19
  • $\begingroup$ what @Guesswhoitis says. also see here $\endgroup$ – chuy Jul 9 '15 at 14:21
  • $\begingroup$ Mmmh nope, nothing happens. I only got the word "Domain" as an output... Could you be more specific ? Is there a package I am supposed to use ? @chuy, I am unfortunately not used to this kind of dense coding, so I don't really see where I could find any piece of answer :o) $\endgroup$ – Darryl Jul 9 '15 at 17:19
  • $\begingroup$ Well, did you assign the output of NDSolve[] to something? $\endgroup$ – J. M.'s torpor Jul 9 '15 at 17:54
  • 1
    $\begingroup$ (You can comment on your own question, regardless of how much rep you have.) $\endgroup$ – J. M.'s torpor Jul 9 '15 at 17:55