DynamicalSystem#

class brainpy.DynamicalSystem(name=None, mode=None)[source]#

Base Dynamical System class.

Note

In general, every instance of DynamicalSystem implemented in BrainPy only defines the evolving function at each time step \(t\).

If users want to define the logic of running models across multiple steps, we recommend users to use for_loop(), LoopOverTime, DSRunner, or DSTrainer.

To be compatible with previous APIs, DynamicalSystem inherits from the DelayRegister. It’s worthy to note that the methods of DelayRegister will be removed in the future, including:

  • .register_delay()

  • .get_delay_data()

  • .update_local_delays()

  • .reset_local_delays()

Parameters:
  • name (optional, str) – The name of the dynamical system.

  • mode (optional, Mode) – The model computation mode. It should be an instance of Mode.

add_aft_update(key, fun)[source]#

Add the after update into this node

add_bef_update(key, fun)[source]#

Add the before update into this node

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

Clear the input at the current time step.

get_aft_update(key)[source]#

Get the after update of this node by the given key.

get_bef_update(key)[source]#

Get the before update of this node by the given key.

get_local_delay(var_name, delay_name)[source]#

Get the delay at the given identifier (name).

Parameters:
  • var_name – The name of the target delay variable.

  • delay_name – The identifier of the delay.

Returns:

The delayed data at the given delay position.

has_aft_update(key)[source]#

Whether this node has the after update of the given key.

has_bef_update(key)[source]#

Whether this node has the before update of the given key.

jit_step_run(i, *args, **kwargs)[source]#

The jitted step function for running.

Parameters:
  • i – The current running index.

  • *args – The arguments of update() function.

  • **kwargs – The arguments of update() function.

Returns:

The update function returns.

Return type:

out

property mode: Mode#

Mode of the model, which is useful to control the multiple behaviors of the model.

register_local_delay(var_name, delay_name, delay_time=None, delay_step=None)[source]#

Register local relay at the given delay time.

Parameters:
reset(*args, **kwargs)[source]#

Reset function which reset the whole variables in the model (including its children models).

reset() function is a collective behavior which resets all states in this model.

See https://brainpy.readthedocs.io/en/latest/tutorial_toolbox/state_resetting.html for details.

step_run(i, *args, **kwargs)[source]#

The step run function.

This function can be directly applied to run the dynamical system. Particularly, i denotes the running index.

Parameters:
  • i – The current running index.

  • *args – The arguments of update() function.

  • **kwargs – The arguments of update() function.

Returns:

The update function returns.

Return type:

out

supported_modes: Optional[Sequence[Mode]] = None#

Supported computing modes.

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

The function to specify the updating rule.