Exemple #1
0
def run_param_sweep_2d():
    dx = 0.2
    L = 5.0
    dim = 2
    t_max = 40.0
    dt = 0.1

    D_rhos = np.logspace(-1, 2, 10)
    mus = np.logspace(-1, 2, 10)
    for D_rho, mu in product(D_rhos, mus):
        if D_rho != mu:
            m = ModelAbstract(dim, dt, dx, L, D_rho, mu, walls=None)
            while m.t < t_max:
                m.iterate()
            rho_final = m.get_rho()
            print(D_rho, mu, rho_final.max(), np.var(rho_final))
Exemple #2
0
def run_model_abstract_2d():
    dx = 0.2
    L = 5.0
    dim = 2
    t_max = 40.0
    dt = 0.1

    D_rho = 22.
    mu = 44.

    # walls = bannock.walls.Maze(L, dim=2, dx=dx, d=2 * dx, seed=None)
    # walls = bannock.walls.Traps(L, dx=dx, n=1, d=dx, w=10*dx, s=2*dx)
    walls = None

    m = ModelAbstract(dim, dt, dx, L, D_rho, mu, walls)

    fig = plt.figure()
    ax_rho = fig.add_subplot(2, 1, 1)
    ax_c = fig.add_subplot(2, 1, 2)
    plot_rho = ax_rho.imshow([[0]], cmap='Reds', interpolation='nearest',
                             origin='lower', extent=2 * [-L / 2.0, L / 2.0])
    plot_c = ax_c.imshow([[0]], cmap='Reds', interpolation='nearest',
                         origin='lower', extent=2 * [-L / 2.0, L / 2.0])

    ax_cb = plt.axes([0.875, 0.2, 0.05, 0.7])
    fig.colorbar(plot_rho, cax=ax_cb)

    plt.ion()
    plt.show()
    every = 1

    while m.t < t_max:
        if not m.i % every:
            plot_rho.set_data(m.get_rho())
            plot_c.set_data(m.get_c())
            plot_rho.autoscale()
            plot_c.autoscale()
            fig.canvas.draw_idle()
            print(m.t, np.var(m.get_rho()))
        m.iterate()
Exemple #3
0
def run_model_abstract_1d():
    dx = 0.4
    L = 5.0
    dim = 1
    t_max = 160.0
    dt = 2.0

    D_rho = 0.01
    mu = 0.215

    m = ModelAbstract(dim, dt, dx, L, D_rho, mu, walls=None)

    print(m.get_x().shape, m.get_c().shape)
    raw_input()
    fig = plt.figure()
    ax_rho = fig.add_subplot(2, 1, 1)
    ax_c = fig.add_subplot(2, 1, 2)
    plot_rho = ax_rho.plot(m.get_x(), m.get_rho(), c='red')[0]
    plot_c = ax_c.plot(m.get_x(), m.get_c(), c='green')[0]
    plt.ion()
    plt.show()
    every = 1

    while m.t < t_max:
        if not m.i % every:
            plot_rho.set_ydata(m.get_rho())
            plot_c.set_ydata(m.get_c())
            rho = m.get_rho()
            rho_ran = rho.max() - rho.min()
            rho_max = rho.max() + 0.1 * rho_ran
            rho_min = rho.min() - 0.1 * rho_ran
            ax_rho.set_ylim(rho_min, rho_max)
            c = m.get_c()
            c_ran = c.max() - c.min()
            c_max = c.max() + 0.1 * c_ran
            c_min = c.min() - 0.1 * c_ran
            ax_c.set_ylim(c_min, c_max)
            fig.canvas.draw()
            print(m.t, np.var(rho))
        m.iterate()