Beispiel #1
0
    def test_transfer(self):
        """Lcapy: check transfer function

        """

        a = Circuit()
        a.add('R1 1 0 1')
        a.add('R2 1 2 2')
        a.add('C1 2 0 1')

        H = a.transfer(1, 0, 2, 0)
        self.assertEqual2(H, 1 / (2 * s + 1), "Incorrect transfer function")
        h = H.inverse_laplace()
        self.assertEqual2(h, exp(-t / 2) * Heaviside(t) / 2,
                          "Incorrect impulse response")        
Beispiel #2
0
    def test_transfer(self):
        """Lcapy: check transfer function

        """

        a = Circuit()
        a.add('R1 1 0 1')
        a.add('R2 1 2 2')
        a.add('C1 2 0 1')

        H = a.transfer(1, 0, 2, 0)
        self.assertEqual2(H, 1 / (2 * s + 1), "Incorrect transfer function")
        h = H.inverse_laplace()
        self.assertEqual2(h, exp(-t / 2) * Heaviside(t) / 2,
                          "Incorrect impulse response")        
from matplotlib.pyplot import savefig
from lcapy import Circuit, j, f, s, degrees, pi

b = Circuit('opamp-voltage-follower-RC-load-open-loop.sch')
G = b.transfer(2, 0, 4, 0)

f1 = 10
f2 = 1e6
A0 = 1e6

A = A0 * (1 / (1 + j * f / f1)) * (1 / (1 + j * f / f2))
A = A.subs(f, s / (j * 2 * pi))

Ro = 40
R = 20
C = 100e-9

G = G.subs({'A': A, 'Ro': Ro, 'R': R, 'C': C})

ax = G.bode_plot((1, 10e6), plot_type='dB-degrees')
ax[0].set_ylim(-30, 130)
ax[1].set_ylim(-240, 0)

savefig(__file__.replace('.py', '.png'), bbox_inches='tight')
Beispiel #4
0
from lcapy import Circuit, j, f, pi
from numpy import linspace

cct = Circuit()

cct.add('P1 1 0; down')
cct.add('L1 1 2 0.1; right')
cct.add('C1 2 3 1e-3; right')
cct.add('R1 3 4 10; down')
cct.add('W1 0 4; right')
H = cct.transfer(1, 0, 3, 4)
A = H(j * 2 * pi * f)

fv = linspace(0, 100, 400)

A.magnitude.dB.plot(fv)
A.phase.plot(fv)

A.plot(fv, log_scale=True)
Beispiel #5
0
from matplotlib.pyplot import savefig
from lcapy import Circuit, f

a = Circuit('filter1.sch')
H = a.transfer('P1', 'P2')
Hv = H.subs({'R1': 22, 'C1': 100e-9, 'R2': 1e6, 'C2': 1e-9})
Hv.bode_plot((0.1, 10e3))

savefig(__file__.replace('.py', '.png'), bbox_inches='tight')
from lcapy import Circuit, f, oo
from numpy import logspace

a = Circuit('opamp-piezo-amplifier1.sch')

H = a.transfer('Cs', 'Po')(f).limit('A', oo)

defs1 = {
    'R1': 100,
    'R2': 900,
    'Cs': 1e-9,
    'Rs': 100e6,
    'C': 100e-6,
    'Vn': 2e-9,
    'Inp': 5e-15,
    'Inn': 5e-15
}
defs2 = {
    'R1': 100,
    'R2': 900,
    'Cs': 1e-9,
    'Rs': 100e6,
    'C': 10e-6,
    'Vn': 2e-9,
    'Inp': 5e-15,
    'Inn': 5e-15
}
defs3 = {
    'R1': 100,
    'R2': 900,
    'Cs': 1e-9,
Beispiel #7
0
from matplotlib.pyplot import savefig
from lcapy import Circuit, j, f, s, degrees, pi

a = Circuit('opamp-voltage-follower-C-load.sch')
H = a.transfer(2, 0, 1, 0)

f1 = 10
f2 = 1e6
A0 = 1e6

A = A0 * (1 / (1 + j * f / f1)) * (1 / (1 + j * f / f2))
A = A.subs(f, s / (j * 2 * pi))

Ro = 40
C = 100e-9

H = H.subs({'A': A, 'Ro': Ro, 'C': C})

H.plot()

savefig(__file__.replace('.py', '.png'), bbox_inches='tight')
Beispiel #8
0
from lcapy import Circuit, j, f, pi
from numpy import linspace

cct = Circuit()

cct.add('P1 1 0; down')
cct.add('L1 1 2 0.1; right') 
cct.add('C1 2 3 1e-3; right') 
cct.add('R1 3 4 10; down') 
cct.add('W1 0 4; right') 
H = cct.transfer(1, 0, 3, 4)
A = H(j * 2 * pi * f)

fv = linspace(0, 100, 400)

A.magnitude.dB.plot(fv)
A.phase.plot(fv)

A.plot(fv, log_scale=True)