ModelingToolkit.jl
ModelingToolkit.jl copied to clipboard
sparsity pattern J vs J-gamma*I
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.