Action Potential Simulator
Fire a nerve action potential and see where its shape comes from, with sodium and potassium conductance, threshold and the refractory period adjustable.
Simulator
- Fired Whether each stimulus produced a regenerative spike, judged by whether the membrane’s own sodium current carried the upstroke.
- Both fired
- Threshold current The smallest current that fires, at this pulse duration, found by searching. It is not a constant: it moves with duration and with both conductances.
- 6.92 µA/cm²
- Peak potential Heads towards ENa, 50 mV, and always stops short because potassium is already opening.
- 39.71 mV
- Spike amplitude Peak minus rest. Set by the equilibrium potentials, which is why a bigger stimulus does not give a bigger spike.
- 104.7 mV
- Undershoot The afterhyperpolarisation, which heads towards EK, -77 mV, while potassium conductance is still raised.
- -76.18 mV
- Resting potential Found as the steady state of these conductances rather than assumed, so it moves when you change them.
- -65 mV
- Membrane potential (mV)
- Resting potential
- Peak of a failed stimulus
- Sodium conductance (mS/cm²)
- Potassium conductance (mS/cm²)
Citing this tool
Last updated . Add the date you accessed it as well, which a citation of a page that can change asks for. If a specific result matters, cite the permalink from the tool’s share row instead of this page: it reproduces the exact parameters.
The equation
Hodgkin and Huxley (1952)
This is a squid, at 6.3 degrees C
Every number on this page comes from Hodgkin and Huxley’s 1952 fit to the giant axon of Loligo, measured at 6.3 degrees C. That matters more than it sounds. The spike here lasts several milliseconds; a mammalian axon at body temperature fires in about one, because the same gates open and shut several times faster when they are warm. The refractory intervals you can measure with the paired stimulus are correspondingly long.
A real neuron also has channels this model does not contain: A type potassium, persistent sodium, calcium channels, calcium activated potassium, and in many cells a hyperpolarisation activated current. Four state variables reproduce the squid impulse remarkably well and are the right thing to learn the mechanism from. They are not a human neuron, and the millisecond figures here should not be quoted as if they were.
Four equations, and nothing else
One equation says the membrane is a capacitor being charged and discharged by whatever current
is flowing:
C·dV/dt = I − gNa·m³h·(V − ENa) − gK·n⁴·(V − EK) − gL·(V − EL). Three more say
that each gating variable relaxes towards a voltage dependent target:
dx/dt = αₓ(1 − x) − βₓ·x.
That is the whole model. Threshold is not in it. All-or-none is not in it. Neither refractory period is in it. Every one of those falls out, and watching them appear from four lines of algebra is the reason this simulation is worth more than a labelled diagram of a spike.
The powers are doing real work. m³ means three independent activation gates must
all be open, which produces the S shaped delay at the start of the upstroke that a single gate
cannot. h is a separate inactivation gate that closes as the membrane depolarises,
which is what makes the sodium current transient instead of sustained. That transience is where
refractoriness comes from.
Why a threshold exists at all
There is no threshold parameter to set. What there is, is a race. Depolarise the membrane a
little and two things start happening at once: sodium activation m begins to rise,
which brings in inward current and depolarises further, and potassium activation
n begins to rise while leak current grows, both of which pull back towards rest.
Sodium is faster. Potassium and leak are stronger at first because they start from an open
baseline.
Below some depolarisation the pull back wins and the membrane settles. Above it the sodium feedback wins, and once it wins it accelerates: more depolarisation opens more sodium channels, which depolarises more. Threshold is the crossover point of that race, which is why it is not a property of the sodium channel. Raise the potassium conductance in the controls and the threshold current in the readouts goes up, without sodium having changed at all.
It is also why threshold is not really a voltage. Set the stimulus just under threshold and watch where the trace peaks: that is the dashed orange line. Now shorten the pulse and the same peak voltage no longer fires, because the gates have had less time at that voltage. The threshold current in the readouts is quoted at the pulse duration you have set, and it moves when you change it.
Why it overshoots towards ENa and undershoots towards EK
A membrane potential always sits somewhere between the equilibrium potentials of the ions that
can cross it, pulled towards whichever has most conductance at that instant. At rest potassium
and leak dominate, so the membrane sits near −65 mV. At the peak of the spike the
sodium conductance is briefly an order of magnitude larger than the potassium conductance, so
the membrane is dragged most of the way towards ENa = +50 mV.
It never gets there. By the time sodium conductance peaks, h is already closing and
n is already opening, so there is never an instant where sodium is the only
conductance. The peak here lands around +40 mV, and it is a good check on any
implementation that it stops short of ENa rather than touching it.
The undershoot is the same argument in reverse. Potassium conductance is slow to open and slow
to close, so it is still raised well after the potential has come back down. For a few
milliseconds the membrane is more potassium selective than it is at rest, so it sits closer to
EK = −77 mV than to −65 mV. That is the afterhyperpolarisation, and it
ends when n finally relaxes.
Two refractory periods, two different causes
This is the part worth spending time on, and it is what the second stimulus is for. Both pulses are identical, and the only thing you change is the gap between them.
- The absolute refractory period. Bring the interval down to about 4 ms and the
second stimulus does nothing, at any amplitude the slider offers. The cause is
h: sodium inactivation gates closed during the spike and have not reopened, so most sodium channels are simply unavailable. Current cannot substitute for channels that cannot conduct. - The relative refractory period. Around 8 to 15 ms something different happens. Leave the stimulus at 10 µA/cm² and the second pulse still fails. Raise it to 60 µA/cm² and it succeeds. Here enough sodium channels have recovered, but two things are working against them: potassium conductance is still elevated, and the membrane is hyperpolarised, which means there is further to go to reach threshold. The cell is harder to fire, not impossible to fire, and the threshold has genuinely risen.
Those are two mechanisms, not one mechanism with two names, but in this model no single control
moves only one of them. Lower the sodium conductance far enough and both periods lengthen,
because there is less margin while h recovers: at 40 mS/cm² even 60 µA/cm² fails
until the gap is about 8 ms rather than 7 ms. Raise the potassium conductance and both lengthen
too, because the extra outward current raises the threshold the recovering sodium channels have
to beat.
One further detail you may notice: at intervals around 20 ms the second spike can be very
slightly taller than the first. That is not an artefact. During the undershoot the membrane is
hyperpolarised, so the steady state of h is higher than at rest, and
h transiently overshoots its resting value on the way back. Briefly, more sodium
channels are available than usual.
What all-or-none actually claims
The claim is not that the spike is digital, or that the model contains a switch. It is that the
amplitude is set by the equilibrium potentials and the conductance ratio at the peak, and those
barely depend on how hard the membrane was pushed. Try it: at 10 µA/cm² the peak is near
+39 mV, and at 40 µA/cm² it is near +41 mV. Four times the stimulus
buys about two millivolts.
This is the whole reason neural coding works the way it does. A spike cannot carry the strength of a stimulus in its height, because its height is not available to be modulated. What does change with stimulus strength is the latency, which you can see shorten as you raise the current, and, in a cell driven continuously, the firing rate. Intensity is in the rate. It is also why a spike can propagate down a metre of axon without fading: each patch of membrane regenerates a full sized spike from its own conductances rather than passing along an attenuating signal.
What is not fixed is the amplitude across different membranes. Halve the sodium conductance and the spike gets smaller and eventually fails altogether. All-or-none holds for one membrane across a range of stimuli, which is a much narrower claim than it is usually given credit for.
Reading the conductance panel
The lower panel is the explanation for the upper one. Sodium conductance rises first, steeply, and then falls while the potential is still high, which is inactivation rather than the potential coming back down. Potassium conductance rises later and more slowly and is still falling when the sodium curve has returned to nothing.
Look at the ordering rather than the sizes. If potassium rose as fast as sodium there would be no spike at all, and you can demonstrate that by pushing the potassium conductance up towards 100 mS/cm²: the threshold current climbs, and the spike, when you finally get one, is shorter and smaller.
What this model leaves out
Space. This is one patch of membrane, so nothing propagates. There is no conduction velocity here, no myelin, and no saltatory conduction, all of which need the cable equation and an axon with length.
Temperature. The rate constants are fixed at 6.3 degrees C. Real work applies a Q₁₀ factor of about 3 to the gating rates, which is what turns a several millisecond squid spike into a one millisecond mammalian one.
Ion accumulation and the pump. ENa and EK are held constant, as if the concentrations either side never change. In reality each spike moves a small amount of sodium in and potassium out, and the Na/K ATPase restores it. Over one spike the shift is negligible, which is why holding them fixed is fair; over a long high frequency train in a fine axon it is not.
Other channels, and single channel behaviour. No calcium, no A type potassium, no persistent sodium, no synaptic conductances. The gating variables are also deterministic fractions of a large population; a real patch with a handful of channels is stochastic, and can fire spontaneously from channel noise alone, which nothing here can do.
Common mistakes
- Treating threshold as a fixed voltage. It depends on how fast you arrive, on the pulse duration, and on both conductances. A slow depolarisation can pass the voltage a fast one fired at and never fire, because sodium inactivates on the way.
- Calling the refractory period one thing. Absolute is sodium inactivation. Relative is raised potassium conductance plus the hyperpolarisation. Different causes, different remedies, and only the second one yields to a stronger stimulus.
- Reading these millisecond figures as human values. Squid, 6.3 degrees C. A mammalian spike is about 1 ms wide.
- Saying the sodium channel closes to end the spike. It inactivates, which is a separate gate and a separate state. An inactivated channel cannot be reopened by depolarisation; it has to be repolarised first. That distinction is exactly why there is a refractory period.
- Thinking a bigger stimulus gives a bigger spike. It gives an earlier spike. The height is set by ENa, EK and the conductance ratio.
- Believing the potential reaches ENa. It never does, in this model or in a real axon, because potassium and inactivation are already under way at the peak.
- Assuming the concentration gradients change during a spike. They barely move. The potential swings by 100 mV on a charge transfer far too small to shift the concentrations, which is why the equilibrium potentials can be treated as constants.
- Expecting the undershoot to pass EK. It cannot. Potassium conductance pulls towards EK and no further, and leak is still pulling the other way.
Model and assumptions
- Method
- Runge-Kutta 4th order
- Fixed step
- 0.01 ms
- Repeatability
- Deterministic. The same link gives the same numbers on any machine.
What it assumes
- The Hodgkin and Huxley 1952 squid giant axon at 6.3 degrees C, with their original rate constants.
- One isopotential compartment, so there is no propagation along the axon and no cable equation.
- Four state variables, membrane voltage plus the m, h and n gates, with sodium conductance as m cubed times h and potassium as n to the fourth.
Where it stops holding. Other temperatures or other cell types, both of which change the rate constants. The step sits about nine times inside RK4’s stability limit at the default settings and about four times inside it at the highest sodium and potassium settings. That limit is set by the membrane equation during the spike, not by a gate, and past it a run fails outright rather than degrading.
Numerical accuracy
- Estimated error
- 1.1e-4 mV in the membrane potential, about 1.5e-6 of the largest value reached
- How that was obtained
- Running the same problem again at half the step changed the answer by at most 1.1e-4 mV over 30 ms. Richardson extrapolation of that difference gives the figure above.
- Observed order
- 4.12, measured from a second halving rather than assumed
- Conditions
- 120 and 36 mS/cm^2, 10 uA/cm^2 for 1 ms, paired at 20 ms, the shipped defaults
The injected current is a rectangular pulse sampled once per step at its midpoint, so the error is largest at the pulse edges and on the spike’s rising phase, which is where this sup norm is taken.
Common questions
Why is there a threshold at all?
Because sodium channels open in response to depolarisation, and opening them depolarises the cell further. Below threshold, potassium leaving still outpaces sodium entering, so the disturbance dies away. Above it, the sodium current wins and the loop runs away with itself until the channels inactivate. Threshold is not a property of a single channel: it is the membrane potential at which that positive feedback overtakes the outward currents, which is why it shifts when you change either conductance.
Why can a neuron not fire again immediately?
Two separate reasons, and they produce two different refractory periods. Sodium channels do not simply close after opening, they inactivate, and inactivation only lifts once the membrane has repolarised. While most of them are inactivated no stimulus of any size can fire the cell, which is the absolute refractory period. After that, enough recover to fire but the potassium conductance is still elevated and the cell is hyperpolarised, so a larger than normal stimulus is needed. That is the relative refractory period, and together they set the maximum firing rate.
Why does the potential overshoot past zero and then undershoot?
Because each ion drives the membrane towards its own equilibrium potential. At the peak the membrane is dominated by sodium conductance, so it heads towards the sodium equilibrium potential, +50 mV in this model, and gets partway there before inactivation stops it. During repolarisation potassium conductance is still rising and stays high after sodium has shut, so the membrane is briefly dominated by potassium and heads towards the potassium equilibrium potential, −77 mV in this model, which is below the resting potential. That is the hyperpolarising afterpotential.
Is this a human neuron?
No, and it matters. These are Hodgkin and Huxley’s original 1952 parameters for the squid giant axon at 6.3 °C, which is the model the whole framework was built and tested on. A mammalian neuron at 37 °C has faster gating, a briefer spike of about 1 ms rather than several, and additional channel types this model does not contain. The mechanism is the same and the shape is recognisable, but do not read the millisecond figures as human values.
What does all-or-none actually mean?
That the size of the spike does not encode the size of the stimulus. Increase the stimulus above threshold and the action potential does not get taller, because its amplitude is set by the sodium and potassium equilibrium potentials rather than by what triggered it. What a stronger stimulus does is fire the cell sooner and, if sustained, fire it more often. Information is carried in the firing rate, not the spike height. The pulses here are too brief to sustain a train, but the first half is easy to see: raise the current well above threshold and the spike comes much sooner, at much the same height.