Hi out there!
I am trying to use MonteCarloMeasurements.jl together with MTK to solve a differential equation with uncertain parameters.
using ModelingToolkit, DifferentialEquations
using MonteCarloMeasurements
using CairoMakie
@independent_variables t
D = Differential(t)
@parameters my_param = 1.5
@variables xp(t) Tp(t)
function my_problematic_function(xp)
xp^1.8
end
eqs = [
D(xp) ~ my_param * my_problematic_function(xp),
D(Tp) ~ (Tp + my_param * my_problematic_function(xp))
]
@named sys_model = System(eqs, t)
sys = mtkcompile(sys_model)
tspan = (0.0, 30.0)
u0_nom = [
sys.xp => 0.75,
sys.Tp => 293.15]
prob = ODEProblem(sys, u0_nom, tspan; jac=true)
# Redefine prob with uncertain parameters
prob_uncertain = remake(prob; u0 = u0_nom, p=[my_param=> 1.6 ± 0.3])
sol_uncertain = solve(prob_uncertain, Tsit5())
I think I ran into a bug. Whenever I take the power of a variable, I get a stackoverflow-error.
Warning: detected a stack overflow; program state may be corrupted, so further execution might be unreliable.
ERROR: StackOverflowError:
This might need a fix. I would also be interested in workarounds!
Thanks for your efforts in advance.