New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docstrings for all of the problem types #151
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,73 @@ $(TYPEDEF) | |
""" | ||
struct StandardBVProblem end | ||
|
||
""" | ||
@doc doc""" | ||
$(TYPEDEF) | ||
|
||
Defines an BVP problem. | ||
Documentation Page: https://diffeq.sciml.ai/stable/types/bvp_types/ | ||
|
||
## Mathematical Specification of a BVP Problem | ||
|
||
To define a BVP Problem, you simply need to give the function ``f`` and the initial | ||
condition ``u₀`` which define an ODE: | ||
|
||
```math | ||
\frac{du}{dt} = f(u,p,t) | ||
``` | ||
|
||
along with an implicit function `bc!` which defines the residual equation, where | ||
|
||
```math | ||
bc(u,p,t) = 0 | ||
``` | ||
|
||
is the manifold on which the solution must live. A common form for this is the | ||
two-point `BVProblem` where the manifold defines the solution at two points: | ||
|
||
```math | ||
u(t_0) = a | ||
u(t_f) = b | ||
``` | ||
|
||
## Problem Type | ||
|
||
### Constructors | ||
|
||
```julia | ||
TwoPointBVProblem{isinplace}(f,bc!,u0,tspan,p=NullParameters();kwargs...) | ||
BVProblem{isinplace}(f,bc!,u0,tspan,p=NullParameters();kwargs...) | ||
``` | ||
|
||
For any BVP problem type, `bc!` is the inplace function: | ||
|
||
```julia | ||
bc!(residual, u, p, t) | ||
``` | ||
|
||
where `residual` computed from the current `u`. `u` is an array of solution values | ||
where `u[i]` is at time `t[i]`, while `p` are the parameters. For a `TwoPointBVProblem`, | ||
`t = tspan`. For the more general `BVProblem`, `u` can be all of the internal | ||
time points, and for shooting type methods `u=sol` the ODE solution. | ||
Note that all features of the `ODESolution` are present in this form. | ||
In both cases, the size of the residual matches the size of the initial condition. | ||
|
||
Parameters are optional, and if not given then a `NullParameters()` singleton | ||
will be used which will throw nice errors if you try to index non-existent | ||
parameters. Any extra keyword arguments are passed on to the solvers. For example, | ||
if you set a `callback` in the problem, then that `callback` will be added in | ||
every solve call. | ||
|
||
### Fields | ||
|
||
* `f`: The function for the ODE. | ||
* `bc`: The boundary condition function. | ||
* `u0`: The initial condition. Either the initial condition for the ODE as an | ||
initial value problem, or a `Vector` of values for ``u(t_i)`` for collocation | ||
methods | ||
* `tspan`: The timespan for the problem. | ||
* `p`: The parameters for the problem. Defaults to `NullParameters` | ||
* `kwargs`: The keyword arguments passed onto the solves. | ||
Comment on lines
+63
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe one could use DocStringExtensions.FIELDS and add docstrings to the fields in the struct definition below instead. Possibly that's more robust when modifying fields. When JuliaLang/julia#29478 is fixed it would also allow users to access docstrings of fields directly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of them use it, some of them don't. But I think that would be "perfect is the enemy of good" here, since I won't have the time to split them all up so I think I'll plan to merge and open issue about splitting out the fields docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, just wanted to mention it 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're heard 😅 |
||
""" | ||
struct BVProblem{uType,tType,isinplace,P,F,bF,PT,K} <: AbstractBVProblem{uType,tType,isinplace} | ||
f::F | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,70 @@ | ||
# f(t,u,du,res) = 0 | ||
""" | ||
@doc doc""" | ||
$(TYPEDEF) | ||
|
||
Defines an implicit ordinary differential equation (ODE) or | ||
differential-algebraic equation (DAE) problem. | ||
Documentation Page: https://diffeq.sciml.ai/stable/types/dae_types/ | ||
|
||
## Mathematical Specification of an DAE Problem | ||
|
||
To define a DAE Problem, you simply need to give the function ``f`` and the initial | ||
condition ``u₀`` which define an ODE: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
|
||
```math | ||
0 = f(du,u,p,t) | ||
``` | ||
|
||
`f` should be specified as `f(du,u,p,t)` (or in-place as `f(resid,du,u,p,t)`). | ||
Note that we are not limited to numbers or vectors for `u₀`; one is allowed to | ||
provide `u₀` as arbitrary matrices / higher dimension tensors as well. | ||
|
||
## Problem Type | ||
|
||
### Constructors | ||
|
||
- `DAEProblem(f::DAEFunction,du0,u0,tspan,p=NullParameters();kwargs...)` | ||
- `DAEProblem{isinplace}(f,du0,u0,tspan,p=NullParameters();kwargs...)` : | ||
Defines the DAE with the specified functions. | ||
`isinplace` optionally sets whether the function is inplace or not. This is | ||
determined automatically, but not inferred. | ||
|
||
Parameters are optional, and if not given then a `NullParameters()` singleton | ||
will be used which will throw nice errors if you try to index non-existent | ||
parameters. Any extra keyword arguments are passed on to the solvers. For example, | ||
if you set a `callback` in the problem, then that `callback` will be added in | ||
every solve call. | ||
|
||
For specifying Jacobians and mass matrices, see the | ||
[DiffEqFunctions](@ref performance_overloads) | ||
page. | ||
|
||
### Fields | ||
|
||
* `f`: The function in the ODE. | ||
* `du0`: The initial condition for the derivative. | ||
* `u0`: The initial condition. | ||
* `tspan`: The timespan for the problem. | ||
* `differential_vars`: A logical array which declares which variables are the | ||
differential (non algebraic) vars (i.e. `du'` is in the equations for this | ||
variable). Defaults to nothing. Some solvers may require this be set if an | ||
initial condition needs to be determined. | ||
* `p`: The parameters for the problem. Defaults to `NullParameters` | ||
* `kwargs`: The keyword arguments passed onto the solves. | ||
|
||
## Example Problems | ||
|
||
Examples problems can be found in [DiffEqProblemLibrary.jl](https://github.com/JuliaDiffEq/DiffEqProblemLibrary.jl/blob/master/src/dae_premade_problems.jl). | ||
|
||
To use a sample problem, such as `prob_dae_resrob`, you can do something like: | ||
|
||
```julia | ||
#] add DiffEqProblemLibrary | ||
using DiffEqProblemLibrary.DAEProblemLibrary | ||
# load problems | ||
DAEProblemLibrary.importdaeproblems() | ||
prob = DAEProblemLibrary.prob_dae_resrob | ||
sol = solve(prob,IDA()) | ||
``` | ||
""" | ||
struct DAEProblem{uType,duType,tType,isinplace,P,F,K,D} <: AbstractDAEProblem{uType,duType,tType,isinplace} | ||
f::F | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially should be
``u_0``
.