pymor.models.transfer_function
¶
Module Contents¶
- class pymor.models.transfer_function.FactorizedTransferFunction(dim_input, dim_output, K, B, C, D, dK=None, dB=None, dC=None, dD=None, parameters={}, sampling_time=0, name=None)[source]¶
Bases:
TransferFunction
Transfer functions in generalized coprime factor form.
This class describes input-output systems given by a transfer function of the form \(H(s, \mu) = \mathcal{C}(s, \mu) \mathcal{K}(s, \mu)^{-1} \mathcal{B}(s, \mu) + \mathcal{D}(s, \mu)\).
Parameters
- dim_input
The number of inputs.
- dim_output
The number of outputs.
- K, B, C, D
Functions that take
s
and return anOperator
.- dK, dB, dC, dD
Functions that take
s
and return anOperator
that is the derivative of K, B, C, D (optional).- parameters
The
Parameters
of the transfer function.- sampling_time
0
if the system is continuous-time, otherwise a positive number that denotes the sampling time (in seconds).- name
Name of the system.
- class pymor.models.transfer_function.TransferFunction(dim_input, dim_output, tf, dtf=None, parameters={}, sampling_time=0, name=None)[source]¶
Bases:
pymor.core.cache.CacheableObject
,pymor.parameters.base.ParametricObject
Class for systems represented by a transfer function.
This class describes input-output systems given by a (parametrized) transfer function \(H(s, \mu)\).
Parameters
- dim_input
The number of inputs.
- dim_output
The number of outputs.
- tf
The transfer function H, given by a callable that takes a complex value
s
and, if parametric, aparameter value
mu
. The result oftf(s, mu)
is aNumPy array
of shape(dim_output, dim_input)
.- dtf
The complex derivative of
H
with respect tos
(optional).- parameters
The
Parameters
of the transfer function.- sampling_time
0
if the system is continuous-time, otherwise a positive number that denotes the sampling time (in seconds).- name
Name of the system.
Methods
Compute magnitudes and phases.
Draw the Bode plot for all input-output pairs.
Evaluate the derivative of the transfer function.
Evaluate the transfer function.
Evaluate the transfer function on the imaginary axis.
Compute H2 inner product with an
LTIModel
.Compute the H2-norm using quadrature.
Draw the magnitude plot.
- bode(w, mu=None)[source]¶
Compute magnitudes and phases.
Parameters
- w
A sequence of angular frequencies at which to compute the transfer function.
- mu
Parameter values
for which to evaluate the transfer function.
Returns
- mag
Transfer function magnitudes at frequencies in
w
,NumPy array
of shape(len(w), self.dim_output, self.dim_input)
.- phase
Transfer function phases (in radians) at frequencies in
w
,NumPy array
of shape(len(w), self.dim_output, self.dim_input)
.
- bode_plot(w, mu=None, ax=None, Hz=False, dB=False, deg=True, **mpl_kwargs)[source]¶
Draw the Bode plot for all input-output pairs.
Parameters
- w
A sequence of angular frequencies at which to compute the transfer function.
- mu
Parameter values
for which to evaluate the transfer function.- ax
Axis of shape (2 *
self.dim_output
,self.dim_input
) to which to plot. If not given,matplotlib.pyplot.gcf
is used to get the figure and create axis.- Hz
Should the frequency be in Hz on the plot.
- dB
Should the magnitude be in dB on the plot.
- deg
Should the phase be in degrees (otherwise in radians).
- mpl_kwargs
Keyword arguments used in the matplotlib plot function.
Returns
- artists
List of matplotlib artists added.
- eval_dtf(s, mu=None)[source]¶
Evaluate the derivative of the transfer function.
Parameters
- s
Laplace variable as a complex number.
- mu
Returns
Transfer function value as a 2D
NumPy array
.
- eval_tf(s, mu=None)[source]¶
Evaluate the transfer function.
Parameters
- s
Laplace variable as a complex number.
- mu
Returns
Transfer function value as a 2D
NumPy array
.
- freq_resp(w, mu=None)[source]¶
Evaluate the transfer function on the imaginary axis.
Parameters
- w
A sequence of angular frequencies at which to compute the transfer function.
- mu
Parameter values
for which to evaluate the transfer function.
Returns
- tfw
Transfer function values at frequencies in
w
,NumPy array
of shape(len(w), self.dim_output, self.dim_input)
.
- h2_inner(lti)[source]¶
Compute H2 inner product with an
LTIModel
.Uses the inner product formula based on the pole-residue form (see, e.g., Lemma 1 in [ABG10]). It assumes that
self.tf
is defined on-lti.poles()
.Parameters
- lti
LTIModel
consisting ofOperators
that can be converted toNumPy arrays
. The D operator is ignored.
Returns
- inner
H2 inner product.
- h2_norm(return_norm_only=True, **quad_kwargs)[source]¶
Compute the H2-norm using quadrature.
This method uses
scipy.integrate.quad
and makes no assumptions on the form of the transfer function. It only assumes thatself.tf
is defined over the imaginary axis.By default, the absolute error tolerance in
scipy.integrate.quad
is set to zero (see its optional argumentepsabs
). It can be changed by using theepsabs
keyword argument.Parameters
- return_norm_only
Whether to only return the approximate H2-norm.
- quad_kwargs
Keyword arguments passed to
scipy.integrate.quad
.
Returns
- norm
Computed H2-norm.
- norm_relerr
Relative error estimate (returned if
return_norm_only
isFalse
).- info
Quadrature info (returned if
return_norm_only
isFalse
andfull_output
isTrue
). Seescipy.integrate.quad
documentation for more details.
- mag_plot(w, mu=None, ax=None, ord=None, Hz=False, dB=False, **mpl_kwargs)[source]¶
Draw the magnitude plot.
Parameters
- w
A sequence of angular frequencies at which to compute the transfer function.
- mu
Parameter values
for which to evaluate the transfer function.- ax
Axis to which to plot. If not given,
matplotlib.pyplot.gca
is used.- ord
The order of the norm used to compute the magnitude (the default is the Frobenius norm).
- Hz
Should the frequency be in Hz on the plot.
- dB
Should the magnitude be in dB on the plot.
- mpl_kwargs
Keyword arguments used in the matplotlib plot function.
Returns
- out
List of matplotlib artists added.