Exemplo n.º 1
0
def test_linear():
    var('R1 R2 V0')

    c = SubCircuit(toolkit=symbolic)
    c['V0'] = VS(1, gnd, v=V0, vac=1, toolkit=symbolic)
    c['L'] = L(1,2, L=1e-3)
    c['R1'] = R(2, 3, r = Symbol('R1'))
    c['R2'] = R(3, gnd, r = Symbol('R2'))

    dc = SymbolicDC(c)

    res = dc.solve()

    assert_equal(sympy.simplify(res.v(3, gnd) -  V0*R2/(R1+R2)), 0)
Exemplo n.º 2
0
def test_nonlinear():
    var('k qelectron I0 Isat qelectron T', positive=True, real=True)

    c = SubCircuit(toolkit=symbolic)
    c['I0'] = IS(gnd, 'net1', i=I0, toolkit=symbolic)
    c['D'] = Diode('net1', gnd, IS=Isat, toolkit=symbolic)

    dc = SymbolicDC(c)

    dc.epar.T = T

    res = dc.solve()

    assert_equal(sympy.simplify(res.v('net1') - k * T / qelectron * log(I0/Isat+1)), 0)