pathsim.blocks.mixed.comparator module
- class pathsim.blocks.mixed.comparator.Comparator(threshold=0, tolerance=0.0001)[source]
Bases:
BlockComparator block that sets the output to ‘1’ it the input signal crosses a predefined threshold and to ‘-1’ if it crosses in the reverse direction.
This is realized by the block spawning a zero-crossing event detector that watches the input of the block and locates the transition up to a tolerance.
The block output is determined by a simple sign check in the ‘update’ method.
- Parameters:
- events
internal zero crossing event
- Type:
- update(t)[source]
The ‘update’ method is called iteratively for all blocks BEFORE the timestep to resolve algebraic loops (fixed-point iteraion).
It is meant for instant time blocks (blocks that dont have a delay due to the timestep, such as Amplifier, etc.) and updates the ‘outputs’ of the block directly based on the ‘inputs’ and possibly internal states.
It computes and returns the relative difference between the new output and the previous output (before the step) to track convergence of the fixed-point iteration.
Note
The implementation of the ‘update’ method in the base ‘Block’ class is intended as a fallback and is not performance optimized. Special blocks might reimplement this method differently for higher performance, for example SISO or MISO blocks.