Crank's book is indeed excellent.
I hope these somewhat belated comments add more light than heat.
Remarks about accumulation mechanisms
Be sure to read the article about NMODL that Raj mentioned. With regard
to ion accumulation mechanisms, this is quite similar to the material in
chapter 9 of The NEURON Book.
Initialization of accumulation mechanisms presents a special challenge.
Incorrect initialization can lead to undesired results, such as slow shifts
of concentrations that require prolonged simulations for transients to die
away. Chapter 8 of The NEURON Book contains much useful information
about initialization of accumulation mechanisms that can make such
models much easier to implement and debug.
Kinetic scheme representation is most natural, i.e. easiest to conceptualize
and implement. DEs should be used only for the very simplest
accumulation mechanisms. Anything that involves radial diffusion,
multiple buffers, or organelles, will be much easier to express in terms
of kinetic schemes rather than DEs.
Multiple mechanisms can assert
USEION x . . . WRITE ix
(this ensures conservation of mass when there are multiple sources of
transmembrane ionic flux). However, only one mechanism is allowed to
WRITE the corresponding concentration xi or xo.
Integration methods
NEVER euler. NEVER. You will find legacy code with BREAKPOINT blocks
that assert
SOLVE foo METHOD euler
and they may seem to work, but this is asking for trouble. Just because
it's in ModelDB doesn't mean that it's the right thing to do. Doesn't matter
who it was who wrote it, they shouldn't have, and neither should you.
No new code should be written that uses euler.
Linear ODEs use cnexp.
Nonlinear ODEs and simple ion accumulation (a la cacum.mod in
examples) should use derivimplicit.
Kinetic schemes use sparse.
Where to look for examples of working NMODL code
1. Chapter 9 of The NEURON Book.
2. Hines, M.L. and Carnevale, N.T. Expanding NEURON's repertoire of
mechanisms with NMODL. Neural Computation 12:995-1007, 2000.
Downloadable from
http://www.neuron.yale.edu/neuron/nrnpubs
3. c:\nrnxx\examples\nrniv\nmodl (MSWin) or the corresponding
examples/nrniv/nmodl that UNIX/Linux/OS X users can find in the
gzipped tar sources for NEURON
4. ModelDB, with the following caveat.
General caveat about ModelDB entries
This should not be taken as a criticism of any particular model mentioned
in this thread.
The presence of a model entry in ModelDB means two things: the model
was described in a published paper, and either (a) the authors provided
the source code they used or (b) somebody else developed a
computational implementation of their own.
It should always be kept in mind that the presence of a model entry in
ModelDB should not be regarded as an endorsement of the source code's
"correctness" or programming style. There are many examples of
excellent programming in ModelDB, but also many examples that are
mediocre or worse. Also, many that are otherwise excellent fall into the
category of "legacy code" because of the use of obsolete or deprecated
features of their respective programming languages or simulation
environments.