0. Unless you are already a professional programmer, start reading this article
Wilson et al. Best practices for scientific computing. PLoS Biol, 12, e1001745, 2014, pmid 24415924.
Don't expect to understand everything the first time through. You'll want to keep a copy handy and review it from time to time.
1. Organize your modeling projects into directories. This will make project management much easier. Put all the mod files you need for a particular project in the same directory as the hoc and ses files that need them, and run mknrndll (nrnivmodl for UNIX/Linux users) to compile the mod files. Then make a plain text file called init.hoc, which contains just this line
and put it in the same directory. Under MSWin, use the file browser (they call it Windows Explorer to confuse people), double click on init.hoc, and NEURON will start and automatically load your compiled mechanisms (UNIX/Linux users should just type
at the system prompt in an xterm).
After you have built your custom GUI (CellBuilder, RunControl, PointProcessManagers, Graphs etc.), save everything to a session by clicking on NEURON Main Menu / File / save session. Then edit init.hoc and change it to
load_file("nrngui.hoc") load_file("mysesfile.ses") // or whatever you called the session file
The next time you double click on init.hoc (or type nrngui init.hoc), the mechanisms will be loaded and your custom user interface and model will pop up.
2. As much as possible, use the GUI to specify model properties and control simulations.
3. Whether using the GUI, writing hoc code, or combining the two, it is best to start small and simple. Increase program size and complexity incrementally, and test after every change.
4. Use the d_lambda rule (selectable from the Cell Builder at the click of a button, but also usable from hoc--see the FAQ list) to specify spatial discretization.
5. If it is ever necessary to write hoc code, structure your program as follows:
load_file("nrngui.hoc") specify model topology (create sections, connect sections) specify model geometry (stylized (L, diam) or pt3d method as appropriate) specify instrumentation (IClamps, SEClamps, other Point Processes, graphs) specify simulation flow control (RunControl panel is sufficient for most purposes)
6. Avoid load_proc()--it's very slow under MSWin, so unless you swear never to use MSWin or exchange code with MSWin users, it's more bother than it's worth.
7. Avoid writing your own "main computational loop" (i.e. a "for" or "while" loop that calls fadvance() to march the simulation through time). Use the standard run system's run() to launch simulations.
8. Use topology(), psection(), and especially the GUI's Model View tool to discover what is actually in a model and verify a close match between the model in the computer and the model in your mind. Especially if there is a mismatch between what the model does and what you expected it to do.