Group Abstract Group Abstract

Message Boards Message Boards

WhenEvent issue with vector valued diffeq

Posted 11 years ago
POSTED BY: David Keith
4 Replies
Posted 11 years ago

Yes! Thank you, Ivan. That works fine. And the plot is correct if plotted {t,0,tf}. The mistake was mine in thinking a semicolon could separate parts of a compound statement as actions for WhenEvent. The documentation says actions in a list are evaluated sequentially.

Best regards, David

POSTED BY: David Keith

Yes, sorry, I removed tf = t, if kept the code produce wrong domain. This modification gives correct domain and tf (the plot is still wrong):

eqs = {r''[t] == -{0, 1}, r'[0] == {2, 3}, r[0] == {0, 0}, 
   WhenEvent[r[t][[2]] < 0, {"StopIntegration", tf = t}]};
sol = NDSolveValue[eqs, r, {t, 0, 8}];
sol["Domain"]
tf

{{0., 6.}}

6.

I.M.

POSTED BY: Ivan Morozov
Posted 11 years ago
POSTED BY: David Keith

Hi,

In you example the domain of sol is (0.,6.), looks like when interpolation function is plotted it's values outside the domain are extrapolated.

I.M,

POSTED BY: Ivan Morozov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard