netlist.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:SpicePy 作者: giaccone 项目源码 文件源码
def branch_current(self):
        """
        "branch_current"  computes the branch currents

        :return:
            * self.ib
        """
        # check is branch voltages are available
        if self.vb is None:
            self.branch_voltage()

        ibranch = np.zeros_like(self.vb)
        cnt_l = 0
        cnt_v = 0
        for k, (name, val, voltage) in enumerate(zip(self.names, self.values, self.vb)):
            if name[0].upper() == 'R':
                ibranch[k, ...] = voltage / val
            elif name[0].upper() == 'L':
                ibranch[k, ...] = self.x[self.node_num + cnt_l, ...]
                cnt_l += 1
            elif name[0].upper() == 'C':
                if self.analysis[0].lower() == '.op':    # the current is zero, hence, do nothing
                    pass
                elif self.analysis[0].lower() == '.ac':
                    f = float(self.analysis[-1])
                    Xc = -1.0 / (2 * np.pi * f * val)
                    ibranch[k] = voltage / (Xc * 1j)
                elif self.analysis[0].lower() == '.tran':
                    from scipy.interpolate import CubicSpline
                    cs = CubicSpline(self.t, voltage)
                    csd = cs.derivative()
                    ibranch[k, ...] = val * csd(self.t)

            elif name[0].upper() == 'V':
                ibranch[k, ...] = self.x[self.node_num + len(self.isort[1]) + cnt_v, ...]
                cnt_v += 1
            elif name[0].upper() == 'I':
                ibranch[k, ...] = val

        self.ib = ibranch
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号