Skip to content

Commit b13e2e8

Browse files
adds observedfun
1 parent 5637059 commit b13e2e8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,16 @@ function DiffEqBase.DAEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
509509
_jac = nothing
510510
end
511511

512+
obs = observed(sys)
513+
observedfun = let sys = sys, dict = Dict()
514+
function generated_observed(obsvar, u, p, t)
515+
obs = get!(dict, value(obsvar)) do
516+
build_explicit_observed_function(sys, obsvar; checkbounds = checkbounds)
517+
end
518+
obs(u, p, t)
519+
end
520+
end
521+
512522
jac_prototype = if sparse
513523
uElType = u0 === nothing ? Float64 : eltype(u0)
514524
if jac
@@ -526,10 +536,10 @@ function DiffEqBase.DAEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
526536
DAEFunction{iip}(f,
527537
jac = _jac === nothing ? nothing : _jac,
528538
syms = Symbol.(dvs),
529-
jac_prototype = jac_prototype
539+
jac_prototype = jac_prototype,
530540
# missing fields in `DAEFunction`
531541
#indepsym = Symbol(get_iv(sys)),
532-
#observed = observedfun,
542+
observed = observedfun,
533543
)
534544
end
535545

0 commit comments

Comments
 (0)