Skip to content

Commit

Permalink
fix: propagate initializeprobpmap and update_initializeprob! to `…
Browse files Browse the repository at this point in the history
…DAEFunction`
  • Loading branch information
AayushSabharwal committed Nov 21, 2024
1 parent b991a62 commit e3cba50
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/systems/diffeqs/abstractodesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ function DiffEqBase.DAEFunction{iip}(sys::AbstractODESystem, dvs = unknowns(sys)
checkbounds = false,
initializeprob = nothing,
initializeprobmap = nothing,
initializeprobpmap = nothing,
update_initializeprob! = nothing,
kwargs...) where {iip}
if !iscomplete(sys)
error("A completed system is required. Call `complete` or `structural_simplify` on the system before creating a `DAEFunction`")
Expand Down Expand Up @@ -551,7 +553,9 @@ function DiffEqBase.DAEFunction{iip}(sys::AbstractODESystem, dvs = unknowns(sys)
jac_prototype = jac_prototype,
observed = observedfun,
initializeprob = initializeprob,
initializeprobmap = initializeprobmap)
initializeprobmap = initializeprobmap,
initializeprobpmap = initializeprobpmap,
update_initializeprob! = update_initializeprob!)
end

function DiffEqBase.DDEFunction(sys::AbstractODESystem, args...; kwargs...)
Expand Down
15 changes: 15 additions & 0 deletions test/initializationsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -947,3 +947,18 @@ end

@test_nowarn remake(prob, p = prob.p)
end

@test "DAEProblem initialization" begin
@variables x(t) [guess = 1.0] y(t) [guess = 1.0]
@parameters p = missing [guess = 1.0] q = missing [guess = 1.0]
@mtkbuild sys = ODESystem([D(x) ~ p * y + q * t, x^3 + y^3 ~ 5], t; initialization_eqs = [p ^2 + q^3 ~ 3])

# FIXME: solve for du0
prob = DAEProblem(sys, [D(x) => cbrt(4), D(y) => -1 / cbrt(4)], [x => 1.0], (0.0, 1.0), [p => 1.0])

integ = init(prob, DImplicitEuler())
@test integ[x] 1.0
@test integ[y] cbrt(4) rtol = 1e-6
@test integ.ps[p] 1.0
@test integ.ps[q] cbrt(2) rtol = 1e-6
end

0 comments on commit e3cba50

Please sign in to comment.