Opened 13 years ago
Last modified 3 years ago
#1730 closed defect
problems with variability of records and warnings that its values are not assigned. — at Initial Version
Reported by: | Michael Wetter | Owned by: | Michael Wetter |
---|---|---|---|
Priority: | high | Milestone: | 1.19.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: | Michael Wetter |
Description
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;