-
-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
discrete event error for DAE system #3043
Comments
Looks to be due to an odd side effect in the new default ODE algorithm when used with mass matrix ODEs and specifically when it hits an FSAL algorithm as the initial choice. Fixed by SciML/OrdinaryDiffEq.jl#2470 |
This issue still exists. similar to this issue: SciML/OrdinaryDiffEq.jl#2441. For the example above, it works to choose the other solver, such as Rodas4(). But for the default solver, it still occurs the same errors. using ModelingToolkit, DifferentialEquations, Plots
using ModelingToolkit: t_nounits as t, D_nounits as D
@parameters g
@variables x(t) y(t) [state_priority = 10] λ(t)
eqs = [D(D(x)) ~ λ * x
D(D(y)) ~ λ * y - g
x^2 + y^2 ~ 1]
function bb_affect!(integ, u, p, ctx)
println("change the parameters! t = <$(integ.t)> ")
integ.ps[p.g] = ctx
end
reflect = [1] => (bb_affect!, [], [g], [g], 1.1)
pend = ODESystem(eqs, t; name=:pend, discrete_events = reflect)
sys = structural_simplify(pend)
prob = ODEProblem(sys, [x =>1, λ => 0], (0, 1.5), [g => 1], guesses = [y => 1])
sol = solve(prob) the output is:
if I use solver Rodas4(), the output is:
In addition, if I choose a solver like Rodas4(), I think still faces problems. I can solve my mass matrix ODEs on the ModelingToolkit v9.38.0, but I cannot solve that on the later version. The Rodas4() indicates an unstable problem just after the callback function. I know in v9.39 the default and guess scheme has changed, so I have also changed all the default values into guess values and given the initial condition to the ODE problem. Formulating the ODE problem is no problem. Solving ODE problem without the callback is no problem. So I guess there are still some issues there regarding the callback function or reinitialization. |
using the code from the documents to reproduce the error:
I get the error as follows:
Is this a bug? Or do I not use it correctly? I am using the ModelingToolkit v9.39.1.
This is likely related to the reinitialization after the discrete events. If I make the time shorter, there is no error:
I think I am using the discrete event in a correct way, because it works in the ODE system. For example in the following codes:
I just create these cases to show this issue, there is no practical meaning in these cases.
Cross your fingers to fix this problem sooner.
The text was updated successfully, but these errors were encountered: