Differentiator

class pathsim.blocks.differentiator.Differentiator(f_max=100.0)[source]

Bases: Block

Differentiates the input signal.

Uses a first order transfer function with a pole at the origin which implements a high pass filter. Supports vector input.

\[H_\mathrm{diff}(s) = \frac{s}{1 + s / f_\mathrm{max}}\]

The approximation holds for signals up to a frequency of approximately f_max.

Note

Depending on f_max, the resulting system might become stiff or ill conditioned! As a practical choice set f_max to 3x the highest expected signal frequency.

Note

Since this is an approximation of real differentiation, the approximation will not hold if there are high frequency components present in the signal. For example if you have discontinuities such as steps or squere waves.

Example

The block is initialized like this:

#cutoff at 1kHz
D = Differentiator(f_max=1e3)
Parameters:

f_max (float) – highest expected signal frequency

op_dyn

internal dynamic operator for ODE component

Type:

DynamicOperator

op_alg

internal algebraic operator

Type:

DynamicOperator

update(t)[source]

update system equation fixed point loop, with convergence control

Parameters:

t (float) – evaluation time

solve(t, dt)[source]

advance solution of implicit update equation

Parameters:
  • t (float) – evaluation time

  • dt (float) – integration timestep

Returns:

error – solver residual norm

Return type:

float

step(t, dt)[source]

compute update step with integration engine

Parameters:
  • t (float) – evaluation time

  • dt (float) – integration timestep

Returns:

  • success (bool) – step was successful

  • error (float) – local truncation error from adaptive integrators

  • scale (float) – timestep rescale from adaptive integrators