cubie.integrators.algorithms.euler

Euler method implementation for numerical integration.

This module provides the Euler class, which implements the simple first-order Euler method for integrating ordinary differential equations on CUDA devices. The implementation is suitable for systems where high accuracy is not required and the dynamics are not too stiff.

Classes

Euler(precision, dxdt_function, ...[, ...])

Euler integrator algorithm for fixed-step integration.

class cubie.integrators.algorithms.euler.Euler(precision, dxdt_function, buffer_sizes, loop_step_config, save_state_func, update_summaries_func, save_summaries_func, compile_flags=None, **kwargs)[source]

Bases: GenericIntegratorAlgorithm

Euler integrator algorithm for fixed-step integration.

This class implements the simple, first-order Euler method for updating the state of dynamical systems. It uses a fixed time step and is suitable for systems where the dynamics are not too stiff and where high accuracy is not required.

Parameters:
  • precision (type) – Numerical precision type (float32, float64, etc.).

  • dxdt_function (callable) – Function that computes the time derivative of the state.

  • buffer_sizes (object) – Configuration object specifying buffer sizes for integration.

  • loop_step_config (object) – Configuration object for loop step parameters.

  • save_state_func (callable) – Function for saving state values during integration.

  • update_summaries_func (callable) – Function for updating summary statistics.

  • save_summaries_func (callable) – Function for saving summary statistics.

  • compile_flags (object, optional) – Compilation flags for CUDA device function generation.

  • **kwargs – Additional keyword arguments passed to parent class.

Notes

The Euler method approximates the solution to the differential equation dy/dt = f(t, y) using the update rule:

y_{n+1} = y_n + h * f(t_n, y_n)

where h is the step size. This is a first-order method with local truncation error O(h²) and global error O(h).

See also

GenericIntegratorAlgorithm

Base class for integration algorithms

build_loop(precision, dxdt_function, save_state_func, update_summaries_func, save_summaries_func)[source]

Build the CUDA device function for the Euler integration loop.

This method constructs a numba-compiled CUDA device function that implements the Euler integration algorithm with output handling.

Parameters:
  • precision (type) – Numerical precision type for the integration.

  • dxdt_function (callable) – Function that computes time derivatives.

  • save_state_func (callable) – Function for saving state values.

  • update_summaries_func (callable) – Function for updating summary statistics.

  • save_summaries_func (callable) – Function for saving summary statistics.

Returns:

Compiled CUDA device function for Euler integration.

Return type:

callable

Notes

The generated function handles memory allocation, state initialization, the main integration loop, and output generation according to the configured step sizes and buffer requirements.

property shared_memory_required

Calculate the number of shared memory elements required for the loop.

Returns:

Number of elements in shared memory required for state, derivatives, observables, drivers, and summary buffers. Does not include summary arrays as they are handled outside the loop and are common to all algorithms.

Return type:

int