Modlunit:The previous expression is not dimensionless...

NMODL and the Channel Builder.
Post Reply
GTR

Modlunit:The previous expression is not dimensionless...

Post by GTR »

Dear ted,

When I tried to check unit consistency with modlunit in the KDR.mod file below:

Code: Select all

TITLE KDR Potassium Delayed Rectifier

NEURON {
	SUFFIX KDR
	USEION k READ ek WRITE ik
	RANGE gkbar, ik
}
UNITS {
     (mA) = (milliamp)
     (mV) = (millivolt)
     (mS)=(millisiemens)
        }
PARAMETER {
	gkbar=3.84e-3 (mS/cm2) 
	Q10 = 1.2 (1) 
  Q10TEMP = 22 (degC) 

}

STATE {
	n
}

ASSIGNED {
	v (mV)
        ek (mV)
	ik (mA/cm2)
	nalpha
	nbeta (ms)
	celsius (degC) 
  qt (1) 

}

INITIAL {
	settables(v)
        
 qt = Q10^((celsius-Q10TEMP)/10) 

}

BREAKPOINT {
	SOLVE states METHOD cnexp
	ik = gkbar*n*(v - ek)
}

DERIVATIVE states {
	settables(v)
	n'=(nalpha*(1-n))-(nbeta*n)
	}

UNITSOFF

PROCEDURE settables(v(mV)) {
TABLE nalpha,nbeta 
 nalpha=(0.016*(35.1-v))/(exp((35.1-v)/5)-1)
 nbeta=0.25*exp((20-v)/40)
}
UNITSON


I got the following error:

Checking units of ./KDR.mod
1 K
The previous expression is not dimensionless at line 38 in file ./KDR.mod
qt = Q10^((celsius-Q10TEMP)/10) <<ERROR>>


So what about the units of qt?
Do I mislead something from the PROCEDURE section?
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

The error msg only means that the exponent should be dimensionless, but instead has
units of (degC). It doesn't seem to happen under Linux. You can get rid of the error msg
by wrapping UNITSOFF . . . UNITSON around the INITIAL block. Alternatively, you may
be able to eliminate it by changing the expression to

Code: Select all

  qt = Q10^((celsius-Q10TEMP)/10(degC))
(I hope I got this syntax right--maybe there should be a space between the 10 and the
(degC)--can you test and tell me which is correct?). This tells NMODL that 10 also has
the units of (degC), so the quotient is dimensionless.

What I do see under Linux is an error msg about the TABLE statement, which is
incomplete--should look like this

Code: Select all

TABLE nalpha,nbeta FROM -100 TO 100 WITH 200
FYI the units of nalpha and nbeta should be (/ms), not (ms). I don't know why modlunit
didn't complain about n'=... in the DERIVATIVE block.
GTR

Post by GTR »

Dear ted,

You are right.. the quotient should be dimensionless (degC/degC).
I am ashamed of my queries!! I put emhasis on qt as a whole.

Both ways that you suggest either with the space or without it between 10 and (degC eliminate the error msg.
It seems that the compiler is not so sensitive (e.g. need for spaces) when you make modlunit in contrast to mechnrn.dll.

Believe me I had in my code:

Code: Select all

TABLE nalpha,nbeta DEPEND celsius FROM -100 TO 100 WITH 200
but I don't know why my C/P didn't copy it in my topic.
I change units in malpha ,mbeta into (/ms)
Anyway new problem arised.Now I got the error msg:

The previous primary expression with units :0.01 coul/m2-sec
is missing a conversion factor and should read:
(0.001)*()
at line 44 in file ./KDR.mod
ik=gkbar*n*(v-ek)<<ERROR>>


AND SECONDLY:
In a similar check-unit condition in HCN.mod file:

Code: Select all

TITLE HCN channel

NEURON {
	SUFFIX HCN
	 NONSPECIFIC_CURRENT ihcn
	RANGE ghbar, ihcn
	GLOBAL finf,ftau
}

UNITS {
	(mA) = (milliamp)
	(mV) = (millivolt)
         (mS)=(millisiemens)
}

PARAMETER {
	ghbar= 1.01e-3(mS/cm2) 
        Q10 = 2.0 (1) 
  Q10TEMP = 22 (degC) 
}

STATE {
	f
}

ASSIGNED {
	v (mV)
	celsius (degC) 
	ehcn (mV)
	ihcn (mA/cm2)
	finf
	ftau (ms)
        qt (degC) 
	}
UNITSOFF
INITIAL {
	rates(v)
	f = finf
qt = Q10^((celsius-Q10TEMP)/10) 
}
UNITSON
	
BREAKPOINT {
	SOLVE states METHOD cnexp
	ihcn=ghbar*f*(v-ehcn)
}

DERIVATIVE states {
	rates(v)
	f' = (finf - f)/ftau
	
}

UNITSOFF

PROCEDURE rates(v(mV)) {
	TABLE finf, ftau  DEPEND celsius FROM -100 TO 100 WITH 200
	ftau = 1/(exp(-14.59-0.086*v)+exp(-1.87+0.0701*v))
	finf = 1/(1+exp((v+75)/5.5))
}
UNITSON
1) When I wrap UNITSOFF ...UNITSON around HCN's INITIAL block to eliminate the same msg error(dimensionless) I get a new msg error of the same type as above in KDR.mod:

