I would like to use StopIntegration in WhenEvent, when more than one condition should be checked. For example, in the code below I would like to integrate until either q1[t] == 0 or q2[t] == 0
sol[s_] :=
NDSolve[{q1'[t] == -q2[t], q2'[t] == q1[t], q1[0] == Cos[s],
q2[0] == Sin[s],
WhenEvent[
q1[t] == 0 || q2[t] == 0, {tmax = t, "StopIntegration"}]}, {q1,
q2}, {t, 0, 10}]
But it does not work, when I try to check it
Manipulate[
ParametricPlot[
Evaluate[{q1[t], q2[t]} /. sol[s], {t, 0, tmax},
PlotRange -> 1], {{s, Pi/4}, 0, 2 Pi}]
although it works perfectly if I leave only one of the conditions. Of course in this simple example I can just write q1[t]q2[t]==0, but I would like to understand how to proceed in general with more complex conditions.
Thank you in advance.
WhenEvent[{q1[t] == 0, q2[t] == 0}, {youractions}]. Take a look at the "Scope" section of the WhenEvent docs, under "Events", for a similar example. – MarcoB Jun 10 '15 at 13:05q2[t] == 0 && q1[t] > 0works, butq1[t] > 0 && q2[t] == 0does not. – Ivan Jun 10 '15 at 13:20WhenEventexpression work at a time. It would stand to reason that it should accept compound conditions, but either it just doesn't, or I have not found a way to coax it to do it yet... – MarcoB Jun 10 '15 at 22:08f == 0andf == 0 && pred, also with<,>, andMod, are special cases inWhenEvent(see http://mathematica.stackexchange.com/questions/39374/inconsistent-behavior-of-whenevent/39393#39393), compared to the generalpred, where the "event" ispredchanging fromFalsetoTrue. – Michael E2 Jun 10 '15 at 22:21