Skip to content

Commit 3a4a11e

Browse files
Rename DiffEqSystem to ODESystem
1 parent 57ccf33 commit 3a4a11e

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ eqs = [D(x) ~ σ*(y-x),
4343

4444
Each operation builds an `Operation` type, and thus `eqs` is an array of
4545
`Operation` and `Variable`s. This holds a tree of the full system that can be
46-
analyzed by other programs. We can turn this into a `DiffEqSystem` via:
46+
analyzed by other programs. We can turn this into a `ODESystem` via:
4747

4848
```julia
49-
de = DiffEqSystem(eqs,t,[x,y,z],[σ,ρ,β])
50-
de = DiffEqSystem(eqs)
49+
de = ODESystem(eqs,t,[x,y,z],[σ,ρ,β])
50+
de = ODESystem(eqs)
5151
```
5252

5353
where we tell it the variable types and ordering in the first version, or let it

src/systems/diffeqs/diffeqsystem.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export DiffEqSystem, ODEFunction
1+
export ODESystem, ODEFunction
22

33

44
using Base: RefValue
@@ -31,13 +31,13 @@ function to_diffeq(eq::Equation)
3131
end
3232
Base.:(==)(a::DiffEq, b::DiffEq) = isequal((a.x, a.t, a.n, a.rhs), (b.x, b.t, b.n, b.rhs))
3333

34-
struct DiffEqSystem <: AbstractSystem
34+
struct ODESystem <: AbstractSystem
3535
eqs::Vector{DiffEq}
3636
iv::Variable
3737
dvs::Vector{Variable}
3838
ps::Vector{Variable}
3939
jac::RefValue{Matrix{Expression}}
40-
function DiffEqSystem(eqs)
40+
function ODESystem(eqs)
4141
reformatted = to_diffeq.(eqs)
4242

4343
ivs = unique(r[1] for r reformatted)
@@ -58,7 +58,7 @@ struct DiffEqSystem <: AbstractSystem
5858
end
5959

6060

61-
function calculate_jacobian(sys::DiffEqSystem)
61+
function calculate_jacobian(sys::ODESystem)
6262
isempty(sys.jac[]) || return sys.jac[] # use cached Jacobian, if possible
6363
rhs = [eq.rhs for eq sys.eqs]
6464

@@ -67,13 +67,13 @@ function calculate_jacobian(sys::DiffEqSystem)
6767
return jac
6868
end
6969

70-
function generate_jacobian(sys::DiffEqSystem; version::FunctionVersion = ArrayFunction)
70+
function generate_jacobian(sys::ODESystem; version::FunctionVersion = ArrayFunction)
7171
jac = calculate_jacobian(sys)
7272
return build_function(jac, sys.dvs, sys.ps, (sys.iv.name,); version = version)
7373
end
7474

7575
struct DiffEqToExpr
76-
sys::DiffEqSystem
76+
sys::ODESystem
7777
end
7878
function (f::DiffEqToExpr)(O::Operation)
7979
if isa(O.op, Variable)
@@ -86,15 +86,15 @@ function (f::DiffEqToExpr)(O::Operation)
8686
end
8787
(f::DiffEqToExpr)(x) = convert(Expr, x)
8888

89-
function generate_function(sys::DiffEqSystem, vs, ps; version::FunctionVersion = ArrayFunction)
89+
function generate_function(sys::ODESystem, vs, ps; version::FunctionVersion = ArrayFunction)
9090
rhss = [deq.rhs for deq sys.eqs]
9191
vs′ = [clean(v) for v vs]
9292
ps′ = [clean(p) for p ps]
9393
return build_function(rhss, vs′, ps′, (sys.iv.name,), DiffEqToExpr(sys); version = version)
9494
end
9595

9696

97-
function generate_ode_iW(sys::DiffEqSystem, simplify=true; version::FunctionVersion = ArrayFunction)
97+
function generate_ode_iW(sys::ODESystem, simplify=true; version::FunctionVersion = ArrayFunction)
9898
jac = calculate_jacobian(sys)
9999

100100
gam = Variable(:gam; known = true)()
@@ -121,7 +121,7 @@ function generate_ode_iW(sys::DiffEqSystem, simplify=true; version::FunctionVers
121121
return (iW_func, iW_t_func)
122122
end
123123

124-
function DiffEqBase.ODEFunction(sys::DiffEqSystem; version::FunctionVersion = ArrayFunction)
124+
function DiffEqBase.ODEFunction(sys::ODESystem; version::FunctionVersion = ArrayFunction)
125125
expr = generate_function(sys; version = version)
126126
if version === ArrayFunction
127127
ODEFunction{true}(eval(expr))

src/systems/diffeqs/first_order_transform.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ function lower_varname(var::Variable, idv, order)
77
return Variable(name; known = var.known)
88
end
99

10-
function ode_order_lowering(sys::DiffEqSystem)
10+
function ode_order_lowering(sys::ODESystem)
1111
eqs_lowered = ode_order_lowering(sys.eqs, sys.iv)
12-
DiffEqSystem(eqs_lowered, sys.iv, sys.dvs, sys.ps)
12+
ODESystem(eqs_lowered, sys.iv, sys.dvs, sys.ps)
1313
end
1414
function ode_order_lowering(eqs, iv)
1515
var_order = Dict{Variable,Int}()

test/system_construction.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using Test
77
@derivatives D'~t
88

99
function test_diffeq_inference(name, de, iv, dvs, ps)
10-
@testset "DiffEqSystem construction: $name" begin
10+
@testset "ODESystem construction: $name" begin
1111
@test de.iv.name == :t
1212
@test Set([dv.name for dv de.dvs]) == Set(dvs)
1313
@test Set([p.name for p de.ps ]) == Set(ps)
@@ -18,7 +18,7 @@ end
1818
eqs = [D(x) ~ σ*(y-x),
1919
D(y) ~ x*-z)-y,
2020
D(z) ~ x*y - β*z]
21-
de = DiffEqSystem(eqs)
21+
de = ODESystem(eqs)
2222
test_diffeq_inference("standard", de, :t, (:x, :y, :z), (, , ))
2323
generate_function(de, [x,y,z], [σ,ρ,β])
2424
generate_function(de, [x,y,z], [σ,ρ,β]; version=ModelingToolkit.SArrayFunction)
@@ -34,7 +34,7 @@ ModelingToolkit.generate_ode_iW(de)
3434
eqs = [D(x) ~ σ′*(y-x),
3535
D(y) ~ x*-z)-y,
3636
D(z) ~ x*y - β*z]
37-
de = DiffEqSystem(eqs)
37+
de = ODESystem(eqs)
3838
test_diffeq_inference("global iv-varying", de, :t, (:x, :y, :z), (:σ′, , ))
3939
@test begin
4040
f = eval(generate_function(de, [x,y,z], [σ′,ρ,β]))
@@ -47,7 +47,7 @@ ModelingToolkit.generate_ode_iW(de)
4747
eqs = [D(x) ~ σ(t-1)*(y-x),
4848
D(y) ~ x*-z)-y,
4949
D(z) ~ x*y - β*z]
50-
de = DiffEqSystem(eqs)
50+
de = ODESystem(eqs)
5151
test_diffeq_inference("single internal iv-varying", de, :t, (:x, :y, :z), (, , ))
5252
@test begin
5353
f = eval(generate_function(de, [x,y,z], [σ,ρ,β]))
@@ -57,7 +57,7 @@ ModelingToolkit.generate_ode_iW(de)
5757
end
5858

