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

## order in the solution vector CVODE operates with

### Re: order in the solution vector CVODE operates with

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.

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.

### Re: order in the solution vector CVODE operates with

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.

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.

### Re: order in the solution vector CVODE operates with

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.

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.

### Re: order in the solution vector CVODE operates with

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.

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.