simulation.py 文件源码

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

项目:nanopores 作者: mitschabaude 项目源码 文件源码
def panimate(ax, dt, pcoll, patches, boundaries, **kwargs):
    particles = pcoll.P
    coll = ellipse_collection(ax, particles)
    def init():
        return ()
        #ax.clear()
        #ax.add_patch(rect)
        #return (rect, )

    def animate(i):
        if i == 0:
            for patch in patches:
                ax.add_patch(patch)
            ax.add_collection(coll)
        else:
            move(particles, dt, boundaries)
            xy = np.array([p.x[::2].flatten() for p in particles])
            coll.set_offsets(xy)
        return tuple(patches + [coll])

    kwargs = dict(dict(frames=1800, interval=10, blit=True), **kwargs)
    ani = animation.FuncAnimation(ax.figure, animate, init_func=init, **kwargs)
    return ani
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号