Next: Tabulated Calculations Up: Introducing Hsolve for Single Previous: Basic Use: A short Contents

# The `chanmode` Field: Modes of Operation

In the previous example we have seen a basic example of how to setup `hsolve` and configure it to simulate a model represented by two compartments. How is this related to the mathematics we discussed earlier on ? Which numerical scheme was used for the cable equation and which numerical scheme was used for channels ? These questions are answered by inspecting the `chanmode` field. Basically you have to make a major distinction between the lower chanmodes (chanmode 0 and 1) and the higher chanmodes (chanmode 2 to 5). The lower chanmodes are modes intended for compatibility with other Genesis objects and they are slow compared to the higher chanmodes. `Hsolve` will automatically update all the computed fields in the original elements, such as to create the illusion that the original elements still perform their own computations. The updated fields are then available for plotting or for other elements to do additional calculations.

1. chanmode 0 (default): `hsolve` computes the cable equation only (i.e. `hsolve` does the computations of the compartments). All the other elements (Hodgkin-Huxley channels, concentration elements) still do their own calculations. Since `hsolve` does not compute the channel equations, the channel rates are updated at time points independent of update times of the membrane potential. This loss of second-order accuracy results in the penalty of having to use a small time step.

   To communicate variables to/from other elements, `hsolve` uses the message system of Genesis. This makes the chanmode 0 the most compatible mode of operation and it is recommended for people that have developed their own set of custom objects.

2. chanmode 1: hsolve computes the cable equations and the `tabchannel` elements inside the compartments with a staggered time grid. This results in some extra performance but is not completely compatible with all types of setup. More precisely, incoming and outgoing messages for the tabulated channels are ignored, except for the messages that link the channels to the compartments (`CHANNEL`, `VOLTAGE`), single messages coming from a `nernst` element (`EK`) and a single message that is linked with the Z gate (`CONCEN`). If your model contains only tabulated channels, all conductances will be calculated by `hsolve` at time points between the updates of the membrane potential. This maintains the second-order accuracy and thus you can use a larger time step.

   To use chanmode 1 in the previous example, you configure `hsolve` with the following command:

          genesis > setfield solver path "../##[][TYPE=compartment]" chanmode 1

NOTE: The compartmental `Im` field is only computed by `hsolve` running in chanmode 0 or 1 if you turn on the field '`computeIm`'. Calculation of the `Im` field incurs a small performance penalty.

When using the higher chanmodes, `hsolve` will compile all elements that belong to your model to byte-codes. During the simulation these byte-codes are emulated which results in a high performance (the higher chanmodes can be 5-10 times faster than the lower chanmodes, depending on the model structure). To be able to compile an element into byte-codes, `hsolve` must be aware of the element type (the Genesis object) and its computations. The objects `hsolve` is able to compile to byte-codes, are documented in the Genesis manuals.

The higher chanmodes all share the property that `hsolve` computes all the elements present in your model on the staggered time grid, so this guarantees second-order accuracy under all circumstances. A single time step in the simulation will compute the membrane potential at the simulated time after an update of the conductance at an intermediate time point.

In most cases the original elements' fields will not be updated. For `hsolve` the elements only serve as a description of the model to be computed, so we call these elements modeling elements. To inspect calculated values, they have to be fetched with the `findsolvefield` command. We will show examples of the use of this command shortly. The difference between the different chanmodes lies in the fact that some fields might not be computed and are not accessible - even with the `findsolvefield` command - as explained in the following:

1. chanmode 2: The compartmental voltage is stored in the respective fields of the original compartments. Other fields like channel gates are accessible via the `findsolvefield` command. The channel parameters `Gk`, `Ik`, `Ek` and the compartmental membrane current `Im` are not stored by `hsolve`. At every time step of the simulation, `hsolve` will update the membrane potential of the original compartments (that serve as the model) with the computed membrane potential. If you are only interested in membrane potentials, this mode will be handy. Outgoing messages to non computed elements that are created before the `SETUP` call are not supported in this mode.
2. chanmode 3: This is exactly the same as chanmode 2, except that the compartments' `Vm` field is not updated. The membrane potential is only accessible via the `findsolvefield` command.
3. chanmode 4: As in chanmode 3, none of the fields of the modeling elements will be updated, but in this chanmode all fields are accessible with the `findsolvefield` command (including the channel parameters `Gk`, `Ik`, `Ek` and the compartmental `Im` field).
4. chanmode 5: This chanmode is as chanmode 4 (all fields are stored), but the channel parameters `Gk`, `Ik` and `Ek` and the compartmental membrane current `Im` are calculated as relative values (normalized to the compartment surface).

Next: Tabulated Calculations Up: Introducing Hsolve for Single Previous: Basic Use: A short Contents