pySimBlocks.blocks.operators.zero_order_hold

class pySimBlocks.blocks.operators.zero_order_hold.ZeroOrderHold(name: str, sample_time: float)[source]

Bases: Block

Zero-Order Hold (ZOH) block.

Samples the input at discrete instants separated by sample_time and holds the sampled value constant between sampling instants. The input shape is frozen after the first resolution.

sample_time

Sampling period in seconds.

direct_feedthrough = True

True if outputs depend directly on inputs.

initialize(t0: float) None[source]

Sample the initial input and set up the hold state.

Parameters:

t0 – Initial simulation time in seconds.

Raises:
  • RuntimeError – If input 'in' is None at initialization.

  • ValueError – If input is not 2D.

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

Output the current sample or the held value depending on the elapsed time.

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.

Raises:

RuntimeError – If input 'in' is None or block is not initialized.

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

Update the held value and timestamp if a new sample was taken.

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.

Raises:

RuntimeError – If block is not initialized.