Beispiel #1
0
    def __init__(self, Lval, i0=0):

        self.args = (Lval, i0)
        Lval = cExpr(Lval, positive=True)
        i0 = cExpr(i0)
        super(L, self).__init__(Zs.L(Lval), -Vs(i0 * Lval))
        self.L = Lval
        self.i0 = i0
Beispiel #2
0
    def __init__(self, Cval, v0=0):

        self.args = (Cval, v0)
        Cval = cExpr(Cval, positive=True)
        v0 = cExpr(v0)
        super(C, self).__init__(Zs.C(Cval), Vs(v0).integrate())
        self.C = Cval
        self.v0 = v0
Beispiel #3
0
    def __init__(self, Rs, Rp, Cp, Lp):

        self.args = (Rs, Rp, Cp, Lp)
        self.Rs = cExpr(Rs, positive=True)
        self.Rp = cExpr(Rp, positive=True)
        self.Cp = cExpr(Cp, positive=True)
        self.Lp = cExpr(Lp, positive=True)

        N = self.expand()
        super(Xtal, self).__init__(N.Z, N.V)
Beispiel #4
0
    def __init__(self, C0, R1, L1, C1):

        self.C0 = cExpr(C0)
        self.R1 = cExpr(R1)
        self.L1 = cExpr(L1)
        self.C1 = cExpr(C1)

        N = self.expand()
        super(Xtal, self).__init__(N.Z, N.V)
        self.args = (C0, R1, L1, C1)
Beispiel #5
0
    def __init__(self, I, f, phi=0):

        self.args = (I, f, phi)
        I = cExpr(I)
        f = cExpr(f)
        phi = cExpr(phi)

        omega = 2 * sym.pi * f
        foo = (s * sym.cos(phi) + omega * sym.sin(phi)) / (s**2 + omega**2)
        super(Iacstep, self).__init__(Is(I * foo))
Beispiel #6
0
    def __init__(self, Rs, Rp, Cp, Lp):

        self.Rs = cExpr(Rs)
        self.Rp = cExpr(Rp)
        self.Cp = cExpr(Cp)
        self.Lp = cExpr(Lp)

        N = self.expand()
        super(Xtal, self).__init__(N.Z, N.V)
        self.args = (Rs, Rp, Cp, Lp)
Beispiel #7
0
    def __init__(self, C0, R1, L1, C1):

        self.args = (C0, R1, L1, C1)
        self.C0 = cExpr(C0, positive=True)
        self.R1 = cExpr(R1, positive=True)
        self.L1 = cExpr(L1, positive=True)
        self.C1 = cExpr(C1, positive=True)

        N = self.expand()
        super(Xtal, self).__init__(N.Z, N.V)
Beispiel #8
0
    def __init__(self, V, f, phi=0):

        self.args = (V, f, phi)
        V = cExpr(V)
        f = cExpr(f)
        phi = cExpr(phi)

        # Note, cos(-pi / 2) is not quite zero.

        omega = 2 * sym.pi * f
        foo = (s * sym.cos(phi) + omega * sym.sin(phi)) / (s**2 + omega**2)
        super(Vacstep, self).__init__(Vs(V * foo))
Beispiel #9
0
    def __init__(self, I, phi=0):

        self.args = (I, phi)
        I = cExpr(I)
        phi = cExpr(phi)

        self.omega = symbol('omega_1', real=True)
        foo = (s * sym.cos(phi) + self.omega * sym.sin(phi)) / (s**2 +
                                                                self.omega**2)
        super(Iac, self).__init__(Is(foo * I, ac=True))
        # This is not needed when assumptions propagated.
        self.Isc.is_ac = True
        self.i0 = I
        self.phi = phi
Beispiel #10
0
    def __init__(self, V, phi=0):

        self.args = (V, phi)
        V = cExpr(V)
        phi = cExpr(phi)

        # Note, cos(-pi / 2) is not quite zero.

        self.omega = symbol('omega_1', real=True)
        foo = (s * sym.cos(phi) + self.omega * sym.sin(phi)) / (s**2 +
                                                                self.omega**2)
        super(Vac, self).__init__(Vs(foo * V, ac=True))
        # This is not needed when assumptions propagated.
        self.Voc.is_ac = True
        self.v0 = V
        self.phi = phi
Beispiel #11
0
    def stamp(self, cct):
        
        n1, n2, n3, n4 = self.node_indexes
        m1 = self.cct._branch_index(self.name + 'X')
        m2 = self.branch_index

        # m1 is the input branch
        # m2 is the output branch
        # GY.I gives the current through the output branch

        # Could generalise to have different input and output
        # impedances, Z1 and Z2, but if Z1 != Z2 then the device is
        # not passive.

        # V2 = -I1 Z2     V1 = I2 Z1
        # where V2 = V[n1] - V[n2] and V1 = V[n3] - V[n4]
        
        Z1 = cExpr(self.args[0]).expr                    
        Z2 = Z1
        
        if n1 >= 0:
            cct._B[n1, m2] += 1
            cct._C[m1, n1] += 1
        if n2 >= 0:
            cct._B[n2, m2] -= 1
            cct._C[m1, n2] -= 1
        if n3 >= 0:
            cct._B[n3, m1] += 1
            cct._C[m2, n3] += 1
        if n4 >= 0:
            cct._B[n4, m1] -= 1
            cct._C[m2, n4] -= 1                        

        cct._D[m1, m1] += Z2
        cct._D[m2, m2] -= Z1
