Page 1 of 1

problem with nseg

Posted: Tue Jan 25, 2011 8:09 am
by cwei_h
Greetings, I have the following coding problem,

Code: Select all

 
create PRE
access PRE
insert mechA  #a distributed process, containing variable V
PRE.L = 25
PRE.diam = 25

create POST
access POST
insert mechB  #another distributed process, contains  POINTER P, pointing to V
POST.L = 25
POST.diam =25
POST.nseg = 1
gbar_mechB = 0.001
setpointer POST.P_mechB(0.5), PRE.V_mechA(0.5)

objref ic
PRE ic = new IClamp(0.5)
ic.del = 5
ic.amp = 0.01
ic.dur = 50
tstop = 100
init()
run()
 
The above works fine. Problem occurs when nseg of POST is changed to 2 or more, then NEURON gives me Segmentation violation error:

run()
^
fadvance()
advance()
step()
continuerun(300)
and others

What is the cause of this error? I would like to understand this because eventually i would like to have many segments, each with a different gbar_mechB value.

Re: problem with nseg

Posted: Tue Jan 25, 2011 1:07 pm
by ted
cwei_h wrote:Problem occurs when nseg of POST is changed to 2 or more, then NEURON gives me Segmentation violation error
. . .
What is the cause of this error?
Each instance of mechB has its own POINTER variable, and setpointer must be executed for each instance. After specifying nseg in the section that contains mechB, execute a setpointer statement for each segment in that section. Example:

Code: Select all

POST nseg = 3
POST for (x,0) setpointer POST.P_mechB(x), PRE.V_mechA(0.5)
Unrelated comments:
1. It is best for nseg to be an odd number. See NEURON's FAQ list for more information. http://www.neuron.yale.edu/neuron/faq/general-questions
2. Use "access" only once. See the "Hot tips" area of The NEURON Forum for explanation.

Re: problem with nseg

Posted: Tue Jan 25, 2011 8:58 pm
by cwei_h
Ah, I tried this

Code: Select all

POST nseg = 3
POST for (x,0) setpointer POST.P_mechB(x), PRE.V_mechA(0.5)
but it didnt work. However, it did work after i used 'access' only once. (maybe i also changed something but i didnt realise it)
Anyhow, your explanation was very helpful. thank you very much, I greatly appreciate it!