Opened 6 years ago
Last modified 6 years ago
#5254 closed defect
Issue with constaining class in replaceable array of models — at Version 3
Reported by: | Francesco Casella | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 1.14.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description (last modified by )
Please check IBPSA.Fluid.MixingVolumes.BaseClasses.Validation.MixingVolumeHeatMoisturePort. The NF fails with the errors:
[IBPSA latest/Fluid/MixingVolumes/BaseClasses/Validation/MixingVolumeHeatPortWater.mo:15:10-15:67:writable] Warning: 'each' used when modifying non-array element vol. [IBPSA latest/Fluid/MixingVolumes/BaseClasses/Validation/MixingVolumeHeatPortWater.mo:16:11-16:77:writable] Notification: From here: [IBPSA latest/Fluid/MixingVolumes/BaseClasses/PartialMixingVolume.mo:6:3-8:71:writable] Error: Type mismatch in binding initialize_p = {i == 1 and not Medium.singleState for i in 1:3}, expected subtype of Boolean, got type Boolean[3].
The offending code is found here; I'm not sure if it is correct and OMC is wrong, or the other way round.
Change History (3)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
Hmmm, this seems to be a bit tricky as far as I can understand from the Modelica 3.4 spec (7.3.2 Constraining Type).
Examples:
replaceable T1 x[n] constrainedby T2; // your case, T1 should have the same dimensions as T2 replaceable type T=T1[n] constrainedby T2; replaceable T1[n] x constrainedby T2;
In these examples the number of dimensions must be the same in T1 and T2, as well as in a redeclaration. Normally T1 and T2 are scalar types, but both could also be defined as array types – with the same number of dimensions. Thus if T2 is a scalar type (e.g. type T2= Real
) then T1 must also be a scalar type; and if T2 is defined as vector type (e.g. type T2=Real[3]
) then T1 must also be vector type.
As far as I can see from your declaration:
replaceable IBPSA.Fluid.MixingVolumes.BaseClasses.MixingVolumeHeatPort vol[nEle] constrainedby IBPSA.Fluid.MixingVolumes.BaseClasses.MixingVolumeHeatPort( redeclare each package Medium = Medium, each energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, final initialize_p={(i == 1 and not Medium.singleState) for i in 1:nEle}, each m_flow_nominal=1, each V=1, each nPorts=2) "Mixing volume";
As far as I can interpret this, you should not use each in the constrainedby
part as it refers to the type of component vol without the array dimension (which applies to the component, not its type).
comment:3 by , 6 years ago
Description: | modified (diff) |
---|
The error
seems to be related. I can't see anything wrong with this model.