ModelicaSpecification
ModelicaSpecification copied to clipboard
ModelicaCompliance.Components.Prefixes.FlowValidClassType
Reported by eldjillali.talbi on 27 Nov 2013 16:58 UTC The model ModelicaCompliance.Components.Prefixes.FlowValidClassType is using "flow" prefix on a model variable defined at the top level of the model. The specification defines the meaning of a flow variable only as a connector variable. What is the meaning of a flow variable not inside a connector ?
Migrated-From: https://trac.modelica.org/Modelica/ticket/1366
Comment by perost on 27 Nov 2013 19:38 UTC The specification allows flow to be used on type, record and connector components, but does not specify any restrictions on where they may be used except for in records. The specification doesn't specify how such components should be handled outside of connectors, which I interpret to mean that flow has no meaning in such cases. The test case checks that a tool handles this, by simply ignoring the flow prefix on the component.
I believe that it would make sense to only allow flow/stream in certain cases though. I thought I'd opened a ticket about this, but it seems I haven't. It's something which should be more clearly specified though, so I've reassigned this ticket to the specification instead.
Comment by hansolsson on 31 Mar 2016 15:26 UTC Replying to [comment:1 perost]:
The specification allows flow to be used on type, record and connector components, but does not specify any restrictions on where they may be used except for in records. The specification doesn't specify how such components should be handled outside of connectors, which I interpret to mean that flow has no meaning in such cases. The test case checks that a tool handles this, by simply ignoring the flow prefix on the component.
I believe that it would make sense to only allow flow/stream in certain cases though. I thought I'd opened a ticket about this, but it seems I haven't. It's something which should be more clearly specified though, so I've reassigned this ticket to the specification instead.
I agree and propose to add the following to 'model' 4.6 Specialized class
The elements of a model may not have prefixes stream, or flow (but may contain connector elements having such prefixes).
Comment by jmattsson on 1 Apr 2016 08:46 UTC That's not complete - what about block, function, etc? Wouldn't it be better to specify a list of places it is allowed (and forbid it everywhere else)?
Comment by hansolsson on 1 Apr 2016 09:21 UTC Replying to [comment:3 jmattsson]:
That's not complete - what about block, function, etc? Wouldn't it be better to specify a list of places it is allowed (and forbid it everywhere else)?
That's also possible.
Section 4.4.2.2 states that the prefixes may only be allowed on certain components - so the restriction could be placed in that section, i.e. expand it to:
"Type prefixes (that is , flow, stream, discrete, parameter, constant, input, output) shall only be applied for type, record and connector components. Components with flow or stream prefix may only be declared in connector-classes. Components with input or output prefix may only be declared in function, operator function, model, block, class, or connector classes. See also specialized class, Section 4.6."
As for other cases: Function should forbid it (already forbids inner/outer), section 12.2. Block is further restricted based on model. Type has no possibility to add it as far as I see. Record already forbids input, output, inner, outer, stream, flow. Operator record is based on record. Operator function is function in operator record. Connector allows it. Package may contain constants and we should forbid stream/flow/input/output/inner/outer on components in them., add restriction in section 4.6.
One could consider forbidding "constant flow" in general - instead of "flow" in packages, but I don't think that is good since "constant flow" could be acceptable if placed in a connector, e.g. a current-source could have "constant flow Current i;" with a modifier giving the value.