Description of problem
failed to simulate hodgkin-huxley model using brian2, the voltage behaves weird
Minimal code to reproduce problem
sorry to say that the code has to be long, but I tried my best to annotate the code
from brian2 import *
start_scope()
# parameters
area = 20000 * umetre ** 2
Cm = 1 * ufarad * cm ** -2 * area
g_l = 0.3 * msiemens * cm ** -2 * area
El = -54 * mV
EK = -77 * mV
ENa = 50 * mV
g_Na = 120 * msiemens * cm ** -2 * area
g_k = 0.3 * msiemens * cm ** -2 * area
eqs = Equations('''
dv/dt = (I - (g_Na * m ** 3 * h * (v - ENa)) - (g_k * n ** 4 * (v - EK)) - (g_l * (v - El))) / Cm : volt
dn/dt = alpha_n * (1 - n) - beta_n * n : 1
dm/dt = alpha_m * (1 - m) - beta_m * m : 1
dh/dt = alpha_h * (1 - h) - beta_h * h : 1
alpha_n = (0.01 * (v / mV + 50) / (1 - exp(-(v / mV + 50) / 10))) / ms : Hz
beta_n = (0.125 * exp(-(v / mV + 60) / 80)) / ms : Hz
alpha_m = (0.1 * (v / mV + 35) / (1 - exp(-(v / mV + 35) / 10))) / ms : Hz
beta_m = (4.0 * exp(-0.0556 * (v / mV + 60))) / ms : Hz
alpha_h = (0.07 * exp(-0.05 * (v / mV + 60))) / ms : Hz
beta_h = (1 / (1 + exp(-(0.1) * (v / mV + 30)))) / ms : Hz
I : amp
g_Na : siemens
g_k : siemens
g_l : siemens
''')
# set initial condition
group = NeuronGroup(1, eqs, method='exponential_euler')
group.v = El
group.g_Na = g_Na
group.g_k = g_k
group.g_l = g_l
group.n = 0.35
group.m = 0.15
group.h = 0.8
group.I = '10*nA'
state = StateMonitor(group, True, record=True)
What you have aready tried
the same model works when I use numpy to simulate (i.e. to solve the differential equation)
Expected output (if relevant)
i expect to have something like: (only care about the first two graph)
(it says new users can only put one embedded media item in a post, but you can find it in the github link below)
which is produced by a numpy based hodgkin huxley model available on GitHub - HeMuling/Hodgkin-Huxley-model: an implementation of Hodgkin-Huxley model using python