lcapy.smatrix.LaplaceDomainMatrix

class lcapy.smatrix.LaplaceDomainMatrix(*args, **kwargs)

Bases: Matrix

Methods

ILT(**assumptions)

Attributes

rows

cols

class LaplaceDomainExpression(val, **assumptions)

Bases: LaplaceDomain, Expr

s-domain expression or symbol.

ILT(zero_initial_conditions=None, **assumptions)

Attempt inverse Laplace transform.

If causal=True the response is zero for t < 0 and the result is multiplied by Heaviside(t) If ac=True or dc=True the result is extrapolated for t < 0. Otherwise the result is only known for t >= 0.

By default initial conditions are assumed to be zero. This can be controlled by zero_initial_conditions.

angular_fourier(**assumptions)

Convert to angular Fourier domain.

angular_frequency_response(**assumptions)

Convert to angular frequency response domain. Note, this is similar to the angular Fourier domain but not always.

backward_euler_transform()

Approximate s = ln(z) / dt

by s = (1 / dt) * (1 - z**-1). This is also known as the backward difference method.

See also discretize with regards to scaling of the result.

bilinear_transform()

Approximate s = ln(z) / dt

by s = (2 / dt) * (1 - z**-1) / (1 + z**-1)

This is also called Tustin’s method and is equivalent to the trapezoidal method.

See also discretize with regards to scaling of the result.

bode_plot(fvector=None, unwrap=True, var=None, strict=False, phase='radians', **kwargs)

Plot frequency response for a frequency-domain phasor as a Bode plot (but without the straight line approximations).

If var is None or f, fvector specifies the (linear) frequencies (in hertz) otherwise if var is omega, fvector specifies the angular frequencies (in radians).

If fvector is a tuple (f1, f2), it sets the frequency

limits. Since a logarithmic frequency scale is used, f1 must be greater than 0.

unwrap controls phase unwrapping (default True).

This method makes the assumption that the expression is causal. Note, the Bode plot does not exist for marginally stable and unstable systems since jw is outside the region of convergence.

delay(T)

Apply delay of T seconds by multiplying by exp(-s T).

differential_equation(inputsym='x', outputsym='y', normalize_a0=True)

Create differential equation from transfer function.

For example::
>>> H = (s + 3) / (s**2 + 4)
>>> H.differential_equation()
::
           d                    d
    y(t) + --(y(t)) = 4.x(t) + ---(x(t))
           dt                    2
                                 dt
discretize(method=None, alpha=0.5, scale=None)

Convert to a discrete-time approximation in the z-domain:

\(H(z) pprox K H_c(s)\)

where \(K\) is a scale factor.

Note, the default scaling is different for admittance, impedance, transfer function, or undefined expressions compared to voltage and current expressions.

The scaling is chosen so that the discrete-time voltage and current expressions have plots similar to the continuous-time forms. For example, with the impulse-invariance method for a continuous-time voltage signal \(v_c(t)\):

\(v[n] = v_c(n \Delta t)\)

However, for a transfer-function with a continuous-time impulse response \(h_c(t)\), then

\(h[n] = \Delta t h_c(n \Delta t)\).

This corrects the scaling when approximating a continuous-time convolution by a discrete-time convolution.

The default method is ‘bilinear’. Other methods are: ‘impulse-invariance’ ‘bilinear’, ‘tustin’, ‘trapezoidal’ ‘generalized-bilinear’, ‘gbf’ controlled by the parameter alpha, ‘euler’, ‘forward-diff’, ‘forward-euler’ ‘backward-diff’, ‘backward-euler’ ‘simpson’, ‘matched-Z’, ‘zero-pole-matching’

See also dlti_filter.

dlti_filter(method='bilinear', alpha=0.5)

Create DLTI filter using bilinear transform.

See discretize for available methods.

evaluate(svector=None)

Evaluate expression at arg. arg may be a scalar or a vector. The result is of type float or complex.

If arg is iterable, a NumPy array is returned.

There can be only one or fewer undefined variables in the expression. This is replaced by arg and then evaluated to obtain a result.

See also fval and cval.

final_value()

Determine value at t = oo.

forward_euler_transform()

Approximate s = ln(z) / dt

by s = (1 / dt) * (1 - z**-1) / z**-1. This is also known as the forward difference method.

See also discretize with regards to scaling of the result.

fourier(**assumptions)

Convert to Fourier domain.

frequency_response(**assumptions)

Convert to frequency response domain. Note, this is similar to the Fourier domain but not always.

classmethod from_numer_denom(numer, denom)

Create a transfer function from lists of the coefficient for the numerator and denominator.

See also from_zeros_poles_gain, from_poles_residues.

classmethod from_poles_residues(poles, residues)

Create a transfer function from lists of poles and residues.

See also from_zeros_poles_gain, from_numer_denom.

classmethod from_zeros_poles_gain(zeros, poles, K=1)

Create a transfer function from lists of zeros and poles, and from a constant gain.

See also from_poles_residues, from_numer_denom.

