Skip to content
ScienceQuest

Action Potential Simulator

SimulatorUndergraduate Updated

Support ScienceQuest on Buy Me a Coffee (opens in a new tab)

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 toward 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 afterhyperpolarization, which heads toward 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
Parameters
µA/cm²

Compare it with the threshold in the readouts.

MoreLessabout Stimulus current

Just below it, nothing happens. A threshold above 60 is out of this slider’s reach.

ms

Threshold depends on charge, so a shorter pulse needs a much larger current.

mS/cm²

120 in the original fit. Turn it down to watch the spike shrink and then fail.

mS/cm²

36 in the original fit. It sets repolarization and it raises threshold.

Delivers an identical pulse later, which is how refractoriness is measured.

ms

Drag it down until the second spike disappears.

These are squid giant axon parameters at 6.3 degrees C, which is what Hodgkin and Huxley measured. At half height this spike is about 1.5 ms wide and a mammalian cortical neuron’s about 1.2 ms, but its recovery here is much slower, so read the shape and the mechanism from this, not the timings.

  • Membrane potential (mV)
  • Resting potential
  • Peak of a failed stimulus
Membrane potential against time, with the resting potential and the peak of a just-failing stimulus marked. A suprathreshold pulse gives a spike of essentially fixed height; a subthreshold one gives a small bump that decays.
  • Sodium conductance (mS/cm²)
  • Potassium conductance (mS/cm²)
Sodium and potassium conductance against time. Sodium rises first and fast and then inactivates on its own; potassium rises later, more slowly, and stays raised after the potential has come back down, which is what causes the undershoot.
Cite this tool

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.

On the syllabus: MCAT, 3A: Structure and functions of the nervous and endocrine systems and ways these systems coordinate the organ systems.

Teaching with this? You can put it on a class page or LMS for free, with no ads inside the frame. Get the embed code.

The equation

CmdVdt=I−INa−IK−ILC_m\frac{dV}{dt} = I - I_{Na} - I_K - I_L

Hodgkin and Huxley (1952)

The equation as an image to reuse
Action Potential Simulator: the equation C m dV/dt = I - I Na - I K - I L.
The equation the simulator is built on, with its source. Image © ScienceQuest, CC BY 4.0. Free to reuse with credit and a link to this page; how to reuse it. Download PNG

What is an action potential in a neuron?

An action potential is a rapid, temporary reversal of electrical membrane potential across an excitable neuronal membrane. It begins with voltage-gated Na+ channel opening causing rapid depolarization, followed by Na+ inactivation and K+ channel opening driving repolarization and a brief afterhyperpolarization before the membrane settles back to rest. In the Hodgkin-Huxley model simulated here, rest is near −65 mV and the peak reaches about +40 mV.

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. They gave potentials as displacements from rest, and here they are shifted to a resting potential of −65 mV. That matters more than it sounds. At half height the squid spike here is about 1.5 ms wide, close to a mammalian cortical pyramidal neuron at 37 degrees C (about 1.2 ms), and Purkinje neurons and GABAergic interneurons are narrower still, about 0.23 and 0.34 ms (Carter and Bean 2009). What is much slower here is the recovery: the afterhyperpolarization and the refractory period, which you can measure with the paired stimulus.

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 hyperpolarization 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 toward 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 labeled 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 depolarizes, 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. Depolarize the membrane a little and two things start happening at once: sodium activation m begins to rise, which brings in inward current and depolarizes further, and potassium activation n begins to rise while leak current grows, both of which pull back toward rest. Sodium is faster. Potassium and leak are stronger at first because they start from an open baseline.

Below some depolarization the pull back wins and the membrane settles. Above it the sodium feedback wins, and once it wins it accelerates: more depolarization opens more sodium channels, which depolarizes 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 toward ENa and undershoots toward EK

A membrane potential always sits somewhere between the equilibrium potentials of the ions that can cross it, pulled toward 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 toward 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 afterhyperpolarization, 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 below about 6.5 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. From about 7 to 14 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 hyperpolarized, 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 artifact. During the undershoot the membrane is hyperpolarized, 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 meter 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 toward 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. Hodgkin and Huxley scaled the gating rates with a Q₁₀ of 3. Warming this squid model narrows its spike and shrinks it, and before 37 degrees C it stops firing altogether (heat block). A mammalian spike’s speed comes from its own channels and their densities, not from temperature alone.

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 behavior. 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 depolarization 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 hyperpolarization. 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 cortical pyramidal neuron’s spike is about 1.2 ms wide at half height at 37 degrees C, close to this one, but its recovery is much faster.
  • 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 depolarization; it has to be repolarized 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 toward EK and no further, and leak is still pulling the other way.

Sources

Hodgkin AL and Huxley AF, J Physiol 1952;117:500-544, for the equations, the rate constants, the Q₁₀ of 3 and the refractory periods. Carter BC and Bean BP, Neuron 2009;64:898-909, for the widths of mammalian spikes at 37 degrees C. The refractory intervals and the spike width quoted here are this simulator’s own, integrated from Hodgkin and Huxley’s equations.

Model and assumptions

The method, what it assumes and how accurate it is
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 depolarization, and opening them depolarizes 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 point where that positive feedback overtakes the outward currents, and it shifts with pulse duration and with both conductances, so it is not one fixed voltage.

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 repolarized. 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 hyperpolarized, 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 toward its own equilibrium potential. At the peak the membrane is dominated by sodium conductance, so it heads toward the sodium equilibrium potential, +50 mV in this model, and gets partway there before inactivation stops it. During repolarization potassium conductance is still rising and stays high after sodium has shut, so the membrane is briefly dominated by potassium and heads toward the potassium equilibrium potential, −77 mV in this model, which is below the resting potential. That is the hyperpolarizing 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. At half height this squid spike is about 1.5 ms wide, close to a mammalian cortical pyramidal neuron at 37 °C (about 1.2 ms), while Purkinje neurons and interneurons are narrower, about 0.2 to 0.3 ms. The squid recovery is much slower, and mammalian neurons have additional channel types this model does not contain. The mechanism is the same and the shape is recognizable, 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.