Can you prevent Julia from erroring out when solving ODE problem, if Domain Error arises?

say you have a parameter in a ODE system of equations.

x = (u[1]) ^ 0.8

du[1] = x - k_elim
(Downstream effects are unaffected ( lets pretend) – So is Good output I dont want to waste.

du[2]= (…)

As an example. Let us assume the initial condition of u is generated randomly , sometimes is negative , sometimes positive for u1 (that will generate the issue). When negative Julia will error out with Domain Error, because say negative value ^ 0.8 will produce real and imaginary component. However, matlab I seen it not to fail, what I think it did is simply populate the -IC throughout all time final output returned after system is solved, and somehow ignore d[1].

I think isoutofdomain to prevent non-negative is meant for preventing solution for going negative given IC is chosen, or at least one that will not solve a Domain Error, so this option will not help me. I am looking for best practices here. Thanks

Is there a way to ignore the error by options, and simulate the rest ? If you would want me to inquiry more about what matlab might be doing before I re-ask the question , I can ask them their matlab side.

I look forward to your response.

Thank you

Christian

Set isoutofdomain but do abs(u[1])^0.8. That way it won’t error but it will also reject any step where it goes negative.

4 Likes

Hi Chris,

That makes a lot of sense, thanks a lot for your quick response and help!

Best

Thanks

Christian