예제 #1
0
def test_loopanalysis_incorrect_circuit():
    cir = SubCircuit()
    assert_raises(ValueError, lambda: FeedbackLoopAnalysis(cir))

    cir['probe1'] = LoopProbe('out', gnd, 'out_R2', gnd)
    cir['probe2'] = LoopProbe('out', gnd, 'out_R2', gnd)
    assert_raises(ValueError, lambda: FeedbackLoopAnalysis(cir))
예제 #2
0
def test_loopanalysis_numeric():
    cir = SubCircuit()
    cir['A1'] = VCVS(gnd, 'int', 'out', gnd, g = 10)
    cir['R1'] = R('in', 'int')
    cir['probe'] = LoopProbe('out', gnd, 'out_R2', gnd)
    cir['C2'] = C('int', 'out_R2')
    cir['VS'] = VS('in', gnd)

    ana = FeedbackLoopAnalysis(cir)
    res = ana.solve(np.logspace(4,6), complexfreq=True)
    print abs(res['loopgain'])
예제 #3
0
def test_loopanalysis_viiv():
    sympy.var('R1 R2 CL A s')

    cir = SubCircuit(toolkit=symbolic)
    cir['A1'] = VCVS(gnd, 'int', 'out', gnd, g = A, toolkit=symbolic)
    cir['R1'] = R('in', 'int', r=R1)
    cir['probe'] = LoopProbe('out', gnd, 'out_R2', gnd, toolkit=symbolic)
    cir['R2'] = R('int', 'out_R2', r=R2)
    cir['VS'] = VS('in', gnd)

    ana = FeedbackLoopAnalysis(cir, toolkit=symbolic)

    res = ana.solve(s, complexfreq=True)

    assert sympy.simplify(res['loopgain'] - (- A * R1 / (R1 + R2))) == 0
예제 #4
0
def test_deviceanalysis_viiv():
    """Loopgain of a resistor V-I and a I-V amplifier with a vcvs as gain element"""

    sympy.var('R1 R2 CL A s')

    cir = SubCircuit(toolkit=symbolic)
    cir['A1'] = VCVS(gnd, 'int', 'out', gnd, g = A,toolkit=symbolic)
    cir['R1'] = R('in', 'int', r=R1)
    cir['R2'] = R('int', 'out', r=R2)
    cir['VS'] = VS('in', gnd)

    ana = FeedbackDeviceAnalysis(cir, 'A1', toolkit=symbolic)
    res = ana.solve(s, complexfreq=True)

    assert simplify(res['loopgain'] - (- A * R1 / (R1 + R2))) == 0
예제 #5
0
def test_deviceanalysis_sourcefollower():
    """Loopgain of a source follower"""

    gm,RL,CL,s = sympy.symbols('gm RL CL s')

    cir = SubCircuit(toolkit=symbolic)
    cir['M1'] = VCCS('g', 's', gnd, 's', gm = gm,toolkit=symbolic)
    cir['RL'] = R('s', gnd, r=RL)
    cir['CL'] = C('s', gnd, c=CL)
    cir['VS'] = VS('g', gnd)

    ana = FeedbackDeviceAnalysis(cir, 'M1', toolkit=symbolic)
    res = ana.solve(s, complexfreq=True)

    assert_equal(simplify(res['loopgain']), simplify(- gm / (1/RL + s*CL)))
예제 #6
0
from pycircuit.circuit import numeric, SubCircuit, gnd
from pycircuit.circuit.elements import VCVS, VCCS, C

c = SubCircuit()
iplus, iminus, int0, oplus, ominus = c.add_nodes("1", "2", "3", "4", "5")
c["vccs"] = VCCS(iplus, iminus, int0, gnd, gm=1.0)
c["vcvs"] = VCVS(int0, gnd, oplus, ominus, g=-1.0)
c["c"] = C(int0, gnd, c=1.0)
예제 #7
0
# -*- coding: latin-1 -*-
# Copyright (c) 2008 Pycircuit Development Team
# See LICENSE for details.

from pycircuit.circuit import SubCircuit, VCCS, G, C, IS, VS, Parameter, gnd, \
    R, symbolic, TwoPortAnalysis, AC, Noise
