Question: Constrained solutions for differential equations

Hello! I'm really craving for a piece of advice from you pros.
For simplicity's sake let's start with this made-up system.

where

and

Here is solver options with pair of events to get idea about what I want.

Plot of solution



For my purposes it's essential to restrict variables m and D(fi1)(t), D(fi2)(t). While it's very convenient to use piecewise() operator in first case with m, I simply can't find working method for second.

I've tried various events for dsolve, but they trigger only once and I failed to provide continuous restriction on the derivatives in question.

That's what I need in the end:


If there's a way to obtain this result, please, don't make secrets of it :) Thank you in advance!

Please Wait...