Skip to content

Commit 17432c8

Browse files
authored
preserve sys in ODEFunction from ODAEProblem (#1883)
1 parent 0490417 commit 17432c8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/structural_transformation/codegen.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ function build_torn_function(sys;
342342
paramsyms = Symbol.(parameters(sys)),
343343
indepsym = Symbol(get_iv(sys)),
344344
observed = observedfun,
345-
mass_matrix = mass_matrix), states
345+
mass_matrix = mass_matrix,
346+
sys = sys), states
346347
end
347348
end
348349

test/odesystem.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,3 +910,16 @@ else
910910
@test_throws "-cos(Q(t))" prob.f(du, [1, 0], prob.p, 0.0)
911911
@test_throws "sin(P(t))" prob.f(du, [0, 2], prob.p, 0.0)
912912
end
913+
914+
let
915+
@variables t
916+
D = Differential(t)
917+
@variables x(t) = 1
918+
@variables y(t) = 1
919+
@parameters pp = -1
920+
der = Differential(t)
921+
@named sys4 = ODESystem([der(x) ~ -y; der(y) ~ 1 + pp * y + x], t)
922+
sys4s = structural_simplify(sys4)
923+
prob = ODAEProblem(sys4s, [x => 1.0, D(x) => 1.0], (0, 1.0))
924+
@test !isnothing(prob.f.sys)
925+
end

0 commit comments

Comments
 (0)