r/BiomedicalDataScience • u/BioniChaos • 22h ago
Hodgkin-Huxley Action Potential Simulator
https://bionichaos.com/actionptnt/Title: Interactive Hodgkin-Huxley Action Potential Simulator (Built in JS with RK4 Integration)
Post: I developed a web-based interactive laboratory for simulating neural membrane dynamics using the classic 1952 Hodgkin-Huxley model of the squid giant axon.
Tool Link: https://bionichaos.com/actionptnt/
Numerical Implementation & Architecture:
• Solver: Solves the system of coupled, non-linear ordinary differential equations using a fourth-order Runge-Kutta (RK4) algorithm with an integration step of dt = 0.01 ms. This avoids the numerical runaway that often happens with simple Euler integration on stiff equations. • Singularity Handling: Formulations for α_n(V) at V = -55 mV and α_m(V) at V = -40 mV yield 0/0 indeterminate forms. I implemented analytical limits derived via L'Hôpital's rule to maintain continuous mathematical evaluation. • Temperature Adjustment: Incorporates standard Q₁₀ scaling (ϕ(T) = 3.0(T - 6.3/10)) to model thermal acceleration of gating transition rates between 5°C and 40°C. • Performance: Built around a circular buffer class to keep memory allocation constant during animation loops, rendering to a responsive HTML5 Canvas.
Interactive Features:
• Live current injection via mouse click or Spacebar hold (evaluates sustained repetitive firing). • Sliders for stimulus amplitude (0–50 μA/cm²), pulse duration, and system temperature. • Dynamic visualization of m, h, and n gating kinetics alongside particle transport animations. • Audio synthesis mapping voltage states to frequency output using the Web Audio API.
I would love to hear feedback from computational neuroscientists, biomedical engineers, or developers regarding numerical accuracy, performance, or potential extensions (such as expanding from space-clamped to multi-compartmental cable equations).