Opened 11 years ago

Closed 7 years ago

#2541 closed defect (worksforme)

Unable to connect components for fluids

Reported by: marnold014@… Owned by: Per Östlund
Priority: high Milestone: 1.13.0
Component: New Instantiation Version: trunk
Keywords: Cc:

Description (last modified by Lennart Ochel)

When I try to connect any components in a fluid model, I get one of two errors: Illegal to instantiate partial class BaseProperties, or Error occurred while flattening model <test>. Here is a sample code:

model test
  extends Modelica.Icons.Example;
  import Modelica.Fluid;
  Modelica.Fluid.Vessels.OpenTank upperTank(redeclare package Medium = Modelica.Media.Water.StandardWater, height = 20, level_start = 2, crossArea = 0.2, nPorts = 3, portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.1),Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.1),Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.1, height = 10)}) annotation(Placement(transformation(extent = {{-40,20},{0,60}}, rotation = 0)));
  inner Modelica.Fluid.System system(energyDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial) annotation(Placement(transformation(extent = {{-150,-112},{-130,-92}}, rotation = 0)));
  Modelica.Fluid.Sensors.Pressure pressure(redeclare package Medium = Modelica.Media.Water.StandardWater) annotation(Placement(transformation(extent = {{40,16},{60,36}}, rotation = 0)));
  Modelica.Fluid.Pipes.StaticPipe pipe(redeclare package Medium = Modelica.Media.Water.StandardWater, diameter = 0.02, height_ab = -20, length = 200) annotation(Placement(transformation(origin = {0,-30}, extent = {{10,-10},{-10,10}}, rotation = 90)));
  Modelica.Fluid.Vessels.OpenTank lowerTank(height = 20, redeclare package Medium = Modelica.Media.Water.StandardWater, level_start = 2, crossArea = 1, nPorts = 2, portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.1),Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.1, height = 10)}) annotation(Placement(transformation(extent = {{40,-60},{80,-20}}, rotation = 0)));
  Modelica.Blocks.Logical.Hysteresis hysteresis(uLow = 110000.0, uHigh = 250000.0, pre_y_start = true) "mass flow rate signal by pressure control" annotation(Placement(transformation(extent = {{-140,-30},{-120,-10}}, rotation = 0)));
  Modelica.Blocks.Logical.Switch switch1 annotation(Placement(transformation(extent = {{-100,-30},{-80,-10}}, rotation = 0)));
  Modelica.Blocks.Sources.Constant m_flow_off(k = 0) annotation(Placement(transformation(extent = {{-140,10},{-120,30}}, rotation = 0)));
  Modelica.Blocks.Sources.Constant m_flow_on(k = 2) annotation(Placement(transformation(extent = {{-140,-60},{-120,-40}}, rotation = 0)));
  Modelica.Fluid.Pipes.StaticPipe overflow(redeclare package Medium = Modelica.Media.Water.StandardWater, diameter = 0.02, length = 200, height_ab = -20) annotation(Placement(transformation(origin = {20,-10}, extent = {{10,-10},{-10,10}}, rotation = 90)));
  Modelica.Fluid.Sources.MassFlowSource_T boundary(use_m_flow_in = true, m_flow = 0.2, nPorts = 1) annotation(Placement(visible = true, transformation(origin = {-46.8547,-22.9619}, extent = {{-10,-10},{10,10}}, rotation = 0)));
equation
  connect(pressure.p,hysteresis.u) annotation(Line(points = {{61,26},{70,26},{70,80},{-150,80},{-150,-20},{-142,-20}}, color = {0,0,127}, smooth = Smooth.None));
  connect(hysteresis.y,switch1.u2) annotation(Line(points = {{-119,-20},{-102,-20}}, color = {255,0,255}, smooth = Smooth.None));
  connect(m_flow_off.y,switch1.u1) annotation(Line(points = {{-119,20},{-119,5},{-102,5},{-102,-12}}, color = {0,0,127}, smooth = Smooth.None));
  connect(m_flow_on.y,switch1.u3) annotation(Line(points = {{-119,-50},{-110,-50},{-110,-28},{-102,-28}}, color = {0,0,127}, smooth = Smooth.None));
  connect(upperTank.ports[2],pipe.port_a) annotation(Line(points = {{-20,20},{-20,10},{0,10},{0,-20}}, color = {0,127,255}, smooth = Smooth.None));
  connect(pipe.port_a,pressure.port) annotation(Line(points = {{0,-20},{0,10},{50,10},{50,16}}, color = {0,127,255}, smooth = Smooth.None));
  connect(pipe.port_b,lowerTank.ports[1]) annotation(Line(points = {{0,-40},{0,-70},{56,-70},{56,-60}}, color = {0,127,255}, smooth = Smooth.None));
  connect(upperTank.ports[3],overflow.port_a) annotation(Line(points = {{-14.6667,20},{0,20},{0,40},{20,40},{20,0}}, color = {0,127,255}, smooth = Smooth.None));
  connect(overflow.port_b,lowerTank.ports[2]) annotation(Line(points = {{20,-20},{20,-40},{40,-40},{40,-60},{64,-60}}, color = {0,127,255}, smooth = Smooth.None));
  annotation(experiment(StopTime = 25000, Interval = 5.0), __Dymola_Commands(file = "modelica://Modelica/Resources/Scripts/Dymola/Fluid/TanksWithOverflow/plot level and port.m_flow.mos" "plot level and port.m_flow"), Documentation(info = "<html>
<p align=justify>The mass flow rate to the upper tank is controlled by the static pressure at its bottom.
The fluid flows through a pipe and forced by different heights from the upper tank to the lower tank.
</p>
<p>
Additional fluid flows through an overflow pipe if the level of the upper tank exceeds 10m.
Initially the overflow enters the lower tank above its fluid level; later on the fluid level exceeds the overflow port.
</p>
<p>
Note that the number of solver intervals has been increased, accounting for the long simulation time horizon.
Otherwise the simulation may fail due to too large steps subject to events. Alternatively the
simulation accuracy could be increased in order to avoid errors.
</p>

<img src=\"modelica://Modelica/Resources/Images/Fluid/Examples/TanksWithOverflow.png\" border=\"1\"
     alt=\"TanksWithOverflow.png\">
</html>"), Diagram(coordinateSystem(extent = {{-160,-120},{100,100}})));
end test;

when I try to connect the mass flow source, it will not work. This is an exact example pulled from the modelica library.

Change History (11)

comment:1 by Lennart Ochel, 11 years ago

Description: modified (diff)

comment:2 by Lennart Ochel, 11 years ago

If I had to guess, I would say that it is up to ticket #2395.

comment:3 by Martin Sjölund, 10 years ago

Milestone: 1.9.11.9.2

This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).

comment:4 by Martin Sjölund, 10 years ago

Milestone: 1.9.21.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:5 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

comment:6 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:7 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

comment:8 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:9 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:10 by Francesco Casella, 7 years ago

Milestone: 1.12.0Future

The milestone of this ticket has been reassigned to "Future".

If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.

If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".

In both cases, a short informative comment would be welcome.

comment:11 by Christoph Buchner <buchner@…>, 7 years ago

Milestone: Future1.13.0
Resolution: worksforme
Status: newclosed

With the code in the OP, if I set the missing medium redeclare in boundary, and make sure that the indices are correct when connecting (i.e. connect(boundary.ports[1], upperTank.ports[1])), I can connect without problems and this model flattens correctly, so I don't think the issue is present anymore.

Note: See TracTickets for help on using tickets.