finite_difference.py 文件源码

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

项目:house-of-enlightenment 作者: house-of-enlightenment 项目源码 文件源码
def diffuse(self, pixels, delta_t):
        self.pixels.append(np.empty([self.X_MAX, self.Y_MAX], dtype=float))

        if delta_t < 5:
            return

        v = self.diffusion_constant
        h0 = self.pixels[1]
        h, idx = self.hCalc()
        hDiff = (h - h0 * idx)
        h = hDiff * delta_t * v + h0

        # pylint: disable=no-member
        pix = np.array(pixels[:, :][:], dtype=np.int64)
        color = (pix[:, :, 0] << 16) | (pix[:, :, 1] << 8) | (pix[:, :, 2])
        f = np.where(color == 0xFF0000, 0xFFFF, np.where(color == 0xFF00, 0 - 0xFFFF,
                                                         0))[:self.X_MAX, :self.Y_MAX]
        h = h + f
        h = np.clip(h, 0, 0xFFFF)
        self.pixels[2] = np.clip(h, 0, 0xFFFF)

    ##
    # This is the differences between node i,j and it's closest neighbors
    # it's used in calculateing spatial derivitives
    #
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号