nmodl icon indicating copy to clipboard operation
nmodl copied to clipboard

NMODL throws for `x' = 1/x`.

Open 1uc opened this issue 2 years ago • 1 comments

I tried compiling the following mod file:

NEURON {
    SUFFIX leonhard
}

STATE {
 x
}

INITIAL {
  x = 42
}

BREAKPOINT {
    SOLVE dX METHOD cnexp
}

DERIVATIVE dX {
 x' = 1.0/x
}

It fails with:

terminate called after throwing an instance of 'std::runtime_error'
  what():  PRIME encountered during code generation, ODEs not solved?
make: *** [makemod2c_inc:3: leonhard.cpp] Error 134
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
  File "/home/lucg/git/bbp/nmodl/venv/bin/nrnivmodl", line 115, in <module>
    subprocess.check_call([exe, *sys.argv[1:]])
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/lucg/git/bbp/nmodl/venv/lib/python3.11/site-packages/neuron/.data/bin/nrnivmodl', '-nmodl', 'nmodl', 'leonhard.mod']' returned non-zero exit status 2.

indicating that NMODL is unable to solve the ODE, and fails to generate the code required to solve the ODE approximately. Similar for x' = sin(x*x).

1uc avatar Dec 18 '23 15:12 1uc

The behaviour of nrnivmodl is to generate code that solves the ODE via a numerical solver.

1uc avatar Dec 18 '23 15:12 1uc