tdcpy.closed_loop module#

DDAE implementation

class tdcpy.closed_loop.ClosedLoop(system, order, y_indices=None, u_indices=None, K0=None, hK=None, **kwargs)#

Bases: TDSBase

Class representing system - controller interconnection

Parameters:
__init__(system, order, y_indices=None, u_indices=None, K0=None, hK=None, **kwargs)#

Initializes closed-loop system-controller interconnection

                             ___________________
                u1[-1]      |                   |  y1[-1]
            --------------->|                   |---------------->
        u1[0],...,u1[nu-2]  |      SYSTEM       |  y1[0],...,y[ny-2]
                     ------>|                   |-------
                    |       |___________________|       |
                    |                                   |
                    |        ___________________        |
y2[0],...,y2[ny-2]  |       |                   |       | u2[0],...,u1[nu-2]
                     -------|                   |<------
                y2[-1]      |    CONTROLLER     |  u2[-1]
            <---------------|                   |<---------------
                            |___________________|
Parameters:
  • system (DDAE) – system to be controlled

  • order (int) – order of controller, non-negative

  • y_indices (list, optional) – list of indices (outputs of system 1), if not defined, [0] is assumed

  • u_indices (list, optional) – list of indices (inputs of system 2), if not defined, [0] is assumed

  • K0 (npt.NDArray, optional) – initial controller values, shape (order+len(u_indices), order+len(y_indices), mK), if not defined, heuristic is used (TODO)

  • hK (npt.NDArray, optional) – controller delays, shape (mK,), if not defined, [0.] is assumed

Return type:

None

Notes

Examples

>>> from tdcpy import DDAE, ClosedLoop
>>> import numpy as np
>>> A0 = np.array([[0., 1.], [-2., -3.]])
>>> A = np.stack([A0], axis=2)
>>> hA = np.array([1.])
>>> E = np.eye(2)
>>> B1 = np.array([[0.], [1.]])
>>> B = np.stack([B1], axis=2)
>>> hB = np.array([0.])
>>> C1 = np.array([[1., 0.], [0., 1.]])
>>> C = np.stack([C1], axis=2)
>>> hC = np.array([0.])
>>> D1 = np.array([[0., 0.], [0., 0.]])
>>> D = np.stack([D1], axis=2)
>>> hD = np.array([0.])
>>> system = DDAE(E=E, A=A, hA=hA, B=B, hB=hB, C=C, hC=hC, D=D, hD=hD)
>>> order = 1
>>> y_indices = [0, 1]
>>> u_indices = [0]
>>> K0 = np.array([[0., 0.]])
>>> K = np.stack([K0], axis=2)
>>> hK = np.array([0.])
>>> cl = ClosedLoop(system, order, y_indices, u_indices, K, hK)
>>> cl.E.shape
(6, 6)
>>> cl.A.shape
(6, 6, 1)
>>> cl.hA.shape
(1,)
property n: int#

number of variables

property n_inputs: int#

number of inputs

property n_outputs: int#

number of outputs

property E: ndarray[tuple[Any, ...], dtype[_ScalarT]]#

E matrix from TDS representation, shape (n, n)

property uE: ndarray[tuple[Any, ...], dtype[_ScalarT]]#

orthonormal basis for left null space of E

property vE: ndarray[tuple[Any, ...], dtype[_ScalarT]]#

orthonormal basis for right null space of E

property A: ndarray[tuple[Any, ...], dtype[_ScalarT]]#

dynamics matrices

property hA: ndarray[tuple[Any, ...], dtype[_ScalarT]]#

dynamic delays

property mA: int#

number of delays

property B: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None#

input matrices

property hB: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None#

input delays

property mB: int#

number of input delays

property C: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None#

output matrices

property hC: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None#

output delays

property mC: int#

number of output delays

property D: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None#

feed-through matrices

property hD: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None#

feed-through delays

property mD: int#

number of output delays

get_delay_difference_equation()#

associated delay difference equation

property system: DDAE#

Original system we are controlling

property BB: ndarray[tuple[Any, ...], dtype[_ScalarT]]#

input matrix of equivalent closed-loop

property CC: ndarray[tuple[Any, ...], dtype[_ScalarT]]#

output matrix of equivalent closed-loop

property y_indices: list[int]#

indices of system outputs fed to controller

property u_indices: list[int]#

indices of control inputs fed into system

property w_indices: list[int]#

indices of exogenous inputs fed into system

property z_indices: list[int]#

indices of system outputs

property controller: DDAE#

Returns Controller as DDAE

property n_controller_inputs: int#

number of control inputs

property n_controller_outputs: int#

number of control outputs

property controller_order: int#

order of the dynamic controller

property hK#
property mK#
property K#