GSOC'22 Introduction And Ideas

239 views
Skip to first unread message

Anurag Surendra Bhat (B20CS097)

unread,
Mar 10, 2022, 10:54:03 AM3/10/22
to sympy
Hello sympy community,
I am Anurag Bhat , a computer science and engineering sophomore at IIT Jodhpur, India .I have been contributing to SymPy for quite a while now and here is a link to my work -

I have done work in the physics module and recently developed interest in 'physics.control' module after Akshansh Bhatt( GSOC'21 contributor to this module) recently merged my pr relevant to control plots - #23074 - physics : Improved Bode's phase and magnitude plots.
I have previously covered a introduction to control systems in a college course - Signals and Systems . I also had made a basic project like implementation of a system for denoising then deblurring signals V.S. system for deblurring then denoising signals.(File - https://drive.google.com/file/d/1iZDy8O7V5Hi703P7BPFScx0bAFgrM6na/view?usp=sharing)

Coming to the project I have gone over the online sympy documentation of control systems .I have had a brief idea of what proposal writing is like after I went through Akshansh's proposal for last year .I have read the google groups discussion on what use/value does a control package bring to sympy ( Re: [Discussion] GSoC 2020 -- Adding control package to sympy.physics (google.com) ) . Some ideas I got from seeing the previous work done are -
1. Some minor functionalities that MATLAB provides but sympy currently doesn't for transfer functions for it's bandwidth , partial stability etc.
2. Adding more examples and illustrations for the previous work done .
3. Implementing remaining plots in control.plots for eg - root-locus plot , nyquist plot
4. Making TransferFunctionMatrix take numerator/denominator inputs in list format like MATLAB does .

I have started finalizing/compiling all this matter since SymPy was announced to participate in GSOC this year so I'm sure I would have missed some ideas and improvements .Here I would like help from the members of the community .Firstly I would appreciate any suggestions/help/resources regarding this module .Secondly I would request past mentors ( Jason Moore) and  Gsocer's /potential co-mentors( Naman and Akshansh) to guide if these are good ideas to work on, add ideas and show me proper direction since this is my first time exploring the field of open source . 


Regards 
Anurag Bhat.

Eeshaan Jain

unread,
Mar 11, 2022, 11:41:27 AM3/11/22
to sy...@googlegroups.com
Hey,
I'm somewhat unsure, but as far as I've used sympy for controls, I couldn't find an equivalent for finding the frequency response of a digital filter in sympy. There is freqz which does this in MATLAB.

Thanks

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/0dfd01c5-ab44-4624-bdba-9cb76ebc28cbn%40googlegroups.com.

Anurag Surendra Bhat (B20CS097)

unread,
Mar 12, 2022, 12:01:02 AM3/12/22
to sympy
Hi Eeshaan,
The control package in sympy is developing since 2020 but not nearly as powerful as in MATLAB . Thanks for the suggestion ,I'll surely explore it !

Regards,
Anurag.

Anurag Surendra Bhat (B20CS097)

unread,
Mar 18, 2022, 9:39:41 AM3/18/22
to sympy
Hi ,
Previously on this thread ,I had talked about some ideas regarding the control module as a project for GSOC'22 .I have done some research on them and come up with Broad Ideas In Scope To Work On . I request the community to comment on it and add to it .I would also request potential mentors Jason K Moore , Akshansh Bhatt to name a few to have a look at it and review it .I think there is a good scope of improvement in the control package. Once I am certain with the priority order of these ideas I will start drafting a concrete proposal .

These are the ideas that I have accumulated by observing work done in previous years and checking out other CST frameworks .Implementation of all ideas would take extensive discussions with mentors along with a  bunch of new unit tests to check their functioning.

1. Complete pending work from previous years in the control package . Making a well documented module with examples and illustrations was one of Naman’s objectives .It was because people always tend to use softwares with top notch documentation. So PR #22124 will be completed with more examples from documentation of MATLAB and python-control .I also have a course textbook for my control-systems course and can always refer to that for illustrations.
 Another pending thing I can observe which Akshansh had attempted but could not get merged due to some performance issues is the root_locus_plot , there are relevant comments on his PR #21763 regarding this . Along with that the 2 other plots which were proposed to be added in the future were nyquist_plot and nichols_plot.

2. Some bugs need to be fixed and along with that minor changes can be made to the transfer function API ideas.Some of these were pointed out in previous year’s proposal but I believe are not fixed yet.
  1. I have spotted a bug and raised an issue #23247 .Transfer function should not be able to take non-polynomial expressions as input (eg -sin(x) , 2^(x)).

  2. SymPy being a symbolic library ,subs( ) and rewrite( ) are useful properties. ‘TransferFunction’ is basically a rational function ,so it will be a good addition if users can access these methods. ‘TransferFunction’ inherits ‘Basic’,so this can be done. ‘TransferFunctionMatrix’ also lacks these properties.

  3. Restructuring some parts of the code , I feel some functions are unutilized .Minor functionalities for ‘TransferFunction' that are a part of other CST frameworks like MATLAB can be made a part of SymPy too.

    Some of these are -

    • bandwidth(system) - First frequency where gain drops by -3dB of DC value.

    • margin(system) - Gives gain-margin and phase-margin which are used to visualize marginal stability that SymPy’s ‘is_stable()’ gives no information about.

  4. Possible improvements in 'TransferFunction' / 'TransferFunctionMatrix' API - 
    • Making input ‘var’ in ‘TransferFunction’ optional instead of compulsory. Users will only have to specify the variable when there is a conflict.

    • Allowing a MATLAB-like input scheme where users just have to input coefficients of particular degrees of the Transfer Function in order.I personally feel it is an efficient method of input and will itself eliminate many input issues, one of them pointed above as use of non-polynomials.

    For eg. -
    >>Sys = tf([1, 2] ,[1, 2, 3])
    >>Sys(s)
    (s**2 + 2*s)/(s**2 + 2*s + 3)

    • Allowing a declared rational expression to be taken as input in ‘TransferFunction’ to reduce size -

    For eg. - 
    # Current 
    >>> tf1 = TransferFunction(1,1+s,s)
    >>> tf2 = TransferFunction(2,2+s,s)
    >>> t = TransferFunctionMatrix([[tf1, tf2],[-tf1,-tf2]])

    # Proposing to allow 
    >>> exp1 =1/1+s
    >>> exp1 = 1/(1+s)
    >>> exp2 = 2/(2+s) 
    >>> t = TransferFunctionMatrix([[exp1, exp2],[-exp1,-exp2]])

    • Adding support for ‘TransferFunctionMatrix’ objects to be instantiated by passing a list of numerators and a common denominator. This can be an alternative way of object creation.

 3. Introducing ‘StateSpace’ model for effectively representing a State Space system symbolically.
These 3 functions would be essential for State Space system-
  • is_observable( StateSpaceModel )

  • observability_matrix( StateSpaceModel )

  • observable_subspace( StateSpaceModel )

4. Implementing Discrete-time ‘TransferFunction’ model. Discussing the API and making things compatible with the current implementation is a challenge as suggested in Akshansh’s Gsoc 2021 report.



I hope this makes for a suitable project to work on ! Over the next few days I will be doing a more in depth research for more ideas / scope of improvement. Thanks for your time and efforts in going through the content .

Regards,
Anurag .

Anurag Surendra Bhat (B20CS097)

unread,
Mar 25, 2022, 5:52:47 AM3/25/22
to sympy
Hi SymPy community ,

I have surfed over the ideas that I mentioned previously and started drafting the backbone of my proposal .I would be glad if mentors ,specially Jason Moore would review them, so that I can progress towards making the proposal more concrete .All suggestions and comments are welcome.
Thanks!

PS. I have observed that in such a large group with so many incoming mails there are chances that mails get lost and maybe don't get the attention they require .Hence I having been mailing a few people/ potential mentors ,specially in the physics module .I have got positive replies from some of them :) . I have shared an email of ideas with them personally  ,I will be obliged if it is looked into ! Sorry for any inconvenience this might have caused .

Regards,
Anurag Bhat
Reply all
Reply to author
Forward
0 new messages