Skip to content

Commit 836bc2e

Browse files
committed
Revert "Check that equations contain variables" (commited to wrong branch and pushed it...)
This reverts commit 47cdd3b.
1 parent 47cdd3b commit 836bc2e

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

src/utils.jl

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ end
171171
"""
172172
check_equations(eqs, iv)
173173
174-
Assert that ODE equations are well-formed.
174+
Assert that equations are well-formed when building ODE, i.e., only containing a single independent variable.
175175
"""
176176
function check_equations(eqs, iv)
177177
ivs = collect_ivs(eqs)
@@ -183,17 +183,6 @@ function check_equations(eqs, iv)
183183
isequal(single_iv, iv) ||
184184
throw(ArgumentError("Differential w.r.t. variable ($single_iv) other than the independent variable ($iv) are not allowed."))
185185
end
186-
187-
for eq in eqs
188-
vars, pars = collect_vars(eq, iv)
189-
if isempty(vars)
190-
if isempty(pars)
191-
throw(ArgumentError("Equation $eq contains no variables or parameters."))
192-
else
193-
throw(ArgumentError("Equation $eq contains only parameters, but relationships between parameters should be specified with defaults or parameter_dependencies."))
194-
end
195-
end
196-
end
197186
end
198187
"""
199188
Get all the independent variables with respect to which differentials are taken.
@@ -450,12 +439,6 @@ function find_derivatives!(vars, expr, f)
450439
return vars
451440
end
452441

453-
function collect_vars(args...; kwargs...)
454-
unknowns, parameters = [], []
455-
collect_vars!(unknowns, parameters, args...; kwargs...)
456-
return unknowns, parameters
457-
end
458-
459442
function collect_vars!(unknowns, parameters, expr, iv; op = Differential)
460443
if issym(expr)
461444
collect_var!(unknowns, parameters, expr, iv)

test/odesystem.jl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,7 @@ der = Differential(w)
420420
eqs = [
421421
der(u1) ~ t
422422
]
423-
@test_throws ArgumentError ODESystem(eqs, t, vars, pars, name = :foo)
424-
425-
# equations without variables are forbidden
426-
# https://github.com/SciML/ModelingToolkit.jl/issues/2727
427-
@parameters p q
428-
@test_throws ArgumentError ODESystem([p ~ q], t; name = :foo)
429-
@test_throws ArgumentError ODESystem([p ~ 1], t; name = :foo)
430-
@test_throws ArgumentError ODESystem([1 ~ 2], t; name = :foo)
423+
@test_throws ArgumentError ModelingToolkit.ODESystem(eqs, t, vars, pars, name = :foo)
431424

432425
@variables x(t)
433426
@parameters M b k

0 commit comments

Comments
 (0)