numbacs.integration
Module Contents
- numbacs.integration.flowmap(funcptr, t0, T, pts, params, method='dop853', rtol=1e-06, atol=1e-08)[source]
Computes the flow map of the ode defined by funcptr where funcptr is a pointer to a C callback created within numbalsoda using the
@cfuncdecorator. Flow map is computed from initial conditions given by pts where pts has dim (npts,2). t0 denotes initial time and T denotes integration time.- Parameters:
funcptr (int) – pointer to C callback.
t0 (float) – intial time.
T (float) – integration time.
pts (np.ndarray, shape = (npts,2)) – array of points to be integrated.
params (np.ndarray, shape = (nprms,)) – array of parameters to be passed to the ode function defined by funcptr.
method (str, optional) – method to be used by numbalsoda to solve ode. The default is ‘dop853’.
rtol (float, optional) – relative tolerance for ode solver. The default is 1e-6.
atol (float, optional) – absolute tolerance for ode solver. The default is 1e-8.
- Returns:
flowmap – array containing final position of particles pts after integration from [t0,t0+T].
- Return type:
np.ndarray, shape = (npts,2)
- numbacs.integration.flowmap_n(funcptr, t0, T, pts, params, method='dop853', n=2, rtol=1e-06, atol=1e-08)[source]
Computes the flow map of the ode defined by funcptr where funcptr is a pointer to a C callback created within numbalsoda using the
@cfuncdecorator. Flow map is computed from initial conditions given by pts where pts has dim (npts,2). t0 denotes initial time and T denotes integration time, flowmap is returned at n times in [t0,t0+T] (inclusive).- Parameters:
funcptr (int) – pointer to C callback.
t0 (float) – intial time.
T (float) – integration time.
pts (np.ndarray, shape = (npts,2)) – array of points to be integrated.
params (np.ndarray, shape = (nprms,)) – array of parameters to be passed to the ode function defined by funcptr.
method (str, optional) – method to be used by numbalsoda to solve ode. The default is ‘dop853’.
n (int, optional) – number of points to return the flowmap at (including initial condition). The default is 2.
rtol (float, optional) – relative tolerance for ode solver. The default is 1e-6.
atol (float, optional) – absolute tolerance for ode solver. The default is 1e-8.
- Returns:
flowmap (np.ndarray, shape = (npts,n,2)) – array containing n positions of particles pts after integration from [t0,t0+T].
t_eval (np.ndarray, shape = (n,)) – array containing times the flowmap is returned at.
- numbacs.integration.flowmap_grid_2D(funcptr, t0, T, x, y, params, method='dop853', rtol=1e-06, atol=1e-08)[source]
Computes the flow map at the final time of the ode defined by funcptr where funcptr is a pointer to a C callback created within numba using the
@cfuncdecorator. Flow map is computed over the grid defined by x,y. t0 denotes initial time and T denotes integration time.- Parameters:
funcptr (int) – pointer to C callback.
t0 (float) – intial time.
T (float) – integration time.
x (np.ndarray, shape = (nx,)) – array containing x-values.
y (np.ndarray, shape = (ny,)) – array containing y-values.
params (np.ndarray, shape = (nprms,)) – array of parameters to be passed to the ode function defined by funcptr.
method (str, optional) – method to be used by numbalsoda to solve ode. The default is ‘dop853’.
rtol (float, optional) – relative tolerance for ode solver. The default is 1e-6.
atol (float, optional) – absolute tolerance for ode solver. The default is 1e-8.
- Returns:
flowmap – array containing final positions of particles pts after integration from [t0,t0+T].
- Return type:
np.ndarray, shape = (nx,ny,2)
- numbacs.integration.flowmap_grid_ND(funcptr, t0, T, IC_flat, ndims, params, method='dop853', rtol=1e-06, atol=1e-08)[source]
Computes the flow map at the final time of the ode defined by funcptr where funcptr is a pointer to a C callback created within numba using the
@cfuncdecorator. Flow map is computed over the grid defined by IC_flat where IC_flat has shape (nx_1*nx_2*…*nx_ndims*ndims). t0 denotes initial time and T denotes integration time.- Parameters:
funcptr (int) – pointer to C callback.
t0 (float) – intial time.
T (float) – integration time.
IC_flat (np.ndarray, shape = (nx_1*nx_2*...*nx_ndims*ndims,)) – flattened array of initial conditions, can be obtained by IC.flatten() or IC.ravel().
ndims (int) – number of dimensions.
params (np.ndarray, shape = (nprms,)) – array of parameters to be passed to the ode function defined by funcptr.
method (str, optional) – method to be used by numbalsoda to solve ode. The default is ‘dop853’.
rtol (float, optional) – relative tolerance for ode solver. The default is 1e-6.
atol (float, optional) – absolute tolerance for ode solver. The default is 1e-8.
- Returns:
flowmap – array containing final positions of particles IC_flat after integration from [t0,t0+T].
- Return type:
np.ndarray, shape = (nx_1*nx_2*…*nx_ndims,ndims)
- numbacs.integration.flowmap_aux_grid_2D(funcptr, t0, T, x, y, params, h=1e-05, eig_main=True, compute_edge=True, method='dop853', rtol=1e-06, atol=1e-08)[source]
Computes the flow map at the final time of the ode defined by funcptr where funcptr is a pointer to a C callback created within numba using the
@cfuncdecorator. Flow map is computed over the aux grid defined by np.meshgrid(x,y) +-h. t0 denotes initial time and T denotes integration time.- Parameters:
funcptr (int) – pointer to C callback.
t0 (float) – intial time.
T (float) – integration time.
x (np.ndarray, shape = (nx,)) – array containing x-values.
y (np.ndarray, shape = (ny,)) – array containing y-values.
params (np.ndarray, shape = (nprms,)) – array of parameters to be passed to the ode function defined by funcptr.
h (float, optional) – spacing for the auxilary grid. The default is 1e-5.
eig_main (boolean, optional) – flag which determines if integration is performed on main grid in addition to aux grid, used if eigenvalues are to be computed from main grid in ‘C_eig_2D’. The default is True.
compute_edge (boolean, optional) – flag which determines if integration is performed on edge of grid, set to True if ode is defined outside of x,y, False if it is not . The default is True.
method (str, optional) – method to be used by numbalsoda to solve ode. The default is ‘dop853’.
rtol (float, optional) – relative tolerance for ode solver. The default is 1e-6.
atol (float, optional) – absolute tolerance for ode solver. The default is 1e-8.
- Returns:
flowmap_aux – array containing final positions of particles (including aux grid) after integration from [t0,t0+T].
- Return type:
np.ndarray, shape = (nx,ny,n_aux,2)
- numbacs.integration.flowmap_n_grid_2D(funcptr, t0, T, x, y, params, n=50, method='dop853', rtol=1e-06, atol=1e-08)[source]
Computes the flow map of the ode defined by funcptr where funcptr is a pointer to a C callback created within numba using the
@cfuncdecorator. Flow map is computed over the grid defined by x,y. t0 denotes initial time and T denotes integration time, flowmap is returned at n times in [t0,t0+T] (inclusive).- Parameters:
funcptr (int) – pointer to C callback.
t0 (float) – intial time.
T (float) – integration time.
x (np.ndarray, shape = (nx,)) – array containing x-values.
y (np.ndarray, shape = (ny,)) – array containing y-values.
params (np.ndarray, shape = (nprms,)) – array of parameters to be passed to the ode function defined by funcptr. DESCRIPTION.
n (int, optional) – number of points to return the flowmap at. The default is 50.
method (str, optional) – method to be used by numbalsoda to solve ode. The default is ‘dop853’.
rtol (float, optional) – relative tolerance for ode solver. The default is 1e-6.
atol (float, optional) – absolute tolerance for ode solver. The default is 1e-8.
- Returns:
flowmap (np.ndarray, shape = (nx,ny,n,2)) – array containing n positions of particles after integration from [t0,t0+T].
np.ndarray, shape = (n,) – array containing t-values at which flowmap is being returned.
- numbacs.integration.flowmap_n_grid_ND(funcptr, t0, T, IC_flat, ndims, params, n=50, method='dop853', rtol=1e-06, atol=1e-08)[source]
Computes the flow map at the n times of the ode defined by funcptr where funcptr is a pointer to a C callback created within numba using the
@cfuncdecorator. Flow map is computed over the grid defined by IC_flat where IC_flat has shape (nx_1*nx_2*…*nx_ndims*ndims). t0 denotes initial time and T denotes integration time, flowmap is returned at n times in [t0,t0+T] (inclusive).- Parameters:
funcptr (int) – pointer to C callback.
t0 (float) – intial time.
T (float) – integration time.
IC_flat (np.ndarray, shape = (nx_1*nx_2*...*nx_ndims*ndims,)) – flattened array of initial conditions, can be obtained by IC.flatten() or IC.ravel().
ndims (int) – number of dimensions.
params (np.ndarray, shape = (nprms,)) – array of parameters to be passed to the ode function defined by funcptr.
n (int, optional) – number of points to return the flowmap at. The default is 50.
method (str, optional) – method to be used by numbalsoda to solve ode. The default is ‘dop853’.
rtol (float, optional) – relative tolerance for ode solver. The default is 1e-6.
atol (float, optional) – absolute tolerance for ode solver. The default is 1e-8.
- Returns:
flowmap (np.ndarray, shape = (nx_1*nx_2…*nx_ndims,n,ndims)*) – array containing n positions of particles after integration from [t0,t0+T].
np.ndarray, shape = (n,) – array containing t-values at which flowmap is being returned.
- numbacs.integration.flowmap_composition(flowmaps, grid, nT)[source]
Interpolation for flowmap composition method. Returns composed flowmap from intermediate flowmaps.
- Parameters:
flowmaps (np.ndarray, shape = (nT,nx,ny,2)) – flowmaps for each (k+1)*t0 to (k+1)*t0+h for k in {0,…,nT-1}.
grid (tuple) – tuple containing endpoints and number of points for each dimension.
nT (int) – number of intermediate flowmaps.
- Returns:
composed_flowmap – composed flowmap from t0 to t0 + T.
- Return type:
np.ndarray, shape = (nx,ny,2)
- numbacs.integration.flowmap_composition_initial(funcptr, t0, T, h, x, y, grid, params, **kwargs)[source]
Initial step for flowmap composition method. Returns first full flowmap and collection of intermediate flowmaps to be used in successive steps.
- Parameters:
funcptr (int) – pointer to C callback.
t0 (float) – intial time.
T (float) – overall integration time.
h (float) – integration time for each flowmap composition. T/h should be an integer or the results will be incorrect.
x (np.ndarray, shape = (nx,)) – array containing x-values.
y (np.ndarray, shape = (ny,)) – array containing y-values.
grid (tuple) – tuple containing endpoints and number of points for each dimension.
params (np.ndarray, shape = (nprms,)) – array of parameters to be passed to the ode function defined by funcptr.
**kwargs (str,float) – keyword arguments for flowmap_grid_2D.
- Returns:
flowmap0 (np.ndarray, shape = (nx,ny,2)) – flowmap from t0 to t0 + T.
flowmaps (np.ndarray, shape = (nT,nx,ny,2)) – flowmaps for each (k+1)*t0 to (k+1)*t0+h for k in {0,…,nT-1}.
nT (int) – number of points making up integration span
- numbacs.integration.flowmap_composition_step(flowmaps, funcptr, t0, h, nT, x, y, grid, params, **kwargs)[source]
Step for flowmap composition method. Returns full flowmap at current step and collection of intermediate flowmaps to be used in successive steps.
- Parameters:
flowmaps (np.ndarray, shape = (nT,nx,ny,2)) – flowmaps for each (k+1)*t0 to (k+1)*t0+h for k in {0,…,nT-1}.
funcptr (int) – pointer to C callback.
t0 (float) – intial time.
h (float) – integration time for each flowmap composition. T/h should be an integer or the results will be incorrect.
nT (int) – number of intermediate flowmaps.
x (np.ndarray, shape = (nx,)) – array containing x-values.
y (np.ndarray, shape = (ny,)) – array containing y-values.
grid (tuple) – tuple containing endpoints and number of points for each dimension.
params (np.ndarray, shape = (nprms,)) – array of parameters to be passed to the ode function defined by funcptr.
**kwargs (str,float) – keyword arguments for flowmap_grid_2D.
- Returns:
flowmap_k (np.ndarray, shape = (nx,ny,2)) – composed flowmap from t0 to t0 + T.
flowmaps (np.ndarray, shape = (nT,nx,ny,2)) – flowmaps for each (k+1)*t0 to (k+1)*t0+h for k in {1,…,nT}.