Skip to content

Commit 694e0bb

Browse files
Merge branch 'master' into as/scimlfn-specialization
2 parents 108a74a + 1335076 commit 694e0bb

File tree

8 files changed

+49
-20
lines changed

8 files changed

+49
-20
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SciMLBase"
22
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
33
authors = ["Chris Rackauckas <[email protected]> and contributors"]
4-
version = "2.74.1"
4+
version = "2.75.0"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/initialization.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,11 @@ end
301301
function initialization_status(prob::AbstractSciMLProblem)
302302
has_initialization_data(prob.f) || return nothing
303303

304-
sys = prob.f.initialization_data.initializeprob.f.sys
305-
isnothing(sys) && return nothing
304+
iprob = prob.f.initialization_data.initializeprob
305+
isnothing(prob) && return nothing
306306

307-
neqs = length(equations(sys))
308-
nunknowns = length(unknowns(sys))
307+
neqs = length(iprob.f(iprob.u0, iprob.p))
308+
nunknowns = length(iprob.u0)
309309

310310
if neqs > nunknowns
311311
return OVERDETERMINED

src/problems/problem_utils.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ function Base.summary(io::IO, prob::AbstractDEProblem)
2929
no_color,
3030
". In-place: ", type_color, isinplace(prob), no_color)
3131
init = initialization_status(prob)
32-
!isnothing(init) && print(io, "Initialization status: ", type_color,
33-
initialization_status(prob), no_color)
34-
println(io)
35-
print(io, "Non-trivial mass matrix: ", type_color,
36-
!(prob.f.mass_matrix isa LinearAlgebra.UniformScaling{Bool}), no_color)
32+
!isnothing(init) && begin
33+
println(io)
34+
print(io, "Initialization status: ", type_color, initialization_status(prob), no_color)
35+
end
36+
37+
hasproperty(prob.f, :mass_matrix) && begin
38+
println(io)
39+
print(io, "Non-trivial mass matrix: ", type_color, !(prob.f.mass_matrix isa LinearAlgebra.UniformScaling{Bool}), no_color)
40+
end
3741
end
3842

3943
function Base.summary(io::IO, prob::AbstractLinearProblem)

src/remake.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,10 @@ calling `SymbolicIndexingInterface.symbolic_container`, provided for dispatch. R
10851085
the updated `newu0` and `newp`.
10861086
"""
10871087
function late_binding_update_u0_p(prob, root_indp, u0, p, t0, newu0, newp)
1088+
if hasmethod(symbolic_container, Tuple{typeof(root_indp)}) &&
1089+
(sc = symbolic_container(root_indp)) !== root_indp
1090+
return late_binding_update_u0_p(prob, sc, u0, p, t0, newu0, newp)
1091+
end
10881092
return newu0, newp
10891093
end
10901094

@@ -1096,10 +1100,6 @@ Calls `late_binding_update_u0_p(prob, root_indp, u0, p, t0, newu0, newp)` after
10961100
"""
10971101
function late_binding_update_u0_p(prob, u0, p, t0, newu0, newp)
10981102
root_indp = prob
1099-
while hasmethod(symbolic_container, Tuple{typeof(root_indp)}) &&
1100-
(sc = symbolic_container(root_indp)) !== root_indp
1101-
root_indp = sc
1102-
end
11031103
return late_binding_update_u0_p(prob, root_indp, u0, p, t0, newu0, newp)
11041104
end
11051105

src/solutions/ode_solutions.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ function (sol::AbstractODESolution)(t::Number, ::Type{deriv}, idxs,
287287
ps = parameter_values(discs)
288288
for ts_idx in eachindex(discs)
289289
partition = discs[ts_idx]
290-
interp_val = ConstantInterpolation(partition.t, partition.u)(
291-
t, nothing, deriv, nothing, continuity)
290+
interp_val = _hold_discrete(partition.u, partition.t, t)
292291
ps = with_updated_parameter_timeseries_values(sol, ps, ts_idx => interp_val)
293292
end
294293
end
@@ -312,8 +311,7 @@ function (sol::AbstractODESolution)(t::Number, ::Type{deriv}, idxs::AbstractVect
312311
ps = parameter_values(discs)
313312
for ts_idx in eachindex(discs)
314313
partition = discs[ts_idx]
315-
interp_val = ConstantInterpolation(partition.t, partition.u)(
316-
t, nothing, deriv, nothing, continuity)
314+
interp_val = _hold_discrete(partition.u, partition.t, t)
317315
ps = with_updated_parameter_timeseries_values(sol, ps, ts_idx => interp_val)
318316
end
319317
end

test/downstream/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ DelayDiffEq = "5"
3434
DiffEqCallbacks = "3, 4"
3535
ForwardDiff = "0.10"
3636
JumpProcesses = "9.10"
37-
ModelingToolkit = "9.56"
37+
ModelingToolkit = "9.64.1"
3838
ModelingToolkitStandardLibrary = "2.7"
3939
NonlinearSolve = "2, 3, 4"
4040
Optimization = "4"

test/downstream/initialization.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,21 @@ end
5858
@test getp(sys, p)(pobj) 1.0
5959
@test getp(sys, q)(pobj) sqrt(2)
6060
end
61+
62+
@testset "Initialization info printed" begin
63+
@parameters g
64+
@variables x(t) y(t) [state_priority = 10] λ(t)
65+
eqs = [D(D(x)) ~ λ * x
66+
D(D(y)) ~ λ * y - g
67+
x^2 + y^2 ~ 1]
68+
@mtkbuild pend = ODESystem(eqs, t)
69+
70+
prob = ODEProblem(pend, [x => 1, y => 0], (0.0, 1.5), [g => 1], guesses ==> 1])
71+
@test occursin("Initialization status: FULLY_DETERMINED", sprint(summary, prob))
72+
73+
prob = ODEProblem(pend, [], (0.0, 1.5), [g => 1], guesses ==> 1, x => 1, y => 0])
74+
@test occursin("Initialization status: UNDERDETERMINED", sprint(summary, prob))
75+
76+
prob = ODEProblem(pend, [x => 1, y => 0, λ => 2], (0.0, 1.5), [g => 1])
77+
@test occursin("Initialization status: OVERDETERMINED", sprint(summary, prob))
78+
end

test/downstream/solution_interface.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ end
215215
@test sol[x] == xvals
216216
@test is_parameter(sol, p)
217217
@test parameter_index(sol, p) == parameter_index(sys, p)
218-
@test isequal(only(parameter_symbols(sol)), p)
218+
@test any(isequal(p), parameter_symbols(sol))
219219
@test is_independent_variable(sol, t)
220220

221221
tmp = copy(prob.u0)
@@ -341,3 +341,12 @@ end
341341
@test _ss isa SciMLBase.SavedSubsystem
342342
end
343343
end
344+
345+
@testset "Interpolation after final discrete save" begin
346+
@variables x(t) y(t)
347+
@parameters start
348+
@mtkbuild sys=ODESystem([D(x) ~ y, y ~ ifelse(t < start, 1.0, 2.0)], t) additional_passes=[ModelingToolkit.IfLifting]
349+
prob = ODEProblem(sys, [x => 0.0], (0.0, 1.0), [start => 0.5])
350+
sol = solve(prob)
351+
@test sol(0.6, idxs = y) 2.0
352+
end

0 commit comments

Comments
 (0)