Segfault when running serval simulations in a row

When Python is the interpreter, what is a good
design for the interface to the basic NEURON

Moderator: hines

Post Reply
Posts: 1
Joined: Thu May 06, 2010 10:25 am

Segfault when running serval simulations in a row

Post by jere19 »

I've written a python function to simulate the effect of extracellular stimulation on an axon.
If i call the function once, there's no problem. But if i call it again it fails with a segmentation fault and no other message.
I tried to use Python debugger but i didn't get more info.
All i could identify is that it seems to come from the initialization. I think i'm doing something wrong, but i can't see what.

Here are the files :
- the function itself :
- a simple test file calling it :

I'd really appreciate if someone could point me in the right direction.

Site Admin
Posts: 5795
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Segfault when running serval simulations in a row

Post by ted »

Your program is written in such a way that each call to pyAxon.simulation() tries to recreate the model axon, but without destroying the sections that already exist. It is possible to write code that does this properly, but at the cost of increased--and for your purpose, probably unwarranted--complexity. It is best to follow the KISS principle. Instead of stuffing nearly everything into a single procedure, reorganize the code in a more modular way. Specifically, separate it into the following blocks:
specification of biology
specification of instrumentation (stimulation, vector recording)
specification of simulation flow control
where the implementational details of each block depend on how you want each run to differ from its predecessors. For example, if you want to change stimulus parameters between runs (magnitude, time course, or spatial distribution), the "specification of instrumentation" block would contain procedures for adjusting the stimulus. And if you want to change diameters or channel densities between runs, the "specification of biology" would contain one or more procedures that can be called with arguments to adjust the corresponding model parameters. But the code that actually creates individual sections is called only once, during model setup.

The "specification of simulation flow control" would then be one or more procedures with nested "for" loops or iterators that accomplish the following:

Code: Select all

for each parameter combination of interest
  run a simulation and save results
Post Reply