Skip to content

Commit 429c04d

Browse files
committed
more rlc stuff
1 parent 1833f49 commit 429c04d

21 files changed

+10
-5615
lines changed

_site/experiments/RLC/index.html

Lines changed: 9 additions & 9 deletions
Large diffs are not rendered by default.

_site/search.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"href": "experiments/RLC/index.html",
55
"title": "RLC Circuit",
66
"section": "",
7-
"text": "Start with imports\n\nimport numpy as np\nfrom scipy import signal\nimport matplotlib.pyplot as plt\n\nAn RLC circuit can be described with the language of Laplace Transforms and Transfer Functions. This ammounts to the Phasor representation of circuits.\nTake a simple RLC circuit with the impedance\n\\[\nZ(s) = R + sL + \\frac{1}{sC}\n\\]\nThe transfer function of this circuit is\n\\[\nH(s) = \\frac{V_{out}}{V_{in}}\n\\]\nOur output voltage is the capacitor, which is\n\\[\nV_c = V_{in} \\times \\frac{Z_c}{Z(s)} = V_{in} \\frac{\\frac{1}{sC}}{R + sL + \\frac{1}{sC}}\n= V_{in} \\frac{1}{s^2LC + sRC + 1}\n\\]\nThen our final transfer function is\n\\[\nH(s) = \\frac{V_{in} \\frac{1}{s^2LC + sRC + 1}}{V_{in}} = \\frac{1}{s^2LC + sRC + 1}\n\\]\nWe can set our circuit values to the following\n\nR = 10.0 # ohms\nL = 1e-3 # henries\nC = 1e-6 # farads\n\nThen define our system like so\n\nnum = [1.0]\nden = [L*C, R*C, 1.0] # in descending order of degree\n\nsystem = signal.TransferFunction(num, den)\n\nThe resonant frequency of an RLC circuit is defined as\n\\[\nf_{res} = \\frac{1}{2\\pi \\sqrt{LC}}\n\\]\nIn the s-domain, the imaginary component represents angular frequency which allows us to define the resonant frequency at the poles of this function at some given \\(\\omega\\).\nWe can start by writing he denominator in standard form\n\\[\ns^2 + \\frac{R}{L} s + \\frac{1}{LC}\n\\]\nThe resonant frequency makes the denominator 0 (and therefore makes our transfer function blow out to infinity). This means we want to find roots of this function such that they are solely imaginary. The general roots are given by the quadratic formula\n\\[\ns = \\frac{-R/L \\pm \\sqrt{R^2/L^2 - 4/LC}}{2}\n\\]\nif this were to be purely imaginary, that means that \\(R = 0\\) (this implies resistance leads to damping and we can never remove resistance physically, which is why we dont blow out to infinity) Then this implies that\n\\[\ns = \\pm \\frac{i}{\\sqrt{LC}}\n\\]\nWe then define the resonant frequency at \\(s = i \\omega\\), ignoring the sign as negative frequency doesnt change the inherent meaning of the frequency, to get.\n\\[\n\\omega = \\frac{1}{\\sqrt{LC}}\n\\]\nWhich obviously implies the formula we already found. To actually simulate the system, we can supply a signal to it like so\n\nt = np.linspace(0,1,100)\nomega = 4\nV_in = signal.square(omega*2*np.pi*t) \ntout, y, x = signal.lsim(system, V_in, t)\n\nThen plot the input as the following\n\nplt.figure()\nplt.plot(t, V_in, label=\"Input\")\nplt.legend()\nplt.show()\n\n\n\n\n\n\n\n\nAnd the output as\n\nplt.figure()\nplt.plot(t, y, label=\"Output\")\nplt.legend()\nplt.show()"
7+
"text": "Start with imports\n\nimport numpy as np\nfrom scipy import signal\nimport matplotlib.pyplot as plt\n\nAn RLC circuit can be described with the language of Laplace Transforms and Transfer Functions. This ammounts to the Phasor representation of circuits.\nTake a simple RLC circuit with the impedance\n\\[\nZ(s) = R + sL + \\frac{1}{sC}\n\\]\nThe transfer function of this circuit is\n\\[\nH(s) = \\frac{V_{out}}{V_{in}}\n\\]\nOur output voltage is the capacitor, which is\n\\[\nV_c = V_{in} \\times \\frac{Z_c}{Z(s)} = V_{in} \\frac{\\frac{1}{sC}}{R + sL + \\frac{1}{sC}}\n= V_{in} \\frac{1}{s^2LC + sRC + 1}\n\\]\nThen our final transfer function is\n\\[\nH(s) = \\frac{V_{in} \\frac{1}{s^2LC + sRC + 1}}{V_{in}} = \\frac{1}{s^2LC + sRC + 1}\n\\]\nWe can set our circuit values to the following\n\nR = 10.0 # ohms\nL = 1e-3 # henries\nC = 1e-6 # farads\n\nThen define our system like so\n\nnum = [1.0]\nden = [L*C, R*C, 1.0] # in descending order of degree\n\nsystem = signal.TransferFunction(num, den)\n\nThe resonant frequency of an RLC circuit is defined as\n\\[\nf_{res} = \\frac{1}{2\\pi \\sqrt{LC}}\n\\]\nIn the s-domain, the imaginary component represents angular frequency which allows us to define the resonant frequency at the poles of this function at some given \\(\\omega\\).\nWe can start by writing he denominator in standard form\n\\[\ns^2 + \\frac{R}{L} s + \\frac{1}{LC}\n\\]\nThe resonant frequency makes the denominator 0 (and therefore makes our transfer function blow out to infinity). This means we want to find roots of this function such that they are solely imaginary. The general roots are given by the quadratic formula\n\\[\ns = \\frac{-R/L \\pm \\sqrt{R^2/L^2 - 4/LC}}{2}\n\\]\nif this were to be purely imaginary, that means that \\(R = 0\\) (this implies resistance leads to damping and we can never remove resistance physically, which is why we dont blow out to infinity) Then this implies that\n\\[\ns = \\pm \\frac{i}{\\sqrt{LC}}\n\\]\nWe then define the resonant frequency at \\(s = i \\omega\\), ignoring the sign as negative frequency doesnt change the inherent meaning of the frequency, to get.\n\\[\n\\omega = \\frac{1}{\\sqrt{LC}}\n\\]\nWhich obviously implies the formula we already found. To actually simulate the system, we can supply a signal to it like so\n\nt = np.linspace(0,1,100)\nomega = 1\nV_in = signal.square(omega*2*np.pi*t) \ntout, y, x = signal.lsim(system, V_in, t)\n\nThen plot the input as the following\n\nplt.figure()\nplt.plot(t, V_in, label=\"Input\")\nplt.legend()\nplt.show()\n\n\n\n\n\n\n\n\nAnd the output as\n\nplt.figure()\nplt.plot(t, y, label=\"Output\")\nplt.legend()\nplt.show()"
88
}
99
]

0 commit comments

Comments
 (0)