Web Simulation 

 

Hodgkin-Huxley Action Potential

This note provides an interactive, visual simulation of the Hodgkin-Huxley model of neuron action potentials. The Hodgkin-Huxley model, developed by Alan Hodgkin and Andrew Huxley in 1952, describes how electrical signals are generated and propagated in neurons through the opening and closing of ion channels.

The simulation visualizes three neurons connected in a chain (A → B → C). Each neuron is modeled using the four-variable Hodgkin-Huxley equations, which describe the dynamics of membrane potential (V) and three gating variables: sodium activation (m), sodium inactivation (h), and potassium activation (n). When you click "Inject Stimulus", a current pulse is injected into Neuron A, triggering an action potential that propagates through the chain.

The membrane animation shows ion channels (Na+ and K+) embedded in the lipid bilayer. The channels open and close based on the gating variables: Na+ channels open when m³h is high, and K+ channels open when n⁴ is high. Ions flow through open channels, and you can see this visually as colored dots moving through the channels.

NOTE : The simulation uses Forward Euler numerical integration to solve the differential equations. The time step is kept small (0.01 ms) for numerical stability, and multiple physics steps are computed per frame to maintain smooth animation. The synaptic coupling between neurons converts voltage from one neuron into input current for the next neuron in the chain.

Math behind the Simulation

The simulation implements a chain of three Hodgkin-Huxley neurons (A → B → C), where each neuron is modeled by four coupled differential equations. The complete system consists of 12 coupled differential equations (4 per neuron × 3 neurons) that are integrated simultaneously each time step.

State Variables

Each neuron has four state variables:

  • V: Membrane potential (mV) - the electrical voltage across the cell membrane
  • m: Sodium activation gate (dimensionless, 0-1) - controls opening of Na+ channels
  • h: Sodium inactivation gate (dimensionless, 0-1) - controls closing of Na+ channels after opening
  • n: Potassium activation gate (dimensionless, 0-1) - controls opening of K+ channels

For the three-neuron chain, we have 12 state variables total:

  • Neuron A: VA, mA, hA, nA
  • Neuron B: VB, mB, hB, nB
  • Neuron C: VC, mC, hC, nC

Ionic Currents

The total ionic current through the membrane is the sum of three components:

Iion = INa + IK + IL

where:

  • INa = gNa · m³ · h · (V - ENa) - Sodium current
  • IK = gK · n⁴ · (V - EK) - Potassium current
  • IL = gL · (V - EL) - Leak current

The channel openness probabilities are:

  • Na+ channel openness = m³ · h - requires 3 activation gates (m) and 1 inactivation gate (h)
  • K+ channel openness = n⁴ - requires 4 activation gates (n)

Differential Equations for a Single Neuron

For each neuron, the membrane potential evolves according to:

Cm · dV/dt = Iinput - Iion

where Cm is the membrane capacitance and Iinput is the input current (injected stimulus or synaptic input).

The gating variables evolve according to:

dm/dt = αm(V) · (1 - m) - βm(V) · m
dh/dt = αh(V) · (1 - h) - βh(V) · h
dn/dt = αn(V) · (1 - n) - βn(V) · n

where α and β are voltage-dependent rate constants that determine how fast the gates open and close.

Complete System: 12 Coupled Differential Equations

The simulation integrates all 12 equations simultaneously. Here are the explicit equations for all three neurons:

Neuron A:
Cm · dVA/dt = Iinput,A - Iion,A
dmA/dt = αm(VA) · (1 - mA) - βm(VA) · mA
dhA/dt = αh(VA) · (1 - hA) - βh(VA) · hA
dnA/dt = αn(VA) · (1 - nA) - βn(VA) · nA

Neuron B:
Cm · dVB/dt = Iinput,B - Iion,B
dmB/dt = αm(VB) · (1 - mB) - βm(VB) · mB
dhB/dt = αh(VB) · (1 - hB) - βh(VB) · hB
dnB/dt = αn(VB) · (1 - nB) - βn(VB) · nB

Neuron C:
Cm · dVC/dt = Iinput,C - Iion,C
dmC/dt = αm(VC) · (1 - mC) - βm(VC) · mC
dhC/dt = αh(VC) · (1 - hC) - βh(VC) · hC
dnC/dt = αn(VC) · (1 - nC) - βn(VC) · nC

where Iion,i = INa,i + IK,i + IL,i is the total ionic current for neuron i (i ∈ {A, B, C}).

How the Neurons Get Coupled

The coupling constant κ appears in the input current terms Iinput,B and Iinput,C, which directly affect the voltage equations for neurons B and C:

  • In the equation for dVB/dt, the term Iinput,B contains κ · VA, creating a direct coupling from Neuron A's voltage to Neuron B's dynamics.
  • In the equation for dVC/dt, the term Iinput,C contains κ · VB, creating a direct coupling from Neuron B's voltage to Neuron C's dynamics.
  • The coupling is indirect for the gating variables (m, h, n): κ affects VB and VC, which then affect the voltage-dependent rate constants α and β, which in turn affect dm/dt, dh/dt, and dn/dt.

