AnswerBun.com

Exiting CrossSlidingDiscontinuity in NDSolve to follow equilibrium curve

Mathematica Asked on December 3, 2020

I am trying to figure out how to get the solution curve to an NDSolve to slide along once it reaches a boundary and then to exit the CrossSlidingDiscontinuity once it reaches an equilbrium curve and follow the equilibrium curve back within a set boundary.

If the x[t] solution curve reaches the boundary edge on this interval [0,1] I needed it to slide along this boundary, hence I used CrossSlidingDiscontinuity. However once, the solution reaches the yellow equilibrium sine curve, I need it to exit the sliding discontinuity and follow the equilibrium curve. I tried using EventLocator (in the code below). It manages to fall back within [0,1] but does not follow the equilibrium sine curve. I attached the image of the plot below.

I also tried using two WhenEvents (one for when x[t] reaches 1 triggering the sliding and one where x[t] reaches the sine curve triggering to follow the sine curve) but only the sliding WhenEvent was triggered.

Here is my code:

normalDE2[x_, t_] := -(x + 1/2)*(x - 1/2)*(x - (1 + .1*Sin[t]));

testDE3[x_?NumberQ, t_] := 
If[0 < x < 1, normalDE2[x, t], -1*normalDE2[x, t]];

sol4 = NDSolve[{x'[t] == testDE3[x[t], t], x[0] == .75, 
WhenEvent[{x[t] == 1, x[t] == 0}, 
{Print[t],"CrossSlidingDiscontinuity"}]}, 
x, {t, 0, 10},
Method -> {"EventLocator", "Event" -> {x[t] - (1 +.1*Sin[t])},
"EventAction" :> {{x[t] -> (1 + .1*Sin[t])}}}];

Plot[{x[t] /. sol4, (1 + .1*Sin[t])}, {t, 0, 10}, 
Frame -> True, GridLines -> Automatic] 

Plot ImagePlot Image

Add your own answers!

Related Questions

Making histogram from a vector

1  Asked on June 24, 2021 by physmath

   

Table Glitch / Error with binary data

0  Asked on June 23, 2021 by atlasgeo

   

Search in a Dataset

0  Asked on June 22, 2021 by andr-paschold

   

How to make a table from two lists?

5  Asked on June 22, 2021 by user2895279

     

Stationarity Check of TimeSeries

0  Asked on June 21, 2021 by curiousdatascientist

   

Non-linear equation

2  Asked on June 20, 2021 by armin-sharafi

         

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir