Skip to content

Commit f561d23

Browse files
committed
Revert "Remove branch for DifferentialVarsUndefined"
This reverts commit 5141b52.
1 parent 5141b52 commit f561d23

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/OrdinaryDiffEqCore/src/dense/generic_dense.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,16 @@ function interpolation_differential_vars(differential_vars, y₀, idxs)
990990
else
991991
return Trues(size(idxs))
992992
end
993+
elseif differential_vars isa DifferentialVarsUndefined #for non diagonal mass matrices, use linear interpolation.
994+
if y₀ isa Number
995+
return false
996+
elseif idxs === nothing
997+
return Falses(size(y₀))
998+
elseif idxs isa Number
999+
return false
1000+
else
1001+
return Falses(size(idxs))
1002+
end
9931003
elseif idxs isa Number
9941004
return return differential_vars[idxs]
9951005
elseif idxs === nothing

lib/OrdinaryDiffEqCore/src/misc_utils.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@ macro fold(arg)
103103
end
104104
end
105105

106+
struct DifferentialVarsUndefined end
107+
106108
"""
107109
get_differential_vars(f, idxs, timeseries::uType)
108110
109-
Returns an array of booleans, for which `true` refers to a differential variable and `false`
110-
to an algebraic variable. If the function has no mass matrix, returns `nothing` (implying
111-
all variables are differential).
111+
Returns an array of booleans for which values are the differential variables
112+
vs algebraic variables. Returns `nothing` for the cases where all variables
113+
are differential variables. Returns `DifferentialVarsUndefined` if it cannot
114+
be determined (i.e. the mass matrix is not diagonal).
112115
"""
113116
function get_differential_vars(f, u)
114117
if hasproperty(f, :mass_matrix)
@@ -122,7 +125,7 @@ function get_differential_vars(f, u)
122125
elseif !(mm isa SciMLOperators.AbstractSciMLOperator) && isdiag(mm)
123126
return reshape(diag(mm) .!= 0, size(u))
124127
else
125-
return reshape(.~all(iszero, mm, dims=1) .!= 0, size(u))
128+
return DifferentialVarsUndefined()
126129
end
127130
else
128131
return nothing

0 commit comments

Comments
 (0)