cosapp.ports.mode_variable

This module defines the basic class encapsulating mode variable attributes.

Classes

ModeVariable(name, port[, value, unit, ...])

Container for mode variables.

class cosapp.ports.mode_variable.ModeVariable(name: str, port: cosapp.ports.ModeVarPort, value: Any | None = None, unit: str = '', dtype: Any | Tuple[Any, ...] | None = None, desc: str = '', init: Any | None = None, scope: Scope = Scope.PRIVATE)[source]

Bases: BaseVariable

Container for mode variables.

Parameters:
  • name (str) – Variable name

  • port (ModeVarPort, optional) – Port to which the variable belongs

  • value (Any) – Variable value

  • unit (str, optional) – Variable unit; default empty string (i.e. dimensionless)

  • dtype (type or iterable of type, optional) – Variable type; default None (i.e. type of initial value)

  • desc (str, optional) – Variable description; default ‘’

  • init (Any, optional) – Value imposed at the beginning of time simulations, if variable is an output (unused otherwise). If unspecified (default), the variable remains untouched.

  • scope (Scope {PRIVATE, PROTECTED, PUBLIC}, optional) – Variable visibility; default PRIVATE

copy(port: BasePort, name: str | None = None) ModeVariable[source]
property init_expr: cosapp.core.eval_str.EvalString

expression of initial value

Type:

EvalString

init_value() Any[source]

Evaluate and return initial value

initialize() None[source]

Set mode variable to its prescribed initial value.