pySimBlocks.blocks.operators.discrete_integrator

class pySimBlocks.blocks.operators.discrete_integrator.DiscreteIntegrator(name: str, initial_state: TypeAliasForwardRef('ArrayLike') | None = None, method: str = 'euler forward', sample_time: float | None = None)[source]

Bases: Block

Discrete-time integrator block.

Integrates an input signal over time using either Euler forward or Euler backward integration. The state update is:

x[k+1] = x[k] + dt * u[k]

The output differs by method:

y[k] = x[k] (Euler forward)

y[k] = x[k] + dt * u[k] (Euler backward)

Euler forward has no direct feedthrough; Euler backward does. The output shape is resolved from the first non-scalar input and then frozen. A scalar (1,1) input is broadcast to the frozen shape. The output is never None.

method

Integration method, 'euler forward' or 'euler backward'.

initialize(t0: float) None[source]

Set the initial state and output from initial_state or a zero placeholder.

Parameters:

t0 – Initial simulation time in seconds.

output_update(t: float, dt: float) None[source]

Compute the output from the current state according to the integration method.

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.

state_update(t: float, dt: float) None[source]

Advance the integrator state by one step.

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.

Raises:

ValueError – If the state and input shapes are inconsistent after shape resolution.