This makes the 12 equations coupled: while each neuron's gating variables (m, h, n) depend only on that neuron's own voltage, the input currents Iinput,B and Iinput,C depend on the voltages of other neurons, creating interdependencies across all 12 equations.

Synaptic Coupling Between Neurons

The neurons are coupled through synaptic connections in a chain (A → B → C). The input current for each neuron is:

Iinput,A = Istimulus (injected stimulus current)
Iinput,B = κ · max(0, VA - Vrest) / 15.0 (if VA > -55 mV)
Iinput,C = κ · max(0, VB - Vrest) / 15.0 (if VB > -55 mV)

where:

  • Istimulus: Injected stimulus current (from button clicks, can be multiple overlapping pulses)
  • κ: Synaptic coupling strength (µA/cm² per mV)
  • Vrest: Resting potential (-65 mV)
  • The coupling is active only when the source neuron's voltage exceeds -55 mV (threshold)

This creates a unidirectional chain where:

  • Neuron A receives only external stimulus (Istimulus)
  • Neuron B receives synaptic input from A (proportional to A's voltage spike)
  • Neuron C receives synaptic input from B (proportional to B's voltage spike)
  • There is no feedback (B and C do not affect A)

The coupling makes the system of 12 equations coupled: while each neuron's internal dynamics (m, h, n) depend only on its own voltage Vi, the input currents Iinput,i depend on the voltages of other neurons, creating interdependencies.

Rate Constants

The rate constants are functions of voltage:

  • αm(V) = 0.1 · (V + 40) / (1 - exp(-(V + 40)/10))
  • βm(V) = 4 · exp(-(V + 65)/18)
  • αh(V) = 0.07 · exp(-(V + 65)/20)
  • βh(V) = 1 / (1 + exp(-(V + 35)/10))
  • αn(V) = 0.01 · (V + 55) / (1 - exp(-(V + 55)/10))
  • βn(V) = 0.125 · exp(-(V + 65)/80)

Numerical Integration

The simulation uses the Forward Euler method to integrate all 12 differential equations simultaneously. Here are the explicit update equations for all three neurons at each time step:

Neuron A:
VA(t + Δt) = VA(t) + Δt · (Iinput,A - Iion,A) / Cm
mA(t + Δt) = mA(t) + Δt · (αm(VA) · (1 - mA) - βm(VA) · mA)
hA(t + Δt) = hA(t) + Δt · (αh(VA) · (1 - hA) - βh(VA) · hA)
nA(t + Δt) = nA(t) + Δt · (αn(VA) · (1 - nA) - βn(VA) · nA)

Neuron B:
VB(t + Δt) = VB(t) + Δt · (Iinput,B - Iion,B) / Cm
mB(t + Δt) = mB(t) + Δt · (αm(VB) · (1 - mB) - βm(VB) · mB)
hB(t + Δt) = hB(t) + Δt · (αh(VB) · (1 - hB) - βh(VB) · hB)
nB(t + Δt) = nB(t) + Δt · (αn(VB) · (1 - nB) - βn(VB) · nB)

Neuron C:
VC(t + Δt) = VC(t) + Δt · (Iinput,C - Iion,C) / Cm
mC(t + Δt) = mC(t) + Δt · (αm(VC) · (1 - mC) - βm(VC) · mC)
hC(t + Δt) = hC(t) + Δt · (αh(VC) · (1 - hC) - βh(VC) · hC)
nC(t + Δt) = nC(t) + Δt · (αn(VC) · (1 - nC) - βn(VC) · nC)

where Δt = 0.01 ms is the time step. The integration order each time step is:

  1. Calculate input currents Iinput,i for all neurons (stimulus + synaptic coupling from previous step's voltages)
  2. For each neuron, calculate ionic currents Iion,i using current gating variables (mi, hi, ni) and voltage (Vi)
  3. Update all 12 state variables (V, m, h, n for each neuron) simultaneously using Forward Euler
  4. Advance time by Δt

Multiple steps (5 steps) are computed per frame for numerical stability, giving an effective time resolution of 0.05 ms per frame.

Action Potential Mechanism

When a stimulus current is injected:

  1. Membrane potential starts to depolarize (become less negative)
  2. Na+ channels begin to open (m increases) → Na+ ions flow in → further depolarization
  3. This creates positive feedback: more depolarization → more Na+ channels open → more depolarization
  4. The membrane potential rapidly rises to about +50 mV (the spike)
  5. Na+ channels inactivate (h decreases) → Na+ current stops
  6. K+ channels open (n increases) → K+ ions flow out → repolarization
  7. Membrane potential returns to resting state (-65 mV)
  8. K+ channels close slowly, creating a brief hyperpolarization (undershoot)

Chain Propagation

In the chain (A → B → C), the 12 differential equations are coupled through the synaptic connections:

  • When Neuron A fires (VA spikes), its voltage is converted to input current Iinput,B for Neuron B
  • This current appears in Neuron B's voltage equation: dVB/dt depends on Iinput,B, which depends on VA
  • If the coupling is strong enough, Neuron B depolarizes and fires (VB spikes)
  • Neuron B's spike then creates input current Iinput,C for Neuron C
  • Neuron C's voltage equation (dVC/dt) depends on Iinput,C, which depends on VB
  • The signal propagates through the chain: A → B → C

The synaptic coupling strength (κ) determines how effectively the spike propagates. With strong coupling, even small voltage changes in the source neuron can trigger action potentials in the target neuron. The coupling creates a unidirectional flow of information through the chain, with no feedback from downstream neurons to upstream ones.

Usage Example

Follow these steps to explore the Hodgkin-Huxley action potential:

  1. Initial State: When you first load the simulation, three neurons (A, B, C) are shown in their resting state. The membrane potential is at -65 mV, and all ion channels are mostly closed. The voltage graph shows flat lines at the resting potential.
  2. Inject Stimulus: Click the "Inject Stimulus" button to inject a current pulse (20 µA/cm² for 20 ms) into Neuron A. This will trigger an action potential.
    • Watch the Na+ channels in Neuron A open (gates lower) as m³h increases
    • See Na+ ions (orange dots) flow into the cell
    • Observe the voltage spike in the graph (blue line) rising to about +50 mV
    • Watch K+ channels open (gates lower) as n⁴ increases
    • See K+ ions (cyan dots) flow out of the cell
    • Notice the voltage returning to resting state and briefly hyperpolarizing
  3. Observe Chain Propagation: After Neuron A fires, watch how the action potential propagates:
    • Neuron A's voltage spike creates an input current for Neuron B
    • If the coupling is strong enough, Neuron B will fire (red line in graph)
    • Neuron B's spike then triggers Neuron C (green line in graph)
    • You'll see a wave of activity propagating through the chain
  4. Study the Gating Variables: Pay attention to the timing:
    • Na+ channels open quickly (m increases fast) → rapid depolarization
    • Na+ channels inactivate (h decreases) → prevents immediate re-firing (refractory period)
    • K+ channels open slowly (n increases slowly) → repolarization
    • K+ channels close slowly → brief hyperpolarization
  5. Reset and Experiment: Click "Reset" to return all neurons to resting state. Try injecting multiple stimuli to see how the refractory period prevents immediate re-firing.

Tip: The key insight of the Hodgkin-Huxley model is that action potentials emerge from the interaction between voltage-dependent ion channels. The positive feedback loop (depolarization → Na+ channels open → more depolarization) creates the rapid upstroke of the spike, while the slower K+ channels and Na+ inactivation create the downstroke and refractory period.

Parameters

The simulation uses standard Hodgkin-Huxley parameters from the original 1952 paper:

  • gNa: Maximum sodium conductance = 120 mS/cm². Controls how much current flows through open Na+ channels.
  • gK: Maximum potassium conductance = 36 mS/cm². Controls how much current flows through open K+ channels.
  • gL: Leak conductance = 0.3 mS/cm². Represents all other ion channels combined.
  • ENa: Sodium reversal potential = +50 mV. The voltage at which there is no net Na+ current.
  • EK: Potassium reversal potential = -77 mV. The voltage at which there is no net K+ current.
  • EL: Leak reversal potential = -54.4 mV. The voltage at which there is no net leak current.
  • Cm: Membrane capacitance = 1.0 µF/cm². Determines how quickly the membrane potential changes in response to current.
  • Stimulus Current: 20 µA/cm² for 20 ms. The injected current that triggers the action potential.
  • Synaptic Coupling: 0.5 µA/cm² per mV. Determines how strongly one neuron's voltage affects the next neuron in the chain.

Buttons and Controls

  • Inject Stimulus: Injects a current pulse (20 µA/cm² for 20 ms) into Neuron A, triggering an action potential. The simulation automatically starts playing when you click this button.
  • Reset: Resets all neurons to their resting state (V = -65 mV, m = 0.05, h = 0.6, n = 0.32) and clears the voltage history graphs.

Interaction and Visualization

  • Membrane Animation: The top canvas shows a cross-section of three neuron membranes side by side:
    • Lipid Bilayer: The gray horizontal line represents the cell membrane
    • Na+ Channels: Located above the membrane, shown as gates that open (lower) when m³h is high. Orange ions flow through when open.
    • K+ Channels: Located below the membrane, shown as gates that open (lower) when n⁴ is high. Cyan ions flow through when open.
    • Voltage Indicator: The colored bar at the bottom shows the current membrane potential
  • Voltage Graph: The bottom canvas shows a scrolling line graph of membrane potential over time:
    • Blue Line: Neuron A voltage
    • Red Line: Neuron B voltage
    • Green Line: Neuron C voltage
    • The graph scrolls to show the last 100 ms of data
    • Voltage scale: -80 mV (bottom) to +70 mV (top)
  • Info Display: Shows real-time values:
    • Time: Current simulation time in milliseconds
    • Neuron Voltages: Current membrane potential for each neuron