Opened 6 years ago
Closed 8 months ago
#5051 closed defect (fixed)
OM accepts in a model a parameter with no value
Reported by: | massimo ceraolo | Owned by: | Per Östlund |
---|---|---|---|
Priority: | blocker | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: | Adrian Pop |
Description (last modified by )
Consider this package:
package TestParam model ResistorSimple parameter Real R; extends Modelica.Electrical.Analog.Interfaces.OnePort; equation v = R*i; end ResistorSimple; model Circuit Modelica.Electrical.Analog.Basic.Ground ground; Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V=1); ResistorSimple res; equation connect(ground.p, constantVoltage.n); connect(constantVoltage.n, res.p); connect(res.n, ground.p); end Circuit; end TestParam;
I think Circuit should not run because parameter R has no value defined. Instead OM just issues the following message:
[1] 22:53:00 Translation Warning [TestParam: 5:5-5:21]: Parameter res.R has no value, and is fixed during initialization (fixed=true), using available start value (start=0.0) as default value.
and runs.
This can be very tricky in larger models (for instance models using MSL models with default values for parameters) where there may exist many parameters having just start values. In these cases it can be very difficult to understand that one or some of them are indeed undefined.
Change History (6)
comment:1 by , 6 years ago
Description: | modified (diff) |
---|
comment:2 by , 6 years ago
Cc: | added |
---|---|
Component: | *unknown* → New Instantiation |
Milestone: | 1.13.0 → 2.0.0 |
Owner: | changed from | to
follow-up: 4 comment:3 by , 6 years ago
This is already implemented partly in #5062 but only for parameter (fixed=true) annotation(Evaluate=true);
I will discuss with Per and we can make it so that a parameter with (fixed=true)
and no start value gives an error.
comment:4 by , 6 years ago
comment:5 by , 6 years ago
Priority: | high → blocker |
---|
comment:6 by , 8 months ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This issue has been fixed recently. On OM 1.23.0-dev344 the issue is still there, wile in OM 1.24-dev13 the warning has been converted into an error message:
[1] 04:32:41 Translation Error [a: 3:5-3:21]: Parameter res.R has neither value nor start value, and is fixed during initialization (fixed=true).
I re-read section 8.6 of the Modelica Specification. I report here two statements
I understand OMC does not behave correctly: since there is no modifier on the start attribute, using the default start attribute (i.e. zero) to add a parameter binding equation to assign the parameter to the start modifier is not the expected behaviour.
I agree with @ceraolo that such models should fail during compilation with an error message such as:
I guess we should implement this behaviour in the new front end, @adrpo @perost, what do you think?