Trying to find phase and group delay of transfer functions

asked 2015-09-01 19:07:21 +0200

lefti gravatar image

I have several functions I would like to get the phase and group delay. In python I did the following

from sympy import pi, Symbol, I , atan, im, re, simplify, collect, trigsimp, sign

fr = Symbol('fr', real=True) fo = Symbol('fo', real=True) fn = Symbol('fn', real=True) f = Symbol('f',real=True) q = Symbol('q', real=True) qn = Symbol('qn', real=True)

wr = 2pifr wo = 2pifo wn = 2pifn w = 2pif s = I*w

Lp1 - s domain

H_lp1 = wr/(s+wr)

(re_part,im_part) = H_lp1.expand(complex=True).as_real_imag()

H_lp1_ph = atan(im_part/re_part)

Which returns the correct answer but when I try a more complicated function such as

H_lpn2 = ((s2+wn2)(wo/wn)2)/(s2+s(wo/q)+wo**2)

(re_part,im_part) = H_lpn2.expand(complex=True).as_real_imag()

H_lpn2_ph_expanded = atan(im_part/re_part)

H_lpn2_ph = simplify(H_lpn2_ph_expanded)

It does not return the complete solution. Any ideas?

edit retag flag offensive close merge delete