convergence failed repeatedly: err=-7.

NMODL and the Channel Builder.
Post Reply
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

convergence failed repeatedly: err=-7.

Post by Bill Connelly »

Very strange error I was using a model of a t-type calcium channel, but wanted to add temperature sensitivity into it.

It looks like this

Code: Select all

COMMENT
This T-type calcium current was originally reported in Wang XJ et al 1991
This file supplies a version of this current identical to Quadroni and Knopfel 1994
except for gbar and Erev (see notes below).

Slight alterations by William Connelly Cardiff University 2013 for temperature dynamic reversal potential

ENDCOMMENT

NEURON {
	SUFFIX lva
	: NONSPECIFIC_CURRENT i
	USEION ca READ cai, cao WRITE ica
	RANGE Erev, g, gbar, i, cai
	RANGE k, taum, minf, alpha_1, alpha_2, beta_1, beta_2, V_s 
}

UNITS {
	(S)	=	(siemens)
	(mV)	=	(millivolt)
	(mA)	=	(milliamp)
	FARADAY = (faraday) (coulomb)
	R = (k-mole) (joule/degC)
}

PARAMETER {
	gbar = 0.4e-3	(S/cm2) < 0, 1e9 > : Quadroni and Knopfel use 166e-6
	Erev = 120 (mV)	: orig from Wang XJ et al 1991 was 120
	: note: Quadroni and Knopfel 1994 table 1 use 80 instead
	V_s = 0 (mV)	: used to describe effect of changing extracellular [Ca]
			: 0 corresponds to [Ca]outside = 3 mM (p 841)
	qm	= 3		: q10's for activation and inactivation
	qh	= 3		: from Coulter et al., J Physiol 414: 587, 1989

	cai
	cao
	celsius 	(degC)
}

ASSIGNED {
	ica (mA/cm2)
	i (mA/cm2)
	v (mV)
	g (S/cm2)
	k
	alpha_1 (1)
	alpha_2	(1)
	beta_1 (1)
	beta_2 (1)
	carev
	phi_m
	phi_h
	
}

STATE {	m h d }

BREAKPOINT {
	SOLVE states METHOD cnexp
	carev = (1e3) * (R*(celsius+273.15))/(2*FARADAY) * log (cao/cai)
	g = gbar * m^3 * h
	ica = g * (v - carev)
	i = ica	: used only to display the value of the current (section.i_lva(0.5))
}

INITIAL { 	LOCAL C, E
	: assume that v has been constant for a long time
	: (derivable from rate equations in DERIVATIVE block at equilibrium)
	rates(v)
	m = minf(v)
	: h and d are intertwined so more complex than above equilib state for m
	C =  beta_1 / alpha_1
	E =  alpha_2 / beta_2
	h = E / (E * C + E + C)
	d = 1 - (1 + C) * h
	
	phi_m = qm ^ ((celsius-24)/10)
	phi_h = qh ^ ((celsius-24)/10)
}

DERIVATIVE states{ 
	rates(v)
	m' = (minf(v) - m)/taum(v)		: alpham(v) * (1 - m) - betam(v) * m
	h' = alpha_1 * (1 - h - d) - beta_1 * h
	d' =  beta_2 * (1 - h - d) - alpha_2 * d
}

FUNCTION minf(Vm (mV)) (1) {
	minf = 1.0 / (1.0 + exp(-(Vm + V_s + 63)/7.8))
}

FUNCTION taum(Vm (mV)) (ms) {
	taum = ((1.7 + exp( -(Vm + V_s + 28.8)/13.5 )) / (1.0 + exp( -(Vm + V_s + 63)/7.8) )) :/ phi_m
}

PROCEDURE rates(Vm(mV)) { LOCAL tau_2
	k = (0.25 + exp((Vm + V_s + 83.5)/6.3))^0.5 - 0.5
	tau_2 = (240.0 /((1 + exp((Vm + V_s + 37.4)/30)))) :/phi_h : same as tau2 p 842 equation (15)
	alpha_1 = exp( -(Vm + V_s +160.3)/17.8 )	: p 842  equation (14)
	beta_1 = k * alpha_1
	alpha_2 = 1.0 / (( tau_2 * (1.0 + k) ))
	beta_2 = k * alpha_2
}
Note where I've commented out phi_h and phi_m.... with those variables intact, I get the following error occasionally during runs. Any thoughts about what is going on?

Code: Select all

CVode-- At t = 2166.17 and h = 2.832e-05, the corrector
convergence failed repeatedly or with |h| = hmin.

CVode 7c10d8 dend[125] advance_tn failed, err=-7.
err=-7
nrniv: variable step integrator error
 near line 228
 TestDistrib(1)
               ^
fadvance(        )
advance(      )
step(    )
continuerun(3000  )
hines
Site Admin
Posts: 1607
Joined: Wed May 18, 2005 3:32 pm

Re: convergence failed repeatedly: err=-7.

Post by hines »

I'm somewhat disturbed by the diivide by 0 on the first call to INITIAL (phi_h is set after the call to rates which divides by phi_h)
but I don't see how that can cause a convergence error at t=2166... I'd like to reproduce this in the same context you experienced it.
Could you send me a zip file with the neede mod,ses,hoc files to michael dot hines at yale dot edu ? Also let me know which NEURON version
you are using.
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

Re: convergence failed repeatedly: err=-7.

Post by Bill Connelly »

Oh, well that is an obvious mistake. I can report that after fixing that (Setting phi before the call to rates() ), the error has gone away. I'll still send it along to you, just in case you're curious.
Post Reply