Markov#

class braincell.channel.Markov(size, name=None, solver=None, substeps=None)[source]#

Probability-state channel kinetics described by transition pairs.

pairs define one conserved probability pool. One state is eliminated and reconstructed algebraically from the others; dependent_state names it, and declaring it is mandatory. Which state is eliminated changes the conditioning of the steady-state solve, so inferring it from the ordering of pairs – as this template once did – meant that reordering an otherwise-equivalent transition table silently changed the model.

state_values() returns the raw stored states plus the reconstructed dependent state. compute_derivative() uses _kinetic_state_values(), which clips each independent state to [0, 1] before evaluating the transition graph while still reconstructing the dependent state from the raw stored sum. Clipping is governed by clip_states and projects only the values fed to the kinetics; the stored states are untouched.

Transition rates may return either a bare value, read as per-millisecond, or a properly united inverse time; anything else is rejected against the rate method’s own name. This mirrors Gate.time_unit on the HH side, except that the unit is fixed at u.ms rather than declared per transition – the catalogue’s Markov channels all come from NEURON .mod sources written in milliseconds.

Variables:
  • pairs (tuple of Transition or tuple) – Class-level declaration of the transition graph. Each entry is either a Transition or the plain tuple of its fields; both forms are normalised by __init_subclass__.

  • conserve (Any, default 1.0) – Total probability mass the declared states must sum to. Resolved per instance the same way as Gate metadata – a str names an instance attribute, a callable is applied to the instance, anything else is a literal.

  • dependent_state (str) – Name of the state eliminated from the independent set and reconstructed as conserve minus the others. Every subclass that declares pairs must declare this too; omitting it raises ValueError when the subclass is created.

  • default_solver (str, default "backward_euler") – Solver name used by IndependentIntegration when the constructor’s solver argument is not supplied.

  • default_substeps (int, default 1) – Number of solver substeps per outer integration step, used when the constructor’s substeps argument is not supplied.

  • clip_states (bool, default True) – Project each independent state into [0, 1] before evaluating the transition graph, so a probability pool that has drifted off the simplex still yields meaningful kinetics; the stored states themselves are left untouched. On by default, unlike Gate.clip on the HH side, because an out-of-simplex probability pool corrupts the kinetics, whereas an unclipped HH gate is merely inaccurate.

  • reset_to_steady_state (bool, default False) – Make reset_state() delegate to reset_steady_state() rather than zeroing the independent states. Off by default, because solving the stationary distribution is only meaningful for a channel whose transition graph is well conditioned at the reset voltage; the catalogue’s resurgent sodium and calcium-gated potassium schemes opt in.

clip_states: ClassVar[bool] = True#

Project independent states into [0, 1] before evaluating the transition graph. On by default: a probability pool that leaves the simplex makes the kinetics meaningless, whereas an HH gate merely becomes inaccurate. See Gate.clip for the HH-side switch.

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.

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.

make_integration(*args, **kwargs)[source]#

Run one step of the configured solver on this submodule.

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.

reset_to_steady_state: ClassVar[bool] = False#

Opt in to seeding reset_state() from the stationary distribution instead of zeros. See the class docstring.