Week 8

Mid Term Evaluations …. Hello everyone, hope this blog finds you well.

Last week I had spoken about a couple of pull requests which I was pushing to be merged and was gradually moving towards the end of phase 2. This week, my task was to investigate the pull requests to a deeper extent, find out edge cases and make sure they were covered. I also delved into the codebase and raised some issues which will be the last bunch of mistakes to tackle in phase 2 of GSOC.

Aim :

I could send in the pull request to add Gain and Phase margins: #25418.
I do not see any major blockers to the pull request as of now, but we will surely discuss it in our weekly meeting.

This week we also had our Midterm Evaluation and tada !!! I have passed the evaluation succesfully :)

Work : Let us go through the Pull Requests in brief.

  1. Phase Margin:
     >>> tf = TransferFunction(1, s**3 + 2*s**2 + s, s)
     >>> phase_margin(tf)
     180*(-pi + atan((-1 + (-2*18**(1/3)/(9 + sqrt(93))**(1/3) + 12**(1/3)*(9 + sqrt(93))**(1/3))**2/36)/(-12**(1/3)*(9 + sqrt(93))**(1/3)/3 + 2*18**(1/3)/(3*(9 + sqrt(93))**(1/3)))))/pi + 180
    
     >>> tf1 = TransferFunction(s**3, s**2 + 5*s, s)
     >>> phase_margin(tf1)
     -180 + 180*(atan(sqrt(2)*(-51/10 - sqrt(101)/10)*sqrt(1 + sqrt(101))/(2*(sqrt(101)/2 + 51/2))) + pi)/pi
    
  2. Gain Margin:
     >>> tf = TransferFunction(1, s**3 + 2*s**2 + s, s)
     >>> gain_margin(tf)
     20*log(2)/log(10)
    
     >>> tf1 = TransferFunction(s**3, s**2 + 5*s, s)
     >>> gain_margin(tf1)
     oo
    

Work : Let us go through the raised Issues in brief.

  1. Need for phase unwrapping :
    There is a discrepancy between SymPy and other control toolkits concerning the phase data generated by the bode plot for frequency response. By definition ,phase = arg(H(jw)) which is correctly implemented. The difference in value arrives due to the the principal argument of arg being (180,180]. Due to this there is a sudden change in behavior of the phase plot as values tend to -180 (sudden jump by ~360 which is not the true nature of the system).
    To make the phase plot continuous, we would require phase unwrapping. This issue has been opened here #25444

I could have simply tackled this with the following numpy library function numpy.unwrap . But since sympy is a symbolic library we want to make our methods as free as possible from numpy’s numerical functions. I would try to sort this issue out by next week.

Future Work : This marks the end of phase 2 from my end. Now we only need to polish the work and send in pull requests as soon as we figure out the issues.
From next week onwards I would shift to Phase 3 work where I will work on State Space Models. The initial few days I will be focussing on learning about State Space Models through course textbooks and online lectures. This will be followed by the implementation.

Address

Mumbai, Maharashtra, India