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
W 0_1 0; right
W 0 0_2; right
Rin 2_2 0_2; down, v=v_{in}
W3 2 2_2; right
E1 3 0_3 2 0 A; down, l=A v_{in}
Rout 3 4; right, size=1.5
RL 4 0_4; down
W 0_2 0_3; size=1.2
W 0_3 0_4
P1 4 0_4; down
""")
cct.draw()



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


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

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


Out[3]:
$$\frac{A R_{L} R_{\mathrm{in}}}{\left(R_{L} + R_{\mathrm{out}}\right) \sqrt{C^{2} R_{\mathrm{in}}^{2} R_{s}^{2} \omega^{2} + \left(R_{\mathrm{in}} + R_{s}\right)^{2}}}$$

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


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

In [5]:
H1 = H.subs({'C': 1e-9, 'Rs': 25e3, 'RL': 5e3, 'Rin' : 500e3, 'Rout' : 1e3, 'A' : 2})
H1(j * omega)


Out[5]:
$$\frac{200000 \mathrm{j} \omega}{3 \left(- \omega^{2} + 42000 \mathrm{j} \omega\right)}$$

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



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