Page 1 of 1

Segfault when running serval simulations in a row

Posted: Thu May 06, 2010 10:38 am
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.


Re: Segfault when running serval simulations in a row

Posted: Mon May 10, 2010 12:20 pm
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