Description of problem
I aim to simulate a large network of 20.000 Hodgkin-Huxley neurons. This works, but when I change the synaptic weights to the desired value, I almost always get a ZeroDivionError: float division. This does not appear to occur in my code, but in something that brian does to process the code. I cannot seem to fix it. Can anyone help me?
Minimal code to reproduce problem
area = 300*umetre**2
Cm = (1*ufarad*cm**-2) * area
gl = (0.3*msiemens*cm**-2) * area
El = -65*mV
EK = -77*mV
ENa = 55*mV
g_na = (40*msiemens*cm**-2) * area
g_kd = (35*msiemens*cm**-2) * area
tau_ampa = 5*ms
tau_nmda = 150*ms
Eampa = 0.0*mV
Enmda = 0.0*mV
Mg2 = 1.
N_noise = 1 # number of inputs
N_rate = 5*Hz # rate of each input
w_noise = 0.05*nS #weight of the noise (PART OF PROBLEM)
N = 20000 #number of neurons
simtime = 1*second #simulation time
eqs = Equations('''
dv/dt = (-gl*(v-El)-
g_na*(m*m*m)*h*(v-ENa)-
g_kd*(n*n*n*n)*(v-EK)-I_syn+I)/Cm : volt
dm/dt = (xm-m)/tau_m : 1
dn/dt = (xn-n)/tau_n : 1
dh/dt = (xh-h)/tau_h : 1
I_syn = g_ampa*(v-Eampa) + g_nmda*(v-Enmda)/(1+Mg2*exp(-0.062*v/mV)/3.57) : amp
I :amp
dg_nmda/dt = -g_nmda*(1./tau_nmda) : siemens
dg_ampa/dt = -g_ampa*(1./tau_ampa) : siemens
alpha_m = 0.182*(v/mV+35)/(1-exp(-(v/mV+35)/9))/ms: Hz
beta_m = -0.124*(v/mV+35)/(1-exp((v/mV+35)/9))/ms: Hz
alpha_h = 0.25*exp(-(v/mV+90)/12)/ms : Hz
beta_h = 0.25*exp((v/mV+62)/6)/exp((v/mV+90)/12)/ms : Hz
alpha_n = 0.01*(v/mV-25)/(1-exp(-(v/mV-25)/9))/ms: Hz
beta_n = -0.002*(v/mV-25)/(1-exp((v/mV-25)/9))/ms: Hz
xm = alpha_m/(alpha_m+beta_m) :1
xn = alpha_n/(alpha_n+beta_n) :1
xh = alpha_h/(alpha_h+beta_h) :1
tau_m = 1/(alpha_m+beta_m) :second
tau_n = 1/(alpha_n+beta_n) :second
tau_h = 1/(alpha_h+beta_h) :second
''')
P = NeuronGroup(N, model=eqs, threshold='v>-20*mV', refractory=3*ms,
method='exponential_euler')
Syn = Synapses(P, P, on_pre={'ampa': 'g_ampa+=0.02*nS',
'nmda': 'g_nmda+=0.02*nS'}) # make connections (HERE THE WEIGHTS ARE ALSO THE PROBLEM)
Syn.connect(p=0.1)
Syn.ampa.delay = '(2.+randn())*ms'
Syn.nmda.delay = '(2.+randn())*ms'
P.v = -65*mV
Synnos = PoissonInput(P, 'g_ampa', N_noise, N_rate, w_noise, order=1) #synaptic noise
run(simtime, report='text')
What you have aready tried
I’ve tried to reduce the number of neurons and number of connections. This only changes the values of the synaptic weights for which I get this error.
Expected output (if relevant)
Actual output (if relevant)
Full traceback of error (if relevant)
Traceback (most recent call last):
File "/home/Nina/.conda/envs/brianenv/lib/python3.6/code.py", line 91, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/home/Nina/Downloads/pycharm-2020.2.3/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/home/Nina/Downloads/pycharm-2020.2.3/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/Nina/PycharmProjects/pythonProject/main.py", line 89, in <module>
run(simtime, report='text')
File "/home/Nina/.conda/envs/brianenv/lib/python3.6/site-packages/brian2/units/fundamentalunits.py", line 2392, in new_f
result = f(*args, **kwds)
File "/home/Nina/.conda/envs/brianenv/lib/python3.6/site-packages/brian2/core/magic.py", line 374, in run
namespace=namespace, profile=profile, level=2+level)
File "/home/Nina/.conda/envs/brianenv/lib/python3.6/site-packages/brian2/core/magic.py", line 232, in run
namespace=namespace, profile=profile, level=level+1)
File "/home/Nina/.conda/envs/brianenv/lib/python3.6/site-packages/brian2/core/base.py", line 280, in device_override_decorated_function
return func(*args, **kwds)
File "/home/Nina/.conda/envs/brianenv/lib/python3.6/site-packages/brian2/units/fundamentalunits.py", line 2392, in new_f
result = f(*args, **kwds)
File "/home/Nina/.conda/envs/brianenv/lib/python3.6/site-packages/brian2/core/network.py", line 1080, in run
obj.run()
File "/home/Nina/.conda/envs/brianenv/lib/python3.6/site-packages/brian2/core/base.py", line 183, in run
codeobj()
File "/home/Nina/.conda/envs/brianenv/lib/python3.6/site-packages/brian2/codegen/codeobject.py", line 102, in __call__
return self.run()
File "/home/Nina/.conda/envs/brianenv/lib/python3.6/site-packages/brian2/codegen/runtime/cython_rt/cython_rt.py", line 153, in run
return self.compiled_code.main(self.namespace)
File "_cython_magic_aa3bcd64e641e8c37f7a0a182088943a.pyx", line 532, in _cython_magic_aa3bcd64e641e8c37f7a0a182088943a.main
ZeroDivisionError: float division