Skip to content

NMODL's integrate2c generates a solution containing the unimplemented LambertW function #3579

@JCGoran

Description

@JCGoran

Context

The integrate2c function is used for solving ODEs when the method is set to cnexp.

Overview of the issue

The following code (ODE taken from this model):

from neuron.nmodl.ode import integrate2c
integrate2c("dop' = -vmax/((km/dop)+1)", "dt", {"vmax", "km"})

returns:

'dop = km*LambertW(dop*exp((dop - dt*vmax)/km)/km)'

which contains the Lambert W function, that has no implementation in C/C++, and hence compilation of the resulting output file with a C++ compiler fails.

Expected result/behavior

We have a couple of options here:

  1. modify the model which uses this ODE to use the derivimplicit solver instead of the cnexp one. Note that this only solves the problem for that model
  2. the integrate2c function also has a section that uses the Pade approximant to evaluate the RHS numerically, so we can use that. Not sure whether there is any impact on the accuracy though, so we can probably provide a warning-level notification to the user about this
  3. give up on this ODE and throw an error informing the user they should select another method for solving this particular ODE

UPDATE: NOCMODL converts the cnexp solver into derivimplicit:

Could not translate using cnexp method; using derivimplicit

so we should match the behavior.

Minimal working example - MWE

  • build NEURON with NRN_ENABLE_NMODL=ON. Note that you may need to use this branch of NEURON
  • obtain the model linked above
  • run nrnivmodl dop.mod

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions