-
-
Notifications
You must be signed in to change notification settings - Fork 49
Inspiration from PETSc ODE/DAE solvers for API and algorithms #30
Comments
I read over the project list in the GSOC page on the julia site (julialang.org/gsoc/2014/) "Project: PETSc integration for scalable technical computing PETSc is a widely used framework of data structures and computational routines suitable for massively scaling scientific computations. Many of these algorithms are also ideally suited for big data applications such as computing principal components of very large sparse matrices and solving complicated forecasting models with distributed methods for solving partial differential equations. This project proposal is to develop a new Julia package to interface with PETsc, thus allowing users access to state of the art scalable algorithms for optimization, eigenproblem solvers, finite element mesh computations, and hyperbolic partial differential equation solvers. The more mathematically oriented student may choose to study the performance of these various algorithms as compared to other libraries and naïve implementations. Alternatively, students may also be interested in working on the LLVM BlueGene port for deploying Julia with PetSc integration in an actual supercomputing environment. Expected Results: Wrapper package for the PETSc suite of libraries." It's a good idea to recreate the API in native Julia when, if someone does this project, the PETCs framework can be called directly from Julia?
What is your opinion on this? |
You're quite right to be concerned at the possibility of overhead because of calling an external library. In fact, benchmarking the PETSc interface vs one or a few particular algorithms reimplemented in native Julia could make for a very nice component of a summer project. The usual counterargument is that computing the functions and its derivatives will probably be expensive anyway, but it's an assertion that can be tested. |
The main reason to implement this in pure Julia is to support ODE integration with arbitrary types; basically, you want to support integrating ODE functions over any normed vector space, i.e. any type that supports at least |
Another reason to implement in Julia, is that many more people will be able to dive into the source code for the solvers they are using if it is written in Julia. This topic for this issue is anyway to draw inspiration from the API's for the PETSc solvers, into our own API discussions, not reimplementing everything in Julia. If someone are going to create wrappers for PETSc in Julia, it would be nice if they could make it effortlessly as a new backend for the solvers in ODE.jl |
Here a quick comparison of the PETSc and the matlab API for stiff solvers, e.g. Matlab's
The PETSc interface unifies the two matlab interfaces quite nicely. Also solvers which only support the (PS: anther reason to re-implement some of the PETSc-solvers in Julia is that PETSc is a big dependency which involves a lot of compilation. Too much to ask of someone just wanting to solve a ODE.) |
If we decided to generalize the API to the form PETSc uses, i.e. What is a good way to handle the case when the user calls a solver with both I think the idea of the API is really nice, and perhaps it's possible to create a wrapper function which, much like e.g. the (This comment somehow disappeared when I posted it about an hour ago...) |
Regarding API, I think we should prescribe both:
Not all solvers will support the second form, which is fine; they will just throw a All solvers which support the second form should also define the first form. Most simply, they may of course define |
This sounds good and would also be compatible with the API already defined. |
On second thought, although we should definitely have a simple interface (PETSc has you create a problem "object" and provides various methods to modify its properties. I suppose we could have something in a similar spirit but more Julian.) |
Matlab also sets the Jacobian or its sparsity structure in the ode-options. We could have a keyword argument, say |
We have actually introduced a keyword I like the idea of having a "problem type" and using dispatch to select the most appropriate solver, but IMO we should also support a low-level interface like |
@acroy, a problem type is a lower level interface than |
Rather than throw a I'm unsure about the problem specific types, and whether there is a place for them in this package. At the moment, What I was talking about in case of a general wrapper function, was something that would look like this (in pseudocode):
|
@tlycken, only defining the API for methods that make sense is what throws a The problem with your general wrapper is that there is no easy way to implement a test like |
Speaking from my experience I think it would be nice to support four types of equations with increasing generality:
Optionally, the second case could be split into I think these four types strike a balance between providing enough information on the equation and being easy enough to handle them through the API. Unfortunately, this complicates the process of passing the user defined jacobian as for each type of equation we have to provide a different version of jacobian. For example in the first case we should provide The downside of this approach is that it would need a lot of code inside the functions Please let me know what do you think about these ideas. |
@pwl, I don't think that anything but the simplest interfaces, possibly just case (1), should have the user passing a function directly. For everything else, the user should just pass an opaque |
@stevengj I think this is an even better option for practical purposes: you could seamlessly switch between various methods and apply them to the same What about returning additional data from the solver? Data such as the number of function/jacobian evaluations, local error estimates, steps accepted vs. steps rejected etc. These results can be very solver-dependent, but on the other hand they might be useful to compare the performance of different solvers. |
I'm not sure what "this" you are referring to. For benchmarking, all you really want is to count either wall-clock time or number of function/Jacobian evaluations. Both of these can be implemented by the user (e.g. by adding a counter into their function) without modifying the solver. |
Sorry for being ambiguous. By "this" I meant your proposal to enclose all the equation-related data into one structure. You are also correct about the counters, some of them can be definitely removed from the implementation of the solvers. |
What about outputting derivatives as well as the solution? For explicit systems like |
Currently |
Note that when integrating |
This is to propose to support the API PETSc uses for its ODE/DAE solvers.
I think the PETSc framework is the nicest around and the most modern (afaik).
(Other issues related are #20, #18, JuliaLang/julia#75)
The PETSc ODE/DAE solvers have been implemented over the last few years with modern developments in mind (they are citing papers from 2003, 2009), which is more than can be said for most other suites of ODE solvers which carry decades old ballast around. It supports, explicit, implicit and IMEX methods for ODEs and DAEs all within the same API. The API is based around formulating the problem like
For problems using implicit methods this is used as
F(t, u, u') =0
forexplicit ones to
u'=G(t, u)
(i.e.F=u'
), IMEX mixes the two at once.Best have a look at the PETSc manual which gives a nice concise intro (Chapter 6):
http://www.mcs.anl.gov/petsc/petsc-current/docs/manual.pdf
PETSc has a liberal licence so code could probably be translated
from PETSc into Julia. The problem with that approach is that
one needs to understand the whole PETSc framework, otherwise
the code looks quite obfuscated.
Further, some cool solvers PETSc has:
http://www.mcs.anl.gov/petsc/petsc-3.4/docs/manualpages/TS/TSGL.html#TSGL
These methods contain Runge-Kutta and multistep
schemes (e.g. BDF) as special cases. As far as I can tell with
my limited ODE/DAE solver knowledge, these are the best
currently available.
http://www.mcs.anl.gov/petsc/petsc-3.4/docs/manualpages/TS/TSARKIMEX.html
"These methods are intended for problems with well-separated
time scales, especially when a slow scale is strongly nonlinear
such that it is expensive to solve with a fully implicit
method."
Disclaimer: I have not actually used the PETSc solvers, just read
the docs and wished I could use them in Matlab...
The text was updated successfully, but these errors were encountered: