TransWikia.com

WhenEvent with 2 conditions to stop integration

Mathematica Asked by Ruth Lazkoz on July 26, 2021

I have this code that does not even work for a single condition, say

s = NDSolve[{x'[t] == -y[t] - 0.5 x[t]^2, y'[t] == x[t] - y[t]^3, 
   x[0] == 0.7, y[0] == 0.2, 
   WhenEvent[
    x[t]^2 + y[t]^2 < 0.2, {tMax = t, "StopIntegration"}]}, {x, 
   y}, {t, 300}];

ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0., 30.}]

and I want to go even further and include an additional condition like this

s = NDSolve[{x'[t] == -y[t] - 0.5 x[t]^2, y'[t] == x[t] - y[t]^3, 
   x[0] == 0.7, y[0] == 0.2, 
   WhenEvent[
    x[t]^2 + y[t]^2 < 0.7|| x[t]<1., {tMax = t, "StopIntegration"}]}, {x, 
   y}, {t, 300}]

Any suggestions?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP