Inconsistent units

NMODL and the Channel Builder.
Post Reply
shyam_u2
Posts: 77
Joined: Sun Feb 20, 2011 7:15 pm

Inconsistent units

Post by shyam_u2 »

Hi all,

I have this mod mechanism to compute local oxygen concentration from bath oxygen concentration and from the activity of Nakpumps in neuron and glia. The mod file compiles without any error. However, running this script with modlunit returns a conversion error which I couldn't understand. Any help would be greatly appreciated.

Code: Select all

COMMENT
computation of local tissue oxygen concentration

ENDCOMMENT

NEURON {
	SUFFIX updateo2o
	RANGE o2o
	POINTER ip,igp,rho
}

UNITS {
	(mV) = (millivolt)
	(mA) = (milliamp)
	(molar) = (1/liter)
	(mM) = (millimolar)
	(um)	= (micron)
	:(mg) = (milligram)
	(L) = (liter)
	FARADAY = (faraday) (coulombs)
}

PARAMETER {
	al	= 5.3e-3   (mg/mole)		
	o2     =   12  (mg/L) :Bath oxygen
	delx2 = 10000 (um2)
	D = 1.7 (um2/ms) 
}

ASSIGNED { 
  diam (micron)
  ip (mA/cm2)
  igp (mA/cm2)
  rho (1)

}

INITIAL {

o2o=o2
	
}

STATE {
  o2o (mg/L)
}

BREAKPOINT { 
	SOLVE state METHOD cnexp 
	
}

DERIVATIVE state {
o2o' = al*((1e4)*4*(ip)/(rho*diam*FARADAY)+ (1e4)*4*(igp)/(rho*diam*FARADAY)) + (D/delx2)*(o2-o2o)
	
}
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Inconsistent units

Post by ted »

What is the error message?
shyam_u2
Posts: 77
Joined: Sun Feb 20, 2011 7:15 pm

Re: Inconsistent units

Post by shyam_u2 »

The previous primary expression with units: 1 kg/m3-sec is missing a conversion factor and should read:
(6.02217e+026)*() at line 54 in file updateo2o.mod
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Inconsistent units

Post by ted »

The right hand side of the equation for o2o' is too complex for you to fix all possible units errors at one time.
Deal with one major term at a time. First change
o2o' = al*((1e4)*4*(ip)/(rho*diam*FARADAY)+ (1e4)*4*(igp)/(rho*diam*FARADAY)) + (D/delx2)*(o2-o2o)
to
: o2o' = al*((1e4)*4*(ip)/(rho*diam*FARADAY)+ (1e4)*4*(igp)/(rho*diam*FARADAY)) + (D/delx2)*(o2-o2o)
o2o' = al*((1e4)*4*(ip)/(rho*diam*FARADAY) )
Then check with modlunit. After you have fixed whatever problems there might be, check and fix whatever problems modlunit discovers in
o2o' = al*( (1e4)*4*(igp)/(rho*diam*FARADAY))
After that has been fixed, check and fix whatever problems modlunit discovers in
o2o' = (D/delx2)*(o2-o2o)
Then combine the three fixed terms, including whatever scale factors were needed to pass modlunit's tests, and check again. This time there should be no more problems.
Post Reply