Skip to content

Commit f9e4e19

Browse files
authored
Merge pull request #810 from SciML/isautonomous
add isautonomous
2 parents 5f9d51b + b6a4d3c commit f9e4e19

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkit"
22
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
33
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
4-
version = "5.6.4"
4+
version = "5.7.0"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ jacobian_sparsity(sys::AbstractODESystem) =
9999
jacobian_sparsity([eq.rhs for eq equations(sys)],
100100
[dv for dv in states(sys)])
101101

102+
function isautonomous(sys::AbstractODESystem)
103+
tgrad = calculate_tgrad(sys;simplify=true)
104+
all(iszero,tgrad)
105+
end
106+
102107
function DiffEqBase.ODEFunction(sys::AbstractODESystem, args...; kwargs...)
103108
ODEFunction{true}(sys, args...; kwargs...)
104109
end
@@ -198,7 +203,7 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
198203
$fsym(u,p,t) = $f_oop(u,p,t)
199204
$fsym(du,u,p,t) = $f_iip(du,u,p,t)
200205
end
201-
206+
202207
tgradsym = gensym(:tgrad)
203208
if tgrad
204209
tgrad_oop, tgrad_iip = generate_tgrad(sys, dvs, ps;

test/odesystem.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ sys = ODESystem(eqs)
243243
@test all(isequal.(states(sys), [x, y, z]))
244244
@test all(isequal.(parameters(sys), [σ, β]))
245245
@test equations(sys) == eqs
246+
@test ModelingToolkit.isautonomous(sys)
246247

247248
# issue 701
248249
using ModelingToolkit

0 commit comments

Comments
 (0)