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:
- Calculate input currents Iinput,i for all neurons (stimulus + synaptic coupling from previous step's voltages)
- For each neuron, calculate ionic currents Iion,i using current gating variables (mi, hi, ni) and voltage (Vi)
- Update all 12 state variables (V, m, h, n for each neuron) simultaneously using Forward Euler
- 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:
- Membrane potential starts to depolarize (become less negative)
- Na+ channels begin to open (m increases) → Na+ ions flow in → further depolarization
- This creates positive feedback: more depolarization → more Na+ channels open → more depolarization
- The membrane potential rapidly rises to about +50 mV (the spike)
- Na+ channels inactivate (h decreases) → Na+ current stops
- K+ channels open (n increases) → K+ ions flow out → repolarization
- Membrane potential returns to resting state (-65 mV)
- 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.