aquakin.time_average#

aquakin.time_average(integrand, t, axis=0)[source]#

Trapezoidal time-average of integrand over the window [t0, t1].

The single public helper behind every time-averaged index – the design, aeration_system, ghg and evaluation modules all call it directly rather than re-wrapping it. The argument order is always (values, t) (values first, times second); keep it that way so no module re-introduces an inverted-signature local copy.

For a single saved point – exactly what Plant.run_to_steady_state() returns (the terminal state only) – the window has zero width, but the time-average of a constant is that constant, so the single sample is returned directly. This yields the meaningful instantaneous (steady-state) value for a one-point solution instead of dividing by a zero window (which previously raised ZeroDivisionError in aeration_energy, or gave a spurious zero in the guarded kernels). The metric kernels here are called eagerly on concrete arrays after a solve, so the t.shape[0] branch is a static check.

Parameters:
  • integrand (array) – Values at the save times, with the time axis at axis.

  • t (array) – Save times, shape (n_t,).

  • axis (int) – The time axis of integrand (default 0).

Returns:

The time-average, reduced along axis (a 0-d array for a 1-D integrand). Callers that need a Python float wrap the result in float(...), as the scalar metric kernels here do.

Return type:

jnp.ndarray