# FitzHugh-Nagumo Model: understanding dynamical phase transition
### Introduction
The FitzHugh-Nagumo model, as introduced in our class, is deceptively straightforward, facilitating initial simulations using the Brian platform. Despite its apparent simplicity, fully grasping the diverse dynamical phenomena it can exhibit is a far more complex task. This report aims to elucidate three distinct bifurcation modes within the FitzHugh-Nagumo model, as observed in our simulations. To facilitate this, a user-friendly interface was developed, allowing for nuanced observation of simulations with adjustable parameters. By focusing on these specific bifurcation types, we aim to deepen our understanding not only of the model itself but also of the intricate dynamical phase transitions it can demonstrate. This exploration bridges theoretical knowledge with practical application, highlighting the model's multifaceted nature despite its seemingly simple setup.
### 1. Description of the FitzHugh-Nagumo Model
The FitzHugh-Nagumo model is a simplification of the Hodgkin-Huxley model, originally developed to describe the electrical activity in neurons. It captures the essential dynamics of spiking neurons using two differential equations:
$\frac{dv}{dt}=\frac{v-\frac{v^3}{3}-w+I}{\tau_v}$
Here, $v$ represents the membrane potential, $I$ is the external input current, and $\tau_v$ is the time constant for the membrane potential. The term $v-\frac{v^3}{3}$ introduces nonlinearity, accounting for the activation and deactivation dynamics of the neuron.
The second equation models the recovery process:
$\frac{dw}{dt}=\frac{v+a-b\cdot w}{\tau_v}$
In this equation, $w$ stands for the recovery variable, which captures processes such as ion channel inactivation. The parameters $a$ and $b$ help regulate the recovery dynamics, and $\tau_w$ is the time constant for the recovery variable.
The FitzHugh-Nagumo model is widely used in neuroscience and related fields to study neuronal excitability, oscillations, and pattern formation in neural networks.
### 2. Explanation of SNIC Bifurcation
SNIC, or Saddle-Node on Invariant Circle, bifurcation is a critical concept in the study of dynamical systems, particularly in the context of neuronal dynamics. In a SNIC bifurcation:
* The system transitions from a excitable system (with a stable node and an unstable node) to a limit cycle (oscillatory state).
* This transition is characterized by the collision of a stable and an unstable fixed point on an invariant circle, leading to the emergence of oscillations.
* The hallmark of a SNIC bifurcation is the onset of oscillations with an initially very low frequency, which gradually increases with further changes in a control parameter, such as the input current in the case of the FitzHugh-Nagumo model.
* SNIC bifurcations are crucial for understanding phenomena like the onset of rhythmic activities in neurons and are integral to theories of how neural oscillations start and stop.

(Maruyama et al., 2017)
### 3. Explanation of Supercritical and Subcritical Hopf Bifurcations
In dynamical systems, hopf bifurcations can be categorized as either supercritical or subcritical, based on how the system transitions to new behaviors:
* Supercritical Bifurcation:
In a supercritical bifurcation, as a control parameter crosses a critical threshold, the system smoothly transitions from a stable state to a new behavior, such as the onset of stable oscillations (limit cycles).
This type of bifurcation is typically associated with a stable and continuous transition, where small changes in the parameter lead to small and predictable changes in the system's dynamics.
* Subcritical Bifurcation:
Contrarily, in a subcritical bifurcation, the transition is abrupt and can lead to large and sudden changes in the system's behavior as the parameter crosses a critical value.
This bifurcation often involves the sudden appearance of an unstable behavior, such as large-amplitude oscillations, which can then lead to a stable state through a further change in the parameter.
Both supercritical and subcritical bifurcations are fundamental in understanding the complex behavior of nonlinear dynamical systems, including neuronal models like the FitzHugh-Nagumo model.

(Maruyama et al., 2017)
### 4. Computational Simulation using Brian simulator
```
#Setting up for Brian
eqs = Equations('''
dv/dt = (v-(v**3)/3 - w + I)/tau_v : 1
dw/dt = (v + a - b*w)/tau_w : 1
I : 1
''')
```
In our study, we utilize Brian's equation setting capabilities to configure the FitzHugh-Nagumo model. We establish a 'group' consisting of a single neuron and employ the StateMonitor to record all state variables.
```
num_neurons = 1
group = NeuronGroup(num_neurons, eqs,threshold='v > 0',refractory='v > 0',method='rk4')
M = StateMonitor(group, True, record=True) # record all state variables
```
We establish a 'group' consisting of a single neuron and employ the StateMonitor to record all state variables.
```
#parameters
tau_v = 1*ms
tau_w = 12.5*ms
a = 0.7
b = 0.8
# Initial states
group.v = 0
group.w = 0
group.I = 0
#run
store()
run(50*ms)
group.v = -0.6
run(50*ms)
restore()
```
We define the parameters and initial states of the system. To stimulate the neuron, we directly modify the voltage, setting $v=0.6$ starting from $50ms$. This intervention successfully triggers an action potential, analogous to the behavior observed in the Hodgkin-Huxley model.

