- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Problem with FluidPort
Problem with FluidPort
Problem with FluidPort
Hello
Please help me with Modelica.Fluid.Interfaces.FluidPort. I'm trying to create two models "WaterSource" and "WaterSink" and connect them (the final model is named WaterSourceSink) . The following code in OpenModelica:
Code:
model WaterSource
replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium model" annotation(choicesAllMatching = true);
parameter Medium.MassFlowRate w0 = 0;
parameter Medium.Temperature t0 = 0;
Modelica.Fluid.Interfaces.FluidPort_a port_a annotation(Placement(visible = true, transformation(origin = {98, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {98, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
port_a.m_flow = -w0;
port_a.h_outflow = Modelica.Media.Water.WaterIF97_base.specificEnthalpy_pT(port_a.p, t0);
annotation(Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics = {Polygon(origin = {-14.04, 0}, fillColor = {0, 0, 255}, fillPattern = FillPattern.CrossDiag, points = {{-67.956, 0}, {-67.956, 20}, {50.044, 20}, {50.044, 40}, {68.044, 0}, {50.044, -40}, {50.044, -20}, {-67.956, -20}, {-67.956, -20}, {-67.956, 0}})}));
end WaterSource;
Code:
model WaterSink
replaceable package Medium = Modelica.Media.Water.StandardWater constrainedby Modelica.Media.Interfaces.PartialMedium "Medium model" annotation(choicesAllMatching = true);
parameter Medium.AbsolutePressure p = 1e5;
Modelica.Fluid.Interfaces.FluidPort_b port_b annotation(Placement(visible = true, transformation(origin = {-98, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-98, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
port_b.p = p;
annotation(Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics = {Ellipse(origin = {0, -40}, fillColor = {0, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-66, 32}, {66, -32}}, endAngle = 360), Polygon(origin = {-36.15, -16}, fillColor = {0, 0, 255}, fillPattern = FillPattern.CrossDiag, points = {{-53.8536, 22}, {-31.8536, 22}, {-11.8536, 18}, {12.1464, 10}, {30.1464, 0}, {48.1464, -16}, {54.1464, -22}, {-3.85355, -22}, {-5.85355, -12}, {-9.85355, -2}, {-15.8536, 4}, {-27.8536, 10}, {-41.8536, 14}, {-53.8536, 16}, {-53.8536, 22}})}));
end WaterSink;
Code:
model WaterSourceSink
MyPowerPlant.Simple.WaterSource watersource1 annotation(Placement(visible = true, transformation(origin = {-52, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
MyPowerPlant.Simple.WaterSink watersink1 annotation(Placement(visible = true, transformation(origin = {10, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(watersource1.port_a, watersink1.port_b) annotation(Line(points = {{-42, 0}, {0, 0}, {0, 0}, {0, 0}}, color = {0, 127, 255}));
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})));
end WaterSourceSink;
When the "Check of MyPowerPlant.Simple.Examples.WaterSourceSink completed successfully. Class MyPowerPlant.Simple.Examples.WaterSourceSink has 5 equation(s) and 6 variable(s). 4 of these are trivial equation(s)". And such a code in the "InstantiateModel":
Code:
class MyPowerPlant.Simple.Examples.WaterSourceSink
parameter Real watersource1.w0(quantity = "MassFlowRate.unusablePartialMedium", unit = "kg/s", min = -100000.0, max = 100000.0) = 0.0 "Массовый расход";
parameter Real watersource1.t0(quantity = "ThermodynamicTemperature", unit = "K", displayUnit = "degC", min = 1.0, max = 10000.0, start = 300.0, nominal = 300.0) = 0.0;
Real watersource1.port_a.m_flow(quantity = "MassFlowRate.unusablePartialMedium", unit = "kg/s", min = -100000.0, max = 100000.0) "Mass flow rate from the connection point into the component";
Real watersource1.port_a.p(quantity = "Pressure", unit = "Pa", displayUnit = "bar", min = 0.0, max = 100000000.0, start = 100000.0, nominal = 100000.0) "Thermodynamic pressure in the connection point";
Real watersource1.port_a.h_outflow(quantity = "SpecificEnergy", unit = "J/kg", min = -10000000000.0, max = 10000000000.0, nominal = 1000000.0) "Specific thermodynamic enthalpy close to the connection point if m_flow < 0";
parameter Real watersink1.p(quantity = "Pressure", unit = "Pa", displayUnit = "bar", min = 611.657, max = 100000000.0, start = 5000000.0, nominal = 1000000.0) = 100000.0 "Давление";
Real watersink1.port_b.m_flow(quantity = "MassFlowRate.unusablePartialMedium", unit = "kg/s", min = -100000.0, max = 100000.0) "Mass flow rate from the connection point into the component";
Real watersink1.port_b.p(quantity = "Pressure", unit = "Pa", displayUnit = "bar", min = 0.0, max = 100000000.0, start = 100000.0, nominal = 100000.0) "Thermodynamic pressure in the connection point";
Real watersink1.port_b.h_outflow(quantity = "SpecificEnergy", unit = "J/kg", min = -10000000000.0, max = 10000000000.0, nominal = 1000000.0) "Specific thermodynamic enthalpy close to the connection point if m_flow < 0";
equation
watersource1.port_a.m_flow = -watersource1.w0;
watersource1.port_a.h_outflow = Modelica.Media.Water.WaterIF97_base.specificEnthalpy_pT(watersource1.port_a.p, watersource1.t0, 0);
watersink1.port_b.p = watersink1.p;
watersource1.port_a.m_flow + watersink1.port_b.m_flow = 0.0;
watersink1.port_b.p = watersource1.port_a.p;
end MyPowerPlant.Simple.Examples.WaterSourceSink;
Thus in the model is not equation for enthalpy "watersource1.port_a.h_outflow = watersink1.port_b.h_outflow".
Sorry for my bad english
Re: Problem with FluidPort
Perhaps in my previous post, I did not accurately explain the problem. Therefore, I attach to this letter a package with the models in the format ".mo". The problem is that I do not understand why the model "WaterSourceSink" does not work. I just started to deal with OpenModelica, so really hope to help. Thanks in advance for your help.
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Problem with FluidPort