lynx.Diagram.get_tf

Diagram.get_tf(from_signal: str, to_signal: str) Any[source]

Extract transfer function from one signal to another.

Converts a Lynx diagram to a python-control TransferFunction object. This is the preferred method for SISO subsystem analysis where you want the classic numerator/denominator representation.

Signal Reference Patterns:

Uses the same 4-tier priority system as get_ss(): 1. IOMarker labels (‘r’, ‘y’) 2. Connection labels (‘error’, ‘control’) 3. Block.port format (‘controller.out’, ‘plant.in’) 4. Block labels - SISO only (‘controller’, ‘plant’)

Parameters:
  • from_signal – Source signal name using any of the 4 reference patterns

  • to_signal – Destination signal name using any of the 4 reference patterns

Returns:

Transfer function from from_signal → to_signal

Return type:

control.TransferFunction

Raises:
  • SignalNotFoundError – If either signal doesn’t exist in the diagram

  • ValidationError – If diagram has missing I/O markers or unconnected ports

  • DiagramExportError – If python-control conversion fails

Note

For MIMO systems, use get_ss() instead as transfer functions are only well-defined for SISO systems. python-control will raise an error if you try to convert a MIMO state-space to transfer function.

Examples

>>> # Extract closed-loop transfer function using IOMarker labels
>>> tf_ry = diagram.get_tf('r', 'y')
>>> print(tf_ry)
>>> # TransferFunction:
>>> #     10
>>> # -------------
>>> # s^2 + 5 s + 6
>>>
>>> # Analyze using python-control functions
>>> import control as ct
>>> import numpy as np
>>> t = np.linspace(0, 5, 500)
>>> t_out, y_out = ct.step_response(tf_ry, t)
>>>
>>> # Extract plant transfer function using block labels
>>> tf_plant = diagram.get_tf('plant.in', 'plant.out')
>>> print(f"Plant DC gain: {tf_plant.dcgain()}")
>>>
>>> # Compute loop gain for stability analysis
>>> L = diagram.get_tf('error', 'y')  # Loop gain
>>> gm, pm, wgm, wpm = ct.margin(L)
>>> print(f"Phase margin: {pm:.1f} degrees")