The results are presented in two plots. The left plot illustrates the dynamic changes in membrane potential ($v$) and recovery variable ($w$) over simulation time. Complementing this, the right plot offers a phase diagram ($v−w$) that includes nullclines and the fixed point, providing a different perspective on the system's behavior.
```
group.I = input_I #the value of current
```
Additionally, we experiment with inputting to the system through injected current, which is our primary method for investigating various dynamical phase transitions. This approach allows us to observe and analyze the neuron's response to different external stimuli.

The user-friendly interface developed enhances our ability to easily visualize the process of dynamical phase transitions. This tool is instrumental in bringing theoretical concepts to life, allowing for a more intuitive understanding of complex dynamics in the FitzHugh-Nagumo model.
### 5. Results
#### Simulate SNIC bifurcation

After adjusting the parameters, we identified the saddle-node on an invariant circle (SNIC) bifurcation as described. In the first panel, the applied current causes only minor perturbations around the fixed point, leading to a rapid stabilization of the variables $v$ and $w$ back to constant values. In the second panel, the system traverses the limit cycle once, indicating initiation near the unstable point in the SNIC's excitable system. This singular traversal suggests a finely-tuned balance between stability and excitability. For the third panel, post-bifurcation behavior reveals the same limit cycle as observed in the previous panel. However, in this instance, the system sustains continuous oscillation within the limit cycle, highlighting a distinct shift in dynamical behavior post-bifurcation.
#### Simulate supercritical Hopf bifurcation


After parameter adjustments, we have successfully identified the supercritical Hopf bifurcation. In the first panel, despite perturbations, the variables $v$ and $w$ eventually stabilize back to the fixed point. The second panel presents a more complex scenario: as the injected current increases, a limit cycle gradually emerges. However, pinpointing the exact moment of its formation remains challenging. Panels three and four depict a further increase in injected current, revealing a notable characteristic of the supercritical Hopf bifurcation: the amplitude of oscillation within the limit cycle increases progressively. This observation is consistent with the expected dynamical behavior of a system undergoing a supercritical Hopf bifurcation.
#### Simulate subcritical Hopf bifurcation


After adjusting the parameters, we successfully identified a subcritical Hopf bifurcation. In the first panel, despite the application of a strong current and significant perturbations, the system eventually stabilizes back to the stable fixed point. In the second panel, although the system does not immediately return to the stable fixed point, the damping trajectories of the amplitudes of $v$ and $w$ suggest that, given sufficient time, it would eventually stabilize.
The third panel presents a stark contrast: with only a slight increase in current from the previous panel, a clear and persistent limit cycle oscillation emerges. This oscillation is characterized by a high amplitude, which is indicative of a subcritical Hopf bifurcation model. Here, the system abruptly transitions to high-amplitude oscillations.
Finally, in the fourth panel, a further increase in injected current leads to a noticeable increase in the amplitude of oscillation. This observation aligns with the expected behavior of a system undergoing a subcritical Hopf bifurcation, where increasing external stimulus progressively intensifies the system's response.
### 6. Discussion
After experimenting with the parameters in the FitzHugh-Nagumo Model using Brian, I was astonished by the multitude of dynamical phase transitions that a single model can exhibit through mere parameter adjustments. This exploration led to the observation of even more unexpected behaviors within the model. Unfortunately, my current level of knowledge limits my ability to precisely categorize these behaviors into specific bifurcation modes.
To enhance my understanding and observation capabilities, I developed a UI system to visualize the entire simulation process. This tool has significantly facilitated my ability to observe real-time changes during bifurcations, deepening my comprehension of dynamical phase transitions, a concept I've been learning about in my academic coursework. The visualization provided by the UI system has been instrumental in linking theoretical knowledge with practical, observable phenomena.
### 7. Reference
Murayama, Yoriko, et al. "Low temperature nullifies the circadian clock in cyanobacteria through Hopf bifurcation." *Proceedings of the National Academy of Sciences* 114.22 (2017): 5641-5646.