The previous primary expression with units :0.01 coul/m2-sec
is missing a conversion factor and should read:
(0.001)*()
at line 45 in file ./HCN.mod
ihcn=ghbar*f*(v-ehcn)<<ERROR>>


2) when I use the alternative way you suggested ,that is adding (degC) in:

Code: Select all

INITIAL {
.........
qt = Q10^((celsius-Q10TEMP)/10(degC))
} 
I got a different msg error:

units: 1

units: 1 K
The units of the previous two expressions are not conformable
at line 39 in file ./HCN.mod
qt = Q10^((celsius-Q10TEMP)/10(degC))<<ERROR>>


Why this happens with modlunit in HCN.mod file?
Is this due to the fact that in KDR.mod I use alpha and beta functions in contrast with HCN.mod that I use rates?
I face this problem in most of my .mod files where I had implemented temperature dependent rates.I use MSwin.

thank you,
George.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

GTR wrote:I am ashamed of my queries!!
No need for shame. Everybody makes mistakes like this. The important thing is to be
learn what can cause units inconsistencies, how to fix them, and how to tell which
inconsistencies are serious and which can be ignored. This particular one is not
serious in and of itself. However, modlunit quits after discovering the first inconsistency,
so a trivial inconsistency like this can block discovery of a more important one.
new problem arised.Now I got the error msg:

The previous primary expression with units :0.01 coul/m2-sec
is missing a conversion factor and should read:
(0.001)*()
at line 44 in file ./KDR.mod
ik=gkbar*n*(v-ek)<<ERROR>>
Case in point. This units inconsistency was always present--you just couldn't detect
it with modlunit because modlunit quit after it hit the first one.

It's easy to discover the cause of this problem, and even easier to fix it.
ik uses (mA/cm2) and v-ek is in (mV), so gkbar should be in (S/cm2)--but your code
says gkbar is in (mS/cm2). With these units, the right hand side of the equation is 1000
times too big. The fix is to change your code by including a scale factor of 0.001--change
the line to this

Code: Select all

ik=(0.001)*gkbar*n*(v-ek)
Notice that the scale factor is inside a pair of parentheses. This tells modlunit that the
number 0.001 is a scale factor, so when you test the revised file with modlunit, the
error message goes away. Also notice that modlunit told you what was wrong, and
exactly what to do. That's the kind of error message I like to get.
AND SECONDLY:
In a similar check-unit condition in HCN.mod file:
Now you know what to do about this one.
units: 1

units: 1 K
The units of the previous two expressions are not conformable
at line 39 in file ./HCN.mod
qt = Q10^((celsius-Q10TEMP)/10(degC))<<ERROR>>
This time modlunit is telling you that the right and left hand sides of the equation have
different units. Hint 1: check the declarations of qt and Q10. Hint 2: why didn't this error
message happen with KDR.mod?
GTR

Post by GTR »

Dear Ted,

Ok,I noticed the difference.I had declared qt having units in (degC) in HCN.mod while in the other I have stated it as dimensionless in the assigned block.

But I need again your help and I promise you to be the last one.....for modlunits.
I comprehended the need for units consistency between the two sides of current equation that you explained before but where modlunit locates the
problem in SKCa.mod when it tells about 'nonconformability' in these two expressions:

units:0.001 m2-kg/sec2-coul

units:1/m3
indicating:
at line 44 in file ./SKCa.mod
rates<v<<ERROR>>>

Code: Select all

NEURON {
	SUFFIX sKCa
	USEION k READ ek WRITE ik
	USEION ca READ cai
	RANGE w, gk, gbar
	RANGE winf, wtau
	GLOBAL q10, temp, qt
}

UNITS {
	(mA) = (milliamp)
	(mV) = (millivolt)
	(mS) = (millisiemens)
        (molar) = (1/liter)
        (mM)=(millimolar)
	
} 

PARAMETER {
	gbar =6.84e-5  	(mS/cm2)
	v 		(mV)
	celsius		(degC)
	temp = 23	(degC)		: original temp 	
	q10  = 1.5			: temperature sensitivity
        cai  		(mM)
} 


ASSIGNED {
	
	ik 		(mA/cm2)
	gk		(mS/cm2)
	ek		(mV)
	winf
	wtau 		(ms)
        qt(1)	
	z                (/ms)
}
 

STATE { w }

INITIAL { 
	rates(v)
	w = winf
}

BREAKPOINT {
        SOLVE states METHOD cnexp
	gk = gbar*w
	ik = (1e-3) * gk * (v - ek)
} 

LOCAL nexp

DERIVATIVE states {   :Computes state variable n 
        rates(v)      :             at the current v and dt.
        w' =  (winf-w)/wtau

}

PROCEDURE rates(cai(mM)) {  
        qt = q10^((celsius - temp)/10)
        z=exp(-log(cai)+0.3)  
        wtau =40
	winf =0.81/((1+z)/0.46)

 }      
regards.
George.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

The procedure declaration starts with
PROCEDURE rates(cai(mM))
but you're calling it as rates(v). There are multiple mistakes here. For one thing, rates()
doesn't even need an argument--it knows the value of cai without having to be told.
Post Reply