Opened 10 years ago
Closed 10 years ago
#3057 closed defect (fixed)
Erronous FMI ModelStructure
Reported by: | Rüdiger Franke | Owned by: | Willi Braun |
---|---|---|---|
Priority: | critical | Milestone: | 1.9.2 |
Component: | FMI | Version: | trunk |
Keywords: | Cc: |
Description
In many cases the ModelStructure generated for FMI 2 is wrong. The following example triggers some of the problems:
model ModelStructureTest parameter Integer switch = 1; parameter Real p = 1; input Real u1; input Real u2; output Integer y1; output Real y2; equation y1 = switch; if switch > 0 then y2 = p*u1; else y2 = u2; end if; end ModelStructureTest;
OpenModelica #23881 generates the following modelDescription.xml:
<ModelVariables> <!-- Index of variable = "3" --> <ScalarVariable name="u1" valueReference="0" variability="continuous" causality="input" initial="approx"><Real/></ScalarVariable> <!-- Index of variable = "4" --> <ScalarVariable name="u2" valueReference="1" variability="continuous" causality="input" initial="approx"><Real/></ScalarVariable> <!-- Index of variable = "5" --> <ScalarVariable name="y2" valueReference="2" variability="continuous" causality="output" initial="calculated"><Real/></ScalarVariable> <!-- Index of variable = "7" --> <ScalarVariable name="p" valueReference="3" variability="fixed" causality="parameter" initial="exact"><Real start="1.0"/></ScalarVariable> <!-- Index of variable = "6" --> <ScalarVariable name="y1" valueReference="0" variability="discrete" causality="output" initial="calculated"><Integer/></ScalarVariable> <!-- Index of variable = "8" --> <ScalarVariable name="switch" valueReference="1" variability="fixed" causality="parameter" initial="exact"><Integer start="1"/></ScalarVariable> </ModelVariables> <ModelStructure> <Outputs> <Unknown index="5" dependencies="3" dependenciesKind="dependent"/> <Unknown index="6"/> </Outputs> <Derivatives></Derivatives> <InitialUnknowns></InitialUnknowns> </ModelStructure>
The ModelVariables and ModelStructure exhibit the following errors:
- ModelVariables starts with index 3 instead of 1 (because the model contains no states?)
- ModelVariables lists the indices 5, 7, 6, 8 in this order (because the model contains integers?)
- ModelStructure/Outputs doesn't mention the dependency of y2 on u2 (because the parameter switch gets evaluated -- it works with an input switch?)
Change History (10)
follow-ups: 2 3 4 comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
comment:2 by , 10 years ago
Replying to wbraun:
Replying to rfranke:
The ModelVariables and ModelStructure exhibit the following errors:
- ModelVariables starts with index 3 instead of 1 (because the model contains no states?)
Yes, it's because the model contains no states and
we add for some reasons a strange dummy state.
fixed in r23937.
comment:3 by , 10 years ago
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
Replying to wbraun:
Replying to rfranke:
The ModelVariables and ModelStructure exhibit the following errors:
- ModelVariables starts with index 3 instead of 1 (because the model contains no states?)
Yes, it's because the model contains no states and
we add for some reasons a strange dummy state.
- ModelVariables lists the indices 5, 7, 6, 8 in this order (because the model contains integers?)
Yes, it's because of the integers.
- ModelStructure/Outputs doesn't mention the dependency of y2 on u2 (because the parameter switch gets evaluated -- it works with an input switch?)
No, the parameter shouldn't evaluated, I'll check that.
Okay, yes the parameter is replaced in FrontEnd(see #3059), so the output is correct to the input ;).
follow-ups: 6 8 comment:5 by , 10 years ago
The changes didn't make it into today's nightly build for Windows anymore -- it's still r23933 :-(
Under Linux I got r23940 and there it looks good!
Btw. something went wrong with the binaries path under Linux recently. Since a couple of weeks it's not called binaries/linux64
anymore, but binaries/makefileParams.platform
!?
Regarding the parameters: couldn't modelDescription.xml skip structural parameters to make sure that they cannot be modified anymore?
Alternatively structural parameters might be marked with causality="calculatedParameter"
, as seen for finalized parameters, e.g. when declaring:
model ModelStructureTest final parameter Integer switch = 1; ...
follow-up: 7 comment:6 by , 10 years ago
Replying to rfranke:
The changes didn't make it into today's nightly build for Windows anymore -- it's still r23933 :-(
Under Linux I got r23940 and there it looks good!
Btw. something went wrong with the binaries path under Linux recently. Since a couple of weeks it's not called
binaries/linux64
anymore, butbinaries/makefileParams.platform
!?
I had changed there something, but it works for me, anyway, I'll check that.
Regarding the parameters: couldn't modelDescription.xml skip structural parameters to make sure that they cannot be modified anymore?
Alternatively structural parameters might be marked with
causality="calculatedParameter"
, as seen for finalized parameters, e.g. when declaring:
model ModelStructureTest final parameter Integer switch = 1; ...
That sound reasonable, I'll see what I can do.
comment:7 by , 10 years ago
Replying to wbraun:
Replying to rfranke:
Btw. something went wrong with the binaries path under Linux recently. Since a couple of weeks it's not called
binaries/linux64
anymore, butbinaries/makefileParams.platform
!?
I had changed there something, but it works for me, anyway, I'll check that.
Hopefully it's fixed in r23946.
comment:8 by , 10 years ago
comment:9 by , 10 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Testing the fixes, a remaining fourth problem shows up: The index counter jumps if there are constants present. The example:
model ModelStructureTest2 parameter Integer switch = 1; constant Real p = 1; input Real u1; end ModelStructureTest2;
gives:
<ModelVariables> <!-- Index of variable = "1" --> <ScalarVariable name="u1" initial="approx" causality="input" variability="continuous" valueReference="0"><Real/></ScalarVariable> <!-- Index of variable = "3" --> <ScalarVariable name="switch" initial="exact" causality="parameter" variability="fixed" valueReference="0"><Integer start="1"/></ScalarVariable> </ModelVariables>
Replying to rfranke:
Yes, it's because the model contains no states and
we add for some reasons a strange dummy state.
Yes, it's because of the integers.
No, the parameter shouldn't evaluated, I'll check that.