In [1]:
from lcapy import Circuit, j, omega, s
cct = Circuit("""
Vi 1 0_1 step; down
Rs 1 2; right, size=1.5
C 2 0; down, v=v_C
W1 0_1 0; right
W2 0 0_2; right
P1 2_2 0_2; down
RL 2_2 0_2; down
W3 2 2_2;right""")
cct.draw()



In [2]:
H = cct.RL.V(s) / cct.Vi.V(s)

In [3]:
H(j * omega)


Out[3]:
$$\frac{\mathrm{j} \omega}{C R_{s} \left(- \omega^{2} + \frac{\mathrm{j} \omega \left(R_{L} + R_{s}\right)}{C R_{L} R_{s}}\right)}$$

In [4]:
H(j * omega).magnitude


Out[4]:
$$\frac{\sqrt{C^{2} R_{s}^{2} \omega^{6} + \frac{\omega^{4} \left(R_{L} + R_{s}\right)^{2}}{R_{L}^{2}}}}{C^{2} R_{s}^{2} \omega^{4} + \frac{\omega^{2} \left(R_{L} + R_{s}\right)^{2}}{R_{L}^{2}}}$$

In [5]:
H(j * omega).phase_degrees


Out[5]:
$$- \frac{180 \operatorname{atan}{\left(\frac{C R_{L} R_{s} \omega}{R_{L} + R_{s}} \right)}}{\pi}$$

In [6]:
H1 = H.subs('C', 1e-9).subs('Rs', 25e3).subs('RL', 5e3)
H1(j * omega)


Out[6]:
$$\frac{40000 \mathrm{j} \omega}{- \omega^{2} + 240000 \mathrm{j} \omega}$$

In [7]:
from numpy import logspace
w = logspace(2, 6, 500)
%matplotlib inline
ax = H1(j * omega).dB.plot(w, log_frequency=True)



In [8]:
ax = H1(j * omega).phase_degrees.plot(w, log_frequency=True)