Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ 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)
isempty(vars) && !isempty(pars) &&
throw(ArgumentError("Equation $eq contains only parameters, but relationships between parameters should be specified with defaults or parameter_dependencies."))
end
end
"""
Get all the independent variables with respect to which differentials are taken.
Expand Down
6 changes: 6 additions & 0 deletions test/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ eqs = [
]
@test_throws ArgumentError ModelingToolkit.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)

@variables x(t)
@parameters M b k
eqs = [D(D(x)) ~ -b / M * D(x) - k / M * x]
Expand Down