ただのメモ

他の人に見せても良い方のメモ

Brusselator

Brusselator model 

Brusselator - Wikipedia

 

 b = 1 + a^2を超えるか否かでダイナミクスが変化するらしい

hopf 分岐の現象の例を理解する上で良い。

Euler methodでモデルする。

 

======================

import numpy as np
import matplotlib.pyplot as plt
import random
import time
import matplotlib.animation as animation


def main():
    time_start = time.time()
    fig, ax = plt.subplots(figsize=(10,10))

    def f(x,y):
        a = 1;
        b = 2.5
        dt = T / N
        x_diff = a + x ** 2 * y - b * x - x
        y_diff = b * x - x ** 2 * y
        return (dt * x_diff, dt * y_diff)

    ims = []
    x = np.random.random(100)
    y = np.random.random(100)

    T = 10 * 20
    N = 10000 * 5

    for i in range(N):
        dx, dy = f(x, y)
        x, y = x + dx, y + dy
        if i % 100 == 0:
            im1 = ax.plot(x,y,color = "red",linestyle = "None",marker = "o")
            ims.append(im1)

    ani = animation.ArtistAnimation(fig,ims,interval = 10)

    ax.set_aspect("equal")
    time_end = time.time()
    plt.show()
    print(time_end - time_start)


if __name__ == '__main__':
    main()

========================