This information is part of the Modelica Standard Library maintained by the Modelica Association.

Define causality and/or block diagram connection semantic (depending on context)


connector RealInput = input Real;
connector RealOutput = output Real;

block Integrator
  RealInput  u;
  RealOutput y;
  Real x;
  der(x) = u;
  y = x;
end Integrator;


class_definition :
   [ encapsulated ]
   [ partial ]
   ( class | model | record | block | connector | type |
     package | function )
   IDENT class_specifier

class_specifier :
   string_comment composition end IDENT
   | "=" base_prefix name [ array_subscripts ] [ class_modification ] comment
   | "=" enumeration "(" ( [enum_list] | ":" ) ")" comment

base_prefix :

composition  :
   { public element_list |
     protected element_list |
     equation_clause |
   [ external [ language_specification ]
              [ external_function_call ] [ annotation ";" ]
              [ annotation  ";" ] ]

element_list :
   { element ";" | annotation  ";" }

element :
   import_clause |
   extends_clause |
   [ final ]
   [ inner | outer ]
   ( ( class_definition | component_clause) |
     replaceable ( class_definition | component_clause)
        [constraining_clause comment])

   type_prefix type_specifier [ array_subscripts ] component_list

type_prefix :
   [ flow ]
   [ discrete | parameter | constant ] [ input | output ]


The prefixes input and output have a slightly different semantic meaning depending on the context where they are used:

  • In functions, these prefixes define the computational causality of the function body, i.e., given the variables declared as input, the variables declared as output are computed in the function body.
  • In simulation models and blocks (i.e., on the top level of a model or block that shall be simulated), these prefixes define the interaction with the environment where the simulation model or block is used. Especially, the input prefix defines that values for such a variable have to be provided from the simulation environment and the output prefix defines that the values of the corresponding variable can be directly utilized in the simulation environment.
  • In component models and blocks, the input prefix defines that a binding equation has to be provided for the corresponding variable when the component is utilized in order to guarantee a locally balanced model (i.e., the number of local equations is identical to the local number of unknowns). Example:
      block FirstOrder
         input Real u;
      end FirstOrder;
      model UseFirstOrder
         FirstOrder firstOrder(u=time); // binding equation for u
      end UseFirstOrder;
    The output prefix does not have a particular effect in a model or block component and is ignored.
  • In connectors, prefixes input and output define that the corresponding connectors can only be connected according to block diagram semantics (e.g., a connector with an output variable can only be connected to a connector where the corresponding variable is declared as input). There is the restriction that connectors which have at least one variable declared as input must be externally connected (in order to get a locally balanced model, where the number of local unknowns is identical to the number of unknown equations). Together with the block diagram semantics rule this means, that such connectors must be connected exactly once externally.
  • In records, prefixes input and output are not allowed, since otherwise a record could not be, e.g., passed as input argument to a function.