diff --git a/src/utils.jl b/src/utils.jl index 47012b012c..4ee221e14f 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -171,7 +171,7 @@ end """ check_equations(eqs, iv) -Assert that ODE equations are well-formed. +Assert that equations are well-formed when building ODE, i.e., only containing a single independent variable. """ function check_equations(eqs, iv) ivs = collect_ivs(eqs) @@ -183,17 +183,6 @@ function check_equations(eqs, iv) isequal(single_iv, iv) || throw(ArgumentError("Differential w.r.t. variable ($single_iv) other than the independent variable ($iv) are not allowed.")) end - - for eq in eqs - vars, pars = collect_vars(eq, iv) - if isempty(vars) - if isempty(pars) - throw(ArgumentError("Equation $eq contains no variables or parameters.")) - else - throw(ArgumentError("Equation $eq contains only parameters, but relationships between parameters should be specified with defaults or parameter_dependencies.")) - end - end - end end """ Get all the independent variables with respect to which differentials are taken. @@ -450,12 +439,6 @@ function find_derivatives!(vars, expr, f) return vars end -function collect_vars(args...; kwargs...) - unknowns, parameters = [], [] - collect_vars!(unknowns, parameters, args...; kwargs...) - return unknowns, parameters -end - function collect_vars!(unknowns, parameters, expr, iv; op = Differential) if issym(expr) collect_var!(unknowns, parameters, expr, iv) diff --git a/test/odesystem.jl b/test/odesystem.jl index 04331008a1..ab28f5cb47 100644 --- a/test/odesystem.jl +++ b/test/odesystem.jl @@ -420,14 +420,7 @@ der = Differential(w) eqs = [ der(u1) ~ t ] -@test_throws ArgumentError ODESystem(eqs, t, vars, pars, name = :foo) - - # equations without variables are forbidden - # https://github.com/SciML/ModelingToolkit.jl/issues/2727 -@parameters p q -@test_throws ArgumentError ODESystem([p ~ q], t; name = :foo) -@test_throws ArgumentError ODESystem([p ~ 1], t; name = :foo) -@test_throws ArgumentError ODESystem([1 ~ 2], t; name = :foo) +@test_throws ArgumentError ModelingToolkit.ODESystem(eqs, t, vars, pars, name = :foo) @variables x(t) @parameters M b k