Skip to content

Commit 77a7469

Browse files
Merge pull request #853 from ChrisRackauckas-Claude/bump-breaking-sciml3-diffeqbase7
Bump docs for SciMLBase v3 / DiffEqBase v7 / OrdinaryDiffEq v7
2 parents 7cf30b7 + dad468a commit 77a7469

14 files changed

Lines changed: 134 additions & 159 deletions

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DiffEqDocs"
22
uuid = "d91efeb5-c178-44a6-a2ee-51685df7c78e"
33
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
4-
version = "7.20.0"
4+
version = "7.21.0"
55

66
[deps]
77
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

docs/Project.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ DASSL = "2"
6464
DDEProblemLibrary = "0.1"
6565
DataFrames = "1.4"
6666
DelayDiffEq = "5.52"
67-
DiffEqBase = "6.106"
68-
DiffEqCallbacks = "3, 4"
67+
DiffEqBase = "7"
68+
DiffEqCallbacks = "4"
6969
DifferentialEquations = "7.14"
7070
Distributions = "0.25"
7171
Documenter = "1"
@@ -80,18 +80,18 @@ ODEInterfaceDiffEq = "3"
8080
ODEProblemLibrary = "0.1, 1"
8181
Optimization = "3, 4, 5"
8282
OptimizationNLopt = "0.2, 0.3"
83-
OrdinaryDiffEq = "6.76"
84-
OrdinaryDiffEqBDF = "1"
85-
OrdinaryDiffEqCore = "1, 2.0, 3.1"
83+
OrdinaryDiffEq = "7"
84+
OrdinaryDiffEqBDF = "2"
85+
OrdinaryDiffEqCore = "4"
8686
Plots = "1"
87-
RecursiveArrayTools = "3, 4"
87+
RecursiveArrayTools = "4"
8888
SDEProblemLibrary = "0.1, 1"
8989
SciMLBase = "3.1"
9090
SciMLOperators = "0.3, 0.4, 1"
9191
SimpleDiffEq = "1"
9292
SparseConnectivityTracer = "0.6, 1"
9393
StaticArrays = "1"
9494
SteadyStateDiffEq = "2.4"
95-
StochasticDiffEq = "6.70"
95+
StochasticDiffEq = "7"
9696
Sundials = "4.11.3, 5"
9797
Unitful = "1"

docs/src/basics/faq.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,18 +522,20 @@ Here we use a cached temporary array to avoid the allocations of matrix
522522
multiplication. When autodifferentiation occurs, the element type of `u` is
523523
`Dual` numbers, so `A*u` produces `Dual` numbers, so the error arises when it
524524
tries to write into `tmp`. There are two ways to avoid this. The first way,
525-
the easy way, is to just turn off autodifferentiation with the `autodiff=false`
526-
option in the solver. Every solver which uses autodifferentiation has this option.
527-
Thus, we'd solve this with:
525+
the easy way, is to swap the AD backend for a numerical one via the
526+
`autodiff` keyword on the solver, using the `ADTypes` interface
527+
(`AutoFiniteDiff()`). Every solver which uses autodifferentiation accepts
528+
this. Thus, we'd solve this with:
528529

529530
```julia
530-
import DifferentialEquations as DE, OrdinaryDiffEq as ODE
531+
import DifferentialEquations as DE, OrdinaryDiffEq as ODE, ADTypes
531532
prob = DE.ODEProblem(f, ones(5, 5), (0.0, 1.0))
532-
sol = DE.solve(prob, ODE.Rosenbrock23(autodiff = false))
533+
sol = DE.solve(prob, ODE.Rosenbrock23(autodiff = ADTypes.AutoFiniteDiff()))
533534
```
534535

535-
and it will use a numerical differentiation fallback (DiffEqDiffTools.jl) to
536-
calculate Jacobians.
536+
and it will use a numerical differentiation fallback (FiniteDiff.jl) to
537+
calculate Jacobians. (Prior to OrdinaryDiffEq v7 the shortcut
538+
`autodiff = false` did the same thing; v7 requires an `ADTypes` object.)
537539

