def test_filtered_noise3(self): """Lcapy: check circuit filtered noise""" a = Circuit() a.add('V1 1 0 noise 20') a.add('R1 1 2 1') a.add('C1 2 0 2') self.assertEqual(a.C1.V.n.rms(), 5 * sqrt(2), "Incorrect capacitor voltage")
def value_rms(self): return self.value_peak() / sqrt(2)
from lcapy import f, sqrt In = 1e-12 * sqrt(250 / f + 1) ax = (In * 1e12).plot((0.1, 10e3), loglog=True) ax.grid(True, 'both') ax.set_ylabel('Noise current density pA$/\sqrt{\mathrm{Hz}}$') ax.set_ylim(0.1, 100) from matplotlib.pyplot import savefig savefig(__file__.replace('.py', '.png'), bbox_inches='tight')
from lcapy import f, sqrt Vn = 1e-9 * sqrt(3.5 / f + 1) ax = (Vn * 1e9).plot((0.1, 10e3), loglog=True) ax.grid(True, 'both') ax.set_ylabel('Noise voltage density nV$/\sqrt{\mathrm{Hz}}$') ax.set_ylim(0.1, 10) from matplotlib.pyplot import savefig savefig(__file__.replace('.py', '.png'), bbox_inches='tight')
from lcapy import s, sympify, j, sqrt zeta = sympify('zeta_', real=True) omega0 = sympify('omega0', real=True) p1a = -zeta * omega0 + j * omega0 * sqrt(1 - zeta**2) p1b = -zeta * omega0 - j * omega0 * sqrt(1 - zeta**2) alpha1 = sympify('alpha_1', real=True) omega1 = sympify('omega_1', real=True) p1a = -alpha1 + j * omega1 p1b = -alpha1 - j * omega1 H = p1a * p1b / ((s - p1a) * (s - p1b)) G = H / s g = G.partfrac().inverse_laplace(causal=True) h = H.partfrac().inverse_laplace(causal=True) def topy(expr): s = str(expr) s = s.replace('**', '^').replace('_', '').replace('*', ' * ').replace( '^', '**').replace('Heaviside(t)', '(t >= 0)').replace('/', ' / ') return s print(topy(g))
from lcapy import Circuit, sqrt, f, oo Rs = 30 G = 1000 R1 = 100 R2 = (G - 1) * R1 Vn = 1e-9 * sqrt(3.5 / f + 1) In = 1e-12 * sqrt(250 / f + 1) T = 273 + 20 k_B = 1.38e-23 a = Circuit('opamp-noninverting-amplifier.sch') an = a.noisy() Vno = an[8].V.n(f) Vno = Vno.limit('A', oo) Vnov = Vno.subs({ 'R1': R1, 'R2': R2, 'In1': 0, 'In2': 0, 'Vn': Vn, 'Rs': Rs, 'k_B': k_B, 'T': 0