Skip to content

Commit aaee38b

Browse files
massive documentation update
1 parent 326a457 commit aaee38b

14 files changed

+603
-60
lines changed

docs/src/basics/faq.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ know the Jacobian is sparse, `linear_solver=:GMRES` is a good option. Once
121121
again, a good reference for how to handle PDE discretizations can be found
122122
[at this blog post](http://www.stochasticlifestyle.com/solving-systems-stochastic-pdes-using-gpus-julia/).
123123

124+
#### My Problem Has Discontinuities and is Unstable / Slow, What Do I Do?
125+
126+
[This Discourse post](https://discourse.julialang.org/t/handling-instability-when-solving-ode-problems/9019/5)
127+
goes into detail for how to handle discontinuities in your ODE function and how
128+
to use that extra information to speed up the solver.
129+
124130
## Complicated Models
125131

126132
#### Can I switch my ODE function in the middle of integration?
@@ -218,10 +224,10 @@ Yes! Take a look at the
218224
[sensitivity analysis](http://docs.juliadiffeq.org/latest/analysis/sensitivity.html)
219225
page for more details.
220226

221-
If the algorithm does not have differentiation of parameter-depedendent events,
222-
then you simply need to make the initial condition have elements of Dual numbers.
227+
If the algorithm does not have differentiation of parameter-depedendent events,
228+
then you simply need to make the initial condition have elements of Dual numbers.
223229
If the algorithm uses Dual numbers, you need to make sure that time is also
224-
given by Dual numbers.
230+
given by Dual numbers.
225231

226232
To show this in action, let's say we want to find the Jacobian of solution
227233
of the Lotka-Volterra equation at `t=10` with respect to the parameters.
@@ -241,7 +247,7 @@ end
241247
This function takes in new parameters and spits out the solution at the end.
242248
We make the inital condition `eltype(p).([1.0,1.0])` so that way it's typed to
243249
be Dual numbers whenever `p` is an array of `Dual` numbers, and we do the same
244-
for the timespan just to show what you'd do if there was parameters-dependent events.
250+
for the timespan just to show what you'd do if there was parameters-dependent events.
245251
Then we can take the Jacobian via ForwardDiff.jl:
246252

247253
```julia

docs/src/features/performance_overloads.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ The full interface available to the solvers is as follows:
2020
state `u` at time `t`.
2121
- `analytic`: Defines an analytical solution using `u0` at time `t` with `p`
2222
which will cause the solvers to return errors. Used for testing.
23-
- `invW`: The inverse of `M - gamma*J` where `J` is the `jac`.
24-
- `invW_t`: The inverse of `M/gamma - J` where `J` is the `jac`.
23+
- `Wfact`: The LU-factorization of `M - gamma*J` where `J` is the `jac`.
24+
- `Wfact_t`: The LU-factorization of `M/gamma - J` where `J` is the `jac`.
2525
- `ggprime`: See the definition in the SDEProblem page.
26+
- `syms`: Allows you to name your variables for automatic names in plots and
27+
other output.
2628

2729
### ODEFunction
2830

@@ -33,9 +35,10 @@ function ODEFunction{iip,recompile}(f;
3335
tgrad=nothing, # (dT,u,p,t) or (u,p,t)
3436
jac=nothing, # (J,u,p,t) or (u,p,t)
3537
jac_prototype=nothing, # Type for the Jacobian
36-
invW=nothing, # (iW,u,p,t) or (u,p,t)
37-
invW_t=nothing, # (iW,u,p,t) or (u,p,t)
38+
Wfact=nothing, # (iW,u,p,gamma,t) or (u,p,gamma,t)
39+
Wfact_t=nothing, # (iW,u,p,gamma,t) or (u,p,gamma,t)
3840
paramjac = nothing, # (pJ,u,p,t) or (u,p,t)
41+
colorvec = nothing,
3942
syms = nothing) # collection of names for variables
4043
```
4144

@@ -67,10 +70,11 @@ function SDEFunction{iip,recompile}(f,g;
6770
tgrad=nothing,
6871
jac=nothing,
6972
jac_prototype=nothing,
70-
invW=nothing,
71-
invW_t=nothing,
73+
Wfact=nothing,
74+
Wfact_t=nothing,
7275
paramjac = nothing,
7376
ggprime = nothing,
77+
colorvec = nothing,
7478
syms = nothing)
7579
```
7680

@@ -94,9 +98,10 @@ function RODEFunction{iip,recompile}(f;
9498
tgrad=nothing,
9599
jac=nothing,
96100
jac_prototype=nothing,
97-
invW=nothing,
98-
invW_t=nothing,
101+
Wfact=nothing,
102+
Wfact_t=nothing,
99103
paramjac = nothing,
104+
colorvec = nothing,
100105
syms = nothing)
101106
```
102107

@@ -109,8 +114,8 @@ function DAEFunction{iip,recompile}(f;
109114
tgrad=nothing,
110115
jac=nothing, # (J,du,u,p,gamma,t) or (du,u,p,gamma,t)
111116
jac_prototype=nothing,
112-
invW=nothing,
113-
invW_t=nothing,
117+
Wfact=nothing,
118+
Wfact_t=nothing,
114119
paramjac = nothing,
115120
syms = nothing)
116121
```
@@ -127,9 +132,10 @@ function DDEFunction{iip,recompile}(f;
127132
tgrad=nothing,
128133
jac=nothing,
129134
jac_prototype=nothing,
130-
invW=nothing,
131-
invW_t=nothing,
135+
Wfact=nothing,
136+
Wfact_t=nothing,
132137
paramjac = nothing,
138+
colorvec = nothing,
133139
syms = nothing)
134140
```
135141

@@ -240,7 +246,7 @@ The Jacobian should be given in the form `gamma*dG/d(du) + dG/du ` where `gamma`
240246
is given by the solver. This means that the signature is:
241247

242248
```julia
243-
f(::Type{Val{:jac}},J,du,u,p,gamma,t)
249+
f(J,du,u,p,gamma,t)
244250
```
245251

246252
For example, for the equation
@@ -255,7 +261,7 @@ end
255261
we would define the Jacobian as:
256262

257263
```julia
258-
function testjac(::Type{Val{:jac}},J,du,u,p,gamma,t)
264+
function testjac(J,du,u,p,gamma,t)
259265
J[1,1] = gamma - 2.0 + 1.2 * u[2]
260266
J[1,2] = 1.2 * u[1]
261267
J[2,1] = - 1 * u[2]
@@ -266,9 +272,7 @@ end
266272

267273
## Symbolically Calculating the Functions
268274

269-
ParameterizedFunctions.jl automatically calculates as many of these functions as
270-
possible and generates the `ODEFunction` using SymEngine. Thus, for good performance
271-
with the least work, it is one can try ParameterizedFunctions.jl.
272-
273-
Additionally, an up-and-coming effort in the JuliaDiffEq ecosystem is
274-
ModelingToolkit.jl for performing these calculations more generically.
275+
See the `modelingtoolkitize` function from
276+
[ModelingToolkit.jl](https://github.com/JuliaDiffEq/ModelingToolkit.jl) for
277+
automatically symbolically calculating the Jacobian for numerically-defined
278+
functions.

0 commit comments

Comments
 (0)