generalized_bilinear_transform(alpha=0.5)

Approximate s = ln(z) / dt

by s = (1 / dt) * (1 - z**-1) / (alpha + (1 - alpha) * z**-1))

When alpha = 0 this is equivalent to the forward Euler (forward difference) method.

When alpha = 0.5 this is equivalent to the bilinear transform, aka, Tustin’s method or the trapezoidal method.

When alpha = 1 this is equivalent to the backward Euler (backward difference) method.

See also discretize with regards to scaling of the result.

impulse_invariance_transform()

This samples the impulse response and then calculates the Z-transform. It does not work if the impulse response has Dirac deltas, say for a transfer function that is a pure delay or is not-strictly proper.

The discrete-time and continuous-time impulse responses are identical at the sampling instants n * dt.

The data needs to be sampled many times the bandwidth to avoid aliasing.

See also bilinear_transform and matched_ztransform.

See also discretize with regards to scaling of the result.

impulse_response(tvector=None)

Evaluate transient (impulse) response.

inverse_laplace(zero_initial_conditions=None, **assumptions)

Attempt inverse Laplace transform.

If causal=True the response is zero for t < 0 and the result is multiplied by Heaviside(t) If ac=True or dc=True the result is extrapolated for t < 0. Otherwise the result is only known for t >= 0.

By default initial conditions are assumed to be zero. This can be controlled by zero_initial_conditions.

property jomega

Return expression with s = j omega.

laplace(**assumptions)

Convert to s-domain.

lti_filter(normalize_a0=True)

Create continuous-time linear time-invariant filter from continuous-time transfer function.

matched_ztransform()

Match poles and zeros of H(s) to approximate H(z).

If there are no zeros, this is equivalent to impulse_invariance.

See also bilinear_transform and impulse_invariance_transform.

See also discretize with regards to scaling of the result.

nichols_plot(fvector=None, var=None, **kwargs)

Plot frequency response for a frequency-domain phasor as a Nichols plot (dB versus phase). fvector specifies the frequencies. If it is a tuple (f1, f2), it sets the frequency limits.

npoints set the number of plotted points.

This method makes the assumption that the expression is causal.

norm_angular_fourier(**assumptions)

Convert to normalized angular Fourier domain.

norm_fourier(**assumptions)

Convert to normalized Fourier domain.

nyquist_plot(fvector=None, var=None, **kwargs)

Plot frequency response for a frequency-domain phasor as a Nyquist plot (imaginary part versus real part). fvector specifies the frequencies. If it is a tuple (f1, f2), it sets the frequency limits.

npoints set the number of plotted points.

The unit circle is shown by default. This can be disabled with unitcircle=False.

This method makes the assumption that the expression is causal.

phasor(**assumptions)

Convert to phasor domain.

phasor_ratio(**assumptions)

Convert to phasor ratio domain.

plot(**kwargs)

Plot pole-zero map.

kwargs include: axes - the plot axes to use otherwise a new figure is created xlabel - the x-axis label (default Re(s)) ylabel - the y-axis label (default Im(s)) xscale - the x-axis scaling yscale - the y-axis scaling pole_color – the color of the pole markers zero_color – the color of the zero markers in addition to those supported by the matplotlib plot command.

The plot axes are returned.

pole_zero_plot(**kwargs)

Plot pole-zero map.

post_initial_value()

Determine post-initial value at t = 0+.

response(xvector, tvector, method='bilinear', alpha=0.5)

Evaluate response to input signal xvector at times specified by tvector. This returns a NumPy array.

The default method is ‘bilinear’. Other methods are: ‘impulse-invariance’ ‘bilinear’, ‘tustin’, ‘trapezoidal’ ‘generalized-bilinear’, ‘gbf’ controlled by the parameter alpha ‘euler’, ‘forward-diff’, ‘forward-euler’ ‘backward-diff’, ‘backward-euler’.

See also discretize with regards to scaling of the result.

simpson_transform()

Approximate s = ln(z) / dt

by s = (3 / dt) * (z**2 - 1) / (z**2 + 4 * z + 1). This is more accurate than the other methods but doubles the system order and can produce unstable poles.

See also discretize with regards to scaling of the result.

property ss

Return state-space representation using controllable canonical form. For other forms, use state_space().

state_space(form='CCF')

Create state-space representation from transfer function. Note, state-space representations are not unique and are determined by the form argument. Currently this can be ‘CCF’ for the controllable canonical form, ‘OCF’ for the observable canonical form, or ‘DCF’ for the diagonal canonical form.

step_response(tvector=None)

Evaluate step response.

tdifferentiate()

Differentiate in t-domain (multiply by s).

time(**assumptions)

Convert to time domain.

If causal=True the response is zero for t < 0 and the result is multiplied by Heaviside(t) If ac=True or dc=True the result is extrapolated for t < 0. Otherwise the result is only known for t >= 0.

tintegrate()

Integrate in t-domain (divide by s).

transient_response(tvector=None)

Evaluate transient (impulse) response.