Skip to content

Commit c37ffd0

Browse files
committed
Use matrix-dependent solver for sparse analytical Jacobian example
1 parent 3808c22 commit c37ffd0

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

docs/src/examples/sparse_jacobians.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ Now let's use `modelingtoolkitize` to generate the symbolic version:
6060

6161
```@example sparsejac
6262
@mtkcompile sys = modelingtoolkitize(prob);
63-
nothing # hide
6463
```
6564

6665
Now we regenerate the problem using `jac=true` for the analytical Jacobian
@@ -74,21 +73,20 @@ Hard? No! How much did that help?
7473

7574
```@example sparsejac
7675
using BenchmarkTools
77-
@btime solve(prob, save_everystep = false);
76+
@btime solve(prob, FBDF(), save_everystep = false);
7877
return nothing # hide
7978
```
8079

8180
```@example sparsejac
82-
@btime solve(sparseprob, save_everystep = false);
81+
@btime solve(sparseprob, FBDF(), save_everystep = false);
8382
return nothing # hide
8483
```
8584

86-
Notice though that the analytical solution to the Jacobian can be quite expensive.
87-
Thus in some cases we may only want to get the sparsity pattern. In this case,
88-
we can simply do:
85+
It is also possible to use the numerical Jacobian,
86+
but take advantage of the analytical sparsity pattern:
8987

9088
```@example sparsejac
9189
sparsepatternprob = ODEProblem(sys, Pair[], (0.0, 11.5), sparse = true)
92-
@btime solve(sparsepatternprob, save_everystep = false);
90+
@btime solve(sparsepatternprob, FBDF(), save_everystep = false);
9391
return nothing # hide
9492
```

0 commit comments

Comments
 (0)