Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@ calling `SymbolicIndexingInterface.symbolic_container`, provided for dispatch. R
the updated `newu0` and `newp`.
"""
function late_binding_update_u0_p(prob, root_indp, u0, p, t0, newu0, newp)
if hasmethod(symbolic_container, Tuple{typeof(root_indp)}) &&
(sc = symbolic_container(root_indp)) !== root_indp
return late_binding_update_u0_p(prob, sc, u0, p, t0, newu0, newp)
end
return newu0, newp
end

Expand All @@ -1094,10 +1098,6 @@ Calls `late_binding_update_u0_p(prob, root_indp, u0, p, t0, newu0, newp)` after
"""
function late_binding_update_u0_p(prob, u0, p, t0, newu0, newp)
root_indp = prob
while hasmethod(symbolic_container, Tuple{typeof(root_indp)}) &&
(sc = symbolic_container(root_indp)) !== root_indp
root_indp = sc
end
return late_binding_update_u0_p(prob, root_indp, u0, p, t0, newu0, newp)
end

Expand Down
9 changes: 6 additions & 3 deletions src/scimlfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2808,7 +2808,8 @@ function unwrapped_f(f::NonlinearFunction, newf = unwrapped_f(f.f))
end
end

@add_kwonly function SplitFunction(f1, f2, mass_matrix, _func_cache, analytic, tgrad, jac, jvp,
@add_kwonly function SplitFunction(
f1, f2, mass_matrix, _func_cache, analytic, tgrad, jac, jvp,
vjp, jac_prototype, W_prototype, sparsity, Wfact, Wfact_t, paramjac,
observed, colorvec, sys, initializeprob = nothing, update_initializeprob! = nothing,
initializeprobmap = nothing, initializeprobpmap = nothing, initialization_data = nothing, nlprob_data = nothing)
Expand Down Expand Up @@ -3259,7 +3260,8 @@ function SDEFunction(f, g; kwargs...)
end
SDEFunction(f::SDEFunction; kwargs...) = f

@add_kwonly function SplitSDEFunction(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad, jac,
@add_kwonly function SplitSDEFunction(
f1, f2, g, mass_matrix, _func_cache, analytic, tgrad, jac,
jvp, vjp,
jac_prototype, Wfact, Wfact_t, paramjac, observed,
colorvec, sys, initialization_data = nothing)
Expand Down Expand Up @@ -3344,7 +3346,8 @@ function SplitSDEFunction{iip}(f1, f2, g; kwargs...) where {iip}
end
SplitSDEFunction(f::SplitSDEFunction; kwargs...) = f

@add_kwonly function DynamicalSDEFunction(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad,
@add_kwonly function DynamicalSDEFunction(
f1, f2, g, mass_matrix, _func_cache, analytic, tgrad,
jac, jvp, vjp,
jac_prototype, Wfact, Wfact_t, paramjac,
observed, colorvec,
Expand Down
6 changes: 2 additions & 4 deletions src/solutions/ode_solutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,7 @@ function (sol::AbstractODESolution)(t::Number, ::Type{deriv}, idxs,
ps = parameter_values(discs)
for ts_idx in eachindex(discs)
partition = discs[ts_idx]
interp_val = ConstantInterpolation(partition.t, partition.u)(
t, nothing, deriv, nothing, continuity)
interp_val = _hold_discrete(partition.u, partition.t, t)
ps = with_updated_parameter_timeseries_values(sol, ps, ts_idx => interp_val)
end
end
Expand All @@ -312,8 +311,7 @@ function (sol::AbstractODESolution)(t::Number, ::Type{deriv}, idxs::AbstractVect
ps = parameter_values(discs)
for ts_idx in eachindex(discs)
partition = discs[ts_idx]
interp_val = ConstantInterpolation(partition.t, partition.u)(
t, nothing, deriv, nothing, continuity)
interp_val = _hold_discrete(partition.u, partition.t, t)
ps = with_updated_parameter_timeseries_values(sol, ps, ts_idx => interp_val)
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/downstream/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ DelayDiffEq = "5"
DiffEqCallbacks = "3, 4"
ForwardDiff = "0.10"
JumpProcesses = "9.10"
ModelingToolkit = "9.56"
ModelingToolkit = "9.64.1"
ModelingToolkitStandardLibrary = "2.7"
NonlinearSolve = "2, 3, 4"
Optimization = "4"
Expand Down
11 changes: 10 additions & 1 deletion test/downstream/solution_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ end
@test sol[x] == xvals
@test is_parameter(sol, p)
@test parameter_index(sol, p) == parameter_index(sys, p)
@test isequal(only(parameter_symbols(sol)), p)
@test any(isequal(p), parameter_symbols(sol))
@test is_independent_variable(sol, t)

tmp = copy(prob.u0)
Expand Down Expand Up @@ -341,3 +341,12 @@ end
@test _ss isa SciMLBase.SavedSubsystem
end
end

@testset "Interpolation after final discrete save" begin
@variables x(t) y(t)
@parameters start
@mtkbuild sys=ODESystem([D(x) ~ y, y ~ ifelse(t < start, 1.0, 2.0)], t) additional_passes=[ModelingToolkit.IfLifting]
prob = ODEProblem(sys, [x => 0.0], (0.0, 1.0), [start => 0.5])
sol = solve(prob)
@test sol(0.6, idxs = y) ≈ 2.0
end
Loading