Custom simplifying of ModelingToolkit ODESystem equations

When converting my ODESystem into an ODEProblem to be solved, I find that the full equations are not simplified enough, leading to numerical errors. In particular, one part of the equations looks like this:

Differential(t)(X(t)) ~ exp(a * log(b * X(t)))

This log(...) is causing problems with negative values, when really this can be simplified to (b * X(t))^a so that there aren’t any domain issues.

I found I can simplify the symbolic equations further using a symbolic rewriter from SymbolicUtils.jl. However, I’m not sure what to do from here.

Can I structurally simplify the ODESystem with my own additional rules, or can I supply my own equations to the solver?


The simplification you propose is only valid if you know that the argument of log is positive, hence it cannot be done automatically without this knowledge.

You could write your own simplification pass like you say that modifies the equations in the system. Simply run your pass on the equations and create a new ODESystem using the simplified equations