Skip to content

Commit 73df468

Browse files
Merge pull request #537 from AayushSabharwal/as/mtkv10
refactor: update to ModelingToolkitv10
2 parents f2c8511 + e3dc15e commit 73df468

File tree

7 files changed

+24
-12
lines changed

7 files changed

+24
-12
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ DataInterpolations = "4, 5, 6, 7, 8"
3030
DiffEqBase = "6"
3131
DocStringExtensions = "0.7, 0.8, 0.9"
3232
MLUtils = "0.3, 0.4"
33-
ModelingToolkit = "9"
33+
ModelingToolkit = "10"
34+
OrdinaryDiffEqTsit5 = "1"
3435
Parameters = "0.12"
3536
ProgressMeter = "1.6"
3637
QuadGK = "2.4"
3738
RecipesBase = "1"
3839
Reexport = "1.0"
39-
OrdinaryDiffEqTsit5 = "1"
4040
SciMLStructures = "1"
4141
Setfield = "1"
4242
Statistics = "1"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1313
DataDrivenDiffEq = "1"
1414
Documenter = "1"
1515
Literate = "2.14"
16-
ModelingToolkit = "9"
16+
ModelingToolkit = "10"
1717
OrdinaryDiffEq = "6"
1818
Plots = "1"
1919
StableRNGs = "1"

docs/src/libs/datadrivensparse/example_04.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ using Test #src
2929
end
3030
end
3131

32-
@mtkbuild sys = Autoregulation()
32+
@mtkcompile sys = Autoregulation()
3333
tspan = (0.0, 5.0)
34-
de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan, [])
34+
de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan)
3535
de_solution = solve(de_problem, Tsit5(), saveat = 0.005);
3636
#md plot(de_solution)
3737

src/DataDrivenDiffEq.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ using Parameters
1313
using Setfield
1414

1515
@reexport using ModelingToolkit
16-
using ModelingToolkit: AbstractSystem, AbstractTimeDependentSystem
16+
using ModelingToolkit: AbstractSystem
1717
using SciMLStructures: SciMLStructures as SS
1818
using SymbolicUtils: operation, arguments, iscall, issym
1919
using Symbolics
2020
using Symbolics: scalarize, variable, value
2121
@reexport using ModelingToolkit: unknowns, parameters, independent_variable, observed,
22-
controls, get_iv, get_observed
22+
get_iv, get_observed
2323

2424
using Random
2525
using QuadGK
@@ -67,7 +67,7 @@ const __EMPTY_VECTOR = Vector(undef, 0)
6767

6868
# Basis with an indicator for implicit use
6969
abstract type AbstractDataDrivenFunction{Bool, Bool} end
70-
abstract type AbstractBasis <: AbstractTimeDependentSystem end
70+
abstract type AbstractBasis <: AbstractSystem end
7171

7272
# Collect the DataInterpolations Methods into an Interpolation Type
7373
abstract type AbstractInterpolationMethod end
@@ -98,7 +98,7 @@ include("./basis/utils.jl")
9898
include("./basis/type.jl")
9999
export Basis
100100
export jacobian, dynamics
101-
export implicit_variables, states
101+
export implicit_variables, states, controls
102102
export get_parameter_values, get_parameter_map
103103

104104
include("./utils/basis_generators.jl")

src/basis/type.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,18 @@ function states(b::AbstractBasis)
263263
return getfield(b, :unknowns)
264264
end
265265

266+
function controls(b::AbstractBasis)
267+
ctrls = getfield(b, :ctrls)
268+
systems = getfield(b, :systems)
269+
isempty(systems) && return ctrls
270+
271+
ctrls = copy(ctrls)
272+
for sys in systems
273+
append!(ctrls, unknowns(sys, controls(sys)))
274+
end
275+
return ctrls
276+
end
277+
266278
# For internal use
267279
is_implicit(b::Basis{X, <:Any}) where {X} = X
268280
is_controlled(b::Basis{<:Any, X}) where {X} = X

src/problem/type.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ function ModelingToolkit.observed(p::AbstractDataDrivenProblem, i = :, j = :)
326326
isempty(x) ? x : getindex(x, i, j)
327327
end
328328

329-
function ModelingToolkit.controls(p::AbstractDataDrivenProblem, i = :, j = :)
329+
function controls(p::AbstractDataDrivenProblem, i = :, j = :)
330330
x = getfield(p, :U)
331331
isempty(x) ? x : getindex(x, i, j)
332332
end

test/problem/problem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ end
183183
end
184184
end
185185

186-
@mtkbuild sys = Autoregulation()
186+
@mtkcompile sys = Autoregulation()
187187
tspan = (0.0, 5.0)
188-
de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan, [])
188+
de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan)
189189
de_solution = solve(de_problem, Tsit5(), saveat = 0.005)
190190
prob = DataDrivenProblem(de_solution)
191191
@test is_valid(prob)

0 commit comments

Comments
 (0)