Diffrax Wrapper — ICoMo Toolbox

1.0.3 (original) (raw)

Contents

Diffrax Wrapper#

These are helper functions that wrap some function from the diffrax module like thediffrax.diffeqsolve() function. This is only done for convenience, to define some default values for the parameters of the function. Don’t hesitate to directly the functions from the diffrax module if you need more flexibility.

Functions#

icomo.diffeqsolve(*args, ts_out=None, ODE=None, fixed_step_size=False, **kwargs)[source]#

Solves a system of differential equations.

Wrapper of diffrax.diffeqsolve(). It accepts the same parameters as diffrax.diffeqsolve(). Additionally, for convenience, it allows the specification of the output timesteps ts_out and the system of differential equations ODE as keyword arguments. If not specified, it uses the diffrax.Tsit5 solver. For a simple ODE, it is enough to specify the following keyword arguments:

Parameters:

Return type:

Solution

Returns:

sol – The solution of the system of differential equations. sol.ys contains the variables of the system of differential equations at the output timesteps.

icomo.interpolate_func(ts_in, values, method='cubic', ret_gradients=False)[source]#

Return a diffrax-interpolation function that can be used to interpolate pytensors.

Wrapper of diffrax.CubicInterpolation anddiffrax.LinearInterpolation.

Parameters:

Return type:

Callable[[ArrayLike], Array]

Returns:

interp – The interpolation function. Call interp(t) to evaluate the interpolated variable at time t. t can be a float or an ArrayLike.