Thanks so much for this solution now the connection works well.
Next i set the NODEA and NODEB of the children using GETA and SETA in the branching.mod file as you recommended.
I am having difficulties now setting NODEA and NODEB of the Exts' nodes appropriately.
If i dont touch them they get a very large value since they have zero area and ressistance.
But i am not sure what value should i give them so they would result in 0 current.
Looking at triang and bksub in solve.c i thought that setting them to zero or to a very large number would result with NODERHS=0 but probably this is not the case.
Anyhow when i set them to zero fmatrix shows the updated values but after fcurrent the old values return. so i still cannot get the simulation to run as if there was no splitting.
I am attaching the relevant code
Thanks again for your time!
hoc file
Code: Select all
objref somaref,secref,extVec,strFunc,stim,g1,most
load_file("./sp.hoc")
most = new SectionList()
forall most.append()
strFunc = new StringFunctions()
create Exts[1]
proc hinesDisperseBranching(){local i localobj sl,secRef, clist, avec, bvec
counter = 0
forsec most{
secRef = new SectionRef()
if(secRef.nchild>2){
clist = new List()
for i=0, secRef.nchild-1 {
secRef.child[i] clist.append(new SectionRef())
}
Exts[counter]{
L = 1e-9
diam = 1
Ra = 1e-9
cm = 1e-9
nseg = secRef.nchild-1
}
i=0
Exts[counter]{
for(x){
if (x > 0) {
avec =new Vector()
bvec =new Vector()
printf("x is %f i is %d\n",x,i)
clist.o(i).sec{
avec =new Vector()
bvec =new Vector()
for(y){
avec.append(GetA(y))
bvec.append(GetB(y))
}
}
connect clist.o(i).sec(0), x
k=0
clist.o(i).sec{
for(y){
SetA(y,avec.x(k))
SetB(y,bvec.x(k))
}
}
i +=1
}
}
}
fcurrent()
secRef {
connect Exts[counter](0), 1
}
Exts[counter]{
for(x){
printf("x is %f and sec is %s\n",x,secname())
SetA(x,0)
SetB(x,0)
}
}
counter+=1
}
}
}
proc countExts(){
ext_num=0
forsec most {
somaref= new SectionRef()
if (somaref.nchild>2){
ext_num+=1
}
}
}
countExts()
printf("Creating Exts %d\n",ext_num)
fcurrent()
fmatrix()
create Exts[ext_num]
hinesDisperseBranching()
fmatrix()
access soma
stim = new IClamp(0.5)
stim.del=10
stim.dur=100
stim.amp = 1
finitialize(-65)
tstop=300
g1 = new Graph()
g1.beginline()
forsec "soma"{
insert hh
gnabar_hh = 2*gnabar_hh
}
forsec "apic"{
insert hh
}
forsec "dend"{
insert hh
}
while(t<tstop){
fadvance()
g1.line(t,v(0.5))
}
mod file
Code: Select all
COMMENT
ENDCOMMENT
NEURON { SUFFIX nothing }
VERBATIM
char* secname();
ENDVERBATIM
PROCEDURE init_files(){
VERBATIM {
}
ENDVERBATIM
}
FUNCTION GetA(x) {
VERBATIM {
#if defined(t)
_NrnThread* _nt = nrn_threads;
#endif
Section* sec;
Node* nd;
sec = chk_access();
if (_lx < 0. || _lx > 1.) {
printf("_lx is %f and _lx*(double)(sec->nnode-1) is %f\n",_lx,_lx*(double)(sec->nnode-1));
hoc_execerror("out of range, must be 0 < x <= 1", (char*)0);
}
if (_lx == 1.) {
nd = sec->pnode[sec->nnode-1];
}else{
nd = sec->pnode[(int) (_lx*(double)(sec->nnode-1))];
}
return NODEA(nd);
}
ENDVERBATIM
}
FUNCTION GetB(x) {
VERBATIM {
#if defined(t)
_NrnThread* _nt = nrn_threads;
#endif
Section* sec;
Node* nd;
sec = chk_access();
if (_lx < 0. || _lx > 1.) {
printf("_lx is %f and _lx*(double)(sec->nnode-1) is %f\n",_lx,_lx*(double)(sec->nnode-1));
hoc_execerror("out of range, must be 0 < x <= 1", (char*)0);
}
if (_lx == 1.) {
nd = sec->pnode[sec->nnode-1];
}else{
nd = sec->pnode[(int) (_lx*(double)(sec->nnode-1))];
}
return NODEB(nd);
}
ENDVERBATIM
}
FUNCTION SetA(x,a) {
VERBATIM {
#if defined(t)
_NrnThread* _nt = nrn_threads;
#endif
Section* sec;
Node* nd;
sec = chk_access();
if (_lx < 0. || _lx > 1.) {
hoc_execerror("out of range, must be 0 < x <= 1", (char*)0);
}
if (_lx == 1.) {
nd = sec->pnode[sec->nnode-1];
}else{
nd = sec->pnode[(int) (_lx*(double)(sec->nnode-1))];
}
printf("index is %d,NODEA(nd) is %f _la is %f\n",nd->v_node_index,NODEA(nd),_la);
NODEA(nd) = _la;
}
ENDVERBATIM
}
FUNCTION SetB(x,b) {
VERBATIM {
#if defined(t)
_NrnThread* _nt = nrn_threads;
#endif
Section* sec;
Node* nd;
sec = chk_access();
if (_lx < 0. || _lx > 1.) {
hoc_execerror("out of range, must be 0 < x <= 1", (char*)0);
}
if (_lx == 1.) {
nd = sec->pnode[sec->nnode-1];
}else{
nd = sec->pnode[(int) (_lx*(double)(sec->nnode-1))];
}
printf("index is %d,NODEB(nd) is %f _lb is %f\n",nd->v_node_index,NODEB(nd),_lb);
NODEB(nd) = _lb;
}
ENDVERBATIM
}
PROCEDURE MyPrintMatrix() {
VERBATIM {
Section* sec;
FILE* fm;
fm= fopen("C:\fmatrix.dat", "wb");
Node* nd;
int ii;
#if defined(t)
_NrnThread* _nt = nrn_threads;
#endif
for(ii=0;ii<_nt->end;ii++){
nd=_nt->_v_node[ii];
printf("%d %1.15f %1.15f %1.15f %1.15f\n", ii, NODEB(nd), NODEA(nd), NODED(nd), NODERHS(nd));
}
}
ENDVERBATIM
}
PROCEDURE MyTopology() {
VERBATIM {
int ii;
#if defined(t)
_NrnThread* _nt = nrn_threads;
#endif
for(ii=0;ii<_nt->end;ii++){
printf("%d %d\n", ii, _nt->_v_parent_index[ii]);
}
}
ENDVERBATIM
}