Skip to content

add isautonomous #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2021
Merged
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ModelingToolkit"
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
version = "5.6.4"
version = "5.7.0"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
7 changes: 6 additions & 1 deletion src/systems/diffeqs/abstractodesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ jacobian_sparsity(sys::AbstractODESystem) =
jacobian_sparsity([eq.rhs for eq ∈ equations(sys)],
[dv for dv in states(sys)])

function isautonomous(sys::AbstractODESystem)
tgrad = calculate_tgrad(sys;simplify=true)
all(iszero,tgrad)
end

function DiffEqBase.ODEFunction(sys::AbstractODESystem, args...; kwargs...)
ODEFunction{true}(sys, args...; kwargs...)
end
Expand Down Expand Up @@ -198,7 +203,7 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
$fsym(u,p,t) = $f_oop(u,p,t)
$fsym(du,u,p,t) = $f_iip(du,u,p,t)
end

tgradsym = gensym(:tgrad)
if tgrad
tgrad_oop, tgrad_iip = generate_tgrad(sys, dvs, ps;
Expand Down
1 change: 1 addition & 0 deletions test/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ sys = ODESystem(eqs)
@test all(isequal.(states(sys), [x, y, z]))
@test all(isequal.(parameters(sys), [σ, β]))
@test equations(sys) == eqs
@test ModelingToolkit.isautonomous(sys)

# issue 701
using ModelingToolkit
Expand Down