SemilinearODEProblem errors when quadratic terms are present #4257
Description
Activity
We are actively looking at this in https://github.com/JuliaComputing/SymbolicCompilerPasses.jl which should scale to larger systems. The nonlinear terms should get implictly filled in (as a structural zero in the jacobian) see JuliaComputing/SymbolicCompilerPasses.jl#22 as an example.
Great ! Does that mean that the
SemilinearODEProblemwill be replaced by theoptimize = ...kwargs inODEProblem? Unfortunately, in the current state, passingSCP_BASICleads to a ~250x increase in time to construct theODEProblem(from ~20s to +5000s).I see you mention the jacobian, would it require to pass
jac = truetoODEProblem(once again, I cannot do this since the size and complexity of my equations lead to OOM)?That compile time is definitely not supposed to blow up like that, I'll look into it.
Any updates on this side ? It looks like SymbolicCompilerPasses.jl is not updated anymore.
The active development for SymbolicCompilerPasses.jl has moved to DyadCompilerPasses.jl as part of the Dyad distribution.
Which I suppose cannot be used without the whole Dyad machinery ?
I have seen this be open for a while now. If no one is working on this issue, I would like to be assigned to work on this
ChrisRackauckas-Claude commented
on Oct 9, 2026 MemberMore actions@dwan-ith thanks, you're welcome to take this. Nobody else is working on it.
It still reproduces in public ModelingToolkit today. With ModelingToolkit v11.45.3 on Julia 1.12, running the MRE from the top of this issue:
sys_1 (lorenz): ArgumentError: System sys_1: variable quadratic_Bₘₜₖ_3 does not exist sys_2 (no quadratic): ArgumentError: New length must be >= 0So the case with no quadratic term, which worked when this was filed, now fails as well. It is probably a related bug in the same path.
Everything needed is in this repository; it does not depend on the separate compiler-passes work mentioned above. Places to start:
src/problems/semilinearodeproblem.jl:SemilinearODEProblem/SemilinearODEFunction, which callcalculate_semiquadratic_formand thenadd_semiquadratic_parameters.src/systems/codegen.jl:calculate_semiquadratic_form, andget_quadratic_form_name/get_quadratic_form_param, which generate thequadratic_Bₘₜₖ_iparameters. The lorenz error suggests aB_imatrix is referenced (state 3) without a matching parameter having been added. My guess is that rows whose quadratic part is all zero are skipped in one place but not the other. Thesys_2error points at the empty-quadratic case.
A good PR would add both systems from this issue as tests (
test/semilinearodeproblem.jl, if that is where the existingSemilinearODEProblemtest lives) and check the solution against the plainODEProblemsolution.🤖 Posted by an AI agent (Claude Code, model claude-opus-5-5[1m]) on behalf of Chris Rackauckas: https://claude.ai/code/session_01H4fXBChQshAwfpLMCpEvAX
Describe the bug 🐞
In the test of
SemilinearODEProblem, the function has a linear part, a non-linear part but no quadratic term. Hence, the test pass. However, on the classic lorenz system, it fails.Expected behavior
Correct initialization.
Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()versioninfo()