Equations class

(Shortest import: from brian2 import Equations)

class brian2.equations.equations.Equations(eqns, **kwds)[source]

Bases: Hashable, Mapping

Container that stores equations from which models can be created.

String equations can be of any of the following forms:

  1. dx/dt = f : unit (flags) (differential equation)

  2. x = f : unit (flags) (equation)

  3. x : unit (flags) (parameter)

String equations can span several lines and contain Python-style comments starting with #

Attributes

_substituted_expressions

Cache for equations with the subexpressions substituted

dependencies

Calculate the dependencies of all differential equations and subexpressions.

diff_eq_expressions

A list of (variable name, expression) tuples of all differential equations.

diff_eq_names

All differential equation names.

dimensions

Dictionary of all internal variables and their corresponding physical dimensions.

eq_expressions

A list of (variable name, expression) tuples of all equations.

eq_names

All equation names (including subexpressions).

identifier_checks

A set of functions that are used to check identifiers (class attribute).

identifiers

Set of all identifiers used in the equations, excluding the variables defined in the equations

is_stochastic

Whether the equations are stochastic.

names

All variable names defined in the equations.

ordered

A list of all equations, sorted according to the order in which they should be updated

parameter_names

All parameter names.

stochastic_type

Returns the type of stochastic differential equations (additivive or multiplicative).

stochastic_variables

subexpr_names

All subexpression names.

Methods

check_flags(allowed_flags[, incompatible_flags])

Check the list of flags.

check_identifier(identifier)

Perform all the registered checks.

check_identifiers()

Check all identifiers for conformity with the rules.

check_units(group, run_namespace)

Check all the units for consistency.

get_substituted_expressions([variables, ...])

Return a list of (varname, expr) tuples, containing all differential equations (and optionally subexpressions) with all the subexpression variables substituted with the respective expressions.

register_identifier_check(func)

Register a function for checking identifiers.

substitute(**kwds)

Details

_substituted_expressions

Cache for equations with the subexpressions substituted

dependencies

Calculate the dependencies of all differential equations and subexpressions.

diff_eq_expressions

A list of (variable name, expression) tuples of all differential equations.

diff_eq_names

All differential equation names.

dimensions

Dictionary of all internal variables and their corresponding physical dimensions.

eq_expressions

A list of (variable name, expression) tuples of all equations.

eq_names

All equation names (including subexpressions).

identifier_checks

A set of functions that are used to check identifiers (class attribute). Functions can be registered with the static method Equations.register_identifier_check and will be automatically used when checking identifiers

identifiers

Set of all identifiers used in the equations, excluding the variables defined in the equations

is_stochastic

Whether the equations are stochastic.

names

All variable names defined in the equations.

ordered

A list of all equations, sorted according to the order in which they should be updated

parameter_names

All parameter names.

stochastic_type

Returns the type of stochastic differential equations (additivive or multiplicative). The system is only classified as additive if all equations have only additive noise (or no noise).

stochastic_variables
subexpr_names

All subexpression names.

check_flags(allowed_flags, incompatible_flags=None)[source]

Check the list of flags.

static check_identifier(identifier)[source]

Perform all the registered checks. Checks can be registered via Equations.register_identifier_check.

check_identifiers()[source]

Check all identifiers for conformity with the rules.

check_units(group, run_namespace)[source]

Check all the units for consistency.

get_substituted_expressions(variables=None, include_subexpressions=False)[source]

Return a list of (varname, expr) tuples, containing all differential equations (and optionally subexpressions) with all the subexpression variables substituted with the respective expressions.

static register_identifier_check(func)[source]

Register a function for checking identifiers.

substitute(**kwds)[source]