Week 11
Slowly driving towards completion …. Hello everyone, hope this blog finds you well.
Previous week was the first week of phase 3 and I embarked on implementing an end to end State Space model for Sympy. I explained the design in the last blog. This week I wanted to add symbolic methods to the State Space class. From now I have 4 weeks remaining in Google Summer Of Code’23. Although I am on track to finish the project, I need to focus on getting things merged and work diligently towards addressing any blockers that can stall my work.
Aim :
This week I made several commits towards the State Space model. It can be viewed here.
I also opened a pull request to evaluate the frequency response of a Transfer Function or a Transfer Function Matrix. It can be viewed here.
After this gets merged, I would have finished all of my proposed work from phase 1 and phase 2.
Work : Let us go through the Pull Requests in brief.
Interconversion between the State Space Model and the Transfer Function Model
:>>> from sympy.abc import s >>> from sympy.physics.control import TransferFunction, StateSpace >>> tf = TransferFunction(s**2 + 1, s**3 + 2*s + 10, s) >>> tf.rewrite(StateSpace) StateSpace(Matrix([[ 0, 1, 0], [ 0, 0, 1], [-10, -2, 0]]), Matrix([[0], [0], [1]]), Matrix([[1, 0, 1]]), Matrix([[0]]) >>> A = Matrix([[-5, -1], [3, -1]]) >>> B = Matrix([2, 5]) >>> C = Matrix([[1, 2]]) >>> D = Matrix([0]) >>> ss = StateSpace(A, B, C, D) >>> ss.rewrite(TransferFunction) [[TransferFunction(12*s + 59, s**2 + 6*s + 8, s)]]
Evaluate System Response of a TransferFunction / TransferFunctionMatrix
:>>> tf1 = TransferFunction(1, s**2 + 2*s + 1, s) >>> omega = 0.1 >>> tf1.eval_frequency(I*omega) 1/(0.99 + 0.2*I) >>> tf2 = TransferFunction(s**2, a*s + p, s) >>> tf2.eval_frequency(2) 4/(2*a + p) >>> tf2.eval_frequency(I*2) -4/(2*I*a + p) >>> tf_1 = TransferFunction(3, (s + 1), s) >>> tf_2 = TransferFunction(s + 6, (s + 1)*(s + 2), s) >>> tf_3 = TransferFunction(s + 3, s**2 + 3*s + 2, s) >>> tf_4 = TransferFunction(s**2 - 9*s + 20, s**2 + 5*s - 10, s) >>> tfm_1 = TransferFunctionMatrix([[tf_1, tf_2], [tf_3, tf_4]]) >>> tfm_1.eval_frequency(2) Matrix([ [ 1, 2/3], [5/12, 3/2]]) >>> tfm_1.eval_frequency(I*2) Matrix([ [ 3/5 - 6*I/5, -I], [3/20 - 11*I/20, -101/74 + 23*I/74]])
Future Work : I am already in the midst of writing a test suite so that the design can be robustly reviewed and tested. After that this pull request will be ready for merging. After that the last major pull request of my GSOC project, evaluating the State Space Model will be remaining.