From f19a5ea35f4a90dad1fc675de16bbd126a0e0fda Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 20 Sep 2024 18:01:45 +0530 Subject: [PATCH] Added blog for week 11 & 12. --- package-lock.json | 13 +++- src/assets/Anchors.jsx | 11 +++ src/assets/Footer.jsx | 47 +++++------ src/main.jsx | 10 +-- src/pages/Week11.jsx | 172 +++++++++++++++++++++++++++++++++++++---- src/pages/Week12.jsx | 33 -------- src/pages/Week15.jsx | 68 ++++++++++++++++ src/pages/Week8.jsx | 33 -------- 8 files changed, 278 insertions(+), 109 deletions(-) delete mode 100644 src/pages/Week12.jsx create mode 100644 src/pages/Week15.jsx delete mode 100644 src/pages/Week8.jsx diff --git a/package-lock.json b/package-lock.json index 77492f7..4d22d1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3935,6 +3935,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -4400,6 +4401,7 @@ "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dev": true, "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -5043,6 +5045,14 @@ "react": "^18.3.1" } }, + "node_modules/react-gist": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/react-gist/-/react-gist-1.2.4.tgz", + "integrity": "sha512-uDgPJ08IJsl/7auK3CS53JKGC1P/X7tNCzo9k0r6D/5l+ilsxE1+SAaylJCh0aeyZoJOoxQikKU+MHsAvA9iFw==", + "peerDependencies": { + "react": "0.14.x || ^15.0.0-rc || ^16.0.0-rc || ^17.0.0-rc" + } + }, "node_modules/react-icons": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.2.1.tgz", @@ -5054,7 +5064,8 @@ "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true }, "node_modules/react-katex": { "version": "3.0.1", diff --git a/src/assets/Anchors.jsx b/src/assets/Anchors.jsx index d7ada18..52a293f 100644 --- a/src/assets/Anchors.jsx +++ b/src/assets/Anchors.jsx @@ -50,6 +50,17 @@ const Anchors = () => { +
+
Phase 4
+
+ + Week 11 & 12 + + + Week 15 + +
+
); }; diff --git a/src/assets/Footer.jsx b/src/assets/Footer.jsx index 7d24299..add8420 100644 --- a/src/assets/Footer.jsx +++ b/src/assets/Footer.jsx @@ -1,34 +1,37 @@ import React from 'react' -import { FaGithub, FaLinkedin, FaEnvelope } from 'react-icons/fa'; +import { FaGithub, FaLinkedin, FaEnvelope, FaHeart } from 'react-icons/fa'; const Footer = () => { return (
-
-
-
-
Abhishek Kumar | {new Date().getFullYear()}
+
+
+
+
+
Abhishek Kumar | {new Date().getFullYear()}
+
-
-
- -
-
-

Made with ❤️

+ +
+
+ +

Made with

+
-
) } diff --git a/src/main.jsx b/src/main.jsx index b469504..e3e0f19 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -18,7 +18,7 @@ import Week7 from "./pages/Week7.jsx"; import Week9 from "./pages/Week9.jsx"; import Week10 from "./pages/Week10.jsx"; import Week11 from "./pages/Week11.jsx"; -import Week12 from "./pages/Week12.jsx"; + const router = createBrowserRouter([ { @@ -74,13 +74,9 @@ const router = createBrowserRouter([ element: , }, { - path: "/gsoc24-blog/week11", + path: "/gsoc24-blog/week11-12", element: , - }, - { - path: "/gsoc24-blog/week12", - element: , - }, + } ]); ReactDOM.createRoot(document.getElementById("root")).render( diff --git a/src/pages/Week11.jsx b/src/pages/Week11.jsx index f72cbe7..0be285f 100644 --- a/src/pages/Week11.jsx +++ b/src/pages/Week11.jsx @@ -1,10 +1,94 @@ -import React from 'react' -import Navbar from '../Navbar' -import Anchors from '../assets/Anchors' -import { Divider, Typography } from 'antd'; -const { Title, Paragraph, Text, Link } = Typography; +import { Divider, Image, Typography } from "antd"; +import { FaCodePullRequest } from "react-icons/fa6"; +import Navbar from "../Navbar"; +import Anchors from "../assets/Anchors"; +import Footer from "../assets/Footer"; +const { Title, Paragraph } = Typography; const Week11 = () => { + const code1 = + ` + >>> from sympy import symbols, Matrix + >>> from sympy.physics.control import * + >>> m, k, b = symbols('m k b') + >>> A = Matrix([[0, 1], [-k/m, -b/m]]) + >>> B = Matrix([[0], [1/m]]) + >>> C = Matrix([[1, 0]]) + >>> D = Matrix([[0]]) + >>> ss = StateSpace(A, B, C, D) + >>> ss + StateSpace(Matrix([ + [ 0, 1], + [-k/m, -b/m]]), Matrix([ + [ 0], + [1/m]]), Matrix([[1, 0]]), Matrix([[0]])) + >>> tf = ss.rewrite(TransferFunction)[0][0] + >>> tf + TransferFunction(1, b*s + k + m*s**2, s) +` + const code2 = + ` + >>> from sympy import symbols, Matrix + >>> from sympy.physics.control import StateSpace + >>> K_r, J1, J2, B_r1, B_r2, x2 = symbols('K_r J1 J2 B_r1 B_r2 x2') + >>> A = Matrix([[0, 1, 0], [-K_r/J1, -B_r1/J1, B_r1/J1], [0, B_r1/J2 * x2, - (B_r2 + B_r1)/J2]]) + >>> B = Matrix([[0], [-1/J1], [0]]) + >>> C = Matrix([[1, 0, 0]]) + >>> ss = StateSpace(A, B, C) + >>> ss + StateSpace(Matrix([ + [ 0, 1, 0], + [-K_r/J1, -B_r1/J1, B_r1/J1], + [ 0, B_r1*x2/J2, (-B_r1 - B_r2)/J2]]), Matrix([ + [ 0], + [-1/J1], + [ 0]]), Matrix([[1, 0, 0]]), Matrix([[0]])) +` + const code3 = +` + >>> from sympy import Matrix, symbols, pprint + >>> from sympy.physics.control import * + >>> R, L, C = symbols('R L C') + >>> A = Matrix([[-R/L, -1/L], [1/C, 0]]) + >>> B = Matrix([[1/L], [0]]) + >>> C = Matrix([[0, 1]]) + >>> D = Matrix([[0]]) + >>> ss = StateSpace(A, B, C, D) + >>> ss + StateSpace(Matrix([ + [-R/L, -1/L], + [ 1/C, 0]]), Matrix([ + [1/L], + [ 0]]), Matrix([[0, 1]]), Matrix([[0]])) + + We can convert the StateSpace to TransferFunction by rewrite method. + + >>> tf = ss.rewrite(TransferFunction)[0][0] + >>> tf + TransferFunction(1, C*L*s**2 + C*R*s + 1, s) +` + const code4 = +` + >>> from sympy import symbols, Matrix + >>> from sympy.physics.control import * + >>> R, C = symbols('R C') + >>> A = Matrix([[-2/(R*C), 1/(R*C)], [1/(R*C), -1/(R*C)]]) + >>> B = Matrix([[1/(R*C)], [0]]) + >>> C = Matrix([[0, 1]]) + >>> ss = StateSpace(A, B, C) + >>> ss + StateSpace(Matrix([ + [-2/(C*R), 1/(C*R)], + [ 1/(C*R), -1/(C*R)]]), Matrix([ + [1/(C*R)], + [ 0]]), Matrix([[0, 1]]), Matrix([[0]])) +` + + const imgLink1 = 'https://private-user-images.githubusercontent.com/140839576/362171513-b3eaa366-2a9f-435e-a3ae-a446eb093723.svg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjY4MzM2MjAsIm5iZiI6MTcyNjgzMzMyMCwicGF0aCI6Ii8xNDA4Mzk1NzYvMzYyMTcxNTEzLWIzZWFh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E4NjRlZGZjNTdiZDgzNGE1Yjc0MDY0NTUzOGU4ZDdiY2MwZTY1YmJkYmEyN2JlODA3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.cjdTAw3x7siZ9oaphd9AHt1ZCFkXQZiPrxF_P5PIhLg' + const imgLink3 = 'https://raw.githubusercontent.com/abhiphile/sympy/refs/heads/problems-1/doc/src/tutorials/physics/control/Electrical_Problems_Q1.svg' + const imgLink4 = 'https://raw.githubusercontent.com/abhiphile/sympy/refs/heads/problems-1/doc/src/tutorials/physics/control/Electrical_Problems_Q2.svg' + return ( <> @@ -13,21 +97,83 @@ const Week11 = () => {
-
+
- This is the title ! + Week 11-12: Adding example problems related to StateSpace - - This is par + + In these two weeks I've worked on adding example problems related to StateSpace in control examples. + These include mechanics and electrical problems. + + + Mechanics Problem using StateSpace + + I've added two mechanics probems that can be modelled using StateSpace. The complete documentation for this can be found here. + 1. Spring Mass Damper System + +

+ A spring-mass-damping system can be modeled using a mass (m), a spring with a constant (k), and a damper with a damping coefficient (b). The spring force is proportional to the displacement of the mass, and the damping force is proportional to the velocity of the mass. Find the frequency response of the system. + To model this type of system we have used this. +

+                    {code1}
+                  
+

+ 2. Rotational System + +

+ This problem explains how to model a rotaional system to state-space model. The system has input torque and damping effects. The system consists of two flywheels connected by a spring. We need to model the sytem by using StateSpace. + To model this we have used this. +

+                    {code2}
+                  
+

+ + Electrical Problem using StateSpace + Complete documentation for this can be found here. + 1. Simple RLC Circuit + +

+ In a series RLC circuit, we have a resistor (R) , an inductor (L), and a capacitor (C) connected in series with an input voltage (Vin) + . The state variables are the current through the inductor (i(t)) and the voltage across the capacitor (Vc(t)). We need to model the system to StateSpace. To model this system we can use the following code. +

{code3}
+

+ 2. An Advanced problem. + +

+ Obtain the state model for a system represented by an electrical system as shown above. To model it using SymPy we can use the following code, +

{code4}
+

+
+ Pull Requests + + + (Merged) Added mechanics problems to control tutorials. + +
+ + (Merged) Added electrical problems to electrical_problems file. + +
+ +
+ Abhishek Kumar +
+ GSoC Contributor
+
- - ) -} + ); +}; -export default Week11 \ No newline at end of file +export default Week11; diff --git a/src/pages/Week12.jsx b/src/pages/Week12.jsx deleted file mode 100644 index c874483..0000000 --- a/src/pages/Week12.jsx +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react' -import Navbar from '../Navbar' -import Anchors from '../assets/Anchors' -import { Divider, Typography } from 'antd'; -const { Title, Paragraph, Text, Link } = Typography; - -const Week12 = () => { - return ( - <> - -
-
- -
-
-
- - - This is the title ! - - - This is par - - -
-
-
- - - ) -} - -export default Week12 \ No newline at end of file diff --git a/src/pages/Week15.jsx b/src/pages/Week15.jsx new file mode 100644 index 0000000..1c46bc6 --- /dev/null +++ b/src/pages/Week15.jsx @@ -0,0 +1,68 @@ +import { Divider, Image, Typography } from "antd"; +import { FaCodePullRequest } from "react-icons/fa6"; +import Navbar from "../Navbar"; +import Anchors from "../assets/Anchors"; +import Footer from "../assets/Footer"; +const { Title, Paragraph } = Typography; + +const Week15 = () => { +const code1 = ` + +` +const code2 = ` + +` + return ( + <> + +
+
+ +
+
+
+ + + Week 11-12: Adding example problems related to StateSpace + + + This week, I focused on developing a Python function to generate Nyquist plots for continuous-time Single-Input Single-Output (SISO) Linear Time-Invariant (LTI) systems. A Nyquist plot is a powerful tool used in control theory to assess the stability of a system. +
+ The nyquist_plot function I developed takes a transfer function and generates the Nyquist plot over a specified frequency range. I included customization options for the plot's color, grid visibility, and whether or not to display the plot immediately. +
+ One of the challenges I encountered was ensuring that the function could handle a wide range of systems and accurately plot the frequency response. By using the plot_parametric function, I was able to plot the real and imaginary components of the system's response, along with its mirror image, to create a comprehensive Nyquist plot. +
+ This function will be a useful tool for anyone working with control systems, as it provides a visual representation of the system's stability across a range of frequencies. +
+ Next week, I plan to work on adding problems related to StateSpace and PIDController. + I've used the helper function _get_nyquist_expr() and used it to make the nyquist plot. +
{code1}
+ nyquist_plot function +
{code2}
+ +
+ Pull Requests + + + (Draft) Added nyquist plot to control plots. + +
+ +
+ Abhishek Kumar +
+ GSoC Contributor +
+
+
+
+
+
+ + ); +}; + +export default Week15; diff --git a/src/pages/Week8.jsx b/src/pages/Week8.jsx deleted file mode 100644 index 86e1d04..0000000 --- a/src/pages/Week8.jsx +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react' -import Navbar from '../Navbar' -import Anchors from '../assets/Anchors' -import { Divider, Typography } from 'antd'; -const { Title, Paragraph, Text, Link } = Typography; - -const Week8 = () => { - return ( - <> - -
-
- -
-
-
- - - This is the title ! - - - This is par - - -
-
-
- - - ) -} - -export default Week8 \ No newline at end of file