ngclearn.utils.diffeq package

Submodules

ngclearn.utils.diffeq.ode_utils module

Routines and co-routines for ngc-learn’s differential equation integration backend.

Currently supported back-end forms of integration in ngc-learn include: 1) Euler integration (RK-1); 2) Midpoint method (RK-2); 3) Heun’s method (error-corrector RK-2); 4) Ralston’s method (error-corrector RK-2)

ngclearn.utils.diffeq.ode_utils.get_integrator_code(integrationType)[source]

Convenience function for mapping integrator type string to ngc-learn’s internal integer code value.

Parameters:

integrationType – string indicating integrator type (supported type: rk1` or euler, rk2 or midpoint, rk2_heun or heun, rk2_ralston or ralston)

Returns:

integator type integer code

ngclearn.utils.diffeq.ode_utils.step_euler(t, x, dfx, dt, params, x_scale=1.0)[source]

Iteratively integrates one step forward via the Euler method, i.e., a first-order Runge-Kutta (RK-1) step.

Parameters:
  • t – current time variable to advance by dt

  • x – current variable values to advance/iteratively integrate (at time t)

  • dfx – (ordinary) differential equation co-routine (as implemented in an ngc-learn component)

  • dt – integration time step (also referred to as h in mathematics)

  • params – tuple containing configuration values/hyper-parameters for the (ordinary) differential equation an ngc-learn component will provide

  • x_scale – dampening factor to scale x by (Default: 1)

Returns:

variable values iteratively integrated/advanced to next step (t + dt)

ngclearn.utils.diffeq.ode_utils.step_heun(t, x, dfx, dt, params, x_scale=1.0)[source]

Iteratively integrates one step forward via Heun’s method, i.e., a second-order Runge-Kutta (RK-2) error-corrected step. This method utilizes two (differential) function evaluations to estimate the solution at a given point in time. (Note: ngc-learn internally recognizes “rk2_heun” or “heun” for this routine)

Reference:
Ascher, Uri M., and Linda R. Petzold. Computer methods for ordinary
differential equations and differential-algebraic equations. Society for
Industrial and Applied Mathematics, 1998.
Parameters:
  • t – current time variable to advance by dt

  • x – current variable values to advance/iteratively integrate (at time t)

  • dfx – (ordinary) differential equation co-routine (as implemented in an ngc-learn component)

  • dt – integration time step (also referred to as h in mathematics)

  • params – tuple containing configuration values/hyper-parameters for the (ordinary) differential equation an ngc-learn component will provide

  • x_scale – dampening factor to scale x by (Default: 1)

Returns:

variable values iteratively integrated/advanced to next step (t + dt)

ngclearn.utils.diffeq.ode_utils.step_ralston(t, x, dfx, dt, params, x_scale=1.0)[source]

Iteratively integrates one step forward via Ralston’s method, i.e., a second-order Runge-Kutta (RK-2) error-corrected step. This method utilizes two (differential) function evaluations to estimate the solution at a given point in time. (Note: ngc-learn internally recognizes “rk2_ralston” or “ralston” for this routine)

Reference:
Ralston, Anthony. “Runge-Kutta methods with minimum error bounds.”
Mathematics of computation 16.80 (1962): 431-437.
Parameters:
  • t – current time variable to advance by dt

  • x – current variable values to advance/iteratively integrate (at time t)

  • dfx – (ordinary) differential equation co-routine (as implemented in an ngc-learn component)

  • dt – integration time step (also referred to as h in mathematics)

  • params – tuple containing configuration values/hyper-parameters for the (ordinary) differential equation an ngc-learn component will provide

  • x_scale – dampening factor to scale x by (Default: 1)

Returns:

variable values iteratively integrated/advanced to next step (t + dt)

ngclearn.utils.diffeq.ode_utils.step_rk2(t, x, dfx, dt, params, x_scale=1.0)[source]

Iteratively integrates one step forward via the midpoint method, i.e., a second-order Runge-Kutta (RK-2) step. (Note: ngc-learn internally recognizes “rk2” or “midpoint” for this routine)

Reference:
Ascher, Uri M., and Linda R. Petzold. Computer methods for ordinary
differential equations and differential-algebraic equations. Society for
Industrial and Applied Mathematics, 1998.
Parameters:
  • t – current time variable to advance by dt

  • x – current variable values to advance/iteratively integrate (at time t)

  • dfx – (ordinary) differential equation co-routine (as implemented in an ngc-learn component)

  • dt – integration time step (also referred to as h in mathematics)

  • params – tuple containing configuration values/hyper-parameters for the (ordinary) differential equation an ngc-learn component will provide

  • x_scale – dampening factor to scale x by (Default: 1)

Returns:

variable values iteratively integrated/advanced to next step (t + dt)

Module contents