numbacs.integration =================== .. py:module:: numbacs.integration Module Contents --------------- .. py:function:: flowmap(funcptr, t0, T, pts, params, method='dop853', rtol=1e-06, atol=1e-08) Computes the flow map of the ode defined by funcptr where funcptr is a pointer to a C callback created within numbalsoda using the ``@cfunc`` decorator. 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. :param funcptr: pointer to C callback. :type funcptr: int :param t0: intial time. :type t0: float :param T: integration time. :type T: float :param pts: array of points to be integrated. :type pts: np.ndarray, shape = (npts,2) :param params: array of parameters to be passed to the ode function defined by funcptr. :type params: np.ndarray, shape = (nprms,) :param method: method to be used by numbalsoda to solve ode. The default is 'dop853'. :type method: str, optional :param rtol: relative tolerance for ode solver. The default is 1e-6. :type rtol: float, optional :param atol: absolute tolerance for ode solver. The default is 1e-8. :type atol: float, optional :returns: **flowmap** -- array containing final position of particles pts after integration from [t0,t0+T]. :rtype: np.ndarray, shape = (npts,2) .. py:function:: flowmap_n(funcptr, t0, T, pts, params, method='dop853', n=2, rtol=1e-06, atol=1e-08) Computes the flow map of the ode defined by funcptr where funcptr is a pointer to a C callback created within numbalsoda using the ``@cfunc`` decorator. 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). :param funcptr: pointer to C callback. :type funcptr: int :param t0: intial time. :type t0: float :param T: integration time. :type T: float :param pts: array of points to be integrated. :type pts: np.ndarray, shape = (npts,2) :param params: array of parameters to be passed to the ode function defined by funcptr. :type params: np.ndarray, shape = (nprms,) :param method: method to be used by numbalsoda to solve ode. The default is 'dop853'. :type method: str, optional :param n: number of points to return the flowmap at (including initial condition). The default is 2. :type n: int, optional :param rtol: relative tolerance for ode solver. The default is 1e-6. :type rtol: float, optional :param atol: absolute tolerance for ode solver. The default is 1e-8. :type atol: float, optional :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. .. py:function:: flowmap_grid_2D(funcptr, t0, T, x, y, params, method='dop853', rtol=1e-06, atol=1e-08) 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 ``@cfunc`` decorator. Flow map is computed over the grid defined by x,y. t0 denotes initial time and T denotes integration time. :param funcptr: pointer to C callback. :type funcptr: int :param t0: intial time. :type t0: float :param T: integration time. :type T: float :param x: array containing x-values. :type x: np.ndarray, shape = (nx,) :param y: array containing y-values. :type y: np.ndarray, shape = (ny,) :param params: array of parameters to be passed to the ode function defined by funcptr. :type params: np.ndarray, shape = (nprms,) :param method: method to be used by numbalsoda to solve ode. The default is 'dop853'. :type method: str, optional :param rtol: relative tolerance for ode solver. The default is 1e-6. :type rtol: float, optional :param atol: absolute tolerance for ode solver. The default is 1e-8. :type atol: float, optional :returns: **flowmap** -- array containing final positions of particles pts after integration from [t0,t0+T]. :rtype: np.ndarray, shape = (nx,ny,2) .. py:function:: flowmap_grid_ND(funcptr, t0, T, IC_flat, ndims, params, method='dop853', rtol=1e-06, atol=1e-08) 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 ``@cfunc`` decorator. 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. :param funcptr: pointer to C callback. :type funcptr: int :param t0: intial time. :type t0: float :param T: integration time. :type T: float :param IC_flat: flattened array of initial conditions, can be obtained by IC.flatten() or IC.ravel(). :type IC_flat: np.ndarray, shape = (nx_1*nx_2*...*nx_ndims*ndims,) :param ndims: number of dimensions. :type ndims: int :param params: array of parameters to be passed to the ode function defined by funcptr. :type params: np.ndarray, shape = (nprms,) :param method: method to be used by numbalsoda to solve ode. The default is 'dop853'. :type method: str, optional :param rtol: relative tolerance for ode solver. The default is 1e-6. :type rtol: float, optional :param atol: absolute tolerance for ode solver. The default is 1e-8. :type atol: float, optional :returns: **flowmap** -- array containing final positions of particles IC_flat after integration from [t0,t0+T]. :rtype: np.ndarray, shape = (nx_1*nx_2*...*nx_ndims,ndims) .. py:function:: 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) 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 ``@cfunc`` decorator. Flow map is computed over the aux grid defined by np.meshgrid(x,y) +-h. t0 denotes initial time and T denotes integration time. :param funcptr: pointer to C callback. :type funcptr: int :param t0: intial time. :type t0: float :param T: integration time. :type T: float :param x: array containing x-values. :type x: np.ndarray, shape = (nx,) :param y: array containing y-values. :type y: np.ndarray, shape = (ny,) :param params: array of parameters to be passed to the ode function defined by funcptr. :type params: np.ndarray, shape = (nprms,) :param h: spacing for the auxilary grid. The default is 1e-5. :type h: float, optional :param eig_main: 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. :type eig_main: boolean, optional :param compute_edge: 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. :type compute_edge: boolean, optional :param method: method to be used by numbalsoda to solve ode. The default is 'dop853'. :type method: str, optional :param rtol: relative tolerance for ode solver. The default is 1e-6. :type rtol: float, optional :param atol: absolute tolerance for ode solver. The default is 1e-8. :type atol: float, optional :returns: **flowmap_aux** -- array containing final positions of particles (including aux grid) after integration from [t0,t0+T]. :rtype: np.ndarray, shape = (nx,ny,n_aux,2) .. py:function:: flowmap_n_grid_2D(funcptr, t0, T, x, y, params, n=50, method='dop853', rtol=1e-06, atol=1e-08) Computes the flow map of the ode defined by funcptr where funcptr is a pointer to a C callback created within numba using the ``@cfunc`` decorator. 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). :param funcptr: pointer to C callback. :type funcptr: int :param t0: intial time. :type t0: float :param T: integration time. :type T: float :param x: array containing x-values. :type x: np.ndarray, shape = (nx,) :param y: array containing y-values. :type y: np.ndarray, shape = (ny,) :param params: array of parameters to be passed to the ode function defined by funcptr. DESCRIPTION. :type params: np.ndarray, shape = (nprms,) :param n: number of points to return the flowmap at. The default is 50. :type n: int, optional :param method: method to be used by numbalsoda to solve ode. The default is 'dop853'. :type method: str, optional :param rtol: relative tolerance for ode solver. The default is 1e-6. :type rtol: float, optional :param atol: absolute tolerance for ode solver. The default is 1e-8. :type atol: float, optional :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. .. py:function:: flowmap_n_grid_ND(funcptr, t0, T, IC_flat, ndims, params, n=50, method='dop853', rtol=1e-06, atol=1e-08) 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 ``@cfunc`` decorator. 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). :param funcptr: pointer to C callback. :type funcptr: int :param t0: intial time. :type t0: float :param T: integration time. :type T: float :param IC_flat: flattened array of initial conditions, can be obtained by IC.flatten() or IC.ravel(). :type IC_flat: np.ndarray, shape = (nx_1*nx_2*...*nx_ndims*ndims,) :param ndims: number of dimensions. :type ndims: int :param params: array of parameters to be passed to the ode function defined by funcptr. :type params: np.ndarray, shape = (nprms,) :param n: number of points to return the flowmap at. The default is 50. :type n: int, optional :param method: method to be used by numbalsoda to solve ode. The default is 'dop853'. :type method: str, optional :param rtol: relative tolerance for ode solver. The default is 1e-6. :type rtol: float, optional :param atol: absolute tolerance for ode solver. The default is 1e-8. :type atol: float, optional :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. .. py:function:: flowmap_composition(flowmaps, grid, nT) Interpolation for flowmap composition method. Returns composed flowmap from intermediate flowmaps. :param flowmaps: flowmaps for each (k+1)*t0 to (k+1)*t0+h for k in {0,...,nT-1}. :type flowmaps: np.ndarray, shape = (nT,nx,ny,2) :param grid: tuple containing endpoints and number of points for each dimension. :type grid: tuple :param nT: number of intermediate flowmaps. :type nT: int :returns: **composed_flowmap** -- composed flowmap from t0 to t0 + T. :rtype: np.ndarray, shape = (nx,ny,2) .. py:function:: flowmap_composition_initial(funcptr, t0, T, h, x, y, grid, params, **kwargs) Initial step for flowmap composition method. Returns first full flowmap and collection of intermediate flowmaps to be used in successive steps. :param funcptr: pointer to C callback. :type funcptr: int :param t0: intial time. :type t0: float :param T: overall integration time. :type T: float :param h: integration time for each flowmap composition. T/h should be an integer or the results will be incorrect. :type h: float :param x: array containing x-values. :type x: np.ndarray, shape = (nx,) :param y: array containing y-values. :type y: np.ndarray, shape = (ny,) :param grid: tuple containing endpoints and number of points for each dimension. :type grid: tuple :param params: array of parameters to be passed to the ode function defined by funcptr. :type params: np.ndarray, shape = (nprms,) :param \*\*kwargs: keyword arguments for flowmap_grid_2D. :type \*\*kwargs: str,float :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 .. py:function:: flowmap_composition_step(flowmaps, funcptr, t0, h, nT, x, y, grid, params, **kwargs) Step for flowmap composition method. Returns full flowmap at current step and collection of intermediate flowmaps to be used in successive steps. :param flowmaps: flowmaps for each (k+1)*t0 to (k+1)*t0+h for k in {0,...,nT-1}. :type flowmaps: np.ndarray, shape = (nT,nx,ny,2) :param funcptr: pointer to C callback. :type funcptr: int :param t0: intial time. :type t0: float :param h: integration time for each flowmap composition. T/h should be an integer or the results will be incorrect. :type h: float :param nT: number of intermediate flowmaps. :type nT: int :param x: array containing x-values. :type x: np.ndarray, shape = (nx,) :param y: array containing y-values. :type y: np.ndarray, shape = (ny,) :param grid: tuple containing endpoints and number of points for each dimension. :type grid: tuple :param params: array of parameters to be passed to the ode function defined by funcptr. :type params: np.ndarray, shape = (nprms,) :param \*\*kwargs: keyword arguments for flowmap_grid_2D. :type \*\*kwargs: str,float :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}.