Skip to content

Commit

Permalink
Revert "Check that equations contain variables" (commited to wrong br…
Browse files Browse the repository at this point in the history
…anch and pushed it...)

This reverts commit 47cdd3b.
  • Loading branch information
hersle committed Jul 16, 2024
1 parent 47cdd3b commit 836bc2e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
19 changes: 1 addition & 18 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 1 addition & 8 deletions test/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 836bc2e

Please sign in to comment.