Opened 5 years ago
Last modified 3 years ago
#5598 assigned discussion
redeclaration of input as output with NF
Reported by: | Owned by: | Per Östlund | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | New Instantiation | Version: | v1.14.0-dev-nightly |
Keywords: | replaceable, redeclare, input, output | Cc: |
Description
Hello,
The following error message occurred during testing with the new frontend:
[ReplaceableInput.test: 7:35-7:58]: Invalid redeclaration 'output A', original element is declared 'input'.
However, I couldn't find anything in ModelicaSpec33 Section 7.3 (Redeclaration) about whether such a redeclaration is invalid.
Is this a feature which is not yet implemented or should not be supported in the new frontend? With the old frontend the model ran without problems.
See attached minimal example.
Attachments (1)
Change History (9)
by , 5 years ago
Attachment: | ReplaceableInput.zip added |
---|
comment:1 by , 5 years ago
Component: | Frontend → New Instantiation |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 5 years ago
Yes, redeclarations must be subtypes as far as I understand, and 6.3 says that the input and output prefixes must be matched. It also has a note saying "For a redeclaration of an element the input or output prefix is inherited from the original declaration", which seems to suggest that redeclares aren't expected to contain input/output at all. But as usual there's quite a lot of room for interpretation.
comment:3 by , 5 years ago
From a user's perspective, I can't really see the point in changing an input with an output when redeclaring, because the interface is changed in a way that makes it incompatible with the base class.
@Sven, beyond this test case, can you elaborate on your actual requirement and the rationale behind this kind of redeclares?
comment:4 by , 5 years ago
Hi I'm a colleague of Sven. Here is our use case with more details:
In hydraulic systems the volume flow through an orifice is described by the orifice equation q = alpha * A * sqrt(2*dp/rho).
For complex geometries the area A is hard to describe, but our users have measurements of the volume flow for specific pressures.
That's why in the first step we calculate the hydraulic Area A for a give pressure and volume flow and take this area for the calculation of the current volume flow at the given pressure. So we are using the same equation twice in the same model but with different in and outputs.
To avoid implementing the same equation twice we wrote in a separate model and instantiate it with different in and outputs.
Our main issue is that the basic model which contains only the orifice equation needs to be balanced and we cannot make a partial model and extend it because we are using it the model twice.
comment:5 by , 5 years ago
Milestone: | 1.14.0 → 1.16.0 |
---|
Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0
comment:7 by , 4 years ago
Milestone: | 1.17.0 → 1.18.0 |
---|
Retargeted to 1.18.0 because of 1.17.0 timed release.
From what I understand of Section 6.3 of the specification, if you redeclare an input to be an output you are breaking plug compatibility, so you no longer have a subtype relationship. The whole point of replaceable classes and components is that you preserve the interface and you change the implementation.
The old frontend didn't check this constraint (nor does Dymola), but that doesn't make it correct per se.
@perost, can you please comment on this?