pyyeti.expmint.getEPQ

pyyeti.expmint.getEPQ(A, h, order=1, B=None, half=False)[source]

Returns E, P, Q for the exponential solver given the state-space matrix A.

Parameters:
  • A (2d ndarray) – The state-space matrix: xdot = A x + B u

  • h (scalar) – Time step.

  • order (integer, optional) –

    • 0 for the zero order hold (force stays constant across time step)

    • 1 for the 1st order hold (force can vary linearly across time step)

  • B (d2 ndarray or None; optional) – If array, it multiplies the inputs; if None, it is assumed identity.

  • half (bool; optional) – If B is a 2d ndarray, half is ignored. Otherwise, if half is False, a full size identity (same size as A) is used for B. If half is True, only the first half of the columns are retained (which is handy for converting a 2nd order ODE into a 1st order ODE as pyyeti.ode.SolveExp2 does – where there are force inputs only for the first half of the equations).

Returns:

E, P, Q (2d ndarrays, except if order == 0, Q = 0.) –

These are the coefficient matrices used to solve the ODE:

for j in range(nt):
    d[:, j+1] = E*d[:, j] + P*F[:, j] + Q*F[:, j+1]

Notes

This routine calls either getEPQ1() or getEPQ2() for the bulk of the work. If the 1-norm of A is less than 2.097847961257068 [1], getEPQ1() is called; otherwise, getEPQ2() is called.

References

Examples

>>> from pyyeti import expmint
>>> import numpy as np
>>> import scipy.linalg as la
>>> np.set_printoptions(4)
>>> A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> B = np.array([[0, 1, 0]]).T
>>> E, P, Q = expmint.getEPQ(A, .05, order=1, B=B)
>>> E
array([[ 1.0996,  0.1599,  0.2202],
       [ 0.3099,  1.3849,  0.46  ],
       [ 0.5202,  0.61  ,  1.6998]])
>>> P
array([[ 0.0024],
       [ 0.0308],
       [ 0.0091]])
>>> Q
array([[ 0.0011],
       [ 0.0276],
       [ 0.0041]])
>>> E, P, Q = expmint.getEPQ(A, .05, order=0, B=B)
>>> E
array([[ 1.0996,  0.1599,  0.2202],
       [ 0.3099,  1.3849,  0.46  ],
       [ 0.5202,  0.61  ,  1.6998]])
>>> P
array([[ 0.0034],
       [ 0.0583],
       [ 0.0133]])
>>> Q
0.0