You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tools for representing systems of linear DAEs and ODEs of the form (square or rectangular)
$$E \dot{x} = A x + B u, \quad y = C x + D u,$$
and for generating their Bode plots / frequency responses associated to the transfer matrix
$$H(s) = C (s E - A)^{-1} B + D.$$
Basic Usage
To use, ensure the directory 'linear_daes' ('.\linear_daes' in this repo) is found in your Python search path, make sure that Matplotlib, NumPy, and SciPy are installed (see '.\env\py-linear-daes-env.yml' for a conda environment that can be imported).
Create system matrices as ndarrays of dimension 2 in NumPy, then you can create a LinearDAE object representing the system.
import numpy as np import linear_daes as ld
n = 5 # state dimension m = 1 # input dimension p = 1 # output dimension
# create a random DAE E = np.random.random_sample((n,n)) A = np.random.random_sample((n,n)) B = np.random.random_sample((n,m)) C = np.random.random_sample((p,n)) D = np.random.random_sample((p,m))
system = ld.LinearDAE(A, B, C, D, E, label="System 1")
The LinearDAE constructor checks that dimensions are consistent (the system must be square or rectangular), and it will also check if the system is regular (having unique solutions for consistent initial conditions). While the constructor will accept rectangular (non-square, but consistent dimension) systems, such systems can't be regular so you will not be able to use the Bode plot tools; however, you can still use the LinearDAE object as a container for passing rectangular systems to modules, etc.
You can check if the system is an ODE (det(E) != 0), if it is regular, and its dimensions.
Add some data ticks by specifying the frequency, the system to 'pin' the tick to, and the input/output plot to place the tick on (important for MIMO systems).
w_start = -2 # power of 10 to start evaluating frequencies w_end = 5 # power of 10 to end evaluating frequencies w_num_points = 10000 # total number of log-spaced points to evaluate
bode_plot.show(w_start, w_end, w_num_points)
Note that matplotlib.pyplot.show() erases the plot, so if you want to alter / save / etc the plot before showing, indicate in the show method that the plot should be generated but not shown, then retrieve the plot, do whatever you want, and call the show_after_generate_only method.
Given a LinearDAE, real numbers w_start and w_end, and an integer w_num_points, return the LinearDAE's transfer matrix evaluated at w_num_points log-spaced points in the frequency range [complex(real=0.0,imag=1.0) * 10 ** (w_start), complex(real=0.0,imag=1.0) * 10 ** (w_end)].