Skip to content
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

Clarify nlprob docs for ODEFunction #844

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/scimlfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ ODEFunction{iip,specialize}(f;
sparsity = __has_sparsity(f) ? f.sparsity : jac_prototype,
paramjac = __has_paramjac(f) ? f.paramjac : nothing,
colorvec = __has_colorvec(f) ? f.colorvec : nothing,
nlprob = __has_nlprob(f) ? f.nlprob : nothing,
sys = __has_sys(f) ? f.sys : nothing)
```

Expand Down Expand Up @@ -289,10 +290,16 @@ the usage of `f`. These include:
based on the sparsity pattern. Defaults to `nothing`, which means a color vector will be
internally computed on demand when required. The cost of this operation is highly dependent
on the sparsity pattern.
- `nlprob`: a `NonlinearProblem` that solves `f(u, t, p) = u_tmp`
where the nonlinear parameters are the tuple `(t, u_tmp, p)`.
This will be used as the nonlinear problem inside an implicit solver by specifying `u, u_tmp` and `t`
such that solving this function produces a solution to the implicit step of your solver.
- `nlprob`: some `AbstractNonlinearProblem` to define custom nonlinear problems to be used for
implicit time discretizations. This allows to use extra structure of the ODE function (e.g.
multi-level structure). The rationale here is essentially that implicit ODE integration algorithms
need do solve the a nonlinear problems, usually of the form `dt⋅f(γ⋅z+inner_tmp,p,t) + outer_tmp = z`,
during time integration, where users want to use extra structure of f during the nonlinear solve.
Here `z` is the stage solution vector, `p` is the parameter vector of the ODE problem, `t` is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are dt, inner_tmp, outer_tmp, and z defined? in p? Where in p is it assumed? Or does it match some interface?

Aren't you missing a function that updates the prob based on those values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Tried to resolve this in the latest commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how that addresses it. So okay, how do I update inner_tmp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see how that logic changes in OrdinaryDiffEqNonlinearSolve.jl. From my current understanding the specific ode integrator at hand passes some struct with e.g. inner_tmp into the nlprob (e.g. via remake?) to update these during setup and remake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should have a better interface (a NamedTuple at least would be a step up)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure a functional interface buys us much here since the only things the user is expected to do is get the elements out...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MTK cannot easily generate a NamedTuple. An interface via a function would make it easy to generate via SII

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] functional interface [...]

Functional interface as in non-defective interface or as in function programming?

Regarding the tuples, I think we are on the same page then. I see two main advantage of having structs to control the dispatches for the initialization of different nonlinear solver classes (over having tuples and hard-coded if-else blocks on types):

  1. Being extensible for custom solvers for specific problem classes
  2. Being less error prone to changes, e.g. when there might be some decision in the future to add another possibility to the values of method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does SymbolicIndexingInterface have to do with this?

the time, `dt` the respective time increment`, `γ` is some scaling factor and the temporary
variables are some compatible vectors set by the specific solver.
Note that other implicit techniques, like for example some fully-implicit Runge-Kutta methods,
need to solve different nonlinear systems.

## iip: In-Place vs Out-Of-Place

Expand Down