Opened 5 years ago
Last modified 3 years ago
#5906 accepted defect
compilation error for curved bend
Reported by: | Owned by: | Mahder Alemseged Gebremedhin | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Code Generation | Version: | v1.14.1 |
Keywords: | compilation curved bend | Cc: | Mahder Alemseged Gebremedhin, Andreas Heuermann |
Description (last modified by )
I have build a model containing two boundary condition and two static pipes with one curved bend in between. The model is built without any error (as the number of variables = number of the equations). But during compiling model throws error given below for cured bend in the model.
- I have attached error in the file and the model is given below.
I appreciate your help regarding solving my problem.
model LBendtest1 replaceable package Medium = Modelica.Media.Water.StandardWater; inner Modelica.Fluid.System system(energyDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial) annotation( Placement(visible = true, transformation(origin = {-76, 82}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Fluid.Pipes.StaticPipe pipe(redeclare package Medium = Medium, diameter = 0.02, length = 50, p_a_start = 100000, p_b_start = 100000) annotation( Placement(visible = true, transformation(origin = {-42, -16}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Fluid.Pipes.StaticPipe pipe1(redeclare package Medium = Medium, diameter = 0.02, length = 50, p_a_start = 100000, p_b_start = 100000) annotation( Placement(visible = true, transformation(origin = {42, 42}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Fluid.Sources.MassFlowSource_T boundary(redeclare package Medium = Medium, T = 293.15, m_flow = 0.1, nPorts = 1) annotation( Placement(visible = true, transformation(origin = {-88, -16}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Fluid.Sources.Boundary_pT boundary1(redeclare package Medium = Medium, T = 293.15, nPorts = 1, p = 100000) annotation( Placement(visible = true, transformation(origin = {86, 42}, extent = {{-10, -10}, {10, 10}}, rotation = 180))); Modelica.Fluid.Fittings.Bends.CurvedBend curvedBend1(redeclare package Medium = Medium, geometry = Modelica.Fluid.Fittings.BaseClasses.Bends.CurvedBend.Geometry(d_hyd = 0.02, R_0 = 0.6)) annotation( Placement(visible = true, transformation(origin = {-2, 18}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); equation connect(boundary.ports[1], pipe.port_a) annotation( Line(points = {{-78, -16}, {-52, -16}, {-52, -16}, {-52, -16}}, color = {0, 127, 255})); connect(pipe1.port_b, boundary1.ports[1]) annotation( Line(points = {{52, 42}, {76, 42}}, color = {0, 127, 255})); connect(pipe.port_b, curvedBend1.port_a) annotation( Line(points = {{-32, -16}, {-32, 18}, {-12, 18}}, color = {0, 127, 255})); connect(curvedBend1.port_b, pipe1.port_a) annotation( Line(points = {{8, 18}, {17, 18}, {17, 42}, {32, 42}}, color = {0, 127, 255})); annotation( uses(Modelica(version = "3.2.2"))); end LBendtest1;
Attachments (1)
Change History (8)
by , 5 years ago
Attachment: | compilation error.txt added |
---|
comment:1 by , 5 years ago
Cc: | added |
---|---|
Component: | OMEdit → Code Generation |
Milestone: | NeedsInput → 1.16.0 |
Owner: | set to |
Status: | new → assigned |
@lochel can you take a look at it? I am not sure who should take care of this.
comment:2 by , 5 years ago
Description: | modified (diff) |
---|
comment:4 by , 4 years ago
Status: | assigned → accepted |
---|
This is a known issue. I was not sure what to do about it so I left it unsolved. You can see the same exact problem in ModelicaTest libraries here:
https://libraries.openmodelica.org/branches/newInst/ModelicaTest_3.2.3/ModelicaTest_3.2.3.html
Here is the issue:
You have the record
Modelica.Fluid.Dissipation.PressureLoss.Bend.dp_curvedOverall_IN_con
defined as
record dp_curvedOverall_IN_con "Input record for function dp_curvedOverall_DP and dp_curvedOverall_MFLOW" //bend variables extends Modelica.Fluid.Dissipation.Utilities.Records.PressureLoss.Bend; end dp_curvedOverall_IN_con;
where Modelica.Fluid.Dissipation.Utilities.Records.PressureLoss.Bend is
record Bend "Input for bend" extends EdgedBend; SI.Radius R_0=0.5*d_hyd; end Bend;
where EdgedBend is
record EdgedBend "Input for bend" extends Modelica.Icons.Record; SI.Diameter d_hyd(min=Modelica.Constants.eps) = 0.1; SI.Angle delta=90*PI/180; SI.Length K=0; end EdgedBend;
So essentially you have the record
Modelica.Fluid.Dissipation.PressureLoss.Bend.dp_curvedOverall_IN_con defined as
record dp_curvedOverall_IN_con SI.Diameter d_hyd(min=Modelica.Constants.eps) = 0.1; SI.Angle delta=90*PI/180; SI.Length K=0; SI.Radius R_0=0.5*d_hyd ; end Bend;
And there is another record
Modelica.Fluid.Fittings.BaseClasses.Bends.CurvedBend.Geometry
defined as:
record Geometry "Geometric data for a curved bend" extends Modelica.Icons.Record; SI.Diameter d_hyd; SI.Radius R_0; SI.Angle delta=1.5707963267949; Modelica.Fluid.Types.Roughness K=2.5e-5; end Geometry;
The function Modelica.Fluid.Dissipation.PressureLoss.Bend.dp_curvedOverall_MFLOW expects dp_curvedOverall_IN_con as input but it is given Geometry instead.
The two records are similar but the order of elements is not the same. I think the front-end allows it because they are plug-compatible. However the problem is there is no ordering done on record elements. So by the time we reach codegen we have two incompatible types.
I think this is an issue that can ideally be fixed by MSL by providing a conversion function or by the front end enforcing ordering rules on records. But the later option comes with a number of things to consider if we want to sort record elements. Another option is to generate casting functions for such uses by the front-end. We can probably also work with a CAST() expression for this case.
This is why I left it unresolved for the time being.
comment:6 by , 4 years ago
Milestone: | 1.17.0 → 1.18.0 |
---|
Retargeted to 1.18.0 because of 1.17.0 timed release.
compilation error