-
-
Notifications
You must be signed in to change notification settings - Fork 49
API for ODE solvers #20
Comments
About the If I haven't misunderstood the discussion so far, we've assumed that
I'm a little unsure if this is even possible, and if so on exactly what this would mean for the syntax of the keyword argument, but I hope my idea comes across anyway. Is this approach possible? And if so, does it solve the problem of type specialization? Another solution to get this feature without performance problems, that was suggested in #7 but not listed here, was to have an overload of
|
@acroy Ah. Well, that still leaves the first suggestion, if it's possible - to make the kwargs for |
@tlycken It is not possible to use kwargs for dispatch. It will have to be a positional argument. One thing we can do is to make a wrapped y_final = odeX(F, y0, ODEFinal(t_1, t_end)) I have problems to see the value, because this is a special concept that internally will be represented like y_final = odeX(F, y0, [t_1, t_end], points = :specified )[2][end] And we need to present all the concepts in the last example to the user anyway. PS: I have no opinion on the order of |
@ivarne Ah, cool. It was the point about not being able to use kwargs for multiple dispatch I was forgetting. Then I think we should abandon the (Edit: sorry for closing - a little too hot on my keyboard shortcuts...) |
If we have to stretch too much in order to support |
I think that now is the right time to discuss how different features we want to have impacts the interface. I think |
I still think that |
Do I understand correctly that the out-of-place version would then, to keep things Julian, be something like Overall, I think adding an example in the documentation where we use |
Just want to draw attention to @JeffBezanson's comment in JuliaLang/julia@b425870 about the efficency of the
|
In But for the ODE interface it is often desirable to use a So, if we support the |
Regarding performance of splattering, it's not strictly a requirement for us to use it at all - we've considered it as a way of supporting two different methods:
but there's really no reason (that I'm aware of) for us to implement the second in terms of the first, rather than the other way around. Instead of defining
we could just as well (and perhaps preferrably, considering Jeff's comment) do
and avoid splattering of large arrays. The natural way to generate a big array is by using ranges (i.e. something like |
Basically we only need to support |
@acroy I'm not sure I agree we should tuck on It seems at least that we've reached the following conclusions here:
I think in a first iteration (say, for version 0.2) we could be happy without various convenience features we've discussed - neither an overload on the form |
Another feature which I'd find useful is to be able to use event functions (see #11) to terminate the solver, rather than a specified time range. In that case, I'd want to use an infinite time span and provide an event function which terminates the solver when some condition is met. (Of course, if I provide an infinite time span and a terminate condition which will never be satisfied, I have only myself to blame and Ctrl+C is my friend...) Is this something we'd like to support? In that case, what would be a good way to specify the API for it? |
@tlycken : I fully agree that any convenience features can be postponed and supporting something like Regarding the "abort on event": In principle you can use |
@acroy That's a good point - the fact that |
@ivarne mentioned in #27 that when solving problems for For example, one could imagine specifying |
An important difference in Julia versus Matlab, is that you will not get imaginary results for |
EDIT: as suggested by @ivarne, now a separate issue #30 I have not seen the PETSc ODE/DAE time steppers and their API
For problems using implicit methods this is used as Best have a look at the PETSc manual which gives a nice concise intro (Chapter 6): PETSc has a liberal licence so code could probably be translated Further, some cool solvers PETSc has:
Disclaimer: I have not actually used the PETSc solvers, just read |
@mauro3 Thanks for your input. I would prefer if you could copy your comment into a new issue. I have tried to collect the result into https://github.com/JuliaLang/ODE.jl/blob/master/doc/api.md, and if we make changes to accomodate the methodology in the PETSc solvers, we must do it there. I think the discussion will be more focused if we have separate issues for separate concerns, and not just add random stuff at the end of general issues. |
@ivarne my comment above was really about the PETSc API, so I thought that it would fit into this issue. I opened a new issue for it now. Let me know if you want me to add a 'under consideration' section for PETSc API to https://github.com/JuliaLang/ODE.jl/blob/master/doc/api.md. |
@ivarne Perhaps we should close this issue now, and refer further discussions to new issues and api.md? |
Yes. I almost closed it 2 hours ago, but felt it would be wrong to do that before @mauro3's comments had been moved to a clean issue. |
This is a summary of the discussions in #7 and #4 and intended to reflect the latest decisions about the API.
Each (adaptive) solver accepts 3 arguments (PR in #14 )
F
: the RHS of the ODEdy/dt = F(t,y)
, which is a function oft
andy(t)
and returnsdy/dt::typeof(y)
y0
: initial value (no type specified -> duck typing)tspan
: an array of points at which the solution is requested (length(tspan)>=2
), the elements can be ordered ascending or descending (see ode45 should support stepping from high to low and support a vector of steps #2)Moreover, the following keywords are supported
norm
: user-supplied norm for determining the errorE
(defaultBase.norm
)abstol
and/orreltol
: an integration step is accepted ifE <= abstol || E <= reltol*abs(y)
(ideally we want both criteria for all solvers, done in Use keyword arguments to set the tolerance #13)points=:all | :specified | :final
: controls the type of output according topoints==:all
(default) output is given for each value intspan
as well as for each intermediate point the solver used.points==:specified
output is given only for each value intspan
.points==:final
output is given only for the last value intspan
, i.e. at the end of integration (speculative).maxstep
,minstep
andinitstep
: determine the maximal, minimal and initial integration step.The solver returns two arrays (PR in #14)
tout
: points at which solutions were obtained (also see keywordpoints
)yout
: solutions at timestout
; ifpoints=:all | :specified
is used,yout::Vector{typeof(y0)}
. Forpoints==:final
the solution at the end of the integrationyout::typeof(y0)
is returned (speculative).If we we decide to support non-adaptive solvers (see #9), those should have the same arguments and return values.
The text was updated successfully, but these errors were encountered: