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
1 change: 1 addition & 0 deletions src/initialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function get_initial_values(
t = current_time(integrator)
M = f.mass_matrix

M == I && return u0, p, true
algebraic_vars = [all(iszero, x) for x in eachcol(M)]
algebraic_eqs = [all(iszero, x) for x in eachrow(M)]
(iszero(algebraic_vars) || iszero(algebraic_eqs)) && return u0, p, true
Expand Down
2 changes: 1 addition & 1 deletion src/problems/nonlinear_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ and below.
!!! warn
While `explictfuns![i]` could in theory use `sols[i+1]` in its computation,
these values will not be updated. It is thus the contract of the interface
to not use those values except for as caches to be overriden.
to not use those values except for as caches to be overridden.

!!! note
prob.probs[i].p can be aliased with each other as a performance / memory
Expand Down
17 changes: 16 additions & 1 deletion test/initialization.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using StochasticDiffEq, OrdinaryDiffEq, NonlinearSolve, SymbolicIndexingInterface, Test
using StochasticDiffEq, OrdinaryDiffEq, NonlinearSolve, SymbolicIndexingInterface,
LinearAlgebra, Test

@testset "CheckInit" begin
@testset "ODEProblem" begin
Expand Down Expand Up @@ -27,6 +28,20 @@ using StochasticDiffEq, OrdinaryDiffEq, NonlinearSolve, SymbolicIndexingInterfac
prob, integ, f, SciMLBase.CheckInit(),
Val(SciMLBase.isinplace(f)); abstol = 1e-10)
end

@testset "With I mass matrix" begin
function rhs(u, p, t)
return u
end
prob = ODEProblem(ODEFunction(rhs; mass_matrix = I), ones(2), (0.0, 1.0))
integ = init(prob)
u0, _, success = SciMLBase.get_initial_values(
prob, integ, prob.f, SciMLBase.CheckInit(),
Val(false); abstol = 1e-10
)
@test success
@test u0 == prob.u0
end
end

@testset "DAEProblem" begin
Expand Down
Loading