order in the solution vector CVODE operates with

Anything that doesn't fit elsewhere.
Post Reply
brocke
Posts: 11
Joined: Fri Aug 16, 2013 9:21 am

order in the solution vector CVODE operates with

Post by brocke »

Hi,

is there an appropriate way or interface how to dissect the solution vector y into voltages and conductance from the CVODE part of the code ?
For instance, in the CVodeMalloc the Y0 is given as one state vector. Is there a specific order how the state variables (in particular voltages and channel states) are stored in this vector?

Do I understand it correct that once the solution vector is split, the derivative function (that CVRhsFn cv_f) will take responsibility to calculate/call corresponding odes?

thank you in advance,
e.brocke
brocke
Posts: 11
Joined: Fri Aug 16, 2013 9:21 am

Re: order in the solution vector CVODE operates with

Post by brocke »

Let me try to answer myself in case someone needs. I apologize if information is incorrect or not precise.

It seems like the solution vector has some order of the kind [voltage,gates,..].
The number of voltage variables can be retrieved from CvodeThreadData class, field name: v_node_count_.

About the second part of the question, I am not fully sure yet. The ode functions are setup in the nrncvode/cvodeobj.cpp in NetCvode::set_CVRhsFn(). But it seems to me that it will be messed up once the function is called with a subset of state variables (i.e. only voltages). Most likely it should be done in a different way.
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: order in the solution vector CVODE operates with

Post by hines »

From HOC (or Python) see
https://www.neuron.yale.edu/neuron/stat ... .statename
as well as the states and dstates methods. The number of statenames is the size of the vector returned by cvode.dstates(dest_vector)

With regard to the second question, I'm not sure what you mean by "once the solution vector is split". But
https://www.neuron.yale.edu/neuron/stat ... ml#CVode.f
will calculate dstates given a set of states and t.
brocke
Posts: 11
Joined: Fri Aug 16, 2013 9:21 am

Re: order in the solution vector CVODE operates with

Post by brocke »

Michael, thank you for an answer.

The size of the input vector for the f function should be equal to the number of all state variables in the system. This is how I understand from the documentation. My intention is to be able to operate ( or to call f function for example) voltage variables separately from the channel state variables. As I understand it correct the default linear solver solves voltages and conductances separately, right? For the former it takes advantage of the special structure of the branched cable eq. and for the latter I am not quite sure, does it compute Jacobian in the adaptive step size integration? The question is if there is a way to separate voltage and conductance integration from the user perspective or not going deeply into the code?
I hope my explanation is not that confusing.

thank you.
hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: order in the solution vector CVODE operates with

Post by hines »

Yes, the linear solver handles M*x = b where b is supplied by cvode and x replaces b on return and M is an approximate jacobian distributed throughout the internal neuron code and mod files
which nevertheless is good enough for fast convergence and stability of cvode iterations with respect
to finding a y(t+dt) that satisfies the error tolerance. As you surmized, the the current balance equation part of M is done separately from all the state variables in all the mod files.
All mod files have a function called ode_matsol that solves their portion of the M*x = b problem. In fact that portion by default is a diagonal jacobian approximation so for hh it is only
rates ( _threadargscomma_ v ) ;
Dm = Dm / (1. - dt*( ( ( ( - 1.0 ) ) ) / mtau )) ;
Dh = Dh / (1. - dt*( ( ( ( - 1.0 ) ) ) / htau )) ;
Dn = Dn / (1. - dt*( ( ( ( - 1.0 ) ) ) / ntau )) ;
return 0;
where on entry Dm, etc are the scattered b values,and after exit they are gathered back into b.
Post Reply