Beispiel #12
0
    def __init__(self, v):

        self.args = (v, )
        v = cExpr(v)
        super(Vdc, self).__init__(Vs(v, dc=True) / s)
        # This is not needed when assumptions propagated.
        self.Voc.is_dc = True
        self.v0 = v
Beispiel #13
0
    def __init__(self, i):

        self.args = (i, )
        i = cExpr(i)
        super(Idc, self).__init__(Is(i, dc=True) / s)
        # This is not needed when assumptions propagated.
        self.Isc.is_dc = True
        self.i0 = i
Beispiel #14
0
    def __init__(self, Cval, v0=None):

        self.hasic = v0 is not None
        if v0 is None:
            v0 = 0

        if self.hasic:
            self.args = (Cval, v0)
        else:
            self.args = (Cval, )

        Cval = cExpr(Cval)
        v0 = cExpr(v0)
        self.C = Cval
        self.v0 = v0
        self._Z = Zs.C(Cval)
        self._Voc = Vsuper(Vs(v0) / s)
        self.zeroic = self.v0 == 0
Beispiel #15
0
    def __init__(self, Cval, v0=None):

        self.hasic = v0 is not None
        if v0 is None:
            v0 = 0

        if self.hasic:
            self.args = (Cval, v0)
        else:
            self.args = (Cval, )

        Cval = cExpr(Cval, positive=True)
        v0 = cExpr(v0)
        super(C, self).__init__(Zs.C(Cval), Vs(v0).integrate())
        self.C = Cval
        self.v0 = v0

        self.zeroic = self.v0 == 0
Beispiel #16
0
    def __init__(self, Lval, i0=None):

        self.hasic = i0 is not None
        if i0 is None:
            i0 = 0

        if self.hasic:
            self.args = (Lval, i0)
        else:
            self.args = (Lval, )

        Lval = cExpr(Lval, positive=True)
        i0 = cExpr(i0)
        super(L, self).__init__(Zs.L(Lval), -Vs(i0 * Lval))
        self.L = Lval
        self.i0 = i0

        self.zeroic = self.i0 == 0
Beispiel #17
0
    def stamp(self, cct):
        n1, n2 = self.node_indexes
        m = cct._branch_index(self.args[0])
        F = cExpr(self.args[1]).expr

        if n1 >= 0:
            cct._B[n1, m] -= F
        if n2 >= 0:
            cct._B[n2, m] += F
Beispiel #18
0
    def __init__(self, Lval, i0=None):

        self.hasic = i0 is not None
        if i0 is None:
            i0 = 0

        if self.hasic:
            self.args = (Lval, i0)
        else:
            self.args = (Lval, )

        Lval = cExpr(Lval)
        i0 = cExpr(i0)
        self.L = Lval
        self.i0 = i0
        self._Z = Zs.L(Lval)
        self._Voc = Vsuper(-Vs(i0 * Lval))
        self.zeroic = self.i0 == 0
Beispiel #19
0
    def Z(self):
        """Impedance"""

        kind = self.cct.kind
        Z1 = self.Zs
        if kind in ('s', 'ivp', 'super'):
            return Z1
        elif kind in ('dc', 'time'):
            return cExpr(Z1.jomega(0))
        elif isinstance(kind, str) and kind[0] == 'n':
            return Z1.jomega
        return Z1.jomega(kind)
Beispiel #20
0
    def stamp(self, cct):
        n1, n2 = self.node_indexes
        m = self.branch_index

        if n2 >= 0:
            cct._B[n2, m] += 1
            cct._C[m, n2] += 1

        A = cExpr(self.args[0]).expr

        if n1 >= 0:
            cct._C[m, n1] -= A
Beispiel #21
0
    def Y(self):
        """Admittance"""

        kind = self.cct.kind
        Y1 = self.Ys
        if kind in ('s', 'ivp', 'super'):
            return Y1
        elif kind in ('dc', 'time'):
            return cExpr(Y1.jomega(0))
        elif isinstance(kind, str) and kind[0] == 'n':
            return Y1.jomega
        return Y1.jomega(kind)
Beispiel #22
0
    def stamp(self, cct):
        n1, n2, n3, n4 = self.node_indexes
        G = cExpr(self.args[0]).expr

        if n1 >= 0 and n3 >= 0:
            cct._G[n1, n3] -= G
        if n1 >= 0 and n4 >= 0:
            cct._G[n1, n4] += G
        if n2 >= 0 and n3 >= 0:
            cct._G[n2, n3] += G
        if n2 >= 0 and n4 >= 0:
            cct._G[n2, n4] -= G
