class ImpedanceModule(BasicModule): """ 阻抗模块 """ def __init__(self, parent, bas_name, **kwargs): super().__init__(parent, bas_name) self._param = [None] self.r1 = ImpedanceEdge(self, 'Edge') self.add_element(self.r1) self.create_circuit() self.create_port() self.load_kw(**kwargs) def load_kw(self, **kwargs): if 'z' in kwargs: self._param[0] = kwargs['z'] @property def z(self): return self.param[0] def create_circuit(self): pass def create_port(self): # self.config_port(Port(self.r1, True), Port(self.r1, False)) self.config_port(self.r1.start, self.r1.end) def config_param(self, freq): self.r1.config_param(self.z.z(freq))
class TcsrPower(BasicModule): """ 功出电源 """ def __init__(self, parent, bas_name, **kwargs): super().__init__(parent, bas_name) # self._param = [None] * 2 self._param = [180, None] self.u1 = VolSrcEdge(self, '1理想电压源') self.r1 = ImpedanceEdge(self, '2内阻') self.add_element(self.u1, self.r1) self.create_circuit() self.create_port() self.load_kw(**kwargs) def load_kw(self, **kwargs): if 'u_pwr' in kwargs: self._param[0] = kwargs['u_pwr'] if 'z_pwr' in kwargs: self._param[1] = kwargs['z_pwr'] @property def u_pwr(self): return self.param[0] @property def z_pwr(self): return self.param[1] @property def snd_lvl(self): return self.parent.snd_lvl # def create_circuit(self): # self.u1.start.link_node(self.r1.ports[0]) # # def create_port(self): # self.config_port(self.r1.ports[1], Port(self.u1, False)) def create_circuit(self): self.u1.start.link_node(self.r1.start) def create_port(self): # self.config_port(Port(self.r1, False), Port(self.u1, False)) self.config_port(self.r1.end, self.u1.end) def config_param(self, freq): self.u1.config_param(self.u_pwr) self.r1.config_param(self.z_pwr[self.snd_lvl].z(freq))
def __init__(self, parent, bas_name, **kwargs): super().__init__(parent, bas_name) self._param = [None] self.r1 = ImpedanceEdge(self, 'Edge') self.add_element(self.r1) self.create_circuit() self.create_port() self.load_kw(**kwargs)
def __init__(self, parent, bas_name, **kwargs): super().__init__(parent, bas_name) self._param = [None] * 2 self.l1 = ImpedanceEdge(self, '1共模电感') self.m1 = TcsrXfmr(self, '2变压器') self.c1 = ImpedanceEdge(self, '3电容') self.add_element(self.l1, self.m1, self.c1) self.create_circuit() self.create_port() self.load_kw(**kwargs)
def __init__(self, parent, bas_name, **kwargs): super().__init__(parent, bas_name) # self._param = [None] * 2 self._param = [180, None] self.u1 = VolSrcEdge(self, '1理想电压源') self.r1 = ImpedanceEdge(self, '2内阻') self.add_element(self.u1, self.r1) self.create_circuit() self.create_port() self.load_kw(**kwargs)
def __init__(self, parent, bas_name, **kwargs): super().__init__(parent, bas_name) self._param = [None] * 4 self.r1 = ImpedanceEdge(self, 'R1') self.r2 = ImpedanceEdge(self, 'R2') self.rp1 = ImpedanceEdge(self, 'Rp1') self.rp2 = ImpedanceEdge(self, 'Rp2') self.add_element(self.r1, self.r2, self.rp1, self.rp2) self.create_circuit() self.create_port() self.load_kw(**kwargs)
class PiCircuitModule(BasicModule): """ Pi型二端口网络 """ def __init__(self, parent, bas_name, **kwargs): super().__init__(parent, bas_name) self._param = [None] * 3 self.r1 = ImpedanceEdge(self, 'R1') self.r2 = ImpedanceEdge(self, 'R2') self.r3 = ImpedanceEdge(self, 'R3') self.add_element(self.r1, self.r2, self.r3) self.create_circuit() self.create_port() self.load_kw(**kwargs) def load_kw(self, **kwargs): if 'z1' in kwargs: self._param[0] = kwargs['z1'] if 'z2' in kwargs: self._param[1] = kwargs['z2'] if 'z3' in kwargs: self._param[2] = kwargs['z3'] @property def z1(self): return self.param[0] @property def z2(self): return self.param[1] @property def z3(self): return self.param[2] def create_circuit(self): # self.r1.ports[0].link_node(self.r2.ports[0]) # self.r2.ports[1].link_node(self.r3.ports[0]) # self.r1.ports[1].link_node(self.r3.ports[1]) self.r1.start.link_node(self.r2.start) self.r2.end.link_node(self.r3.start) self.r1.end.link_node(self.r3.end) def create_port(self): # self.config_port(Port(self.r1, True), Port(self.r1, False), # Port(self.r3, True), Port(self.r3, False)) self.config_port(self.r1.start, self.r1.end, self.r3.start, self.r3.end) def config_param(self, freq): self.r1.config_param(self.z1.z(freq)) self.r2.config_param(self.z2.z(freq)) self.r3.config_param(self.z3.z(freq))
class TcsrTADXfmr(BasicModule): """ TAD变压器 """ def __init__(self, parent, bas_name, **kwargs): super().__init__(parent, bas_name) self._param = [None] * 2 self.l1 = ImpedanceEdge(self, '1共模电感') self.m1 = TcsrXfmr(self, '2变压器') self.c1 = ImpedanceEdge(self, '3电容') self.add_element(self.l1, self.m1, self.c1) self.create_circuit() self.create_port() self.load_kw(**kwargs) def load_kw(self, **kwargs): if 'z1' in kwargs: self.m1.load_kw(z1=kwargs['z1'], z3=kwargs['z1']) if 'z2' in kwargs: self.m1.load_kw(z2=kwargs['z2']) if 'n' in kwargs: self.m1.load_kw(n=kwargs['n']) if 'z3' in kwargs: self._param[0] = kwargs['z3'] if 'zc' in kwargs: self._param[1] = kwargs['zc'] @property def z3(self): return self.param[0] @property def zc(self): return self.param[1] # def create_circuit(self): # self.l1.ports[1].link_node(self.m1.ports[0]) # self.c1.ports[0].link_node(self.m1.ports[2]) # # def create_port(self): # self.config_port(self.l1.ports[0], self.m1.ports[1], # self.c1.ports[1], self.m1.ports[3]) def create_circuit(self): self.l1.end.link_node(self.m1.ports[0]) self.c1.start.link_node(self.m1.ports[2]) def create_port(self): # self.config_port(Port(self.l1, True), self.m1.ports[1], # Port(self.c1, False), self.m1.ports[3]) self.config_port(self.l1.start, self.m1.ports[1].node, self.c1.end, self.m1.ports[3].node) def config_param(self, freq): self.l1.config_param(self.z3.z(freq)) self.c1.config_param(self.zc.z(freq)) self.m1.config_param(freq)
class CableModule(BasicModule): """ 电缆模块 """ def __init__(self, parent, bas_name, **kwargs): super().__init__(parent, bas_name) self._param = [None] * 4 self.r1 = ImpedanceEdge(self, 'R1') self.r2 = ImpedanceEdge(self, 'R2') self.rp1 = ImpedanceEdge(self, 'Rp1') self.rp2 = ImpedanceEdge(self, 'Rp2') self.add_element(self.r1, self.r2, self.rp1, self.rp2) self.create_circuit() self.create_port() self.load_kw(**kwargs) def load_kw(self, **kwargs): if 'R' in kwargs: self._param[0] = kwargs['R'] if 'L' in kwargs: self._param[1] = kwargs['L'] if 'C' in kwargs: self._param[2] = kwargs['C'] if 'length' in kwargs: self._param[3] = kwargs['length'] @property def R(self): return self.param[0] @property def L(self): return self.param[1] @property def C(self): return self.param[2] @property def length(self): return self.param[3] def create_circuit(self): self.r1.start.link_node(self.rp1.start) self.r2.start.link_node(self.rp1.end) self.r1.end.link_node(self.rp2.start) self.r2.end.link_node(self.rp2.end) def create_port(self): # self.config_port(Port(self.r1, True), Port(self.r2, True), # Port(self.r1, False), Port(self.r2, False)) self.config_port(self.r1.start, self.r2.start, self.r1.end, self.r2.end) def config_param(self, freq): length = float(self.length) w = 2 * np.pi * freq z0 = float(self.R) + 1j * w * float(self.L) y0 = 10e-10 + 1j * w * float(self.C) # y0 = 1j * w * float(self.C) zc = np.sqrt(z0 / y0) gama = np.sqrt(z0 * y0) zii = zc * np.sinh(gama * length) yii = (np.cosh(gama * length) - 1) / zc / np.sinh(gama * length) self.r1.config_param(zii / 2) self.r2.config_param(zii / 2) self.rp1.config_param(1 / yii) self.rp2.config_param(1 / yii)