From c37ffd07d9653c29bd057d92b69057f092204b13 Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Sat, 20 Sep 2025 19:49:28 +0200 Subject: [PATCH] Use matrix-dependent solver for sparse analytical Jacobian example --- docs/src/examples/sparse_jacobians.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/src/examples/sparse_jacobians.md b/docs/src/examples/sparse_jacobians.md index fd1e6411ab..9c12e9b7aa 100644 --- a/docs/src/examples/sparse_jacobians.md +++ b/docs/src/examples/sparse_jacobians.md @@ -60,7 +60,6 @@ Now let's use `modelingtoolkitize` to generate the symbolic version: ```@example sparsejac @mtkcompile sys = modelingtoolkitize(prob); -nothing # hide ``` Now we regenerate the problem using `jac=true` for the analytical Jacobian @@ -74,21 +73,20 @@ Hard? No! How much did that help? ```@example sparsejac using BenchmarkTools -@btime solve(prob, save_everystep = false); +@btime solve(prob, FBDF(), save_everystep = false); return nothing # hide ``` ```@example sparsejac -@btime solve(sparseprob, save_everystep = false); +@btime solve(sparseprob, FBDF(), save_everystep = false); return nothing # hide ``` -Notice though that the analytical solution to the Jacobian can be quite expensive. -Thus in some cases we may only want to get the sparsity pattern. In this case, -we can simply do: +It is also possible to use the numerical Jacobian, +but take advantage of the analytical sparsity pattern: ```@example sparsejac sparsepatternprob = ODEProblem(sys, Pair[], (0.0, 11.5), sparse = true) -@btime solve(sparsepatternprob, save_everystep = false); +@btime solve(sparsepatternprob, FBDF(), save_everystep = false); return nothing # hide ```