regions.py 文件源码

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

项目:pyfds 作者: emtpb 项目源码 文件源码
def apply(self, old_values, step):
        """Apply the boundary.

        Args:
            old_values: Old values of the points in the boundary.
            step: Time step of the simulation (required if signals are to be applied).

        Returns:
            New values for the points in the boundary.
        """

        if np.ndim(self.value) == 0 or \
                (np.ndim(self.value) == 1 and type(self.value) == list):
            # if a single value or a list of single values for each index is given
                return self.additive * old_values + self.value
        elif type(self.value) == np.ndarray:
            # if a signal is given
            return self.additive * old_values + self.value[step]
        else:
            # if a list of signals for each index is given
            return [self.additive * old_values[ii] + signal[step]
                    for ii, signal in enumerate(self.value)]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号