Week 2 - GSoC 2020

Week 2 of the coding period is now over. It was a week full of learning and a lot of challenges. I had my first meeting with Nikhil and Ishan on June 4, between 5:00 - 6:00 p.m. where we discussed a few things regarding the implementation part for this week, or some general discussions on certain topics.

Here’s a sneak peek at the functionality that I had been working on, this whole week ;)

>>> from sympy.physics.control.lti import TransferFunction
>>> from sympy.abc import s, p
>>> from sympy import init_printing
>>> init_printing(use_unicode=True)
  1. Creating a TransferFunction by providing numerator, denominator and a variable (for anchoring the symbols).
    >>> tf1 = TransferFunction(s**4 + s**3 - 4*s**2 + p, p**4 + s**3 - 4, s)
    >>> tf1
         4    3      2
    p + s  + s  - 4s 
    ──────────────────
      4    3        
    p  + s  - 4
    
  2. Using simplify to explicitly cancel poles and zeros.
    >>> tf2 = TransferFunction((p + 3)*(p - 1), (p - 1)*(p + 5), p)
    >>> simplify(tf2)
    p + 3
    ─────
    p + 5
    
  3. Using expand method to expand the numerator and the denominator whenever needed.
    >>> tf2.expand()
     2          
    p  + 2p - 3
    ────────────
     2          
    p  + 4p - 5
    
  4. Taking power of a TransferFunction.
    >>> tf3 = TransferFunction(s + p, s - p, s)
    >>> tf3**2	
           2
     (p + s) 
    ─────────
           2
    (-p + s) 
    

Other methods also include negation, addition, subtraction, division and multiplication of Transfer Functions. We can even combine all of them and perform operations like tf1*tf2 + tf3/tf4 with them!

Some key highlights of this week’s work are:

  • I worked on the implementation of the TransferFunction class. The implementation is almost over, just some minor tweaks might be needed.

  • Docstrings for the class and all the methods were recently added in the PR.

This PR (#19390) is too big (850+ lines of code) so it’s taking more time than expected, but I will try to get it merged within next two days.

In week 3, after this PR gets in, I will first discuss a few things with my mentors regarding the API for TransferFunctionMatrix class, and then work on adding unit tests for the same.

I have a lot more to learn and implement! :)