# Description of problem

Hi,

I am currently generating data using the same code for different models from json files (Morris-Lecare and 2 versions of Wang-Buzsaki (WB)). I generated data with deterministic models and am now introducing noise. For the Morris-Lecare, this is not a problem. For WB, I get “ZeroDivisionError: float division” error eventually, usually due to an underflow/overflow. My question is if there is a good way to handle this? Or is there something really obvious that I am missing somehow?

(It is also a little odd because if I change the parameter sigma after reading in the json, I get problems even for sigma = 0, but before, I ran the code often without any errors…)

Thanks in advance for any help!

# Minimal code to reproduce problem

This is not the full code, just parts of my model. I can upload it but it is spread across the whole file structure so maybe there is an obvious solution to this already:

odes:

“dv/dt = (I + sigma * xi + IL + INa + IK)/(Cm)”,

“dh/dt = phi * 5*(hAlpha * (1-h) - hBeta*h)",
"dn/dt = phi * 5*(nAlpha * (1-n) - nBeta

*n)"*

functions:

“hAlpha”: “0.07 * exp(-(v/mV+58.0)/20.0)/ms”,

“hBeta”: "1.0/( 1.0 + exp(-0.1(v/mV+28.0)) )/ms”,

functions:

“hAlpha”: “0.07 * exp(-(v/mV+58.0)/20.0)/ms”,

“hBeta”: "1.0/( 1.0 + exp(-0.1

“mInf”: “1/ exprel(-0.1*(v/mV+35.0)) /((1/ exprel(-0.1*(v/mV+35.0))) + 4.0* exp(-(v/mV+60.0)/18.0))”,

“nAlpha”: “0.1 * 1/ exprel(-0.1*(v/mV+34.0+bn))/ms”,

“nBeta”: “0.125* exp(-(v/mV+44.0+bn)/80.0)/ms”

# What you have already tried

- I used “euler” and “heun” as integration methods with dt = 0.001 * ms
- I checked for where my error occurs with

brian2.prefs.codegen.target = (“numpy” )

brian2.prefs.codegen.loop_invariant_optimisations = False

np.seterr(all=“raise”) - I monitored the v,n, (h), and the error occurs when v is close to -35mV and read the corresponding post ZeroDivisionError when changing synaptic weights of large network with HH neurons
- I replaced exp() with exprel() as far as possible

# Traceback of error

example1:

FloatingPointError: underflow encountered in exp

The above exception was the direct cause of the following exception: BrianObjectException Traceback (most recent call last) …

An exception occured during the execution of the ‘run’ block of code object neurongroup_2_stateupdater_codeobject. The error was raised in the following line: _h = (dt * (((_lio_2 * (h * exp(_lio_3 * v))) + (_lio_4 * exp(_lio_3 * v))) - ((_lio_5 * h) / (1.0 + (0.0608100626252179 * exp(_lio_6 * v)))))) + h (See above for original error message and traceback.)

example2:

FloatingPointError: underflow encountered in multiply

The above exception was the direct cause of the following exception: BrianObjectException

Traceback (most recent call last)…

An exception occured during the execution of the ‘run’ block of code object neurongroup_3_stateupdater_codeobject.

The error was raised in the following line:

_v = (((((1.0 * (cm ** 2)) * sigma) * xi) / uF) + (dt * (((((((((((((((- 82534.375) * (cm ** 2)) * h) * mV) * msiemens) / (((((((((((((((((((((((((((((((((((((((((((…

(See above for original error message and traceback.)