borismarin / som-codegen

dLEMS - a distilled version of the Low Entropy Model Specification language used to generate code for numerical integrators.
1 stars 0 forks source link

Limits on gating variables #3

Open robertcannon opened 11 years ago

robertcannon commented 11 years ago

Hi Boris, I saw your note about imposing limits when integrating HH equations with gating variables between 0 and 1. One useful way round this is a change of variables so that instead of 0 < m < 1, the state variable is x where -inf < x < inf and m = exp(x)/(1+ exp(x)).

Then instead of dm/dt = rf * (1 - m) - rr * m you have: dx/dt = (1 + exp(x))^2 / exp(x) * (rf * (1 - m) - rr * m)

This behaves much better with simple integration schemes.

borismarin commented 11 years ago

Thanks @robertcannon ! I wonder which amount of preparsing/optimizations we should apply to expressions in this distilled Lems format; most of my initial experiments involved using a CAS (sympy/symja) to parse math, which allowed for simplifications/facilitated manipulation at the expense of direct correspondence to Lems. Since I am mostly concerned with fancy libraries for integrating ODEs, it would probably be a good idea to preprocess the dynamics and get the most out of numerical integrators.