Beispiel #23
0
    def __init__(self, Rd=1e9, Ro=1e-6, A=100000, Rp=1e9, Rm=1e9):

        # If Ro=0, then Z matrix singular.

        Rd, Ro, A, Rp, Rm = [cExpr(arg) for arg in (Rd, Ro, A, Rp, Rm)]

        Ra = Rp * (Rd + Rm) / (Rp + Rd + Rm)
        Rb = Rm * (Rd + Rp) / (Rp + Rd + Rm)

        Z = ZMatrix3(
            ((Rp + Rd, Rd, 0), (Rd, Rm + Rd, 0), (A * Ra, -A * Rb, Ro)))
        super(Opamp, self).__init__(Z)
        self.args = (Rd, Ro, A, Rp, Rm)
Beispiel #24
0
    def stamp(self, cct):
        n1, n2 = self.node_indexes
        m = self.branch_index

        if n1 >= 0:
            cct._B[n1, m] += 1
            cct._C[m, n1] += 1
        if n2 >= 0:
            cct._B[n2, m] -= 1
            cct._C[m, n2] -= 1

        mc = cct._branch_index(self.args[0])
        G = cExpr(self.args[1]).expr
        cct._D[m, mc] -= G
Beispiel #25
0
    def __init__(self, Rd=1e9, Ro=1e-6, A=100000, Rp=1e9, Rm=1e9):

        # If Ro=0, then Z matrix singular.

        Rd, Ro, A, Rp, Rm = [cExpr(arg) for arg in (Rd, Ro, A, Rp, Rm)]

        Ra = Rp * (Rd + Rm) / (Rp + Rd + Rm)
        Rb = Rm * (Rd + Rp) / (Rp + Rd + Rm)

        Z = ZMatrix3(((Rp + Rd, Rd, 0),
                      (Rd, Rm + Rd, 0),
                      (A * Ra, -A * Rb, Ro)))
        super(Opamp, self).__init__(Z)
        self.args = (Rd, Ro, A, Rp, Rm)
Beispiel #26
0
    def stamp(self, cct):
        n1, n2, n3, n4 = self.node_indexes
        m = self.branch_index

        if n1 >= 0:
            cct._B[n1, m] += 1
            cct._C[m, n1] += 1
        if n2 >= 0:
            cct._B[n2, m] -= 1
            cct._C[m, n2] -= 1

        A = cExpr(self.args[0]).expr

        if n3 >= 0:
            cct._C[m, n3] -= A
        if n4 >= 0:
            cct._C[m, n4] += A
Beispiel #27
0
    def __init__(self, Rval):

        self.args = (Rval, )
        Rval = cExpr(Rval, positive=True)
        super(R, self).__init__(Zs.R(Rval))
        self.R = Rval
Beispiel #28
0
    def __init__(self, Gval):

        self.args = (Gval, )
        Gval = cExpr(Gval, positive=True)
        super(G, self).__init__(Ys.G(Gval))
        self.G = Gval
Beispiel #29
0
    def __init__(self, i):

        self.args = (i, )
        i = cExpr(i)
        super(Istep, self).__init__(Is(i).integrate())
        self.i = i
Beispiel #30
0
    def __init__(self, Rval):

        self.args = (Rval, )
        self.R = cExpr(Rval)
        self._Z = Zs.R(self.R)
Beispiel #31
0
    def __init__(self, v):

        self.args = (v, )
        v = cExpr(v)
        super(Vstep, self).__init__(Vs(v).integrate())
        self.v = v
Beispiel #32
0
    def __init__(self, Gval):

        self.args = (Gval, )
        self.G = cExpr(Gval)
        self._Z = 1 / Ys.G(self.G)
Beispiel #33
0
    def __init__(self, v):

        self.args = (v, )
        v = cExpr(v)
        self._Voc = Vsuper(tExpr(v) * Heaviside(t), causal=True)
        self.v0 = v
Beispiel #34
0
    def __init__(self, Gval):

        self.args = (Gval, )
        Gval = cExpr(Gval, positive=True)
        super(G, self).__init__(Ys.G(Gval))
        self.G = Gval
Beispiel #35
0
    def __init__(self, Rval):

        self.args = (Rval, )
        Rval = cExpr(Rval, positive=True)
        super(R, self).__init__(Zs.R(Rval))
        self.R = Rval
Beispiel #36
0
    def __init__(self, v):

        self.args = (v, )
        v = cExpr(v)
        self._Voc = Vsuper(Vconst(v, dc=True))
        self.v0 = v
Beispiel #37
0
    def __init__(self, i):

        self.args = (i, )
        i = cExpr(i)
        self._Isc = Isuper(tExpr(i) * Heaviside(t), causal=True)
        self.i0 = i
Beispiel #38
0
    def __init__(self, i):

        self.args = (i, )
        i = cExpr(i)
        self._Isc = Isuper(Iconst(i, dc=True))
        self.i0 = i