Skip to content

Commit cc94187

Browse files
refactor: remove ode_order_lowering and dae_order_lowering
1 parent 0f25e77 commit cc94187

File tree

7 files changed

+4
-384
lines changed

7 files changed

+4
-384
lines changed

src/ModelingToolkit.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ include("modelingtoolkitize/nonlinearproblem.jl")
188188

189189
include("systems/nonlinear/homotopy_continuation.jl")
190190
include("systems/nonlinear/initializesystem.jl")
191-
include("systems/diffeqs/first_order_transform.jl")
192191
include("systems/diffeqs/basic_transformations.jl")
193192

194193
include("systems/pde/pdesystem.jl")
@@ -291,9 +290,8 @@ export isinput, isoutput, getbounds, hasbounds, getguess, hasguess, isdisturbanc
291290
tunable_parameters, isirreducible, getdescription, hasdescription,
292291
hasunit, getunit, hasconnect, getconnect,
293292
hasmisc, getmisc, state_priority
294-
export ode_order_lowering, dae_order_lowering, liouville_transform,
295-
change_independent_variable, substitute_component, add_accumulations,
296-
noise_to_brownians
293+
export liouville_transform, change_independent_variable, substitute_component,
294+
add_accumulations, noise_to_brownians
297295
export PDESystem
298296
export Differential, expand_derivatives, @derivatives
299297
export Equation, ConstrainedEquation

src/systems/diffeqs/first_order_transform.jl

Lines changed: 0 additions & 106 deletions
This file was deleted.

test/lowering_solving.jl

Lines changed: 0 additions & 76 deletions
This file was deleted.

test/odesystem.jl

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -153,32 +153,6 @@ du = [0.0]
153153
f(du, [1.0], [t -> t + 2], 5.0)
154154
@test du [27561]
155155

