tdcpy.controller module#

Set of high level API functions for creating controllers

tdcpy.controller.interconnect(tds1, tds2, y1_indices=None, u2_indices=None, y2_indices=None, u1_indices=None, **kwargs)#

Creates and interconnected system from two systems and interconnection indices

Assume we have two systems:

E1 dx1dt = SUM A1[i] x1(t-hA1[i]) + SUM B1[j] u1(t-hB1[j])
      y1 = SUM C1[k] x1(t-hC1[k]) + SUM D1[l] u1(t-hD1[l])

E2 dx2dt = SUM A2[i] x2(t-hA2[i]) + SUM B2[j] u2(t-hB2[j])
      y2 = SUM C2[k] x2(t-hC2[k]) + SUM D2[l] u2(t-hD2[l])

And interconnection defined via indices mapping, then the final system can
be discribed via TODO


x* = [x1, u1, y1, x2, u2, y2]

    E1, 0, 0,  0, 0, 0
    0, 0, 0,  0, 0, 0
E = 0, 0, 0,  0, 0, 0
    0, 0, 0, E2, 0, 0
    0, 0, 0,  0, 0, 0
    0, 0, 0,  0, 0, 0

TODO create scheme and maybe even equations

Parameters:
  • tds1 (DDAE) – system 1 to be interconnected

  • tds2 (DDAE) – system 2 to be interconnected

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

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

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

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

  • **kwargs – compress (bool): perform compression of resulting system, default True

Returns:

interconnected system

Return type:

DDAE

Notes

Examples

>>> from tdcpy.controller import interconnect
>>> from tdcpy.ddae import DDAE
>>> A1 = np.array([[[1.0]]])
>>> hA1 = np.array([0.0])
>>> E1 = np.eye(1)
>>> B1 = np.array([[[1.0]]])
>>> hB1 = np.array([0.0])
>>> C1 = np.array([[[1.0]]])
>>> hC1 = np.array([0.0])
>>> D1 = np.array([[[0.0]]])
>>> hD1 = np.array([0.0])
>>> tds1 = DDAE(A=A1, hA=hA1, E=E1, B=B1, hB=hB1, C=C1, hC=hC1, D=D1, hD=hD1)
>>> A2 = np.array([[[0.5]]])
>>> hA2 = np.array([0.0])
>>> E2 = np.eye(1)
>>> B2 = np.array([[[1.0]]])
>>> hB2 = np.array([0.0])
>>> C2 = np.array([[[1.0]]])
>>> hC2 = np.array([0.0])
>>> D2 = np.array([[[0.0]]])
>>> hD2 = np.array([0.0])
>>> tds2 = DDAE(A=A2, hA=hA2, E=E2, B=B2, hB=hB2, C=C2, hC=hC2, D=D2, hD=hD2)
>>> interconnected = interconnect(tds1, tds2)
>>> interconnected.E.shape
(6, 6)
tdcpy.controller.create_static_controller(K)#

Creates static controller from the matrix of coefficients

Static controller is assumed to be of a form

y = K*u,

but is constructed as DDAE with all delay equal to 0.0 and matrices A, B, C empty, i.e.

I dxdt = A*x + B*u

y = C*x + K*u

Parameters:

K (array) – 1D or 2D array representing static controller gains

Returns:

DDAE representation of static controller

Return type:

DDAE

Notes

Examples

>>> from tdcpy.controller import create_static_controller
>>> K = np.array([[1.0, 2.0], [3.0, 4.0]])
>>> controller = create_static_controller(K)
>>> controller.A.shape
(0, 0, 1)
>>> controller.B.shape
(0, 2, 0)
>>> controller.C.shape
(2, 0, 0)
>>> controller.D.shape
(2, 2, 1)
tdcpy.controller.create_dynamic_controller(A, B, C, D)#

Creates dynamic controller from state space representation

The form is assumed to be

I dxdt = A*x + B*u

y = C*x + K*u

Parameters:
  • A (array) – state matrix, shape (n, n)

  • B (array) – input matrix, shape (n, m)

  • C (array) – output matrix, shape (p, n)

  • D (array) – feedthrough matrix, shape (p, m)

Returns:

ddae – DDAE representation of dynamic controller

Return type:

DDAE

Notes

Examples

>>> from tdcpy.controller import create_dynamic_controller
>>> A = np.array([[0.0, 1.0], [-2.0, -3.0]])
>>> B = np.array([[0.0], [1.0]])
>>> C = np.array([[1.0, 0.0]])
>>> D = np.array([[0.0]])
>>> controller = create_dynamic_controller(A, B, C, D)
>>> controller.A.shape
(2, 2, 1)
>>> controller.B.shape
(2, 1, 1)
>>> controller.C.shape
(1, 2, 1)
>>> controller.D.shape
(1, 1, 1)
tdcpy.controller.interconnect2(tds1, y1_indices=None, u1_indices=None, hA2=None, hB2=None, hC2=None, hD2=None, **kwargs)#

Creates and interconnected system ready for stabilitzation

Parameters:
  • tds1 (DDAE) – system 1 to be interconnected

  • y1_indices (list, optional) – indices of measurements

  • u1_indices (list, optional) – indices of controlled inputs

  • hA2 (array, optional) – controller delays, default None will assume delay vector to be [0.0]

  • hB2 (array, optional) – controller delays, default None will assume delay vector to be [0.0]

  • hC2 (array, optional) – controller delays, default None will assume delay vector to be [0.0]

  • hD2 (array, optional) – controller delays, default None will assume delay vector to be [0.0]

Returns:

ddae – interconnected system

Return type:

DDAE

Examples

>>> from tdcpy.controller import interconnect2
>>> from tdcpy.ddae import DDAE
>>> A1 = np.array([[[1.0]]])
>>> hA1 = np.array([0.0])
>>> E1 = np.eye(1)
>>> B1 = np.array([[[1.0]]])
>>> hB1 = np.array([0.0])
>>> C1 = np.array([[[1.0]]])
>>> hC1 = np.array([0.0])
>>> D1 = np.array([[[0.0]]])
>>> hD1 = np.array([0.0])
>>> tds1 = DDAE(A=A1, hA=hA1, E=E1, B=B1, hB=hB1, C=C1, hC=hC1, D=D1, hD=hD1)
>>> interconnected = interconnect2(tds1)
>>> interconnected.E.shape
(5, 5)
tdcpy.controller.interconnect3(system, y_indices=None, u_indices=None, hA2=None, hB2=None, hC2=None, hD2=None, **kwargs)#

Creates Closed Loop representation

Parameters:
Return type:

DDAE