mixer.py 659 Bytes
from sympy import *
from sympy.simplify.fu import *

init_printing()

A, B, w, t, dphi = symbols('A, B, omega, t, Delta_phi', real=True, imaginary=False)

#polynimial approach of RF mixer
k1, k2, k3 = symbols('k1, k2, k3', real=True, imaginary=False)
e = A*cos(w*t) + B*cos(w*t+dphi-pi/2)
Vmix_poly = k1*e + k2*e**2
Vmix_poly = expand(TR8(TR7(expand(Vmix_poly))))

print('Polynomial result :\n' + pretty(Vmix_poly) + '\n')

#product approach of RF mixer
kphi = symbols('k_phi', real=True, imaginary=False)
Vmix_prod = 2 * kphi * A*cos(w*t) * B*cos(w*t+dphi-pi/2)
Vmix_prod = expand(TR8(TR7(expand(Vmix_prod))))
print('Product result :\n' + pretty(Vmix_prod))