Page 1 of 1

replace i_cap/modify equation for i_cap

Posted: Wed Sep 17, 2014 11:14 am
by leonelmd
I want to implement a special "capacitive" current described by the ODE: i_capn + di_capn/dt = Cdv/dt. I want this current to actually replace the capacitive current.

I saw in this thread that a way to obtain dv/dt (which I need for the ODE in my NMODL file) is via the capacitive current: dv/dt=i_cap/cm ... =16&t=2146

However, since in my case I'm replacing i_cap with i_capn I was setting cm=0 so that i_cap=0. So my question is: is there another way to obtain dv/dt? Perhaps I could set cm=1e=9 (so that i_cap is negligible), but is i_cap/cm a good estimation of dv/dt in this case? Or perhaps I should go to the source and try to modify the ODE for i_cap?

Thanks a lot in advance.

Re: replace i_cap/modify equation for i_cap

Posted: Thu Sep 18, 2014 8:47 am
by hines
Without, perhaps, understanding all of your context, I wonder if you would be happy to replace the membrane capacitance with a linear circuit that you define.
For example, instead of a pure capacitance, three capacitors in parallel each with a different series resistance. You can even put a 0 voltage battery into the
circuit so that you can observe the net capacity current. Anyway, when the linear circuit is developed it can be saved as a class and then instantiated at
every segment where you want to have the more elaborate membrane capacitance model.

Re: replace i_cap/modify equation for i_cap

Posted: Fri Sep 19, 2014 11:30 am
by leonelmd
Thanks for your reply, Michael.
The linear circuit idea makes me very happy indeed :) since I wanted to test other ODE's as well, for which I'd just need to figure out the equivalent circuit. However, I'm not able to save a class from any circuit. I know this sounds silly but I can't find the "Create Class" button that you mentioned in this thread: ... ism#p12814
I use Windows 7, and I checked in v7.2 and v7.3. Is the button available in a different version or OS?
Thank you

Re: replace i_cap/modify equation for i_cap

Posted: Fri Sep 19, 2014 11:45 pm
by ted
"Create class" was added August 25, 2013 ... bbc306cf50
Development code or alpha versions released after that date should have it. Its visible manifestations are the "Create class" button on the LinearCircuit tool's "Parameters" page, and the text in the "LinearCircuit Parameters Hints" panel which is brought up by clicking on that page's Hints button.

Re: replace i_cap/modify equation for i_cap

Posted: Sat Sep 20, 2014 3:39 am
by hines
I can also say that you can add the feature without uninstalling by replacing the files in nrn/lib/hoc/celbild with the latest hg repository versions of those
hoc files. The reason I mention this is because I'm presently suffering several administrative problems in regard to preparing new distributions for mswin which
I hope to be able to overcome in the next several weeks. The repository code is at ... oc/celbild

Re: replace i_cap/modify equation for i_cap

Posted: Sat Sep 20, 2014 1:55 pm
by ted
Maybe you meant the files in nrn/lib/hoc/lincir/ ... hoc/lincir

Re: replace i_cap/modify equation for i_cap

Posted: Sun Sep 21, 2014 3:21 am
by hines
oops. Yes of course. lincir not celbild. Glad you noticed the error.

Re: replace i_cap/modify equation for i_cap

Posted: Thu Sep 25, 2014 12:23 pm
by leonelmd
Thank you so much for your responses, Michael and Ted.

It was really helpful seeing the .hoc template that the LCB generates. In fact, the ODE that I first mentioned can be represented as a series RC, and I used the LCB template to then move to working directly with the LinearMechanism.

Though I have a running implementation that matches what I get in a Matlab implementation, I'm trying to understand what the LinearMechanism does. If I define:

_n = 2
_c = new Matrix(_n,_n,2)
_g = new Matrix(_n,_n,2)

_c.x[0][0] = C
_c.x[0][1] = -C
_c.x[1][0] = C
_c.x[1][1] = -C

_g.x[1][1] = -1/R


_lm = new LinearMechanism(_c, _g, _y, _y0, _b, 0.5)

Then the equations would be (vm the transmembrane potential where I'm coupling this linear mechanism, v2 an auxiliary variable representing the potential at the RC node in my circuit model):
C(vm-v2)' = 0
C(vm-v2)' -1/R v2 = 0

The second equation is easy to interpret. But the first equation, which is coupled to the system, is not totally clear to me since the RHS is zero. Is the LHS of the equation a current that is balanced with the membrane current and so not necessarily zero? And how is the sign convention (if I replace C with -C in this equation I don't get the same results as in Matlab)? Further, suppose I add extracellular mechanism so that I want the R end of my circuit model connected to vext. Then the current balance equation would be -(v2-vext)/R, but again I'm not sure how the sign convention is (opposite sign inconsistent with Matlab implementation).

Thank you!

Re: replace i_cap/modify equation for i_cap

Posted: Thu Sep 25, 2014 2:47 pm
by hines ... inmod.html
gives some details about how the LinearMechanism adds terms to the normal internal current balance equations.