brainpy / BrainPy

Brain Dynamics Programming in Python
https://brainpy.readthedocs.io/
GNU General Public License v3.0
490 stars 89 forks source link

2D bifurcation for 3+ D dynamical systems #629

Open nosratullah opened 4 months ago

nosratullah commented 4 months ago

Hi, Thanks for the awesome software. I was wondering if there's a way to do 2D bifurcation on more than 2D dynamical systems in your software.

Please:

@bp.odeint def int_y(y, t, x, z, Iext, a): return G(x,y,z, Iext, a) @bp.odeint def int_z(x, t, x, y, Iext, a): return H(x,y,z, Iext, a)

analyzer = bp.analysis.Bifurcation2D( model = [int_x, int_y, int_z], target_vars=dict(x=[-3, 3], y=[-3., 3.], z=[-3, 3]), target_pars=dict(a=[0.5, 1.], Iext=[0., 1.]), resolutions={'a': 0.01, 'Iext': 0.01}, ) analyzer.plot_bifurcation(num_rank=10, tol_aux=1e-9) analyzer.show_figure()


Another example which I guess it's more common to use is analyzing the 2D bifurcation diagram of 4D Hodgkin-Huxley model . Maybe with this example I can rephrase my question which is can we perform low-dimensional bifurcation analysis on high-dimensional dynamical system with your software?
Many thanks.
chaoming0625 commented 4 months ago

This is a good question. I will show you inspirational examples, and their limitations.

nosratullah commented 4 months ago

Great! Maybe a good example is provided in this link with PyDSTool. It is a 4D predator-prey system with 2D bifurcation analysis.

chaoming0625 commented 4 months ago

Currently, brainpy does not implement the continuation analysis. However, we can do bifurcation analysis using fast-slow bifurcation analysis: fixing one variable first, then do bifurcation analysis of two remaining variables. For your cases, we can use:

@bp.odeint
def int_x(x, t, y, z, Iext, a):
    return F(x,y,z, Iext, a)

@bp.odeint
def int_y(y, t, x, z, Iext, a):
    return G(x,y,z, Iext, a)
@bp.odeint
def int_z(x, t, x, y, Iext, a):
    return H(x,y,z, Iext, a)

analyzer = bp.analysis.FastSlow2D(
  [int_x, int_y, int_z],
  fast_vars={'x': [-3, 3], 'y': [-3., 3.]},
  slow_vars={'z': [-3., 3.]},
  pars_update={'a': 0.5, 'Iext': 0.5},
  resolutions={'a': 0.01, 'Iext': 0.01}
)
analyzer.plot_bifurcation(num_rank=20)
analyzer.show_figure()

Hoping this message can help you.