-
-
Notifications
You must be signed in to change notification settings - Fork 232
Closed
Description
When RHS equations of ODE include negative term, structural_simplify causes the system to become unbalanced.
Example below (note leading sign on y in dx/dt term in failing case).
function ex_bug()
@variables t
@variables x(t)=1
@variables y(t)=1
@parameters pp= -1
der = Differential(t)
sys1 = ODESystem([der(x)~ y; der(y)~ 1-y+x], t, name=:ex)
sys2 = ODESystem([der(x)~ pp*y; der(y)~ 1-y+x], t, name=:ex)
sys3 = ODESystem([der(x)~ -x; der(y)~ 1-y+x], t, name=:ex)
sys4 = ODESystem([der(x)~ -y; der(y)~ 1-y+x], t, name=:ex)
sys1s = structural_simplify(sys1) # works
sys2s = structural_simplify(sys2) # works
sys3s = structural_simplify(sys3) # works
sys4s = structural_simplify(sys4) # fails
end
Tested on
julia 1.7.3
ModelingToolkit v8.18.3
Symbolics v4.10.3
Error is
ERROR: ExtraVariablesSystemException: The system is unbalanced. There are 2 highest order derivative variables and 1 equations.
More variables than equations, here are the potential extra variable(s):
Differential(t)(x(t))
-Differential(t)(x(t))
x(t)
Summarising:
- dx/dt = -x works
- dx/dt = y works
- dx/dt = pp*y with pp negative works
- dx/dt = -y fails
Metadata
Metadata
Assignees
Labels
No labels