#1730 closed defect (fixed)
problems with variability of records and warnings that its values are not assigned.
| Reported by: | Michael Wetter | Owned by: | Michael Wetter |
|---|---|---|---|
| Priority: | high | Milestone: | 1.19.0 |
| Component: | New Instantiation | Version: | |
| Keywords: | Cc: | Michael Wetter |
Description (last modified by )
If the model below is simulated using
loadModel(TestRecord);
simulate(TestRecord.myModelInstance);
getErrorString();
then the following error occurs:
messages = "Simulation failed for model: TestRecord.myModelInstance
home/mwetter/proj/ldrd/bie/modeling/bie/branches/mwetter/openmodelica/TestRecord.mo:11:5-11:60:writable Error: Component mymodel.p of variability PARAM has binding mytwo of higher variability VAR.
Since mymodel.p is a record in which all members are parameters, my interpretation is that its variability should also be PARAM as opposed to VAR.
If the line
TestRecord.myRecords.myTwo mytwo;
is changed to
parameter TestRecord.myRecords.myTwo mytwo;
then the model simulates, and computes the correct result mymodel.x=2. However, the warning
Warning: Parameter mymodel.p.r has neither value nor start value, and is fixed during initialization (fixed=true)
occurs despite that r is assigned the value 2 in the declaration of myTwo.
//////////////////////////////////////
within ;
package TestRecord
package myRecords
record myTwo = myRecords.BaseRecord(r = 2);
record BaseRecord
parameter Real r;
end BaseRecord;
end myRecords;
model myModel
replaceable parameter TestRecord.myRecords.BaseRecord p;
Real x;
equation
x=p.r;
end myModel;
model myModelInstance
TestRecord.myRecords.myTwo mytwo;
TestRecord.myModel mymodel(p = mytwo);
end myModelInstance;
annotation(uses(Modelica(version = "3.1")));
end TestRecord;
//////////////////////////////////////
Change History (4)
comment:1 by , 13 years ago
| Cc: | mwetter, → mwetter |
|---|---|
| Component: | → Backend |
| Description: | modified (diff) |
comment:2 by , 10 years ago
| Milestone: | → Future |
|---|
comment:3 by , 4 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:4 by , 4 years ago
| Component: | Backend → New Instantiation |
|---|---|
| Milestone: | Future → 1.19.0 |

There's no rule in the Modelica specification that says that a record where all the fields are parameters should also be considered a parameter, so prefixing the record instance with
parameteris required in this case. In that case the model compiles without any warnings now, so I'll consider this fixed.