Skip to content

Commit 0eaf0f9

Browse files
committed
Document ODEProblem
I will also have this in the official docs. Seems really useful.
1 parent f1a17e6 commit 0eaf0f9

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Improved stability in propagating `solve` keywords.
1010
* `get_sol` now returns solution and time vector for generality purposes.
1111
* `get_sol` is now also exported.
12+
* Internal `ODEProblem` constructor correctly merges different callbacks.
1213

1314
# v0.3.3
1415
## Non-breaking

src/continuous.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@ You can use `ds.prob.u0 .= newstate` to set a new state to the system.
3232
The equations of motion **must be** in the form `eom!(t, u, du)`,
3333
which means that they are **in-place** with the mutated argument
3434
`du` the last one. Both `u, du` **must be** `Vector`s. You can still use matrices
35-
in your equations of motion though! Just change `function eom(t, u, du)` to
35+
in your equations of motion though! Just change `function eom!(t, u, du)` to
3636
```julia
37-
function eom(t, u, du)
37+
function eom!(t, u, du)
3838
um = reshape(u, a, b); dum = reshape(du, a, b)
3939
# equations of motion with matrix shape of a×b
4040
```
41-
and you will be able to express the equations with matrix notation.
4241
43-
If you have the `eom` function, and optionally a function for the
42+
If you have the `eom!` function, and optionally a function for the
4443
Jacobian, you can use the constructor
4544
```julia
4645
ContinuousDS(state, eom! [, jacob! [, J]]; tspan = (0.0, 100.0))
@@ -59,7 +58,8 @@ using the module [`ForwardDiff`](http://www.juliadiff.org/ForwardDiff.jl/stable/
5958
As mentioned in our [official documentation](https://juliadynamics.github.io/DynamicalSystems.jl/latest/system_definition#example-using-functors),
6059
it is preferred to use Functors for both the equations of motion and the Jacobian.
6160
62-
To interfece *towards* DifferentialEquations.jl use `ODEIntegrator(ds, stuff...)`.
61+
To interfece *towards* DifferentialEquations.jl use `ODEIntegrator(ds, stuff...)`
62+
and `ODEProblem(ds, stuff...)`.
6363
Notice that you can have performance gains for stiff methods by
6464
explicitly adding a Jacobian caller for DifferentialEquations.jl by defining
6565
`eom!(::Type{Val{:jac}}, t, u, J) = jacob!(t, u, J)`.
@@ -165,6 +165,12 @@ ODEProblem(ds::ContinuousDS, tspan::Tuple, state = ds.prob.u0) =
165165
ODEProblem{true}(ds.prob.f, state, tspan,
166166
callback = ds.prob.callback, mass_matrix = ds.prob.mass_matrix)
167167

168+
"""
169+
ODEProblem(ds::ContinuousDS, t, state = ds.prob.u0 [, callback])
170+
Create a new `ODEProblem` for the given dynamical system that final time `t` (or `tspan`
171+
for tuple `t`), `state` and if given, also merges the `callback` with other existing
172+
callbacks currently in `ds.prob`.
173+
"""
168174
function ODEProblem(ds::ContinuousDS, t::Real, state, cb)
169175
if ds.prob.callback == nothing
170176
return ODEProblem{true}(ds.prob.f, state, (zero(t), t),
@@ -299,7 +305,7 @@ end
299305
"""
300306
get_sol(prob::ODEProblem [, diff_eq_kwargs::Dict, extra_kwargs::Dict])
301307
Solve the `prob` using `solve` and return the solutions vector as well as
302-
the time vector.
308+
the time vector. Always uses the keyword argument `save_everystep=false`.
303309
304310
The second and third
305311
arguments are optional *position* arguments, passed to `solve` as keyword arguments.

0 commit comments

Comments
 (0)