def Z(self): if self._Z is not None: return self._Z if self._Y is not None: return Zs(1 / self._Y) if self._Voc is not None: return Zs(0) if self._Isc is not None: return Zs(1 / Ys(0)) raise ValueError('_Isc, _Voc, _Y, or _Z undefined for %s' % self)
def __init__(self, Yval=Ys(0), Ival=Is(0)): # print('<N> Y:', Yval, 'I:', Ival) if not isinstance(Yval, Ys): raise ValueError('Yval not Ys') if not isinstance(Ival, Is): raise ValueError('Ival not Is') self.Y = Yval self.Isc = Ival super(Norton, self).__init__()
def admittance(self, Np, Nm): """Return s-domain admittance between nodes Np and Nm with independent sources killed. """ new = self.kill() # Connect 1 V s-domain voltage source between nodes and # measure current. new._add('Vin_ %d %d {DiracDelta(t)}' % (Np, Nm)) If = -new.Vin_.I new.remove('Vin_') return Ys(If.laplace())
def Amatrix(self, N1p, N1m, N2p, N2m): """Create A matrix from network, where: I1 is the current flowing into N1p and out of N1m I2 is the current flowing into N2p and out of N2m V1 is V[N1p] - V[N1m] V2 is V[N2p] - V[N2m] """ from lcapy.twoport import AMatrix if self.Voc(N1p, N1m) != 0 or self.Voc(N2p, N2m) != 0: raise ValueError('Network contains independent sources') try: self.add('V1_ %d %d {DiracDelta(t)}' % (N1p, N1m)) # A11 = V1 / V2 with I2 = 0 # Apply V1 and measure V2 with port 2 open-circuit A11 = Hs(self.V1_.V.laplace() / self.Voc(N2p, N2m).laplace()) # A12 = V1 / I2 with V2 = 0 # Apply V1 and measure I2 with port 2 short-circuit A12 = Zs(self.V1_.V.laplace() / self.Isc(N2p, N2m).laplace()) self.remove('V1_') self.add('I1_ %d %d {DiracDelta(t)}' % (N1p, N1m)) # A21 = I1 / V2 with I2 = 0 # Apply I1 and measure I2 with port 2 open-circuit A21 = Ys(-self.I1_.I.laplace() / self.Voc(N2p, N2m).laplace()) # A22 = I1 / I2 with V2 = 0 # Apply I1 and measure I2 with port 2 short-circuit A22 = Hs(-self.I1_.I.laplace() / self.Isc(N2p, N2m).laplace()) self.remove('I1_') A = AMatrix(A11, A12, A21, A22) return A except ValueError: raise ValueError('Cannot create A matrix')
def Y(self): if self._Y is not None: return self._Y return Ys(1 / self.Z)
def __init__(self, Yval): self.args = (Yval, ) Yval = Ys(Yval) self._Z = 1 / Yval
def __init__(self, Gval): self.args = (Gval, ) self.G = cExpr(Gval) self._Z = 1 / Ys.G(self.G)
def __init__(self, Yval): self.args = (Yval, ) Yval = Ys(Yval) super(Y, self).__init__(Yval)
def __init__(self, Gval): self.args = (Gval, ) Gval = cExpr(Gval, positive=True) super(G, self).__init__(Ys.G(Gval)) self.G = Gval
def Y(self): return Ys(1 / self.Z)
def __init__(self, Ival): self.args = (Ival, ) Ival = sExpr(Ival) super(sI, self).__init__(Ys(0), Is(Ival))
def __init__(self, Ival): super(CurrentSource, self).__init__(Ys(0), Is(Ival))