156-
@testset "Issue#17: Conversion to first order ODEs" begin
157-
D3 = D^3
158-
D2 = D^2
159-
@variables u(t) uˍtt(t) uˍt(t) xˍt(t)
160-
eqs = [D3(u) ~ 2(D2(u)) + D(u) + D(x) + 1
161-
D2(x) ~ D(x) + 2]
162-
@named de = System(eqs, t)
163-
de1 = ode_order_lowering(de)
164-
165-
@testset "Issue#219: Ordering of equations in `ode_order_lowering`" begin
166-
lowered_eqs = [D(uˍtt) ~ 2uˍtt + uˍt + xˍt + 1
167-
D(xˍt) ~ xˍt + 2
168-
D(uˍt) ~ uˍtt
169-
D(u) ~ uˍt
170-
D(x) ~ xˍt]
171-
@test isequal(
172-
[ModelingToolkit.var_from_nested_derivative(eq.lhs)[1] for eq in equations(de1)],
173-
unknowns(@named lowered = System(lowered_eqs, t)))
174-
end
175-
176-
test_diffeq_inference("first-order transform", de1, t, [uˍtt, xˍt, uˍt, u, x], [])
177-
du = zeros(5)
178-
ODEFunction(complete(de1))(du, ones(5), nothing, 0.1)
179-
@test du == [5.0, 3.0, 1.0, 1.0, 1.0]
180-
end
181-
182156
# Internal calculations
183157
@parameters σ
184158
a = y - x
@@ -348,16 +322,6 @@ eqs = [D(x) ~ σ * (y - x),
348322
@test issym(equations(sys)[1].rhs)
349323
end
350324

351-
@testset "Issue#708" begin
352-
@parameters a
353-
@variables x(t) y(t) z(t)
354-
@named sys = System([D(x) ~ y, 0 ~ x + z, 0 ~ x - y], t, [z, y, x], [])
355-
356-
sys2 = ode_order_lowering(sys)
357-
M = ModelingToolkit.calculate_massmatrix(sys2)
358-
@test M == Diagonal([1, 0, 0])
359-
end
360-
361325
# issue #609
362326
@variables x1(t) x2(t)
363327

@@ -416,22 +380,6 @@ eqs = [
416380
]
417381
@test_throws ArgumentError ModelingToolkit.System(eqs, t, vars, pars, name = :foo)
418382

419-
@variables x(t)
420-
@parameters M b k
421-
eqs = [D(D(x)) ~ -b / M * D(x) - k / M * x]
422-
ps = [M, b, k]
423-
default_u0 = [D(x) => 0.0, x => 10.0]
424-
default_p = [M => 1.0, b => 1.0, k => 1.0]
425-
@named sys = System(eqs, t, [x], ps; defaults = [default_u0; default_p])
426-
sys = ode_order_lowering(sys)
427-
sys = complete(sys)
428-
prob = ODEProblem(sys, nothing, tspan)
429-
sol = solve(prob, Tsit5())
430-
@test sol.t[end] == tspan[end]
431-
@test sum(abs, sol.u[end]) < 1
432-
prob = ODEProblem{false}(sys, nothing, tspan; u0_constructor = x -> SVector(x...))
433-
@test prob.u0 isa SVector
434-
435383
# check_eqs_u0 kwarg test
436384
@variables x1(t) x2(t)
437385
eqs = [D(x1) ~ -x1]
@@ -1530,64 +1478,6 @@ end
15301478
@test osys1 !== osys2
15311479
end
15321480

1533-
@testset "dae_order_lowering basic test" begin
1534-
@parameters a
1535-
@variables x(t) y(t) z(t)
1536-
@named dae_sys = System([
1537-
D(x) ~ y,
1538-
0 ~ x + z,
1539-
0 ~ x - y + z
1540-
], t, [z, y, x], [])
1541-
1542-
lowered_dae_sys = dae_order_lowering(dae_sys)
1543-
@variables x1(t) y1(t) z1(t)
1544-
expected_eqs = [
1545-
0 ~ x + z,
1546-
0 ~ x - y + z,
1547-
Differential(t)(x) ~ y
1548-
]
1549-
lowered_eqs = equations(lowered_dae_sys)
1550-
sorted_lowered_eqs = sort(lowered_eqs, by = string)
1551-
sorted_expected_eqs = sort(expected_eqs, by = string)
1552-
@test sorted_lowered_eqs == sorted_expected_eqs
1553-
1554-
expected_vars = Set([z, y, x])
1555-
lowered_vars = Set(unknowns(lowered_dae_sys))
1556-
@test lowered_vars == expected_vars
1557-
end
1558-
1559-
@testset "dae_order_lowering test with structural_simplify" begin
1560-
@variables x(t) y(t) z(t)
1561-
@parameters M b k
1562-
eqs = [
1563-
D(D(x)) ~ -b / M * D(x) - k / M * x,
1564-
0 ~ y - D(x),
1565-
0 ~ z - x
1566-
]
1567-
ps = [M, b, k]
1568-
default_u0 = [
1569-
D(x) => 0.0, x => 10.0, y => 0.0, z => 10.0
1570-
]
1571-
default_p = [M => 1.0, b => 1.0, k => 1.0]
1572-
@named dae_sys = System(eqs, t, [x, y, z], ps; defaults = [default_u0; default_p])
1573-
1574-
simplified_dae_sys = structural_simplify(dae_sys)
1575-
1576-
lowered_dae_sys = dae_order_lowering(simplified_dae_sys)
1577-
lowered_dae_sys = complete(lowered_dae_sys)
1578-
1579-
tspan = (0.0, 10.0)
1580-
prob = ODEProblem(lowered_dae_sys, nothing, tspan)
1581-
sol = solve(prob, Tsit5())
1582-
1583-
@test sol.t[end] == tspan[end]
1584-
@test sum(abs, sol.u[end]) < 1
1585-
1586-
prob = ODEProblem{false}(
1587-
lowered_dae_sys, nothing, tspan; u0_constructor = x -> SVector(x...))
1588-
@test prob.u0 isa SVector
1589-
end
1590-
15911481
@testset "Constraint system construction" begin
15921482
@variables x(..) y(..) z(..)
15931483
@parameters a b c d e

test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ end
5151
@safetestset "Symbolic Event Test" include("symbolic_events.jl")
5252
@safetestset "Stream Connect Test" include("stream_connectors.jl")
5353
@safetestset "Domain Connect Test" include("domain_connectors.jl")
54-
@safetestset "Lowering Integration Test" include("lowering_solving.jl")
5554
@safetestset "Dependency Graph Test" include("dep_graphs.jl")
5655
@safetestset "Function Registration Test" include("function_registration.jl")
5756
@safetestset "Precompiled Modules Test" include("precompile_test.jl")

test/state_selection.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ end
2323
@test_skip let pss = partial_state_selection(sys)
2424
@test length(equations(pss)) == 1
2525
@test length(unknowns(pss)) == 2
26-
@test length(equations(ode_order_lowering(pss))) == 2
2726
end
2827

2928
@parameters σ ρ β

0 commit comments

Comments
 (0)