5959
eqs = [D(x) ~ x + 10σ(t-1) + 100σ(t-2) + 1000σ(t^2)]
60-
de = DiffEqSystem(eqs)
60+
de = ODESystem(eqs)
6161
test_diffeq_inference("many internal iv-varying", de, :t, (:x,), (,))
6262
@test begin
6363
f = eval(generate_function(de, [x], [σ]))
@@ -74,7 +74,7 @@ end
7474
@variables u(t) u_tt(t) u_t(t) x_t(t)
7575
eqs = [D3(u) ~ 2(D2(u)) + D(u) + D(x) + 1
7676
D2(x) ~ D(x) + 2]
77-
de = DiffEqSystem(eqs, t)
77+
de = ODESystem(eqs, t)
7878
de1 = ode_order_lowering(de)
7979
lowered_eqs = [D(u_tt) ~ 2u_tt + u_t + x_t + 1
8080
D(x_t) ~ x_t + 2
@@ -89,7 +89,7 @@ a = y - x
8989
eqs = [D(x) ~ σ*a,
9090
D(y) ~ x*-z)-y,
9191
D(z) ~ x*y - β*z]
92-
de = DiffEqSystem(eqs)
92+
de = ODESystem(eqs)
9393
generate_function(de, [x,y,z], [σ,ρ,β])
9494
jac = calculate_jacobian(de)
9595
@test_broken begin
@@ -117,7 +117,7 @@ end
117117
_x = y / C
118118
eqs = [D(x) ~ -A*x,
119119
D(y) ~ A*x - B*_x]
120-
de = DiffEqSystem(eqs)
120+
de = ODESystem(eqs)
121121
@test begin
122122
f = eval(generate_function(de, [x,y], [A,B,C]))
123123
du = [0.0,0.0]

0 commit comments

Comments
 (0)