ModelingToolkit.jl icon indicating copy to clipboard operation
ModelingToolkit.jl copied to clipboard

sparsity pattern J vs J-gamma*I

Open ArnoStrouwen opened this issue 2 years ago • 0 comments

using ModelingToolkit
@variables t x1(t) x2(t)
D = Differential(t)
@named fol = ODESystem([ D(x1)  ~ -x2,D(x2) ~ -x1])
prob = ODEProblem(fol, [x1 => 1.0,x2 => 2.0], (0.0,10.0))
sparsepatternprob = ODEProblem(fol, [x1 => 1.0,x2 => 2.0], (0.0,10.0),sparse=true)
sparsepatternprob.f.jac_prototype
2×2 SparseArrays.SparseMatrixCSC{Float64, Int64} with 2 stored entries:
  ⋅            1.60664e-315
 1.09651e-315   ⋅

It might be slightly better to also make the diagonal non-sparse.

ArnoStrouwen avatar Jun 26 '22 22:06 ArnoStrouwen