We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b48c446 + e1a4e6f commit dacdcf5Copy full SHA for dacdcf5
src/systems/diffeqs/abstractodesystem.jl
@@ -109,9 +109,11 @@ function calculate_massmatrix(sys::AbstractODESystem; simplify=false)
109
eqs = equations(sys)
110
dvs = states(sys)
111
M = zeros(length(eqs),length(eqs))
112
+ state2idx = Dict(s => i for (i, s) in enumerate(dvs))
113
for (i,eq) in enumerate(eqs)
114
if eq.lhs isa Term && operation(eq.lhs) isa Differential
- j = findfirst(x->isequal(tosymbol(x),tosymbol(var_from_nested_derivative(eq.lhs)[1])),dvs)
115
+ st = var_from_nested_derivative(eq.lhs)[1]
116
+ j = state2idx[st]
117
M[i,j] = 1
118
else
119
_iszero(eq.lhs) || error("Only semi-explicit constant mass matrices are currently supported. Faulty equation: $eq.")
0 commit comments