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]
```

Get help from others!

Recent Questions

- How can I transform graph image into a tikzpicture LaTeX code?
- How Do I Get The Ifruit App Off Of Gta 5 / Grand Theft Auto 5
- Iv’e designed a space elevator using a series of lasers. do you know anybody i could submit the designs too that could manufacture the concept and put it to use
- Need help finding a book. Female OP protagonist, magic
- Why is the WWF pending games (“Your turn”) area replaced w/ a column of “Bonus & Reward”gift boxes?

Recent Answers

- Joshua Engel on Why fry rice before boiling?
- Jon Church on Why fry rice before boiling?
- Lex on Does Google Analytics track 404 page responses as valid page views?
- Peter Machado on Why fry rice before boiling?
- haakon.io on Why fry rice before boiling?

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