In [1]:
from sympy import init_session
init_session()
%matplotlib inline
Look at a superposition of two sinusoidal signals:
In [2]:
f=sin(x)*sin(y)
f
Out[2]:
This product can be rewritten as a sum using trigonometric equalities. SymPy has a special function for those:
In [3]:
from sympy.simplify.fu import *
g=TR8(f) # TR8 is a trigonometric expression function from Fu paper
Eq(f, g)
Out[3]:
Now let us take an example with two different angular frequencies:
In [4]:
s = 0.03 # slip
fs = 50 # stator frequency in Hz
fr = (1-s)*fs # rotor frequency in Hz
fr
Out[4]:
In [5]:
alpha=2*pi*fs*t
beta=2*pi*fr*t
Now plot the product of both frequencies:
In [6]:
# Create the plot of the stator rotation frequency in blue:
p1=plot(sin(alpha), (t, 0, 1), show=False, line_color='b', adaptive=False, nb_of_points=5000)
# Create the plot of the rotor rotation frequency in green:
p2=plot(0.5*sin(beta), (t, 0, 1), show=False, line_color='g', adaptive=False, nb_of_points=5000)
# Create the plot of the combined flux in red:
p3=plot(0.5*f.subs([(x, alpha), (y, beta)]), (t, 0, 1),
show=False, line_color='r', adaptive=False, nb_of_points=5000)
# Make the second and third one a part of the first one.
p1.extend(p2)
p1.extend(p3)
# Display the modified plot object.
p1.show()