Opened 11 years ago
Last modified 7 years ago
#2541 closed defect
Unable to connect components for fluids — at Initial Version
Reported by: | Owned by: | Per Östlund | |
---|---|---|---|
Priority: | high | Milestone: | 1.13.0 |
Component: | New Instantiation | Version: | trunk |
Keywords: | Cc: |
Description
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.