Skip to content

Commit 3f201b7

Browse files
Merge pull request #1477 from xtalax/sparseMM
Check against Identity with equality
2 parents 3e7d6be + e0a3708 commit 3f201b7

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ function calculate_massmatrix(sys::AbstractODESystem; simplify=false)
279279
end
280280
M = simplify ? ModelingToolkit.simplify.(M) : M
281281
# M should only contain concrete numbers
282-
M === I ? I : M
282+
M == I ? I : M
283283
end
284284

285285
function jacobian_sparsity(sys::AbstractODESystem)

test/mass_matrix.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using OrdinaryDiffEq, ModelingToolkit, Test
1+
using OrdinaryDiffEq, ModelingToolkit, Test, LinearAlgebra
22
@parameters t
33
@variables y[1:3](t)
44
@parameters k[1:3]
@@ -34,3 +34,10 @@ sol2 = solve(prob_mm2,Rodas5(),reltol=1e-8,abstol=1e-8,tstops=sol.t,adaptive=fal
3434
# MTK expression are canonicalized, so the floating point numbers are slightly
3535
# different
3636
@test Array(sol) Array(sol2)
37+
38+
# Test mass matrix in the identity case
39+
eqs = [D(y[1]) ~ y[1], D(y[2]) ~ y[2], D(y[3]) ~ y[3]]
40+
41+
@named sys = ODESystem(eqs,t,y,k)
42+
43+
@test calculate_massmatrix(sys) === I

test/odesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ D = Differential(t)
358358
eqs = [D(x1) ~ -x1]
359359
@named sys = ODESystem(eqs,t,[x1,x2],[])
360360
@test_throws ArgumentError ODEProblem(sys, [1.0,1.0], (0.0,1.0))
361-
@test_throws DimensionMismatch ODEProblem(sys, [1.0,1.0], (0.0,1.0), check_length=false)
361+
@test_nowarn ODEProblem(sys, [1.0,1.0], (0.0,1.0), check_length=false)
362362

363363
# check inputs
364364
let

0 commit comments

Comments
 (0)