In [ ]:
import sympy
from sympy import *
sympy.init_printing()
s = Symbol('s')
t = Symbol('t', positive=True)
Tool for the solution of linear differential equations.
Definition: For a function $f(t)$ such that:
For a finite real value of $\sigma$, the Laplace transform of $f(t)$ is defined as:
This is the unilateral Laplace transform. Or:
In [ ]:
from IPython.display import Image
Image(filename='img/laplace_fig1.png')
Example: Consider a unitary step function $f(t)$:
In [ ]:
import numpy as np
import matplotlib.pyplot as plt
x = [-1, 0, 0, 1, 2, 3]
y = [0, 0, 1, 1, 1, 1]
plt.plot(x, y, 'r', label='f(t) = u(t)', linewidth=3)
plt.title('Unitary step function')
plt.xlabel('t')
plt.ylabel('f(t)')
plt.legend()
plt.xlim(-1, 3)
plt.ylim(-1, 2)
plt.grid()
plt.show()
It seeks to obtain $f(t)$ from $F(s)$.
1. Multiplication by a constant
2. add and subtract
3. Differentiation
4. Integration
5. Time shift
Where $u\left ( t-T \right )$ is the unitary step offset to the right.
6. Initial value theorem
7. Final value theorem
If and only if $F(s)$ is analytic in the imaginary axis and in the right half-plane of $s$.
Example: Consider the function $F_1(s)$:
The poles of $F_1(s)$ are:
In [ ]:
F1 = 5/(s*(s**2+s+2))
F1.expand()
In [ ]:
from control import *
from scipy import signal
sysF1 = signal.lti([5], [1, 1, 2, 0]) # F1(s) = (5) / (s *** 3 + s ** 2 + 2 * s + 0)
w, H = signal.freqresp(sysF1)
print(sysF1.zeros, sysF1.poles, sysF1.gain)
In [ ]:
plt.plot(sysF1.zeros.real, sysF1.zeros.imag, 'o')
plt.plot(sysF1.poles.real, sysF1.poles.imag, 'x')
plt.title('Poles and Zeros')
plt.xlabel('Re')
plt.ylabel('Im')
plt.xlim(-3, 3)
plt.ylim(-3, 3)
plt.grid()
plt.show()
Since the function is analytic on the imaginary axis and on the right half-plane of $s$, then it fulfills the final value theorem. Thus:
Example: Consider the function $F_2(s)$:
And we know that $f_2 \left ( t \right ) = sin \left ( \omega t \right )$. The poles are: $\pm j \omega $
$ \Rightarrow $ Does not meet the final value theorem
$ \Rightarrow $ We can not determine the final value of $f(t)$.
8. Complex displacement
9. Real convolution (complex multiplication)
Note: $\mathfrak{L}^{-1} \left [ F_1 \left ( s \right ) F_2 \left ( s \right ) \right ] \neq f_1 \left ( t \right ) \, f_2 \left ( t \right ) $
10. Complex convolution (real multiplication)
1. Simple poles
Where the coefficients $A, B, ... Z$ are determined by multiplying both sides by $(s+s_i)$, and replacing $s = -s_i$.
Example: Consider the function $X(s)$:
Both sides by $(s+1)$:
Both sides by $(s+2)$:
Both sides by $(s+3)$:
2. Poles of multiple order.
The procedure is the same, but we have as many terms as polo multiplicity.
Example: Consider the function $X(s)$:
General form:
Therefore, the complete expansion is:
3. Simple complex poles
They develop in the same way.
Workshop: Carry out the expansion by hand by partial fractions of:
Example: Consider the function:
Define $x(t)$ if:
Solution
Applying Laplace:
To calculate the inverse of Laplace, we expand in partial fractions:
And using the tables:
$\frac{5}{2}$ is the stationary response, and the rest is the transient response.
If we are only looking for the stationary response, we can apply the final value theorem:
This is a way, the other option is calculating it directly with sympy:
In [ ]:
import sympy
from sympy import *
sympy.init_printing()
s = Symbol('s')
t = Symbol('t', positive=True)
In [ ]:
X = (-s**2-s+5)/((s)*(s+1)*(s+2))
In [ ]:
X
In [ ]:
X.expand()
In [ ]:
xt = inverse_laplace_transform(X,s,t).evalf().simplify()
In [ ]:
xt
Workshop: Find $x(t)$:
Sol.: $x(t) = 1 +1.19 e^{-17.2t} sin (26.5 t - \theta ), \theta = -56.9^{\circ}$