HH#

class braincell.channel.HH(size, name=None)[source]#

HH gate dynamics with per-gate auto-detected form.

For each gate g exactly one of the following method pairs must exist:

  • f_<g>_inf and f_<g>_tau

  • f_<g>_alpha and f_<g>_beta

HH is the gating-only half of the template layer: it declares gates, resolves and validates them once at subclass-creation time, and implements state initialisation, the conductance product, and the Hodgkin-Huxley derivative from whichever form each gate declares. It does not implement a current – OhmicHH adds the ohmic driving force for the common case, while channels with a non-ohmic current (GHK flux, permeability-scaled calcium channels) subclass HH directly and implement current() themselves.

See also

OhmicHH

Adds an ohmic driving force on top of this gating template.

Gate

Per-gate metadata consumed by gates.

Markov

Sibling template for probability-state (non-HH) kinetics.

Notes

__init_subclass__ resolves and validates gates once, when the subclass is created, rather than lazily at reset_state time. A subclass that declares no gates – HH itself, OhmicHH, or any other abstract intermediate – is skipped by this validation, so such classes stay definable without a concrete gate set.

Variables:
  • gates (tuple of Gate or tuple) – Class-level declaration of the gates a subclass defines. Each entry is either a Gate or the plain tuple of its fields. Set by the subclass; read by __init_subclass__.

  • _resolved_gates (tuple of Gate) – gates normalised to Gate instances. Derived by __init_subclass__; a subclass never sets this directly, but _iter_gates() and every gate-driven method read it.

  • _gate_forms (dict of str to str) – Maps each gate name to "inf_tau" or "alpha_beta", the form detected for it. Derived alongside _resolved_gates and read by _gate_form() to route state init, reset, and the derivative.

compute_derivative(V, *ions)[source]#

Compute the derivative of the channel’s state variables.

This method should be implemented by subclasses to calculate how the channel’s state changes over time.

Parameters:
  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

Raises:

NotImplementedError – This method must be implemented by subclasses.

gate_phi(gate)[source]#

Resolve one gate’s temperature factor.

Resolution order is intentionally simple:

  1. explicit phi

  2. q10 + temp_ref using self.temp

  3. default 1.0

The q10 branch is memoised per gate through cached_q10_factor(); 99 of the catalogue’s 148 gates take it, and recomputing it once per gate per trace costs ~0.3 ms each.

init_state(V, *ions, batch_size=None)[source]#

Initialize the state of the ion channel.

This method should set up the initial state of all variables for the channel.

Parameters:
  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

reset_state(V, *ions, batch_size=None)[source]#

Reset the state of the ion channel.

This method should reset all state variables of the channel to their initial values.

Parameters:
  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.