from pycircuit.circuit.mos import MOS
from sympy import Symbol, simplify, ratsimp, sympify, factor, limit
from numpy import array, zeros
from copy import copy
from pycircuit.circuit.symbolicapprox import *

## Create regulated cascode circuit

c = SubCircuit()

nin, nout, n1 = c.add_nodes('in', 'out', 'n1')

gm1, gm2, gds1, gds2, Cgs1, Cgs2 = [
    Symbol(symname, real=True)
    for symname in 'gm1,gm2,gds1,gds2,Cgs1,Cgs2'.split(',')
]

c['M2'] = MOS(nin, n1, gnd, gnd, gm=gm2, gds=gds2, Cgs=0 * Cgs1)
c['M1'] = MOS(n1, nout, nin, nin, gm=gm1, gds=gds1, Cgs=0 * Cgs2)
#c['r'] = R(nin, gnd, r = Symbol('Rs', real=True))

## Perform twoport analysis with noise

twoportana = TwoPortAnalysis(c,
                             nin,
예제 #8
0
# -*- coding: latin-1 -*-
# Copyright (c) 2008 Pycircuit Development Team
# See LICENSE for details.

from pycircuit.circuit import SubCircuit, VCCS, G, C, IS, VS, Parameter, gnd, \
    R, symbolic, TwoPortAnalysis, AC, Noise
from pycircuit.circuit.mos import MOS
from sympy import Symbol, simplify, ratsimp, sympify, factor, limit
from numpy import array, zeros
from copy import copy
from pycircuit.circuit.symbolicapprox import *
    
## Create regulated cascode circuit

c = SubCircuit()

nin, nout, n1 = c.add_nodes('in', 'out', 'n1')

gm1, gm2, gds1, gds2, Cgs1, Cgs2= [Symbol(symname, real=True) for symname in 'gm1,gm2,gds1,gds2,Cgs1,Cgs2'.split(',')]

c['M2'] = MOS(nin, n1, gnd, gnd, gm = gm2, gds = gds2, Cgs=0*Cgs1)
c['M1'] = MOS(n1, nout, nin, nin, gm = gm1, gds = gds1, Cgs=0*Cgs2)
#c['r'] = R(nin, gnd, r = Symbol('Rs', real=True))

## Perform twoport analysis with noise

twoportana = TwoPortAnalysis(c, nin, gnd, nout, gnd, noise=True, noise_outquantity='i', toolkit=symbolic)

res2port = twoportana.solve(Symbol('s'), complexfreq=True)

y11 = res2port['twoport'].Y[0,0]
예제 #9
0
from numpy.testing import assert_array_almost_equal

## The test vehicle is a 1dB tee resistive attenuator
## designed for 50ohm matching impedance
## o---R1----*---R3---o
##           |
##          R2
##           |
## o---------*--------o
##
T = 290
R1, R3 = 3., 3.
R2 = 433.

circuit.default_toolkit = numeric
cir = SubCircuit()
nin,n1,nout = cir.add_nodes('nin','n1','nout')
cir['R1'] = R(nin,n1,r=R1)
cir['R2'] = R(n1,gnd,r=R2)
cir['R3'] = R(nout,n1,r=R3)

# S,Z,Y-parameters
Sref = np.array([[0.00219681, 0.88898926],[0.88898926, 0.00219681]])
Zref = np.array([[R1+R2, R2],[R2, R2+R3]])
Yref = np.linalg.inv(Zref)
Aref = np.array([[-Yref[1,1]/Yref[1,0], -1/Yref[1,0]],
                  [Yref[0,1]-Yref[0,0]*Yref[1,1]/Yref[1,0], 
                   -Yref[0,0]/Yref[1,0]]])

## Using Bosma's theorem
CYref = 4 * kboltzmann * T * np.real(Yref)
예제 #10
0
from pycircuit.circuit import numeric, SubCircuit, gnd
from pycircuit.circuit.elements import VCVS, VCCS, C

c = SubCircuit()
iplus,iminus,int0,oplus,ominus = c.add_nodes('1', '2', '3', '4', '5')
c['vccs'] = VCCS(iplus,iminus,int0,gnd,gm=1.)
c['vcvs'] = VCVS(int0,gnd,oplus,ominus,g=-1.)
c['c'] = C(int0,gnd, c=1.)