: simple first-order model of potassium dynamics
: from Durstewitz & Gabriel (2006), Cerebral Cortex

NEURON {
        SUFFIX kdyn
        USEION k READ ko,ik WRITE ko 
        RANGE ko
}

UNITS {
        (mM) = (milli/liter)
        (mA) = (milliamp)
        F    = (faraday) (coul)
}

PARAMETER {
        tck    = 7   (ms)           : decay time constant
        koinf = 3.82 	(mM)      : equilibrium k+ concentration
	kiinf = 140     (mM)	  :
        dep   = 70e-3 (micron)     : depth of shell for k+ diffusion
	KAF   = 2 ()		  : K accumulation factor
}

ASSIGNED {
        ik     (mA/cm2)
}

INITIAL {
	ko=koinf
}

STATE { ko (mM) }

BREAKPOINT { 
        SOLVE states METHOD derivimplicit
}

DERIVATIVE states {
        ko'= 1e4*KAF*ik/(F*dep) + (koinf-ko)/tck
}