-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
feat: improve error message when system contains array equations #3081
feat: improve error message when system contains array equations #3081
Conversation
Why would this be required? The codegen doesn't require it if it's a true ODE. |
It doesn't really work very reliably. @variables x(t)[1:2]
@named sys = ODESystem(D(x) ~ x, t)
sys = complete(sys)
prob = ODEProblem(sys, ...) This errors in I could make these cases work, but all of the fixes boil down to scalarizing the equations and/or unknowns. |
And if there are multiple array unknowns or a mix of array/scalars then codegen also won't work without scalarizing the equations. |
Is that really the case? Symbolics.jl handled this awhile back. |
I see no issue with a temporary error message that told people as a temporary workaround this is required, though I think we should look at some of the codegen here since Symbolics should already handle these cases. |
The problem with the codegen is that this system: julia> @named sys = ODESystem([D(x) ~ x, D(y) ~ t], t, [x..., y]) Generates this code: RuntimeGeneratedFunction(#=in ModelingToolkit=#, #=using ModelingToolkit=#, :((ˍ₋out, ˍ₋arg1, t)->begin
#= /Users/aayush/.julia/packages/SymbolicUtils/ij6YM/src/code.jl:385 =#
#= /Users/aayush/.julia/packages/SymbolicUtils/ij6YM/src/code.jl:386 =#
#= /Users/aayush/.julia/packages/SymbolicUtils/ij6YM/src/code.jl:387 =#
begin
begin
var"x(t)" = view(ˍ₋arg1, 1:2)
begin
begin
#= /Users/aayush/.julia/packages/Symbolics/XnDVB/src/build_function.jl:546 =#
#= /Users/aayush/.julia/packages/SymbolicUtils/ij6YM/src/code.jl:434 =# @inbounds begin
#= /Users/aayush/.julia/packages/SymbolicUtils/ij6YM/src/code.jl:430 =#
ˍ₋out[1] = var"x(t)"
ˍ₋out[2] = t
#= /Users/aayush/.julia/packages/SymbolicUtils/ij6YM/src/code.jl:432 =#
nothing
end
end
end
end
end
end)) Which assumes the first element of Which again points to the fact that the system needs to be scalarized |
Also without |
Okay we should fix that, it's fixable. For now, mention that a temporary workaround is to scalarize or structural simplify. |
bdfcba5
to
f47c5d6
Compare
f47c5d6
to
8dea9b1
Compare
Close #2597
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.