538540
We could use `get_tmp` and `dualcache` functions from
539541
[PreallocationTools.jl](https://github.com/SciML/PreallocationTools.jl)

docs/src/basics/integrator.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,29 @@ for i in integrator
5050
end
5151
```
5252

53-
In addition, some helper iterators are provided to help monitor the solution. For
54-
example, the `tuples` iterator lets you view the values:
53+
In addition, you can monitor the solution by reading the current `u` / `t`
54+
off the integrator on each step:
5555

5656
```julia
57-
for (u, t) in tuples(integrator)
57+
for i in integrator
58+
u, t = integrator.u, integrator.t
5859
@show u, t
5960
end
6061
```
6162

62-
and the `intervals` iterator lets you view the full interval:
63+
or view both the previous and current endpoints of each accepted step:
6364

6465
```julia
65-
for (uprev, tprev, u, t) in intervals(integrator)
66+
for i in integrator
67+
uprev, tprev = integrator.uprev, integrator.tprev
68+
u, t = integrator.u, integrator.t
6669
@show tprev, t
6770
end
6871
```
6972

70-
Additionally, you can make the iterator return specific time points via the
71-
`TimeChoiceIterator`:
72-
73-
```julia
74-
ts = range(0, stop = 1, length = 11)
75-
for (u, t) in TimeChoiceIterator(integrator, ts)
76-
@show u, t
77-
end
78-
```
73+
(The old `tuples` / `intervals` / `TimeChoiceIterator` helper iterators were
74+
removed in SciMLBase v3 — iterate the integrator directly and read the field
75+
you want on each step.)
7976

8077
Lastly, one can dynamically control the “endpoint”. The initialization simply makes
8178
`prob.tspan[2]` the last value of `tstop`, and many of the iterators are made to stop
@@ -252,8 +249,8 @@ choose:
252249
```julia
253250
integrator = DE.init(
254251
prob, DE.Tsit5(); dt = 1 // 2^(4), tstops = [0.5], advance_to_tstop = true)
255-
for (u, t) in tuples(integrator)
256-
@test t [0.5, 1.0]
252+
for i in integrator
253+
@test integrator.t [0.5, 1.0]
257254
end
258255
```
259256

docs/src/basics/solution.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,11 @@ number of saved timepoints.
150150
The solution interface also includes some special fields. The problem object
151151
`prob` and the algorithm used to solve the problem `alg` are included in the
152152
solution. Additionally, the field `dense` is a boolean which states whether
153-
the interpolation functionality is available. Further, the field `destats`
154-
contains the internal statistics for the solution process, such as the number
155-
of linear solves and convergence failures. Lastly, there is a mutable state
156-
`tslocation` which controls the plot recipe behavior. By default, `tslocation=0`.
153+
the interpolation functionality is available. Further, the field `stats`
154+
contains the internal statistics
155+
for the solution process, such as the number of linear solves and convergence
156+
failures. Lastly, there is a mutable state `tslocation` which controls the
157+
plot recipe behavior. By default, `tslocation=0`.
157158
Its values have different meanings between partial and ordinary differential equations:
158159

159160
- `tslocation=0` for non-spatial problems (ODEs) means that the plot recipe
@@ -168,7 +169,7 @@ will default to plotting the surface at the final timepoint. The iterator interf
168169
simply iterates the value of `tslocation`, and the `animate` function iterates
169170
the solution calling solve at each step.
170171

171-
## Differential Equation Solver Statistics (destats)
172+
## Differential Equation Solver Statistics (sol.stats)
172173

173174
```@docs
174175
SciMLBase.DEStats

docs/src/examples/min_and_max.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ Let's add the maxima and minima to the plots:
8585

8686
```@example minmax
8787
Plots.plot(sol, vars = (0, 4), plotdensity = 10000)
88-
Plots.scatter!([opt.u], [opt.minimum], label = "Local Min")
89-
Plots.scatter!([opt2.u], [-opt2.minimum], label = "Local Max")
88+
Plots.scatter!([opt.u], [opt.objective], label = "Local Min")
89+
Plots.scatter!([opt2.u], [-opt2.objective], label = "Local Max")
9090
```
9191

9292
### Global Optimization
@@ -108,6 +108,6 @@ gopt2 = OPT.solve(optprob2, OptNL.NLopt.GN_ORIG_DIRECT_L())
108108

109109
```@example minmax
110110
Plots.plot(sol, vars = (0, 4), plotdensity = 10000)
111-
Plots.scatter!([gopt.u], [gopt.minimum], label = "Global Min")
112-
Plots.scatter!([gopt2.u], [-gopt2.minimum], label = "Global Max")
111+
Plots.scatter!([gopt.u], [gopt.objective], label = "Global Min")
112+
Plots.scatter!([gopt2.u], [-gopt2.objective], label = "Global Max")
113113
```

docs/src/extras/timestepping.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
CurrentModule = OrdinaryDiffEqCore
55
```
66

7+
!!! note "OrdinaryDiffEq v7 controller refactor"
8+
Starting with OrdinaryDiffEq v7, each controller (`IController`,
9+
`PIController`, `PIDController`, `PredictiveController`) is a real object
10+
that owns its own state. The `beta1`, `beta2`, `gamma`, `qmin`, `qmax`,
11+
`qsteady_min`, `qsteady_max`, and `qoldinit` tuning parameters now live
12+
on the controller struct, not on `integrator.opts`. The error estimate
13+
previously stored as `integrator.EEst` is obtained with
14+
`OrdinaryDiffEqCore.get_EEst(integrator)`. Fields `qold`, `q11`,
15+
`erracc`, `dtacc`, and `q` moved from `ODEIntegrator` to the controller
16+
cache (`integrator.controller_cache`). The pseudocode below uses the
17+
pre-v7 field names to keep the algorithmic descriptions readable; in the
18+
v7 codebase, each reference corresponds to the equivalent controller
19+
struct / controller cache field.
20+
721
## Common Setup
822

923
All methods start by calculating a scaled error estimate on each scalar component of ``u``:

docs/src/features/io.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@ sol = ODE.solve(prob, ODE.Euler(); dt = 1 // 2^(4));
2020
df = DataFrames.DataFrame(sol)
2121
```
2222

23-
If we set `syms` in the DiffEqFunction, then those names will be used:
23+
If we attach an ModelingToolkit / SciML symbolic system via the problem's
24+
`sys`, then those names will be used:
2425

2526
```@example IO
26-
f = ODE.ODEFunction(f_2dlinear, syms = [:a, :b, :c, :d])
27-
prob = ODE.ODEProblem(f, rand(2, 2), (0.0, 1.0));
28-
sol = ODE.solve(prob, ODE.Euler(); dt = 1 // 2^(4));
2927
df = DataFrames.DataFrame(sol)
3028
```
3129

32-
Many modeling frameworks will automatically set `syms` for this feature.
30+
Modeling frameworks like ModelingToolkit automatically attach a `sys`, which
31+
provides the state/parameter names used here.
3332
Additionally, this data can be saved to a CSV:
3433

3534
```@example IO

docs/src/features/linear_nonlinear.md

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -37,47 +37,18 @@ on the choices.
3737
## Preconditioners: `precs` Specification
3838

3939
Any [LinearSolve.jl-compatible preconditioner](https://docs.sciml.ai/LinearSolve/stable/basics/Preconditioners/)
40-
can be used as a left or right preconditioner. Preconditioners are specified by
41-
the `Pl,Pr = precs(W,du,u,p,t,newW,Plprev,Prprev,solverdata)` function where
42-
the arguments are defined as:
43-
44-
- `W`: the current Jacobian of the nonlinear system. Specified as either
45-
``I - \gamma J`` or ``I/\gamma - J`` depending on the algorithm. This will
46-
commonly be a `WOperator` type defined by OrdinaryDiffEq.jl. It is a lazy
47-
representation of the operator. Users can construct the W-matrix on demand
48-
by calling `convert(AbstractMatrix,W)` to receive an `AbstractMatrix` matching
49-
the `jac_prototype`.
50-
- `du`: the current ODE derivative
51-
- `u`: the current ODE state
52-
- `p`: the ODE parameters
53-
- `t`: the current ODE time
54-
- `newW`: a `Bool` which specifies whether the `W` matrix has been updated since
55-
the last call to `precs`. It is recommended that this is checked to only
56-
update the preconditioner when `newW == true`.
57-
- `Plprev`: the previous `Pl`.
58-
- `Prprev`: the previous `Pr`.
59-
- `solverdata`: Optional extra data the solvers can give to the `precs` function.
60-
Solver-dependent and subject to change.
61-
62-
The return is a tuple `(Pl,Pr)` of the LinearSolve.jl-compatible preconditioners.
63-
To specify one-sided preconditioning, simply return `nothing` for the preconditioner
64-
which is not used.
65-
66-
Additionally, `precs` must supply the dispatch:
40+
can be used as a left or right preconditioner. Preconditioners are configured on the `linsolve`
41+
object itself, through LinearSolve's `Pl` / `Pr` interface. For example:
6742

6843
```julia
69-
Pl, Pr = precs(W, du, u, p, t, ::Nothing, ::Nothing, ::Nothing, solverdata)
44+
using LinearSolve
45+
alg = TRBDF2(linsolve = KrylovJL_GMRES(precs = mypreconditioner))
7046
```
7147

72-
which is used in the solver setup phase to construct the integrator
73-
type with the preconditioners `(Pl,Pr)`.
74-
75-
The default is `precs=DEFAULT_PRECS` where the default preconditioner function
76-
is defined as:
77-
78-
```julia
79-
DEFAULT_PRECS(W, du, u, p, t, newW, Plprev, Prprev, solverdata) = nothing, nothing
80-
```
48+
See the [LinearSolve preconditioners
49+
documentation](https://docs.sciml.ai/LinearSolve/stable/basics/Preconditioners/)
50+
for the expected `precs` function signature (`Pl, Pr = precs(A, p)`) and the
51+
full list of supported preconditioner types.
8152

8253
## Nonlinear Solvers: `nlsolve` Specification
8354

docs/src/features/performance_overloads.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,23 @@ of pre-computed functions to speed up the calculations. This is offered via the
1616
using the in-solver code.
1717

1818
All applicable stiff differential equation solvers in the Julia ecosystem
19-
(OrdinaryDiffEq.jl, StochasticDiffEq.jl, DelayDiffEq.jl, etc.) take the following
20-
arguments for handling the automatic Jacobian construction with the following defaults:
21-
22-
- `chunk_size`: The chunk size used with ForwardDiff.jl. Defaults to `Val{0}()`
23-
and thus uses the internal ForwardDiff.jl algorithm for the choice.
24-
- `autodiff`: Specifies whether to use automatic differentiation via
25-
[ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) or finite
26-
differencing via [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl).
27-
Defaults to `Val{true}()` for automatic differentiation.
28-
- `standardtag`: Specifies whether to use package-specific tags instead of the
29-
ForwardDiff default function-specific tags. For more information, see
30-
[this blog post](https://www.stochasticlifestyle.com/improved-forwarddiff-jl-stacktraces-with-package-tags/).
31-
Defaults to `Val{true}()`.
19+
(OrdinaryDiffEq.jl, StochasticDiffEq.jl, DelayDiffEq.jl, etc.) take an
20+
`autodiff` keyword for handling automatic Jacobian construction. This takes an `ADTypes` object,
21+
which means every AD backend in the Julia ecosystem is supported
22+
through the same interface:
23+
24+
- `autodiff`: Specifies the AD backend to use for Jacobian / gradient
25+
construction via the [ADTypes.jl](https://github.com/SciML/ADTypes.jl)
26+
interface. Common choices include `AutoForwardDiff()` (default),
27+
`AutoFiniteDiff()` (numerical fallback), `AutoEnzyme()`, `AutoZygote()`,
28+
and `AutoMooncake()`. `AutoForwardDiff` and `AutoFiniteDiff` accept their
29+
own tuning kwargs (e.g. `AutoForwardDiff(chunksize=12)`, or
30+
`AutoFiniteDiff(fdtype=Val(:central))`), which replace the old
31+
per-solver `chunk_size` / `diff_type` kwargs.
3232
- `concrete_jac`: Specifies whether a Jacobian should be constructed. Defaults to
3333
`nothing`, which means it will be chosen true/false depending on circumstances
3434
of the solver, such as whether a Krylov subspace method is used for `linsolve`.
35-
- `diff_type`: The type of differentiation used in FiniteDiff.jl if `autodiff=false`.
36-
Defaults to `Val{:forward}`, with alternatives of `Val{:central}` and
37-
`Val{:complex}`.
35+
3836

3937
## Passing Jacobian Function Definitions
4038

0 commit comments

Comments
 (0)