Skip to content

Writing kernels and integration schemes in a more 'function'-like way #2338

@michaeldenes

Description

@michaeldenes

In a parcels kernel, currently (in v3 and v4), you must write your own integration scheme for timestepping your problem. While we provide RK2 and RK4 advection schemes out of the box, writing an RK2/4 kernel for a different process can be incredibly cumbersome (e.g. for Stokes drift, or, especially, biofouling).

A fantastic new enhancement of v4 is the ability to call functions inside a kernel (which was probably possible in v3, but only in slower Scipy mode), which will make coding a kernel far easier, and more modular. However, in the current implementation, a user will still need to write their own integration scheme for their own problem.

An extra enhancement for v4 that would be nice is to have 'integrators'. Users can write their problem in a typical ODE-solver way, e.g. provide a state (e.g. lon, lat, depth from particles), and derivatives (in the case of advection, a function that samples fieldset.UVW), and they can simply call an RK2_integrator, or RK4_integrator (and so on), that will compute the new_state (or, probably better, the dlon, dlat, and so forth).

If of interest, I can probably come up with a working example using advection as an example.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Backlog

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions