From 2fafcd6c3019f75f0d026c21077ff8f3196cfefb Mon Sep 17 00:00:00 2001 From: Hubert Blervaque Date: Mon, 12 Jun 2023 23:20:48 +0200 Subject: [PATCH 1/2] First implementation of MSL-TFS connectors plugs. --- .../ByAssembly/FluidPortMSLtoOutletTFS_ass.mo | 96 ++++++++++++++++ .../ByAssembly/InletTFStoFluidPortMSL_ass.mo | 78 +++++++++++++ .../ByAssembly/Tests/UnitTest_Mixture_OK.mo | 103 ++++++++++++++++++ .../MSLplug/ByAssembly/Tests/package.mo | 8 ++ .../MSLplug/ByAssembly/Tests/package.order | 1 + .../Interfaces/MSLplug/ByAssembly/package.mo | 4 + .../MSLplug/ByAssembly/package.order | 3 + .../ByCode/FluidPortMSLtoOutletTFS_eq.mo | 51 +++++++++ .../ByCode/InletTFStoFluidPortMSL_eq.mo | 37 +++++++ .../Interfaces/MSLplug/ByCode/package.mo | 3 + .../Interfaces/MSLplug/ByCode/package.order | 2 + .../Interfaces/MSLplug/package.mo | 11 ++ .../Interfaces/MSLplug/package.order | 2 + ThermofluidStream/Interfaces/package.order | 1 + .../MSLplug/FluidPortMSL_ForeTFS.mo | 75 +++++++++++++ .../MSLplug/RearTFS_FluidPortMSL.mo | 77 +++++++++++++ .../Undirected/Interfaces/MSLplug/package.mo | 11 ++ .../Interfaces/MSLplug/package.order | 2 + .../Undirected/Interfaces/package.order | 1 + 19 files changed, 566 insertions(+) create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByAssembly/FluidPortMSLtoOutletTFS_ass.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByAssembly/InletTFStoFluidPortMSL_ass.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/UnitTest_Mixture_OK.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.order create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByAssembly/package.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByAssembly/package.order create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/FluidPortMSLtoOutletTFS_eq.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/InletTFStoFluidPortMSL_eq.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/package.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/package.order create mode 100644 ThermofluidStream/Interfaces/MSLplug/package.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/package.order create mode 100644 ThermofluidStream/Undirected/Interfaces/MSLplug/FluidPortMSL_ForeTFS.mo create mode 100644 ThermofluidStream/Undirected/Interfaces/MSLplug/RearTFS_FluidPortMSL.mo create mode 100644 ThermofluidStream/Undirected/Interfaces/MSLplug/package.mo create mode 100644 ThermofluidStream/Undirected/Interfaces/MSLplug/package.order diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/FluidPortMSLtoOutletTFS_ass.mo b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/FluidPortMSLtoOutletTFS_ass.mo new file mode 100644 index 00000000..f1b74328 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/FluidPortMSLtoOutletTFS_ass.mo @@ -0,0 +1,96 @@ +within ThermofluidStream.Interfaces.MSLplug.ByAssembly; +model FluidPortMSLtoOutletTFS_ass + + replaceable package Medium = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Medium model" annotation (choicesAllMatching=true, Documentation(info = " +

Medium package used in both sides of the connector.

+ ")); + final parameter Boolean BoolMonoSubstance = Medium.nS<2; + + //Real Xi[Medium.nXi]; + + Interfaces.Outlet outletTFS(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{8,-20},{48,20}}), iconTransformation(extent={{8,-20},{48,20}}))); + Modelica.Fluid.Interfaces.FluidPort_b inportMSL(redeclare package Medium = Medium) "Fluid connector b (positive design flow direction is from port_a to port_b)" + annotation (Placement(transformation(extent={{-10,-20},{-50,20}}), iconTransformation(extent={{-12,-10},{-32,10}}))); + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium, temperatureFromInput=true, + xiFromInput=not (BoolMonoSubstance)) + annotation (Placement(transformation(extent={{-20,20},{0,40}}))); + Modelica.Fluid.Sources.Boundary_pT boundary( + redeclare package Medium = Medium, + use_p_in=true, + use_X_in=false, + nPorts=1) annotation (Placement(transformation(extent={{8,-28},{-8,-12}}))); + ThermofluidStream.Sensors.SingleSensorSelect singleSensorSelect( + redeclare package Medium = Medium, + quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.p_Pa, + outputValue=true, + filter_output=false) + annotation (Placement(transformation(extent={{36,-26},{20,-14}}))); + Modelica.Fluid.Sensors.Temperature temperature(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{-42,26},{-32,34}}))); + FlowControl.MCV flowGenerator_SF( + redeclare package Medium = Medium, + setpointFromInput=true, + TC=4) annotation (Placement(transformation(extent={{6,38},{22,22}}))); + Modelica.Fluid.Sensors.MassFlowRate massFlowRate(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-20,-24},{-12,-16}}))); + Modelica.Blocks.Math.Gain forUnitCompatibility(k=1) annotation (Placement(transformation( + extent={{-2,-2},{2,2}}, + rotation=90, + origin={-16,-10}))); + Modelica.Blocks.Sources.RealExpression massFraction[Medium.nXi](y=inStream(inportMSL.Xi_outflow)) if not (BoolMonoSubstance) + annotation (Placement(transformation(extent={{-32,20},{-20,28}}))); +equation + //Xi=inStream(inportMSL.Xi_outflow); + + + connect(singleSensorSelect.value_out, boundary.p_in) + annotation (Line(points={{20,-20},{14,-20},{14,-13.6},{9.6,-13.6}}, color={0,0,127})); + connect(outletTFS, singleSensorSelect.inlet) annotation (Line( + points={{28,0},{40,0},{40,-20},{36,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(inportMSL, inportMSL) annotation (Line(points={{-30,0},{-30,0}}, color={0,127,255})); + connect(temperature.T, source.T0_var) annotation (Line(points={{-33.5,30},{-12,30}}, + color={0,0,127})); + connect(boundary.ports[1], massFlowRate.port_b) annotation (Line(points={{-8,-20},{-12,-20}}, color={0,127,255})); + connect(massFlowRate.m_flow, forUnitCompatibility.u) annotation (Line(points={{-16,-15.6},{-16,-12.4}}, color={0,0,127})); + connect(inportMSL, massFlowRate.port_a) annotation (Line(points={{-30,0},{-30,-20},{-20,-20}}, color={0,127,255})); + connect(massFraction.y, source.xi_var) annotation (Line(points={{-19.4,24},{-12,24}}, color={0,0,127})); + connect(inportMSL, temperature.port) annotation (Line(points={{-30,0},{-40,0},{-40,26},{-37,26}}, color={0,127,255})); + connect(forUnitCompatibility.y, flowGenerator_SF.setpoint_var) annotation (Line(points={{-16,-7.8},{-16,2},{14,2},{14,23.6}}, color={0,0,127})); + connect(source.outlet, flowGenerator_SF.inlet) annotation (Line( + points={{0,30},{6,30}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.outlet, outletTFS) annotation (Line( + points={{22,30},{28,30},{28,0}}, + color={28,108,200}, + thickness=0.5)); + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-40,-40},{40,40}}), graphics={ + Rectangle( + extent={{-20,20},{20,-20}}, + lineColor={28,108,200}, + fillPattern=FillPattern.Solid, + fillColor={255,255,255}, + pattern=LinePattern.None), + Line( + points={{-12,0},{20,0}}, + color={28,108,200}, + thickness=0.5), Polygon( + points={{26,-20},{26,20},{56,0},{26,-20}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Ellipse( + extent={{-42,20},{-2,-20}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Text( + extent={{-36,-20},{36,-40}}, + textColor={28,108,200}, + textString="TFS => MSL")}), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40,-40}, + {40,40}}))); +end FluidPortMSLtoOutletTFS_ass; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/InletTFStoFluidPortMSL_ass.mo b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/InletTFStoFluidPortMSL_ass.mo new file mode 100644 index 00000000..99346b48 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/InletTFStoFluidPortMSL_ass.mo @@ -0,0 +1,78 @@ +within ThermofluidStream.Interfaces.MSLplug.ByAssembly; +model InletTFStoFluidPortMSL_ass + + replaceable package Medium = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Medium model" annotation (choicesAllMatching=true, Documentation(info = " +

Medium package used in both sides of the connector.

+ ")); + final parameter Boolean BoolMonoSubstance = Medium.nS<2; + + + Interfaces.Inlet inletTFS(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{-56,-20},{-16,20}}), + iconTransformation(extent={{-56,-20},{-16,20}}))); + Modelica.Fluid.Interfaces.FluidPort_b outportMSL(redeclare package Medium = Medium) "Fluid connector b (positive design flow direction is from port_a to port_b)" + annotation (Placement(transformation(extent={{60,-20},{20,20}}), iconTransformation(extent={{30,-10},{10,10}}))); + + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium, pressureFromInput=true) + annotation (Placement(transformation(extent={{6,20},{26,40}}))); + Modelica.Fluid.Sensors.Pressure pressure(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{36,24}, + {24,36}}))); + Modelica.Fluid.Sources.MassFlowSource_T boundary( + redeclare package Medium = Medium, + use_m_flow_in=true, + use_T_in=true, + use_X_in=not (BoolMonoSubstance), + use_C_in=false, + nPorts=1) annotation (Placement(transformation(extent={{2,-30},{22,-10}}))); + + ThermofluidStream.Sensors.SingleFlowSensor singleFlowSensor( + redeclare package Medium = Medium, + quantity=ThermofluidStream.Sensors.Internal.Types.MassFlowQuantities.m_flow_kgps, + outputValue=true) annotation (Placement(transformation(extent={{-20,28},{-6,38}}))); + ThermofluidStream.Sensors.SingleSensorSelect singleSensorSelect( + redeclare package Medium = Medium, + quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.T_K, + outputValue=true) annotation (Placement(transformation(extent={{-20,-22},{-8,-10}}))); + Modelica.Blocks.Sources.RealExpression realExpression[Medium.nXi](y=Medium.massFraction(inletTFS.state)) if not (BoolMonoSubstance) + annotation (Placement(transformation(extent={{-40,-38},{-20,-18}}))); +equation + //Xi=Medium.massFraction(inletTFS.state); + + connect(outportMSL, pressure.port) annotation (Line(points={{40,0},{30,0},{30,24}}, color={0,127,255})); + connect(pressure.p, sink.p0_var) annotation (Line(points={{23.4,30},{18,30}}, color={0,0,127})); + connect(outportMSL, boundary.ports[1]) annotation (Line(points={{40,0},{32,0},{32,-20},{22,-20}}, color={0,127,255})); + connect(singleFlowSensor.value_out, boundary.m_flow_in) + annotation (Line(points={{-6,33},{-6,-12},{2,-12}}, color={0,0,127})); + connect(inletTFS, singleFlowSensor.inlet) + annotation (Line( + points={{-36,0},{-20,0},{-20,30}}, + color={28,108,200}, + thickness=0.5)); + connect(inletTFS, singleSensorSelect.inlet) + annotation (Line( + points={{-36,0},{-20,0},{-20,-16}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect.value_out, boundary.T_in) annotation (Line(points={{-8,-16},{0,-16}}, color={0,0,127})); + connect(singleFlowSensor.outlet, sink.inlet) annotation (Line( + points={{-6,30},{6,30}}, + color={28,108,200}, + thickness=0.5)); + connect(realExpression.y, boundary.X_in) annotation (Line(points={{-19,-28},{-8,-28},{-8,-24},{0,-24}}, color={0,0,127})); + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-40,-40},{40,40}}), graphics={Polygon( + points={{-30,-20},{-30,20},{0,0},{-30,-20}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Ellipse( + extent={{0,20},{40,-20}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Text( + extent={{-36,-20},{36,-40}}, + textColor={28,108,200}, + textString="TFS => MSL")}), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40,-40}, + {40,40}}))); +end InletTFStoFluidPortMSL_ass; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/UnitTest_Mixture_OK.mo b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/UnitTest_Mixture_OK.mo new file mode 100644 index 00000000..870c0986 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/UnitTest_Mixture_OK.mo @@ -0,0 +1,103 @@ +within ThermofluidStream.Interfaces.MSLplug.ByAssembly.Tests; +model UnitTest_Mixture_OK + extends Modelica.Icons.Example; + replaceable package Medium = ThermofluidStream.Media.myMedia.IdealGases.MixtureGases.CombustionAir + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium annotation ( + choicesAllMatching=true); + //ThermofluidStream.Media.myMedia.Water.WaterIF97_R1pT + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium, temperatureFromInput=true, + xiFromInput=true) annotation ( + Placement(visible = true, transformation(origin={-50,30}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium, p0_par=101300) + annotation ( + Placement(visible = true, transformation(origin={70,30}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + FlowControl.MCV flowGenerator( + redeclare package Medium = Medium, setpointFromInput=true) + annotation (Placement(transformation(extent={{-30,20},{-10,40}}))); + Modelica.Thermal.HeatTransfer.Celsius.ToKelvin toKelvin annotation (Placement( + transformation( + extent={{-4,4},{4,-4}}, + rotation=-90, + origin={-60,38}))); + Modelica.Blocks.Math.Gain gain(k=1) annotation (Placement(transformation( + extent={{-3,-4},{3,4}}, + rotation=-90, + origin={-34,45}))); + inner DropOfCommons dropOfCommons(L=1000) + annotation (Placement(transformation(extent={{80,80},{100,100}}))); + ThermofluidStream.Boundaries.Source source1(redeclare package Medium = Medium, temperatureFromInput=true, + xiFromInput=true) annotation ( + Placement(visible = true, transformation(origin={-50,-10}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Fluid.Sources.FixedBoundary sink1(redeclare package Medium = Medium, + p=101300, + nPorts=1) + annotation (Placement(transformation(extent={{80,-20},{60,0}}))); + InletTFStoFluidPortMSL_ass inletTFStoFluidPortMSL_ass( + redeclare package Medium = Medium) annotation (Placement(transformation(extent={{0,-20},{20,0}}))); + FlowControl.MCV flowGenerator1( + redeclare package Medium = Medium, setpointFromInput=true) + annotation (Placement(transformation(extent={{-30,-20},{-10,0}}))); + Modelica.Fluid.Sources.MassFlowSource_T flowGenerator2( + redeclare package Medium = Medium, + use_m_flow_in=true, + use_T_in=true, + use_X_in=true, + nPorts=1) annotation (Placement(transformation(extent={{-40,-60},{-20,-40}}))); + FluidPortMSLtoOutletTFS_ass fluidPortMSLtoOutletTFS_ass(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{0,-60},{20,-40}}))); + ThermofluidStream.Boundaries.Sink sink2(redeclare package Medium = Medium, p0_par=101300) + annotation ( + Placement(visible = true, transformation(origin={70,-50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.RealExpression x_N2O2[2](y={0.8*exp(-time/1E4),1 - 0.8*exp(-time/1E4)}) annotation (Placement(transformation(extent={{-100,88},{-80,100}}))); + Modelica.Fluid.Sensors.Temperature temperature(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{22,0},{34,10}}))); + Modelica.Fluid.Sensors.Temperature temperature1(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-4,-40},{8,-30}}))); + Modelica.Blocks.Noise.UniformNoise mFlowScenario( + samplePeriod=60, + y_min=0.001, + y_max=15) annotation (Placement(transformation(extent={{-100,66},{-80,80}}))); + Modelica.Blocks.Noise.UniformNoise temperatureScenario( + samplePeriod=60, + y_min=10, + y_max=35) annotation (Placement(transformation(extent={{-100,40},{-80,56}}))); +equation + connect(source.outlet, flowGenerator.inlet) annotation (Line( + points={{-40,30},{-30,30}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator.outlet, sink.inlet) annotation (Line( + points={{-10,30},{60,30}}, + color={28,108,200}, + thickness=0.5)); + connect(source1.outlet, flowGenerator1.inlet) annotation (Line( + points={{-40,-10},{-30,-10}}, + color={28,108,200}, + thickness=0.5)); + connect(inletTFStoFluidPortMSL_ass.inletTFS, flowGenerator1.outlet) annotation (Line( + points={{1,-10},{-10,-10}}, + color={28,108,200}, + thickness=0.5)); + connect(toKelvin.Kelvin, source1.T0_var) annotation (Line(points={{-60,33.6},{-60,-10},{-52,-10}}, + color={0,0,127})); + connect(toKelvin.Kelvin, source.T0_var) annotation (Line(points={{-60,33.6},{-60,30},{-52,30}}, color={0,0,127})); + connect(toKelvin.Kelvin, flowGenerator2.T_in) annotation (Line(points={{-60,33.6},{-60,-46},{-42,-46}}, color={0,0,127})); + connect(gain.y, flowGenerator2.m_flow_in) annotation (Line(points={{-34,41.7},{-34,-30},{-52,-30},{-52,-42},{-40,-42}}, color={0,0,127})); + connect(fluidPortMSLtoOutletTFS_ass.outletTFS, sink2.inlet) annotation (Line( + points={{18.5,-50},{60,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(x_N2O2.y, source.xi_var) annotation (Line(points={{-79,94},{-56,94},{-56,24},{-52,24}}, color={0,0,127})); + connect(x_N2O2.y, flowGenerator2.X_in) annotation (Line(points={{-79,94},{-56,94},{-56,-54},{-42,-54}}, color={0,0,127})); + connect(x_N2O2.y, source1.xi_var) annotation (Line(points={{-79,94},{-56,94},{-56,-16},{-52,-16}}, + color={0,0,127})); + connect(flowGenerator2.ports[1], fluidPortMSLtoOutletTFS_ass.inportMSL) annotation (Line(points={{-20,-50},{4.5,-50}}, color={0,127,255})); + connect(inletTFStoFluidPortMSL_ass.outportMSL, sink1.ports[1]) annotation (Line(points={{15,-10},{60,-10}}, + color={0,127,255})); + connect(inletTFStoFluidPortMSL_ass.outportMSL, temperature.port) annotation (Line(points={{15,-10},{28,-10},{28,0}}, + color={0,127,255})); + connect(temperature1.port, fluidPortMSLtoOutletTFS_ass.inportMSL) annotation (Line(points={{2,-40},{2,-50},{4.5,-50}}, color={0,127,255})); + connect(gain.y, flowGenerator.setpoint_var) annotation (Line(points={{-34,41.7},{-20,41.7},{-20,38}}, color={0,0,127})); + connect(gain.y, flowGenerator1.setpoint_var) annotation (Line(points={{-34,41.7},{-34,8},{-20,8},{-20,-2}}, color={0,0,127})); + connect(mFlowScenario.y, gain.u) annotation (Line(points={{-79,73},{-34,73},{-34,48.6}}, color={0,0,127})); + connect(temperatureScenario.y, toKelvin.Celsius) annotation (Line(points={{-79,48},{-60,48},{-60,42.8}}, color={0,0,127})); + annotation (experiment(StopTime=172800, __Dymola_Algorithm="Dassl")); +end UnitTest_Mixture_OK; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.mo b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.mo new file mode 100644 index 00000000..ec487faa --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.mo @@ -0,0 +1,8 @@ +within ThermofluidStream.Interfaces.MSLplug.ByAssembly; +package Tests "Tests for concepts implemented in the interfaces" +extends Modelica.Icons.ExamplesPackage; + +annotation (Documentation(info=" +

Tests for concepts implemented in the interfaces

+")); +end Tests; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.order b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.order new file mode 100644 index 00000000..825c19bc --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.order @@ -0,0 +1 @@ +UnitTest_Mixture_OK diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/package.mo b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/package.mo new file mode 100644 index 00000000..df4d7bc8 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/package.mo @@ -0,0 +1,4 @@ +within ThermofluidStream.Interfaces.MSLplug; +package ByAssembly + +end ByAssembly; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/package.order b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/package.order new file mode 100644 index 00000000..425621dd --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/package.order @@ -0,0 +1,3 @@ +InletTFStoFluidPortMSL_ass +FluidPortMSLtoOutletTFS_ass +Tests diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/FluidPortMSLtoOutletTFS_eq.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/FluidPortMSLtoOutletTFS_eq.mo new file mode 100644 index 00000000..157312b5 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/FluidPortMSLtoOutletTFS_eq.mo @@ -0,0 +1,51 @@ +within ThermofluidStream.Interfaces.MSLplug.ByCode; +model FluidPortMSLtoOutletTFS_eq + + replaceable package Medium = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Medium model" annotation (choicesAllMatching=true, Documentation(info = " +

Medium package used in both sides of the connector.

+ ")); + parameter ThermofluidStream.Utilities.Units.Inertance L=dropOfCommons.L "Inertance" + annotation (Dialog(tab="Advanced")); + + Interfaces.Outlet outletTFS(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{14,-20},{54,20}}), iconTransformation(extent={{14,-20},{54,20}}))); + Modelica.Fluid.Interfaces.FluidPort_b portMSL(redeclare package Medium = Medium) "Fluid connector b (positive design flow direction is from port_a to port_b)" + annotation (Placement(transformation(extent={{-10,-20},{-50,20}}), iconTransformation(extent={{-12,-10},{-32,10}}))); + +protected + outer ThermofluidStream.DropOfCommons dropOfCommons; + +equation + outletTFS.m_flow + portMSL.m_flow =0; +// portMSL.p = Medium.pressure(outletTFS.state)+outletTFS.r; + L*der(outletTFS.m_flow) = outletTFS.r - 0; + outletTFS.state=Medium.setState_phX(portMSL.p, inStream(portMSL.h_outflow), inStream(portMSL.Xi_outflow)); + portMSL.h_outflow=Medium.specificEnthalpy(outletTFS.state); + + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-40,-40},{40,40}}), graphics={ + Rectangle( + extent={{-20,20},{20,-20}}, + lineColor={28,108,200}, + fillPattern=FillPattern.Solid, + fillColor={255,255,255}, + pattern=LinePattern.None), + Line( + points={{-12,0},{20,0}}, + color={28,108,200}, + thickness=0.5), Polygon( + points={{18,-20},{18,20},{48,0},{18,-20}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Ellipse( + extent={{-42,20},{-2,-20}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Text( + extent={{-36,-20},{36,-40}}, + textColor={28,108,200}, + textString="TFS => MSL")}), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40,-40}, + {40,40}}))); +end FluidPortMSLtoOutletTFS_eq; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/InletTFStoFluidPortMSL_eq.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/InletTFStoFluidPortMSL_eq.mo new file mode 100644 index 00000000..95e03d12 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/InletTFStoFluidPortMSL_eq.mo @@ -0,0 +1,37 @@ +within ThermofluidStream.Interfaces.MSLplug.ByCode; +model InletTFStoFluidPortMSL_eq + + replaceable package Medium = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Medium model" annotation (choicesAllMatching=true, Documentation(info = " +

Medium package used in both sides of the connector.

+")); + + Interfaces.Inlet inletTFS(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{-56,-20},{-16,20}}), + iconTransformation(extent={{-56,-20},{-16,20}}))); + Modelica.Fluid.Interfaces.FluidPort_b portMSL(redeclare package Medium = Medium) + "Fluid connector b (positive design flow direction is from port_a to port_b)" annotation (Placement(transformation(extent={{40,-20}, + {0,20}}), iconTransformation(extent={{30,-10}, + {10,10}}))); + +equation + portMSL.m_flow = -inletTFS.m_flow; + portMSL.p = Medium.pressure(inletTFS.state)+inletTFS.r; + portMSL.h_outflow = Medium.specificEnthalpy(inletTFS.state); + + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-40,-40},{40,40}}), graphics={Polygon( + points={{-30,-20},{-30,20},{0,0},{-30,-20}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Ellipse( + extent={{0,20},{40,-20}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Text( + extent={{-36,-20},{36,-40}}, + textColor={28,108,200}, + textString="TFS => MSL")}), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40,-40}, + {40,40}}))); +end InletTFStoFluidPortMSL_eq; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/package.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/package.mo new file mode 100644 index 00000000..cfbd29c1 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/package.mo @@ -0,0 +1,3 @@ +within ThermofluidStream.Interfaces.MSLplug; +package ByCode +end ByCode; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/package.order b/ThermofluidStream/Interfaces/MSLplug/ByCode/package.order new file mode 100644 index 00000000..b288441f --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/package.order @@ -0,0 +1,2 @@ +InletTFStoFluidPortMSL_eq +FluidPortMSLtoOutletTFS_eq diff --git a/ThermofluidStream/Interfaces/MSLplug/package.mo b/ThermofluidStream/Interfaces/MSLplug/package.mo new file mode 100644 index 00000000..ff85ede4 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/package.mo @@ -0,0 +1,11 @@ +within ThermofluidStream.Interfaces; +package MSLplug + extends Modelica.Icons.Package; + + annotation (Icon(graphics={Text( + extent={{-60,62},{68,-60}}, + textColor={28,108,200}, + textStyle={TextStyle.Italic}, + textString="MSL +TFS ")})); +end MSLplug; diff --git a/ThermofluidStream/Interfaces/MSLplug/package.order b/ThermofluidStream/Interfaces/MSLplug/package.order new file mode 100644 index 00000000..c0d2e1fe --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/package.order @@ -0,0 +1,2 @@ +ByAssembly +ByCode diff --git a/ThermofluidStream/Interfaces/package.order b/ThermofluidStream/Interfaces/package.order index b72a5b15..c28c523a 100644 --- a/ThermofluidStream/Interfaces/package.order +++ b/ThermofluidStream/Interfaces/package.order @@ -4,3 +4,4 @@ StateInput StateOutput SISOFlow Tests +MSLplug diff --git a/ThermofluidStream/Undirected/Interfaces/MSLplug/FluidPortMSL_ForeTFS.mo b/ThermofluidStream/Undirected/Interfaces/MSLplug/FluidPortMSL_ForeTFS.mo new file mode 100644 index 00000000..93fbb20f --- /dev/null +++ b/ThermofluidStream/Undirected/Interfaces/MSLplug/FluidPortMSL_ForeTFS.mo @@ -0,0 +1,75 @@ +within ThermofluidStream.Undirected.Interfaces.MSLplug; +model FluidPortMSL_ForeTFS + + replaceable package Medium = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Medium model" annotation (choicesAllMatching=true, Documentation(info = " +

Medium package used in both sides of the connector.

+ ")); +protected + outer ThermofluidStream.DropOfCommons dropOfCommons; + Modelica.Units.SI.Pressure r; +public + parameter ThermofluidStream.Utilities.Units.Inertance L=dropOfCommons.L "Inertance of pressure" + annotation (Dialog(tab="Advanced")); + + Modelica.Fluid.Interfaces.FluidPort_b portMSL(redeclare package Medium = Medium) + "Fluid connector b (positive design flow direction is from port_a to port_b)" annotation (Placement(transformation(extent={{-20,-20},{-60,20}}),iconTransformation(extent={{-30,-10}, + {-50,10}}))); + + Fore fore annotation (Placement(transformation(extent={{20,-20},{60,20}}), iconTransformation(extent={{20,-20},{60,20}}))); +equation + + // Mass balance + rearTFS.m_flow + portMSL.m_flow = 0; + + // Pressure + der(rearTFS.m_flow)*L = rearTFS.r - r; + Medium.pressure(rearTFS.state_rearwards) + r = portMSL.p; + Medium.pressure(rearTFS.state_forwards) + r = portMSL.p; + + // Enthalpy + portMSL.h_outflow = Medium.specificEnthalpy(rearTFS.state_rearwards); + rearTFS.state_rearwards = Medium.setState_phX(portMSL.p,inStream(portMSL.h_outflow),inStream(portMSL.Xi_outflow)); + +// port_a.Xi_outflow = inStream(port_b.Xi_outflow); +// port_b.Xi_outflow = inStream(port_a.Xi_outflow); +// port_a.C_outflow = inStream(port_b.C_outflow); +// port_b.C_outflow = inStream(port_a.C_outflow); + + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-40,-40},{40,40}}), graphics={ + Rectangle( + extent={{-40,20},{40,-20}}, + pattern=LinePattern.None, + lineColor={0,0,0}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Text( + extent={{-36,32},{36,12}}, + textColor={28,108,200}, + textString="MSL <=> TFS"), + Polygon( + points={{8,-12.5},{28,-20.5},{8,-28.5},{8,-12.5}}, + lineColor={0,128,255}, + fillColor={0,128,255}, + fillPattern=FillPattern.Solid, + visible=showDesignFlowDirection), + Polygon( + points={{8,-14},{20,-20},{8,-27},{8,-14}}, + lineColor={255,255,255}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + visible=allowFlowReversal), + Line( + points={{20,-20.5},{-24,-20.5}}, + color={0,128,255}, + visible=showDesignFlowDirection), + Line( + points={{28,2},{-30,2}}, + color={0,128,255}, + visible=showDesignFlowDirection), + Line( + points={{28,-2},{-30,-2}}, + color={0,128,255}, + visible=showDesignFlowDirection)}), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40,-40}, + {40,40}}))); +end FluidPortMSL_ForeTFS; diff --git a/ThermofluidStream/Undirected/Interfaces/MSLplug/RearTFS_FluidPortMSL.mo b/ThermofluidStream/Undirected/Interfaces/MSLplug/RearTFS_FluidPortMSL.mo new file mode 100644 index 00000000..b13ab8d0 --- /dev/null +++ b/ThermofluidStream/Undirected/Interfaces/MSLplug/RearTFS_FluidPortMSL.mo @@ -0,0 +1,77 @@ +within ThermofluidStream.Undirected.Interfaces.MSLplug; +model RearTFS_FluidPortMSL + + replaceable package Medium = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Medium model" annotation (choicesAllMatching=true, Documentation(info = " +

Medium package used in both sides of the connector.

+ ")); +protected + outer ThermofluidStream.DropOfCommons dropOfCommons; + Modelica.Units.SI.Pressure r; +public + parameter ThermofluidStream.Utilities.Units.Inertance L=dropOfCommons.L "Inertance of pressure" + annotation (Dialog(tab="Advanced")); + + Modelica.Fluid.Interfaces.FluidPort_b portMSL(redeclare package Medium = Medium) + "Fluid connector b (positive design flow direction is from port_a to port_b)" annotation (Placement(transformation(extent={{60,-20},{20,20}}), iconTransformation(extent={{50,-10}, + {30,10}}))); + ThermofluidStream.Undirected.Interfaces.Rear rearTFS(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{-60,-20},{-20,20}}), + iconTransformation(extent={{-60,-20},{-20,20}}))); + +equation + + // Mass balance + rearTFS.m_flow + portMSL.m_flow = 0; + + // Pressure + der(rearTFS.m_flow)*L = rearTFS.r - r; + Medium.pressure(rearTFS.state_rearwards) + r = portMSL.p; + Medium.pressure(rearTFS.state_forwards) + r = portMSL.p; + + // Enthalpy + portMSL.h_outflow = Medium.specificEnthalpy(rearTFS.state_rearwards); + rearTFS.state_rearwards = Medium.setState_phX(portMSL.p,inStream(portMSL.h_outflow),inStream(portMSL.Xi_outflow)); + +// port_a.Xi_outflow = inStream(port_b.Xi_outflow); +// port_b.Xi_outflow = inStream(port_a.Xi_outflow); +// port_a.C_outflow = inStream(port_b.C_outflow); +// port_b.C_outflow = inStream(port_a.C_outflow); + + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-40,-40},{40,40}}), graphics={ + Rectangle( + extent={{-40,20},{40,-20}}, + pattern=LinePattern.None, + lineColor={0,0,0}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid), + Text( + extent={{-36,32},{36,12}}, + textColor={28,108,200}, + textString="TFS <=> MSL"), + Polygon( + points={{8,-12.5},{28,-20.5},{8,-28.5},{8,-12.5}}, + lineColor={0,128,255}, + fillColor={0,128,255}, + fillPattern=FillPattern.Solid, + visible=showDesignFlowDirection), + Polygon( + points={{8,-14},{20,-20},{8,-27},{8,-14}}, + lineColor={255,255,255}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + visible=allowFlowReversal), + Line( + points={{20,-20.5},{-24,-20.5}}, + color={0,128,255}, + visible=showDesignFlowDirection), + Line( + points={{30,2},{-28,2}}, + color={0,128,255}, + visible=showDesignFlowDirection), + Line( + points={{30,-2},{-28,-2}}, + color={0,128,255}, + visible=showDesignFlowDirection)}), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40,-40}, + {40,40}}))); +end RearTFS_FluidPortMSL; diff --git a/ThermofluidStream/Undirected/Interfaces/MSLplug/package.mo b/ThermofluidStream/Undirected/Interfaces/MSLplug/package.mo new file mode 100644 index 00000000..2c4be27e --- /dev/null +++ b/ThermofluidStream/Undirected/Interfaces/MSLplug/package.mo @@ -0,0 +1,11 @@ +within ThermofluidStream.Undirected.Interfaces; +package MSLplug + extends Modelica.Icons.Package; + + annotation (Icon(graphics={Text( + extent={{-60,62},{68,-60}}, + textColor={28,108,200}, + textStyle={TextStyle.Italic}, + textString="MSL +TFS ")})); +end MSLplug; diff --git a/ThermofluidStream/Undirected/Interfaces/MSLplug/package.order b/ThermofluidStream/Undirected/Interfaces/MSLplug/package.order new file mode 100644 index 00000000..5762021d --- /dev/null +++ b/ThermofluidStream/Undirected/Interfaces/MSLplug/package.order @@ -0,0 +1,2 @@ +RearTFS_FluidPortMSL +FluidPortMSL_ForeTFS diff --git a/ThermofluidStream/Undirected/Interfaces/package.order b/ThermofluidStream/Undirected/Interfaces/package.order index 35f60414..92d2a506 100644 --- a/ThermofluidStream/Undirected/Interfaces/package.order +++ b/ThermofluidStream/Undirected/Interfaces/package.order @@ -2,3 +2,4 @@ Fore Rear SISOBiFlow Tests +MSLplug From fc79adda038c1a2ecb5ca92398ac83715f4a38c7 Mon Sep 17 00:00:00 2001 From: Hubert Blervaque Date: Fri, 23 Jun 2023 17:38:21 +0200 Subject: [PATCH 2/2] For pull request to share models (and associated issues) to connect MSL and TFS fluid connectors. Firstly the directed flow connectors and then for undirected flow connectors. --- .../MSLplug/ByAssembly/Tests/TargetTest_00.mo | 184 +++++++++++ .../ByAssembly/Tests/TargetTest_01_NOK.mo | 194 ++++++++++++ .../ByAssembly/Tests/TargetTest_02_NOK.mo | 229 ++++++++++++++ .../ByAssembly/Tests/UnitTest_Mixture_OK.mo | 225 +++++++++++--- .../MSLplug/ByAssembly/Tests/package.order | 3 + .../ByCode/FluidPortMSLtoOutletTFS_eq.mo | 4 +- .../ByCode/Tests/SimpleCoolingCycle.mo | 283 +++++++++++++++++ .../ByCode/Tests/SimpleCoolingCycle_01_OK.mo | 291 ++++++++++++++++++ .../Tests/SimpleCoolingCycle_02MCV_NOK.mo | 282 +++++++++++++++++ .../MSLplug/ByCode/Tests/TargetTest_00_NOK.mo | 192 ++++++++++++ .../MSLplug/ByCode/Tests/TargetTest_01_NOK.mo | 198 ++++++++++++ .../ByCode/Tests/TargetTest_02_NoFlow.mo | 245 +++++++++++++++ .../Tests/UnitTest_NoMixtureOnlyForNow_OK.mo | 254 +++++++++++++++ .../MSLplug/ByCode/Tests/package.mo | 8 + .../MSLplug/ByCode/Tests/package.order | 7 + .../Interfaces/MSLplug/ByCode/package.order | 1 + .../MSLplug/Tests/TargetTest_10_NOK.mo | 260 ++++++++++++++++ .../MSLplug/Tests/TargetTest_12_NOK.mo | 278 +++++++++++++++++ .../Interfaces/MSLplug/Tests/package.mo | 8 + .../Interfaces/MSLplug/Tests/package.order | 2 + .../Interfaces/MSLplug/package.order | 1 + 21 files changed, 3103 insertions(+), 46 deletions(-) create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_00.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_01_NOK.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_02_NOK.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle_01_OK.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle_02MCV_NOK.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_00_NOK.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_01_NOK.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_02_NoFlow.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/UnitTest_NoMixtureOnlyForNow_OK.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/package.mo create mode 100644 ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/package.order create mode 100644 ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/TargetTest_10_NOK.mo create mode 100644 ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/TargetTest_12_NOK.mo create mode 100644 ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/package.mo create mode 100644 ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/package.order diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_00.mo b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_00.mo new file mode 100644 index 00000000..e7c8dc0c --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_00.mo @@ -0,0 +1,184 @@ +within ThermofluidStream.Interfaces.MSLplug.ByAssembly.Tests; +model TargetTest_00 + extends Modelica.Icons.Example; + + replaceable package Medium = ThermofluidStream.Media.myMedia.Water.StandardWaterOnePhase + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + annotation ( + choicesAllMatching=true); + + parameter Modelica.Units.NonSI.Temperature_degC T_SP=80 "Solar field outlet temperature setpoint" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC l_s=55 "Security maximum temperature threshold for production switching" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC hyst_prod_pre=5 "Temperature hysteresis for switches in between in production and out of production" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_SP=10 "Security margin deduced from the temperature setpoint to switch in production (compared with l_s and valuabe process temperature)." + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_min=5 "Minimum temperature difference supplied to the process" + annotation(Dialog(group = "Control")); + parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "nominal mass flow rate for regularisation" + annotation(Dialog(tab = "Advanced", group = "Regularisation parameters")); + parameter Boolean computeL=true "Compute L from r and l" annotation (Dialog(tab="Advanced", group="Flow inertance")); + + HeatExchangers.CounterFlowNTU pHEXSimplified( + redeclare package MediumA = Medium, + redeclare package MediumB = Medium, + A=10) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=-90, + origin={20,10}))); + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{56,30},{76,50}}))); + + ThermofluidStream.FlowControl.MCV mCV( + redeclare package Medium = Medium, massFlow_set_par=1) + annotation (Placement(transformation(extent={{50,-10},{30,-30}}))); + ThermofluidStream.FlowControl.MCV flowGenerator_SF( + redeclare package Medium = Medium, massFlow_set_par=10) + annotation (Placement(transformation(extent={{-30,-10},{-50,-30}}))); + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{80,-30},{60,-10}}))); + inner DropOfCommons dropOfCommons(L=1000) + annotation (Placement(transformation(extent={{-80,60},{-60,80}}))); + inner Modelica.Fluid.System system annotation (Placement(transformation(extent={{-100,60},{-80,80}}))); + Modelica.Blocks.Noise.UniformNoise heatScenario( + samplePeriod=60, + y_min=-100, + y_max=5000) annotation (Placement(transformation(extent={{-110,0},{-90,20}}))); + Modelica.Blocks.Noise.UniformNoise mFlowScenario( + samplePeriod=60, + y_min=0.001, + y_max=15) annotation (Placement(transformation(extent={{100,-10},{80,10}}))); + Processes.ThermalConvectionPipe thermalConvectionPipe( + redeclare package Medium = Medium, + r=0.2, + l=100) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-60,10}))); + Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow prescribedHeatFlow annotation (Placement(transformation(extent={{-84,6},{-76,14}}))); + Boundaries.Reservoir reservoir(redeclare package Medium = Medium, A_surf(displayUnit="m2")) annotation (Placement(transformation(extent={{0,-30},{-20,-10}}))); +protected + parameter Medium.ThermodynamicState state_0_CS = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_CS = Medium.density(state_0_CS); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_CS = Medium.specificHeatCapacityCp(state_0_CS); + parameter Medium.ThermodynamicState state_0_cuve = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_cuve = Medium.density(state_0_cuve); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_cuve = Medium.specificHeatCapacityCp(state_0_cuve); + +equation + + connect(mCV.outlet, pHEXSimplified.inletB) annotation (Line( + points={{30,-20},{26,-20},{26,-4.44089e-15}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletB, sink.inlet) annotation (Line( + points={{26,20},{26,40},{56,40}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.inlet, source.outlet) annotation (Line( + points={{50,-20},{60,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.outlet, thermalConvectionPipe.inlet) annotation (Line( + points={{-50,-20},{-60,-20},{-60,0}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.outlet, pHEXSimplified.inletA) + annotation (Line( + points={{-60,20},{-60,40},{14,40},{14,20}}, + color={28,108,200}, + thickness=0.5)); + connect(heatScenario.y, prescribedHeatFlow.Q_flow) annotation (Line(points={{-89,10},{-84,10}}, color={0,0,127})); + connect(thermalConvectionPipe.heatPort, prescribedHeatFlow.port) annotation (Line(points={{-70,10},{-76,10}}, color={191,0,0})); + connect(flowGenerator_SF.inlet, reservoir.outlet) annotation (Line( + points={{-30,-20},{-20,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletA, reservoir.inlet) annotation (Line( + points={{14,0},{14,-20},{0,-20}}, + color={28,108,200}, + thickness=0.5)); + annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + experiment( + StopTime=3600, + Interval=60, + __Dymola_Algorithm="Dassl"), + __Dymola_Commands( + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","weather.T_amb","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-5.0,90.0}, + grid=true, + colors={{28,108,200},{238,46,47},{217,67,180},{0,140,72},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"})} "Temp CS", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,697}, + y={"weather.T_amb","solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-10.0,90.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47},{217,67,180},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"}),createPlot( + id=1, + position={0,0,1614,697}, + y={"stratifiedTank_Diffuser.T_lay[1]","stratifiedTank_Diffuser.T_lay[3]","stratifiedTank_Diffuser.T_lay[5]","stratifiedTank_Diffuser.T_lay[7]","stratifiedTank_Diffuser.T_lay[9]", + "stratifiedTank_Diffuser.T_lay[11]","stratifiedTank_Diffuser.T_lay[13]","stratifiedTank_Diffuser.T_lay[15]","stratifiedTank_Diffuser.T_lay[17]","stratifiedTank_Diffuser.T_lay[19]", + "stratifiedTank_Diffuser.T_lay[20]"}, + range={0.0,195.0,10.0,80.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47},{0,140,72},{217,67,180},{0,0,0},{162,29,33},{244,125,35},{102,44,145},{28,108,200},{238,46,47},{0,140,72}}, + patterns={LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid, + LinePattern.Solid,LinePattern.Dash,LinePattern.Dash,LinePattern.Dash}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","degC","degC","degC","degC","degC","degC"})} "Températures CS et cuve", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"prod_switch.y","flowGenerator_SF.V_flow_out","flowGenerator_SF.V_flow_sp"}, + range={0.0,700000.0,-5.0,50.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"","m3/h","m3/h"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.L"}, + range={0.0,700000.0,-1000000.0,11000000.0}, + grid=true, + subPlot=202, + colors={{28,108,200}}, + timeUnit="s", + displayUnits={"1/m"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.dr","flowGenerator_SF.dr_set"}, + range={0.0,700000.0,-4.0,4.0}, + grid=true, + subPlot=201, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.p_in","flowGenerator_SF.p_out"}, + range={0.0,700000.0,0.5,4.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"})} "Inertance analysis")); +end TargetTest_00; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_01_NOK.mo b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_01_NOK.mo new file mode 100644 index 00000000..46b00f87 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_01_NOK.mo @@ -0,0 +1,194 @@ +within ThermofluidStream.Interfaces.MSLplug.ByAssembly.Tests; +model TargetTest_01_NOK + extends Modelica.Icons.Example; + + replaceable package Medium = ThermofluidStream.Media.myMedia.Water.StandardWaterOnePhase + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + annotation ( + choicesAllMatching=true); + + parameter Modelica.Units.NonSI.Temperature_degC T_SP=80 "Solar field outlet temperature setpoint" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC l_s=55 "Security maximum temperature threshold for production switching" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC hyst_prod_pre=5 "Temperature hysteresis for switches in between in production and out of production" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_SP=10 "Security margin deduced from the temperature setpoint to switch in production (compared with l_s and valuabe process temperature)." + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_min=5 "Minimum temperature difference supplied to the process" + annotation(Dialog(group = "Control")); + parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "nominal mass flow rate for regularisation" + annotation(Dialog(tab = "Advanced", group = "Regularisation parameters")); + parameter Boolean computeL=true "Compute L from r and l" annotation (Dialog(tab="Advanced", group="Flow inertance")); + + HeatExchangers.CounterFlowNTU pHEXSimplified( + redeclare package MediumA = Medium, + redeclare package MediumB = Medium, + A=10) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=-90, + origin={20,10}))); + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{56,30},{76,50}}))); + + ThermofluidStream.FlowControl.MCV mCV( + redeclare package Medium = Medium, massFlow_set_par=1) + annotation (Placement(transformation(extent={{50,-10},{30,-30}}))); + ThermofluidStream.FlowControl.MCV flowGenerator_SF( + redeclare package Medium = Medium, massFlow_set_par=10) + annotation (Placement(transformation(extent={{-30,-10},{-50,-30}}))); + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{80,-30},{60,-10}}))); + inner DropOfCommons dropOfCommons(L=1000) + annotation (Placement(transformation(extent={{-80,60},{-60,80}}))); + inner Modelica.Fluid.System system(g=0.0000001) + annotation (Placement(transformation(extent={{-100,60},{-80,80}}))); + Modelica.Blocks.Noise.UniformNoise heatScenario( + samplePeriod=60, + y_min=-100, + y_max=5000) annotation (Placement(transformation(extent={{-100,0},{-80,20}}))); + Processes.ThermalConvectionPipe thermalConvectionPipe( + redeclare package Medium = Medium, + r=0.2, + l=100) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-60,10}))); + Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow prescribedHeatFlow annotation (Placement(transformation(extent={{-80,6},{-72,14}}))); + FluidPortMSLtoOutletTFS_ass fluidPortMSLtoOutletTFS_ass(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-18,-24},{-26,-16}}))); + InletTFStoFluidPortMSL_ass inletTFStoFluidPortMSL_ass(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{10,-24},{2,-16}}))); + Modelica.Fluid.Vessels.OpenTank tank( + height=1000, + crossArea=0.01, + p_ambient=100000, + level_start(displayUnit="cm") = 0.1, + redeclare package Medium = Medium, + use_portsData=false, + nPorts=2) annotation (Placement(transformation(extent={{-18,-20},{2,0}}))); +protected + parameter Medium.ThermodynamicState state_0_CS = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_CS = Medium.density(state_0_CS); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_CS = Medium.specificHeatCapacityCp(state_0_CS); + parameter Medium.ThermodynamicState state_0_cuve = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_cuve = Medium.density(state_0_cuve); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_cuve = Medium.specificHeatCapacityCp(state_0_cuve); + +equation + + connect(mCV.outlet, pHEXSimplified.inletB) annotation (Line( + points={{30,-20},{26,-20},{26,-4.44089e-15}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletB, sink.inlet) annotation (Line( + points={{26,20},{26,40},{56,40}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.inlet, source.outlet) annotation (Line( + points={{50,-20},{60,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.outlet, thermalConvectionPipe.inlet) annotation (Line( + points={{-50,-20},{-60,-20},{-60,0}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.outlet, pHEXSimplified.inletA) + annotation (Line( + points={{-60,20},{-60,40},{14,40},{14,20}}, + color={28,108,200}, + thickness=0.5)); + connect(heatScenario.y, prescribedHeatFlow.Q_flow) annotation (Line(points={{-79,10},{-80,10}}, color={0,0,127})); + connect(thermalConvectionPipe.heatPort, prescribedHeatFlow.port) annotation (Line(points={{-70,10},{-72,10}}, color={191,0,0})); + connect(flowGenerator_SF.inlet, fluidPortMSLtoOutletTFS_ass.outletTFS) + annotation (Line( + points={{-30,-20},{-24.8,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletA, inletTFStoFluidPortMSL_ass.inletTFS) + annotation (Line( + points={{14,-2.66454e-15},{14,-20},{9.6,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(inletTFStoFluidPortMSL_ass.outportMSL, tank.ports[1]) annotation (Line(points={{4,-20},{-9,-20}}, color={0,127,255})); + connect(tank.ports[2], fluidPortMSLtoOutletTFS_ass.inportMSL) annotation (Line(points={{-7,-20},{-19.8,-20}}, color={0,127,255})); + annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + experiment( + StopTime=3600, + Interval=60, + __Dymola_Algorithm="Dassl"), + __Dymola_Commands( + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","weather.T_amb","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-5.0,90.0}, + grid=true, + colors={{28,108,200},{238,46,47},{217,67,180},{0,140,72},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"})} "Temp CS", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,697}, + y={"weather.T_amb","solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-10.0,90.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47},{217,67,180},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"}),createPlot( + id=1, + position={0,0,1614,697}, + y={"stratifiedTank_Diffuser.T_lay[1]","stratifiedTank_Diffuser.T_lay[3]","stratifiedTank_Diffuser.T_lay[5]","stratifiedTank_Diffuser.T_lay[7]","stratifiedTank_Diffuser.T_lay[9]", + "stratifiedTank_Diffuser.T_lay[11]","stratifiedTank_Diffuser.T_lay[13]","stratifiedTank_Diffuser.T_lay[15]","stratifiedTank_Diffuser.T_lay[17]","stratifiedTank_Diffuser.T_lay[19]", + "stratifiedTank_Diffuser.T_lay[20]"}, + range={0.0,195.0,10.0,80.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47},{0,140,72},{217,67,180},{0,0,0},{162,29,33},{244,125,35},{102,44,145},{28,108,200},{238,46,47},{0,140,72}}, + patterns={LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid, + LinePattern.Solid,LinePattern.Dash,LinePattern.Dash,LinePattern.Dash}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","degC","degC","degC","degC","degC","degC"})} "Températures CS et cuve", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"prod_switch.y","flowGenerator_SF.V_flow_out","flowGenerator_SF.V_flow_sp"}, + range={0.0,700000.0,-5.0,50.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"","m3/h","m3/h"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.L"}, + range={0.0,700000.0,-1000000.0,11000000.0}, + grid=true, + subPlot=202, + colors={{28,108,200}}, + timeUnit="s", + displayUnits={"1/m"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.dr","flowGenerator_SF.dr_set"}, + range={0.0,700000.0,-4.0,4.0}, + grid=true, + subPlot=201, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.p_in","flowGenerator_SF.p_out"}, + range={0.0,700000.0,0.5,4.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"})} "Inertance analysis")); +end TargetTest_01_NOK; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_02_NOK.mo b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_02_NOK.mo new file mode 100644 index 00000000..8ddf6d42 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/TargetTest_02_NOK.mo @@ -0,0 +1,229 @@ +within ThermofluidStream.Interfaces.MSLplug.ByAssembly.Tests; +model TargetTest_02_NOK + extends Modelica.Icons.Example; + + replaceable package Medium = ThermofluidStream.Media.myMedia.Water.StandardWaterOnePhase + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + annotation ( + choicesAllMatching=true); + + parameter Modelica.Units.NonSI.Temperature_degC T_SP=80 "Solar field outlet temperature setpoint" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC l_s=55 "Security maximum temperature threshold for production switching" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC hyst_prod_pre=5 "Temperature hysteresis for switches in between in production and out of production" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_SP=10 "Security margin deduced from the temperature setpoint to switch in production (compared with l_s and valuabe process temperature)." + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_min=5 "Minimum temperature difference supplied to the process" + annotation(Dialog(group = "Control")); + parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "nominal mass flow rate for regularisation" + annotation(Dialog(tab = "Advanced", group = "Regularisation parameters")); + parameter Boolean computeL=true "Compute L from r and l" annotation (Dialog(tab="Advanced", group="Flow inertance")); + + HeatExchangers.CounterFlowNTU pHEXSimplified( + redeclare package MediumA = Medium, + redeclare package MediumB = Medium, + A=10) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=-90, + origin={20,-10}))); + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{56,10},{76,30}}))); + + ThermofluidStream.FlowControl.MCV mCV( + redeclare package Medium = Medium, + setpointFromInput=true, + massFlow_set_par=1) + annotation (Placement(transformation(extent={{50,-50},{30,-30}}))); + ThermofluidStream.FlowControl.MCV flowGenerator_SF( + redeclare package Medium = Medium, massFlow_set_par=10) + annotation (Placement(transformation(extent={{-44,-30},{-64,-50}}))); + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{80,-50},{60,-30}}))); + inner DropOfCommons dropOfCommons(L=1000) + annotation (Placement(transformation(extent={{-80,60},{-60,80}}))); + inner Modelica.Fluid.System system(g=0.0000001) + annotation (Placement(transformation(extent={{-100,60},{-80,80}}))); + Modelica.Blocks.Noise.UniformNoise heatScenario( + samplePeriod=60, + y_min=-100, + y_max=5000) annotation (Placement(transformation(extent={{-110,-20},{-90,0}}))); + Modelica.Blocks.Noise.UniformNoise mFlowScenario( + samplePeriod=60, + y_min=0.001, + y_max=15) annotation (Placement(transformation(extent={{100,-30},{80,-10}}))); + Processes.ThermalConvectionPipe thermalConvectionPipe( + redeclare package Medium = Medium, + r=0.2, + l=100) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-70,-10}))); + Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow prescribedHeatFlow annotation (Placement(transformation(extent={{-88,-14},{-80,-6}}))); + FluidPortMSLtoOutletTFS_ass fluidPortMSLtoOutletTFS_ass(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-32,-44},{-40,-36}}))); + InletTFStoFluidPortMSL_ass inletTFStoFluidPortMSL_ass(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-4,-44},{-12,-36}}))); + Modelica.Fluid.Vessels.OpenTank tank( + height=1000, + crossArea=0.01, + p_ambient=100000, + level_start(displayUnit="cm") = 0.1, + redeclare package Medium = Medium, + use_portsData=false, + nPorts=2) annotation (Placement(transformation(extent={{-32,-40},{-12,-20}}))); + FlowControl.Switch switch annotation (Placement(transformation(extent={{-6,26},{6,14}}))); + Topology.JunctionT2 junctionT2_1 annotation (Placement(transformation(extent={{0,-46},{10,-34}}))); + Sensors.SingleSensorSelect singleSensorSelect(quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.T_C, outputValue=true) + annotation (Placement(transformation(extent={{-56,20},{-36,40}}))); + Modelica.Blocks.Continuous.LimPID PID( + controllerType=Modelica.Blocks.Types.SimpleController.PI, + yMax=1, + yMin=0) annotation (Placement(transformation(extent={{-24,36},{-16,44}}))); + Modelica.Blocks.Sources.RealExpression stepoint(y=80) annotation (Placement(transformation(extent={{-46,32},{-34,48}}))); +protected + parameter Medium.ThermodynamicState state_0_CS = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_CS = Medium.density(state_0_CS); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_CS = Medium.specificHeatCapacityCp(state_0_CS); + parameter Medium.ThermodynamicState state_0_cuve = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_cuve = Medium.density(state_0_cuve); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_cuve = Medium.specificHeatCapacityCp(state_0_cuve); + +equation + + connect(mCV.outlet, pHEXSimplified.inletB) annotation (Line( + points={{30,-40},{26,-40},{26,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletB, sink.inlet) annotation (Line( + points={{26,0},{26,20},{56,20}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.inlet, source.outlet) annotation (Line( + points={{50,-40},{60,-40}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.outlet, thermalConvectionPipe.inlet) annotation (Line( + points={{-64,-40},{-70,-40},{-70,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(heatScenario.y, prescribedHeatFlow.Q_flow) annotation (Line(points={{-89,-10},{-88,-10}}, color={0,0,127})); + connect(thermalConvectionPipe.heatPort, prescribedHeatFlow.port) annotation (Line(points={{-80,-10},{-80,-10}}, + color={191,0,0})); + connect(flowGenerator_SF.inlet, fluidPortMSLtoOutletTFS_ass.outletTFS) + annotation (Line( + points={{-44,-40},{-38.8,-40}}, + color={28,108,200}, + thickness=0.5)); + connect(inletTFStoFluidPortMSL_ass.outportMSL, tank.ports[1]) annotation (Line(points={{-10,-40},{-23,-40}}, color={0,127,255})); + connect(tank.ports[2], fluidPortMSLtoOutletTFS_ass.inportMSL) annotation (Line(points={{-21,-40},{-33.8,-40}}, color={0,127,255})); + connect(thermalConvectionPipe.outlet, switch.inlet) annotation (Line( + points={{-70,0},{-70,20},{-6,20}}, + color={28,108,200}, + thickness=0.5)); + connect(switch.outletA, pHEXSimplified.inletA) annotation (Line( + points={{6,20},{14,20},{14,0}}, + color={28,108,200}, + thickness=0.5)); + connect(inletTFStoFluidPortMSL_ass.inletTFS, junctionT2_1.outlet) annotation (Line( + points={{-4.4,-40},{0,-40}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletA, junctionT2_1.inletB) annotation (Line( + points={{14,-20},{14,-40},{10,-40}}, + color={28,108,200}, + thickness=0.5)); + connect(switch.outletB, junctionT2_1.inletA) annotation (Line( + points={{0,14},{0,-30},{5,-30},{5,-34}}, + color={28,108,200}, + thickness=0.5)); + connect(mFlowScenario.y, mCV.setpoint_var) annotation (Line(points={{79,-20},{40,-20},{40,-32}}, color={0,0,127})); + connect(thermalConvectionPipe.outlet, singleSensorSelect.inlet) + annotation (Line( + points={{-70,0},{-70,20},{-60,20},{-60,30},{-56,30}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect.value_out, PID.u_m) annotation (Line(points={{-36,30},{-20,30},{-20,35.2}}, color={0,0,127})); + connect(stepoint.y, PID.u_s) annotation (Line(points={{-33.4,40},{-24.8,40}}, color={0,0,127})); + connect(PID.y, switch.u) annotation (Line(points={{-15.6,40},{0,40},{0,24.8}}, color={0,0,127})); + annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + experiment( + StopTime=3600, + Interval=60, + __Dymola_Algorithm="Dassl"), + __Dymola_Commands( + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","weather.T_amb","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-5.0,90.0}, + grid=true, + colors={{28,108,200},{238,46,47},{217,67,180},{0,140,72},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"})} "Temp CS", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,697}, + y={"weather.T_amb","solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-10.0,90.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47},{217,67,180},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"}),createPlot( + id=1, + position={0,0,1614,697}, + y={"stratifiedTank_Diffuser.T_lay[1]","stratifiedTank_Diffuser.T_lay[3]","stratifiedTank_Diffuser.T_lay[5]","stratifiedTank_Diffuser.T_lay[7]","stratifiedTank_Diffuser.T_lay[9]", + "stratifiedTank_Diffuser.T_lay[11]","stratifiedTank_Diffuser.T_lay[13]","stratifiedTank_Diffuser.T_lay[15]","stratifiedTank_Diffuser.T_lay[17]","stratifiedTank_Diffuser.T_lay[19]", + "stratifiedTank_Diffuser.T_lay[20]"}, + range={0.0,195.0,10.0,80.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47},{0,140,72},{217,67,180},{0,0,0},{162,29,33},{244,125,35},{102,44,145},{28,108,200},{238,46,47},{0,140,72}}, + patterns={LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid, + LinePattern.Solid,LinePattern.Dash,LinePattern.Dash,LinePattern.Dash}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","degC","degC","degC","degC","degC","degC"})} "Températures CS et cuve", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"prod_switch.y","flowGenerator_SF.V_flow_out","flowGenerator_SF.V_flow_sp"}, + range={0.0,700000.0,-5.0,50.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"","m3/h","m3/h"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.L"}, + range={0.0,700000.0,-1000000.0,11000000.0}, + grid=true, + subPlot=202, + colors={{28,108,200}}, + timeUnit="s", + displayUnits={"1/m"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.dr","flowGenerator_SF.dr_set"}, + range={0.0,700000.0,-4.0,4.0}, + grid=true, + subPlot=201, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.p_in","flowGenerator_SF.p_out"}, + range={0.0,700000.0,0.5,4.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"})} "Inertance analysis")); +end TargetTest_02_NOK; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/UnitTest_Mixture_OK.mo b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/UnitTest_Mixture_OK.mo index 870c0986..3378799a 100644 --- a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/UnitTest_Mixture_OK.mo +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/UnitTest_Mixture_OK.mo @@ -8,96 +8,233 @@ model UnitTest_Mixture_OK ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium, temperatureFromInput=true, xiFromInput=true) annotation ( - Placement(visible = true, transformation(origin={-50,30}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Placement(visible = true, transformation(origin={-36,80}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium, p0_par=101300) annotation ( - Placement(visible = true, transformation(origin={70,30}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Placement(visible = true, transformation(origin={70,80}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); FlowControl.MCV flowGenerator( redeclare package Medium = Medium, setpointFromInput=true) - annotation (Placement(transformation(extent={{-30,20},{-10,40}}))); + annotation (Placement(transformation(extent={{-18,90},{2,70}}))); Modelica.Thermal.HeatTransfer.Celsius.ToKelvin toKelvin annotation (Placement( transformation( - extent={{-4,4},{4,-4}}, - rotation=-90, - origin={-60,38}))); + extent={{-5,5},{5,-5}}, + rotation=0, + origin={-59,89}))); Modelica.Blocks.Math.Gain gain(k=1) annotation (Placement(transformation( - extent={{-3,-4},{3,4}}, - rotation=-90, - origin={-34,45}))); + extent={{-4,-4},{4,4}}, + rotation=0, + origin={-70,60}))); inner DropOfCommons dropOfCommons(L=1000) - annotation (Placement(transformation(extent={{80,80},{100,100}}))); + annotation (Placement(transformation(extent={{-100,-100},{-80,-80}}))); ThermofluidStream.Boundaries.Source source1(redeclare package Medium = Medium, temperatureFromInput=true, xiFromInput=true) annotation ( - Placement(visible = true, transformation(origin={-50,-10}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Placement(visible = true, transformation(origin={-38,50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Fluid.Sources.FixedBoundary sink1(redeclare package Medium = Medium, p=101300, nPorts=1) - annotation (Placement(transformation(extent={{80,-20},{60,0}}))); + annotation (Placement(transformation(extent={{80,40},{60,60}}))); InletTFStoFluidPortMSL_ass inletTFStoFluidPortMSL_ass( - redeclare package Medium = Medium) annotation (Placement(transformation(extent={{0,-20},{20,0}}))); + redeclare package Medium = Medium) annotation (Placement(transformation(extent={{12,40},{32,60}}))); FlowControl.MCV flowGenerator1( redeclare package Medium = Medium, setpointFromInput=true) - annotation (Placement(transformation(extent={{-30,-20},{-10,0}}))); + annotation (Placement(transformation(extent={{-18,40},{2,60}}))); Modelica.Fluid.Sources.MassFlowSource_T flowGenerator2( redeclare package Medium = Medium, use_m_flow_in=true, use_T_in=true, use_X_in=true, - nPorts=1) annotation (Placement(transformation(extent={{-40,-60},{-20,-40}}))); - FluidPortMSLtoOutletTFS_ass fluidPortMSLtoOutletTFS_ass(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{0,-60},{20,-40}}))); + nPorts=1) annotation (Placement(transformation(extent={{-28,10},{-8,30}}))); + FluidPortMSLtoOutletTFS_ass fluidPortMSLtoOutletTFS_ass(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{14,10},{34,30}}))); ThermofluidStream.Boundaries.Sink sink2(redeclare package Medium = Medium, p0_par=101300) annotation ( - Placement(visible = true, transformation(origin={70,-50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - Modelica.Blocks.Sources.RealExpression x_N2O2[2](y={0.8*exp(-time/1E4),1 - 0.8*exp(-time/1E4)}) annotation (Placement(transformation(extent={{-100,88},{-80,100}}))); - Modelica.Fluid.Sensors.Temperature temperature(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{22,0},{34,10}}))); - Modelica.Fluid.Sensors.Temperature temperature1(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-4,-40},{8,-30}}))); + Placement(visible = true, transformation(origin={70,20}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.RealExpression x_N2O2[2](y={0.8*exp(-time/1E4),1 - 0.8*exp(-time/1E4)}) annotation (Placement(transformation(extent={{-100,94},{-80,106}}))); + Modelica.Fluid.Sensors.Temperature temperature(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{34,60},{46,70}}))); + Modelica.Fluid.Sensors.Temperature temperature1(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-2,24},{10,34}}))); Modelica.Blocks.Noise.UniformNoise mFlowScenario( samplePeriod=60, y_min=0.001, - y_max=15) annotation (Placement(transformation(extent={{-100,66},{-80,80}}))); + y_max=15) annotation (Placement(transformation(extent={{-100,56},{-80,64}}))); Modelica.Blocks.Noise.UniformNoise temperatureScenario( samplePeriod=60, y_min=10, - y_max=35) annotation (Placement(transformation(extent={{-100,40},{-80,56}}))); + y_max=35) annotation (Placement(transformation(extent={{-100,84},{-80,94}}))); + Boundaries.Source source_FixedPressure( + redeclare package Medium = Medium, + pressureFromInput=true, + temperatureFromInput=true, + xiFromInput=true) annotation (Placement(visible=true, transformation( + origin={-36,-30}, + extent={{-10,-10},{10,10}}, + rotation=0))); +public + InletTFStoFluidPortMSL_ass inletTFStoFluidPortMSL_ass_FixedPressure(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{-6,-38},{10,-22}}))); + Modelica.Fluid.Pipes.StaticPipe pipe_FixedPressure( + redeclare package Medium = Medium, + length=1, + diameter=0.1, + redeclare model FlowModel = Modelica.Fluid.Pipes.BaseClasses.FlowModels.NominalTurbulentPipeFlow (dp_nominal=100, m_flow_nominal=10)) + annotation (Placement(transformation(extent={{20,-40},{40,-20}}))); + Modelica.Fluid.Sources.FixedBoundary sink_FixedPressure( + redeclare package Medium = Medium, + use_p=true, + p(displayUnit="Pa"), + nPorts=1) annotation (Placement(transformation(extent={{100,-40},{80,-20}}))); + Modelica.Fluid.Sensors.Temperature T_FixedFlow1(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{60,-28},{72,-18}}))); + Boundaries.Source source_FixedPressure1( + redeclare package Medium = Medium, + pressureFromInput=true, + temperatureFromInput=true, + xiFromInput=true) annotation (Placement(visible=true, transformation( + origin={-36,-60}, + extent={{-10,-10},{10,10}}, + rotation=0))); +public + InletTFStoFluidPortMSL_ass inletTFStoFluidPortMSL_ass_FixedPressure1(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{22,-68},{38,-52}}))); + Modelica.Fluid.Sources.FixedBoundary sink_FixedPressure1( + redeclare package Medium = Medium, + use_p=true, + p(displayUnit="Pa"), + nPorts=1) annotation (Placement(transformation(extent={{100,-70},{80,-50}}))); + Modelica.Fluid.Sensors.Temperature T_FixedFlow2(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{62,-58},{72,-48}}))); + Processes.FlowResistance flowResistance( + redeclare package Medium = Medium, + r=0.1, + l=1, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarPressureLoss) + annotation (Placement(transformation(extent={{-14,-70},{6,-50}}))); + Boundaries.Sink sink3(redeclare package Medium = Medium) + annotation ( + Placement(visible = true, transformation(origin={90,-90}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Fluid.Sources.Boundary_pT boundary( + redeclare package Medium = Medium, + use_p_in=true, + use_T_in=true, + use_X_in=true, + nPorts=1) annotation (Placement(transformation(extent={{-36,-100},{-16,-80}}))); + inner Modelica.Fluid.System system annotation (Placement(transformation(extent={{-100,-80},{-80,-60}}))); + Modelica.Blocks.Continuous.FirstOrder firstOrder(T=2) annotation (Placement(transformation( + extent={{-4,-4},{4,4}}, + rotation=-90, + origin={-78,-10}))); + Modelica.Fluid.Pipes.StaticPipe pipe_FixedPressure1( + redeclare package Medium = Medium, + length=1, + diameter=0.1, + redeclare model FlowModel = Modelica.Fluid.Pipes.BaseClasses.FlowModels.NominalTurbulentPipeFlow (dp_nominal=100, m_flow_nominal=10)) + annotation (Placement(transformation(extent={{-2,-100},{18,-80}}))); + FluidPortMSLtoOutletTFS_ass fluidPortMSLtoOutletTFS_ass1(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{32,-100},{52,-80}}))); +protected + Modelica.Blocks.Math.Add add(k1=100) + annotation (Placement(transformation(extent={{-74,-38},{-66,-30}}))); + Modelica.Blocks.Sources.RealExpression pAtm(y=101325) + annotation (Placement(transformation( + extent={{-5.5,-5.5},{5.5,5.5}}, + rotation=0, + origin={-86.5,-36.5}))); equation connect(source.outlet, flowGenerator.inlet) annotation (Line( - points={{-40,30},{-30,30}}, + points={{-26,80},{-18,80}}, color={28,108,200}, thickness=0.5)); connect(flowGenerator.outlet, sink.inlet) annotation (Line( - points={{-10,30},{60,30}}, + points={{2,80},{60,80}}, color={28,108,200}, thickness=0.5)); connect(source1.outlet, flowGenerator1.inlet) annotation (Line( - points={{-40,-10},{-30,-10}}, + points={{-28,50},{-18,50}}, color={28,108,200}, thickness=0.5)); connect(inletTFStoFluidPortMSL_ass.inletTFS, flowGenerator1.outlet) annotation (Line( - points={{1,-10},{-10,-10}}, + points={{13,50},{2,50}}, color={28,108,200}, thickness=0.5)); - connect(toKelvin.Kelvin, source1.T0_var) annotation (Line(points={{-60,33.6},{-60,-10},{-52,-10}}, + connect(toKelvin.Kelvin, source1.T0_var) annotation (Line(points={{-53.5,89},{-53.5,50},{-40,50}}, color={0,0,127})); - connect(toKelvin.Kelvin, source.T0_var) annotation (Line(points={{-60,33.6},{-60,30},{-52,30}}, color={0,0,127})); - connect(toKelvin.Kelvin, flowGenerator2.T_in) annotation (Line(points={{-60,33.6},{-60,-46},{-42,-46}}, color={0,0,127})); - connect(gain.y, flowGenerator2.m_flow_in) annotation (Line(points={{-34,41.7},{-34,-30},{-52,-30},{-52,-42},{-40,-42}}, color={0,0,127})); + connect(toKelvin.Kelvin, source.T0_var) annotation (Line(points={{-53.5,89},{-53.5,80},{-38,80}}, + color={0,0,127})); + connect(toKelvin.Kelvin, flowGenerator2.T_in) annotation (Line(points={{-53.5,89},{-53.5,24},{-30,24}}, color={0,0,127})); + connect(gain.y, flowGenerator2.m_flow_in) annotation (Line(points={{-65.6,60},{-48,60},{-48,28},{-28,28}}, color={0,0,127})); connect(fluidPortMSLtoOutletTFS_ass.outletTFS, sink2.inlet) annotation (Line( - points={{18.5,-50},{60,-50}}, + points={{31,20},{60,20}}, color={28,108,200}, thickness=0.5)); - connect(x_N2O2.y, source.xi_var) annotation (Line(points={{-79,94},{-56,94},{-56,24},{-52,24}}, color={0,0,127})); - connect(x_N2O2.y, flowGenerator2.X_in) annotation (Line(points={{-79,94},{-56,94},{-56,-54},{-42,-54}}, color={0,0,127})); - connect(x_N2O2.y, source1.xi_var) annotation (Line(points={{-79,94},{-56,94},{-56,-16},{-52,-16}}, + connect(x_N2O2.y, source.xi_var) annotation (Line(points={{-79,100},{-44,100},{-44,74},{-38,74}}, + color={0,0,127})); + connect(x_N2O2.y, flowGenerator2.X_in) annotation (Line(points={{-79,100},{-44,100},{-44,16},{-30,16}}, color={0,0,127})); + connect(x_N2O2.y, source1.xi_var) annotation (Line(points={{-79,100},{-44,100},{-44,44},{-40,44}}, color={0,0,127})); - connect(flowGenerator2.ports[1], fluidPortMSLtoOutletTFS_ass.inportMSL) annotation (Line(points={{-20,-50},{4.5,-50}}, color={0,127,255})); - connect(inletTFStoFluidPortMSL_ass.outportMSL, sink1.ports[1]) annotation (Line(points={{15,-10},{60,-10}}, - color={0,127,255})); - connect(inletTFStoFluidPortMSL_ass.outportMSL, temperature.port) annotation (Line(points={{15,-10},{28,-10},{28,0}}, + connect(flowGenerator2.ports[1], fluidPortMSLtoOutletTFS_ass.inportMSL) annotation (Line(points={{-8,20},{6,20},{6,20},{18.5,20}}, + color={0,127,255})); + connect(inletTFStoFluidPortMSL_ass.outportMSL, sink1.ports[1]) annotation (Line(points={{27,50},{60,50}}, color={0,127,255})); + connect(inletTFStoFluidPortMSL_ass.outportMSL, temperature.port) annotation (Line(points={{27,50},{40,50},{40,60}}, color={0,127,255})); - connect(temperature1.port, fluidPortMSLtoOutletTFS_ass.inportMSL) annotation (Line(points={{2,-40},{2,-50},{4.5,-50}}, color={0,127,255})); - connect(gain.y, flowGenerator.setpoint_var) annotation (Line(points={{-34,41.7},{-20,41.7},{-20,38}}, color={0,0,127})); - connect(gain.y, flowGenerator1.setpoint_var) annotation (Line(points={{-34,41.7},{-34,8},{-20,8},{-20,-2}}, color={0,0,127})); - connect(mFlowScenario.y, gain.u) annotation (Line(points={{-79,73},{-34,73},{-34,48.6}}, color={0,0,127})); - connect(temperatureScenario.y, toKelvin.Celsius) annotation (Line(points={{-79,48},{-60,48},{-60,42.8}}, color={0,0,127})); - annotation (experiment(StopTime=172800, __Dymola_Algorithm="Dassl")); + connect(temperature1.port, fluidPortMSLtoOutletTFS_ass.inportMSL) annotation (Line(points={{4,24},{4,20},{18.5,20}}, color={0,127,255})); + connect(gain.y, flowGenerator.setpoint_var) annotation (Line(points={{-65.6,60},{-8,60},{-8,72}}, color={0,0,127})); + connect(gain.y, flowGenerator1.setpoint_var) annotation (Line(points={{-65.6,60},{-8,60},{-8,58}}, color={0,0,127})); + connect(mFlowScenario.y, gain.u) annotation (Line(points={{-79,60},{-74.8,60}}, color={0,0,127})); + connect(temperatureScenario.y, toKelvin.Celsius) annotation (Line(points={{-79,89},{-65,89}}, color={0,0,127})); + connect(pipe_FixedPressure.port_a,inletTFStoFluidPortMSL_ass_FixedPressure. outportMSL) annotation (Line(points={{20,-30},{6,-30}}, color={0,127,255})); + connect(source_FixedPressure.outlet,inletTFStoFluidPortMSL_ass_FixedPressure. inletTFS) + annotation (Line( + points={{-26,-30},{-5.2,-30}}, + color={28,108,200}, + thickness=0.5)); + connect(pipe_FixedPressure.port_b,sink_FixedPressure. ports[1]) + annotation (Line(points={{40,-30},{80,-30}}, color={0,127,255})); + connect(pAtm.y, add.u2) annotation (Line(points={{-80.45,-36.5},{-80.45,-36.4},{-74.8,-36.4}}, color={0,0,127})); + connect(add.y,source_FixedPressure. p0_var) + annotation (Line(points={{-65.6,-34},{-50,-34},{-50,-24},{-38,-24}}, color={0,0,127})); + connect(pipe_FixedPressure.port_b,T_FixedFlow1. port) + annotation (Line(points={{40,-30},{66,-30},{66,-28}}, color={0,127,255})); + connect(inletTFStoFluidPortMSL_ass_FixedPressure1.outportMSL,T_FixedFlow2. port) annotation (Line(points={{34,-60},{67,-60},{67,-58}}, color={0,127,255})); + connect(inletTFStoFluidPortMSL_ass_FixedPressure1.outportMSL,sink_FixedPressure1. ports[1]) annotation (Line(points={{34,-60},{80,-60}}, color={0,127,255})); + connect(source_FixedPressure1.outlet,flowResistance. inlet) annotation (Line( + points={{-26,-60},{-14,-60}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistance.outlet,inletTFStoFluidPortMSL_ass_FixedPressure1. inletTFS) + annotation (Line( + points={{6,-60},{22.8,-60}}, + color={28,108,200}, + thickness=0.5)); + connect(toKelvin.Kelvin, source_FixedPressure.T0_var) annotation (Line(points={{-53.5,89},{-53.5,-30},{-38,-30}}, color={0,0,127})); + connect(toKelvin.Kelvin, source_FixedPressure1.T0_var) annotation (Line(points={{-53.5,89},{-53.5,-60},{-38,-60}}, color={0,0,127})); + connect(add.y, source_FixedPressure1.p0_var) annotation (Line(points={{-65.6,-34},{-50,-34},{-50,-54},{-38,-54}}, color={0,0,127})); + connect(add.y, boundary.p_in) annotation (Line(points={{-65.6,-34},{-50,-34},{-50,-82},{-38,-82}}, color={0,0,127})); + connect(toKelvin.Kelvin, boundary.T_in) annotation (Line(points={{-53.5,89},{-53.5,-86},{-38,-86}}, color={0,0,127})); + connect(x_N2O2.y, source_FixedPressure.xi_var) annotation (Line(points={{-79,100},{-44,100},{-44,-36},{-38,-36}}, color={0,0,127})); + connect(x_N2O2.y, source_FixedPressure1.xi_var) annotation (Line(points={{-79,100},{-44,100},{-44,-66},{-38,-66}}, color={0,0,127})); + connect(x_N2O2.y, boundary.X_in) annotation (Line(points={{-79,100},{-44,100},{-44,-94},{-38,-94}}, color={0,0,127})); + connect(mFlowScenario.y, firstOrder.u) annotation (Line(points={{-79,60},{-78,60},{-78,-5.2}}, color={0,0,127})); + connect(firstOrder.y, add.u1) annotation (Line(points={{-78,-14.4},{-78,-31.6},{-74.8,-31.6}}, color={0,0,127})); + connect(pipe_FixedPressure1.port_b, fluidPortMSLtoOutletTFS_ass1.inportMSL) annotation (Line(points={{18,-90},{36.5,-90}}, color={0,127,255})); + connect(boundary.ports[1], pipe_FixedPressure1.port_a) annotation (Line(points={{-16,-90},{-2,-90}}, color={0,127,255})); + connect(fluidPortMSLtoOutletTFS_ass1.outletTFS, sink3.inlet) annotation (Line( + points={{49,-90},{80,-90}}, + color={28,108,200}, + thickness=0.5)); + annotation (experiment(StopTime=3600, __Dymola_Algorithm="Dassl"), Diagram(graphics={ + Text( + extent={{-34,0},{58,-24}}, + textColor={217,67,180}, + textString="Pressure boundaries"), + Text( + extent={{-34,100},{50,88}}, + textColor={217,67,180}, + textString="Fixed m_flow"), + Text( + extent={{50,-74},{60,-78}}, + textColor={255,0,0}, + textString="NOK"), + Line( + points={{2,-68},{20,-76},{46,-76},{64,-88}}, + color={255,0,0}, + smooth=Smooth.Bezier, + arrow={Arrow.None,Arrow.Filled})})); end UnitTest_Mixture_OK; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.order b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.order index 825c19bc..7256cda7 100644 --- a/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.order +++ b/ThermofluidStream/Interfaces/MSLplug/ByAssembly/Tests/package.order @@ -1 +1,4 @@ UnitTest_Mixture_OK +TargetTest_00 +TargetTest_01_NOK +TargetTest_02_NOK diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/FluidPortMSLtoOutletTFS_eq.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/FluidPortMSLtoOutletTFS_eq.mo index 157312b5..b97b454a 100644 --- a/ThermofluidStream/Interfaces/MSLplug/ByCode/FluidPortMSLtoOutletTFS_eq.mo +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/FluidPortMSLtoOutletTFS_eq.mo @@ -9,7 +9,7 @@ model FluidPortMSLtoOutletTFS_eq annotation (Dialog(tab="Advanced")); Interfaces.Outlet outletTFS(redeclare package Medium = Medium) - annotation (Placement(transformation(extent={{14,-20},{54,20}}), iconTransformation(extent={{14,-20},{54,20}}))); + annotation (Placement(transformation(extent={{8,-20},{48,20}}), iconTransformation(extent={{8,-20},{48,20}}))); Modelica.Fluid.Interfaces.FluidPort_b portMSL(redeclare package Medium = Medium) "Fluid connector b (positive design flow direction is from port_a to port_b)" annotation (Placement(transformation(extent={{-10,-20},{-50,20}}), iconTransformation(extent={{-12,-10},{-32,10}}))); @@ -34,7 +34,7 @@ equation points={{-12,0},{20,0}}, color={28,108,200}, thickness=0.5), Polygon( - points={{18,-20},{18,20},{48,0},{18,-20}}, + points={{26,-20},{26,20},{56,0},{26,-20}}, lineColor={28,108,200}, fillColor={255,255,255}, fillPattern=FillPattern.Solid), diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle.mo new file mode 100644 index 00000000..ac9c3979 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle.mo @@ -0,0 +1,283 @@ +within ThermofluidStream.Interfaces.MSLplug.ByCode.Tests; +model SimpleCoolingCycle "Basic cooling cycle with a load" +extends Modelica.Icons.Example; + + replaceable package Medium_liquid = Media.myMedia.Water.ConstantPropertyLiquidWater + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Liquid model" + annotation(choicesAllMatching = true); + + replaceable package Medium_air = ThermofluidStream.Media.myMedia.Air.DryAirNasa + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Air model" + annotation(choicesAllMatching = true); + + ThermofluidStream.HeatExchangers.CounterFlowNTU heatExchange_CounterFlowNTU( + redeclare package MediumA = Medium_air, + redeclare package MediumB = Medium_liquid, + A=10) annotation (Placement(transformation(extent={{80,4},{100,24}}))); + Boundaries.VolumeFlex flexVolume( + redeclare package Medium = Medium_liquid, + V_ref=0.02, + p_start=100000, + T_start=278.15) + annotation (Placement(transformation(extent={{40,10},{20,30}}))); + ThermofluidStream.Processes.Pump pump( + redeclare package Medium = Medium_liquid, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + redeclare function dp_tau_pump = ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_centrifugal) + annotation (Placement(transformation(extent={{-20,10},{-40,30}}))); + ThermofluidStream.Processes.ThermalConvectionPipe thermalConvectionPipe( + redeclare package Medium = Medium_liquid, + r=0.005, + l=1) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-80,50}))); + ThermofluidStream.Processes.FlowResistance flowResistance( + redeclare package Medium = Medium_liquid, + r=0.05, + l=1, + redeclare function pLoss = + ThermofluidStream.Processes.Internal.FlowResistance.linearQuadraticPressureLoss ( + k=1e5)) + annotation (Placement(transformation(extent={{80,70},{100,90}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1( + redeclare package Medium = Medium_liquid, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{70,20},{50,40}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2( + redeclare package Medium = Medium_liquid, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{10,20},{-10,40}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3( + redeclare package Medium = Medium_liquid, + digits=2, + outputMassFlowRate=true, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{-50,20},{-70,0}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm4( + redeclare package Medium = Medium_liquid, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{10,10},{-10,-10}}, + rotation=180, + origin={-10,90}))); + ThermofluidStream.Boundaries.Source source( + redeclare package Medium = Medium_air, + T0_par=283.15, + p0_par=101300) + annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={18,-10}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm5( + redeclare package Medium = Medium_air, + temperatureUnit="degC") + annotation (Placement( + transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={62,-2}))); + ThermofluidStream.Boundaries.Sink sink( + redeclare package Medium = Medium_air, + p0_par=101300) annotation (Placement( + transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={176,8}))); + Modelica.Mechanics.Rotational.Sources.Speed speed + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=90, + origin={-30,-18}))); + Modelica.Mechanics.Rotational.Sources.Speed speed1 + annotation (Placement(transformation(extent={{60,-90},{80,-70}}))); + + ThermofluidStream.Processes.Fan fan( + redeclare package Medium = Medium_air, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + redeclare function dp_tau_fan = + Processes.Internal.TurboComponent.dp_tau_const_isentrop ( + omega_ref=100)) + annotation (Placement(transformation(extent={{140,-2},{160,18}}))); + Modelica.Blocks.Sources.RealExpression pump_speed(y=80 + 273.15) + annotation (Placement(transformation(extent={{-140,-30},{-160,-10}}))); + Modelica.Blocks.Sources.RealExpression fan_speed(y=400) + annotation (Placement(transformation(extent={{20,-60},{40,-40}}))); + Modelica.Thermal.HeatTransfer.Components.HeatCapacitor heatCapacitor(C=500, T(start=373.15, fixed=true)) + annotation (Placement(transformation(extent={{-120,50},{-100,70}}))); + Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow prescribedHeatFlow + annotation (Placement(transformation(extent={{-150,40},{-130,60}}))); + Modelica.Blocks.Sources.RealExpression heat_load(y=10000) + annotation (Placement(transformation(extent={{-180,80},{-160,100}}))); + inner ThermofluidStream.DropOfCommons dropOfCommons + annotation (Placement(transformation(extent={{160,80},{180,100}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm6( + redeclare package Medium = Medium_liquid, temperatureUnit="degC") + annotation (Placement(transformation(extent={{-10,10},{10,-10}}, + rotation=180, + origin={120,30}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm7( + redeclare package Medium = Medium_air, + temperatureUnit="degC") + annotation (Placement( + transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={120,-2}))); + Modelica.Blocks.Sources.RealExpression actual_heatPortTemp( + y=thermalConvectionPipe.heatPort.T) + annotation (Placement(transformation(extent={{-180,-90},{-160,-70}}))); + Modelica.Blocks.Interaction.Show.RealValue realValue( + use_numberPort=false, + number=thermalConvectionPipe.heatPort.T - 273.15) + annotation (Placement(transformation(extent={{-160,20},{-180,0}}))); + ThermofluidStream.Utilities.showRealValue showRealValue + annotation (Placement(transformation(extent={{-120,-26},{-100,-6}}))); + ThermofluidStream.Utilities.showRealValue showRealValue1( + use_numberPort=false, + description="eff", + number=heatExchange_CounterFlowNTU.effectiveness) + annotation (Placement(transformation(extent={{80,20},{100,40}}))); + Modelica.Blocks.Sources.CombiTimeTable combiTimeTable( + table=[0,5000; 2000,5000; + 2000.01,10000; 4000,10000; 4000.01,25000; 6000,25000; 6000.01,5000; 10000, + 5000]) + annotation (Placement(transformation(extent={{-180,40},{-160,60}}))); + Modelica.Blocks.Math.Gain gain(k=-3) + annotation (Placement(transformation(extent={{20,-90},{40,-70}}))); + Modelica.Blocks.Continuous.LimPID PID( + controllerType=Modelica.Blocks.Types.SimpleController.PI, + k=30, + Ti=2, + yMax=-5, + yMin=-5000) + annotation (Placement(transformation(extent={{-160,-60},{-140,-40}}))); + Modelica.Blocks.Math.Gain gain1(k=-0.001) + annotation (Placement(transformation(extent={{-120,-60},{-100,-40}}))); + Modelica.Blocks.Math.Feedback feedback + annotation (Placement(transformation(extent={{-90,-40},{-70,-60}}))); + Modelica.Blocks.Continuous.PI PI( + k=3000, + T=0.1, + initType=Modelica.Blocks.Types.Init.InitialState) + annotation (Placement(transformation(extent={{-60,-60},{-40,-40}}))); + ThermofluidStream.Utilities.showRealValue showRealValue2 + annotation (Placement(transformation(extent={{-100,-40},{-120,-20}}))); + ThermofluidStream.Utilities.Icons.DLRLogo dLRLogo annotation (Placement(transformation(extent={{142,-98},{178,-62}}))); +equation + connect(multiSensor_Tpm1.inlet, heatExchange_CounterFlowNTU.outletB) + annotation (Line( + points={{70,20},{80,20}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm1.outlet, flexVolume.inlet) annotation (Line( + points={{50,20},{40,20}}, + color={28,108,200}, + thickness=0.5)); + connect(flexVolume.outlet, multiSensor_Tpm2.inlet) annotation (Line( + points={{20,20},{10,20}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm2.outlet, pump.inlet) annotation (Line( + points={{-10,20},{-20,20}}, + color={28,108,200}, + thickness=0.5)); + connect(pump.outlet, multiSensor_Tpm3.inlet) annotation (Line( + points={{-40,20},{-50,20}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm3.outlet, thermalConvectionPipe.inlet) annotation ( + Line( + points={{-70,20},{-80,20},{-80,40}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.outlet, multiSensor_Tpm4.inlet) annotation ( + Line( + points={{-80,60},{-80,80},{-20,80}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistance.inlet, multiSensor_Tpm4.outlet) annotation (Line( + points={{80,80},{0,80}}, + color={28,108,200}, + thickness=0.5)); + connect(source.outlet, multiSensor_Tpm5.inlet) annotation (Line( + points={{28,-10},{40,-10},{40,8},{52,8}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm5.outlet, heatExchange_CounterFlowNTU.inletA) + annotation (Line( + points={{72,8},{80,8}}, + color={28,108,200}, + thickness=0.5)); + connect(sink.inlet, fan.outlet) annotation (Line( + points={{166,8},{160,8}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.heatPort, heatCapacitor.port) + annotation (Line(points={{-90,50},{-110,50}}, color={191,0,0})); + connect(heatCapacitor.port, prescribedHeatFlow.port) + annotation (Line(points={{-110,50},{-130,50}}, color={191,0,0})); + connect(heatExchange_CounterFlowNTU.inletB, multiSensor_Tpm6.outlet) + annotation (Line( + points={{100,20},{110,20}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm6.inlet, flowResistance.outlet) annotation (Line( + points={{130,20},{140,20},{140,80},{100,80}}, + color={28,108,200}, + thickness=0.5)); + connect(heatExchange_CounterFlowNTU.outletA, multiSensor_Tpm7.inlet) + annotation (Line( + points={{100,8},{110,8}}, + color={28,108,200}, + thickness=0.5)); + connect(fan.inlet, multiSensor_Tpm7.outlet) annotation (Line( + points={{140,8},{130,8}}, + color={28,108,200}, + thickness=0.5)); + connect(fan.flange, speed1.flange) + annotation (Line(points={{150,-2},{150,-40},{100,-40},{100,-80},{80,-80}}, + color={0,0,0})); + connect(pump.flange, speed.flange) + annotation (Line(points={{-30,10},{-30,-8}}, color={0,0,0})); + connect(speed1.w_ref, gain.y) annotation (Line(points={{58,-80},{41,-80}}, + color={0,0,127})); + connect(PID.y, showRealValue.numberPort) annotation (Line(points={{-139,-50},{-130,-50},{-130,-16},{-121.5,-16}}, + color={0,0,127})); + connect(PID.u_s, pump_speed.y) + annotation (Line(points={{-162,-50},{-170,-50},{-170,-20},{-161,-20}}, + color={0,0,127})); + connect(actual_heatPortTemp.y, PID.u_m) annotation (Line(points={{-159,-80},{-150,-80},{-150,-62}}, + color={0,0,127})); + connect(PID.y, gain1.u) + annotation (Line(points={{-139,-50},{-122,-50}}, color={0,0,127})); + connect(gain1.y, feedback.u1) + annotation (Line(points={{-99,-50},{-88,-50}}, color={0,0,127})); + connect(multiSensor_Tpm3.m_flow_out, feedback.u2) annotation (Line(points={{-70,16},{-80,16},{-80,-42}}, + color={0,0,127})); + connect(PI.y, speed.w_ref) + annotation (Line(points={{-39,-50},{-30,-50},{-30,-30}}, + color={0,0,127})); + connect(feedback.y, PI.u) + annotation (Line(points={{-71,-50},{-62,-50}}, color={0,0,127})); + connect(PID.y, gain.u) annotation (Line(points={{-139,-50},{-130,-50},{-130,-80},{18,-80}}, + color={0,0,127})); + connect(showRealValue2.numberPort, feedback.u1) annotation (Line(points={{-98.5,-30},{-92,-30},{-92,-50},{-88,-50}}, + color={0,0,127})); + connect(prescribedHeatFlow.Q_flow, combiTimeTable.y[1]) + annotation (Line(points={{-150,50},{-159,50}}, color={0,0,127})); + + annotation ( + experiment( + StopTime=10000, + Tolerance=1e-6, + Interval=10, + __Dymola_Algorithm="Dassl"), + Icon(coordinateSystem(extent={{-100,-100},{100,100}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-180,-100},{180,100}})), + Documentation(info=" +

This cooling cycle is regulated to hit a temperature target. The load is a prescribed heatflow and comes from a table.

+


Owner: Niels Weber

+")); +end SimpleCoolingCycle; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle_01_OK.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle_01_OK.mo new file mode 100644 index 00000000..604c28fd --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle_01_OK.mo @@ -0,0 +1,291 @@ +within ThermofluidStream.Interfaces.MSLplug.ByCode.Tests; +model SimpleCoolingCycle_01_OK "Basic cooling cycle with a load" +extends Modelica.Icons.Example; + + replaceable package Medium_liquid = Media.myMedia.Water.ConstantPropertyLiquidWater + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Liquid model" + annotation(choicesAllMatching = true); + + replaceable package Medium_air = ThermofluidStream.Media.myMedia.Air.DryAirNasa + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Air model" + annotation(choicesAllMatching = true); + + ThermofluidStream.HeatExchangers.CounterFlowNTU heatExchange_CounterFlowNTU( + redeclare package MediumA = Medium_air, + redeclare package MediumB = Medium_liquid, + A=10) annotation (Placement(transformation(extent={{86,4},{106,24}}))); + ThermofluidStream.Processes.Pump pump( + redeclare package Medium = Medium_liquid, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + redeclare function dp_tau_pump = ThermofluidStream.Processes.Internal.TurboComponent.dp_tau_centrifugal) + annotation (Placement(transformation(extent={{-26,10},{-46,30}}))); + ThermofluidStream.Processes.ThermalConvectionPipe thermalConvectionPipe( + redeclare package Medium = Medium_liquid, + r=0.005, + l=1) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-80,50}))); + ThermofluidStream.Processes.FlowResistance flowResistance( + redeclare package Medium = Medium_liquid, + r=0.05, + l=1, + redeclare function pLoss = + ThermofluidStream.Processes.Internal.FlowResistance.linearQuadraticPressureLoss ( + k=1e5)) + annotation (Placement(transformation(extent={{80,70},{100,90}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1( + redeclare package Medium = Medium_liquid, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{82,20},{68,40}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2( + redeclare package Medium = Medium_liquid, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{-6,20},{-20,42}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3( + redeclare package Medium = Medium_liquid, + digits=2, + outputMassFlowRate=true, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{-52,20},{-72,0}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm4( + redeclare package Medium = Medium_liquid, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{10,10},{-10,-10}}, + rotation=180, + origin={-10,90}))); + ThermofluidStream.Boundaries.Source source( + redeclare package Medium = Medium_air, + T0_par=283.15, + p0_par=101300) + annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={18,-10}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm5( + redeclare package Medium = Medium_air, + temperatureUnit="degC") + annotation (Placement( + transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={62,-2}))); + ThermofluidStream.Boundaries.Sink sink( + redeclare package Medium = Medium_air, + p0_par=101300) annotation (Placement( + transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={176,8}))); + Modelica.Mechanics.Rotational.Sources.Speed speed + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=90, + origin={-36,-18}))); + Modelica.Mechanics.Rotational.Sources.Speed speed1 + annotation (Placement(transformation(extent={{60,-90},{80,-70}}))); + + ThermofluidStream.Processes.Fan fan( + redeclare package Medium = Medium_air, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + redeclare function dp_tau_fan = + Processes.Internal.TurboComponent.dp_tau_const_isentrop ( + omega_ref=100)) + annotation (Placement(transformation(extent={{140,-2},{160,18}}))); + Modelica.Blocks.Sources.RealExpression pump_speed(y=80 + 273.15) + annotation (Placement(transformation(extent={{-140,-30},{-160,-10}}))); + Modelica.Blocks.Sources.RealExpression fan_speed(y=400) + annotation (Placement(transformation(extent={{20,-60},{40,-40}}))); + Modelica.Thermal.HeatTransfer.Components.HeatCapacitor heatCapacitor(C=500, T(start=373.15, fixed=true)) + annotation (Placement(transformation(extent={{-120,50},{-100,70}}))); + Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow prescribedHeatFlow + annotation (Placement(transformation(extent={{-150,40},{-130,60}}))); + Modelica.Blocks.Sources.RealExpression heat_load(y=10000) + annotation (Placement(transformation(extent={{-180,80},{-160,100}}))); + inner ThermofluidStream.DropOfCommons dropOfCommons + annotation (Placement(transformation(extent={{160,80},{180,100}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm6( + redeclare package Medium = Medium_liquid, temperatureUnit="degC") + annotation (Placement(transformation(extent={{-10,10},{10,-10}}, + rotation=180, + origin={124,30}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm7( + redeclare package Medium = Medium_air, + temperatureUnit="degC") + annotation (Placement( + transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={120,-2}))); + Modelica.Blocks.Sources.RealExpression actual_heatPortTemp( + y=thermalConvectionPipe.heatPort.T) + annotation (Placement(transformation(extent={{-180,-90},{-160,-70}}))); + Modelica.Blocks.Interaction.Show.RealValue realValue( + use_numberPort=false, + number=thermalConvectionPipe.heatPort.T - 273.15) + annotation (Placement(transformation(extent={{-160,20},{-180,0}}))); + ThermofluidStream.Utilities.showRealValue showRealValue + annotation (Placement(transformation(extent={{-120,-26},{-100,-6}}))); + ThermofluidStream.Utilities.showRealValue showRealValue1( + use_numberPort=false, + description="eff", + number=heatExchange_CounterFlowNTU.effectiveness) + annotation (Placement(transformation(extent={{80,20},{100,40}}))); + Modelica.Blocks.Sources.CombiTimeTable combiTimeTable( + table=[0,5000; 2000,5000; + 2000.01,10000; 4000,10000; 4000.01,25000; 6000,25000; 6000.01,5000; 10000, + 5000]) + annotation (Placement(transformation(extent={{-180,40},{-160,60}}))); + Modelica.Blocks.Math.Gain gain(k=-3) + annotation (Placement(transformation(extent={{20,-90},{40,-70}}))); + Modelica.Blocks.Continuous.LimPID PID( + controllerType=Modelica.Blocks.Types.SimpleController.PI, + k=30, + Ti=2, + yMax=-5, + yMin=-5000) + annotation (Placement(transformation(extent={{-160,-60},{-140,-40}}))); + Modelica.Blocks.Math.Gain gain1(k=-0.001) + annotation (Placement(transformation(extent={{-120,-60},{-100,-40}}))); + Modelica.Blocks.Math.Feedback feedback + annotation (Placement(transformation(extent={{-90,-40},{-70,-60}}))); + Modelica.Blocks.Continuous.PI PI( + k=3000, + T=0.1, + initType=Modelica.Blocks.Types.Init.InitialState) + annotation (Placement(transformation(extent={{-60,-60},{-40,-40}}))); + ThermofluidStream.Utilities.showRealValue showRealValue2 + annotation (Placement(transformation(extent={{-100,-40},{-120,-20}}))); + ThermofluidStream.Utilities.Icons.DLRLogo dLRLogo annotation (Placement(transformation(extent={{144,-96},{180,-60}}))); + FluidPortMSLtoOutletTFS_eq fluidPortMSLtoOutletTFS_eq(redeclare package Medium = Medium_liquid) + annotation (Placement(transformation(extent={{18,16},{10,24}}))); + InletTFStoFluidPortMSL_eq inletTFStoFluidPortMSL_eq(redeclare package Medium = Medium_liquid) + annotation (Placement(transformation(extent={{46,16},{38,24}}))); + Modelica.Fluid.Vessels.OpenTank tank( + height(displayUnit="m") = 2, + crossArea(displayUnit="m2") = 0.01, + p_ambient=100000, + level_start(displayUnit="cm") = 0.1, + redeclare package Medium = Medium_liquid, + use_portsData=false, + nPorts=2) annotation (Placement(transformation(extent={{18,20},{38,40}}))); +equation + connect(multiSensor_Tpm1.inlet, heatExchange_CounterFlowNTU.outletB) + annotation (Line( + points={{82,20},{86,20}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm2.outlet, pump.inlet) annotation (Line( + points={{-20,20},{-26,20}}, + color={28,108,200}, + thickness=0.5)); + connect(pump.outlet, multiSensor_Tpm3.inlet) annotation (Line( + points={{-46,20},{-52,20}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm3.outlet, thermalConvectionPipe.inlet) annotation ( + Line( + points={{-72,20},{-80,20},{-80,40}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.outlet, multiSensor_Tpm4.inlet) annotation ( + Line( + points={{-80,60},{-80,80},{-20,80}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistance.inlet, multiSensor_Tpm4.outlet) annotation (Line( + points={{80,80},{0,80}}, + color={28,108,200}, + thickness=0.5)); + connect(source.outlet, multiSensor_Tpm5.inlet) annotation (Line( + points={{28,-10},{40,-10},{40,8},{52,8}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm5.outlet, heatExchange_CounterFlowNTU.inletA) + annotation (Line( + points={{72,8},{86,8}}, + color={28,108,200}, + thickness=0.5)); + connect(sink.inlet, fan.outlet) annotation (Line( + points={{166,8},{160,8}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.heatPort, heatCapacitor.port) + annotation (Line(points={{-90,50},{-110,50}}, color={191,0,0})); + connect(heatCapacitor.port, prescribedHeatFlow.port) + annotation (Line(points={{-110,50},{-130,50}}, color={191,0,0})); + connect(heatExchange_CounterFlowNTU.inletB, multiSensor_Tpm6.outlet) + annotation (Line( + points={{106,20},{114,20}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm6.inlet, flowResistance.outlet) annotation (Line( + points={{134,20},{140,20},{140,80},{100,80}}, + color={28,108,200}, + thickness=0.5)); + connect(heatExchange_CounterFlowNTU.outletA, multiSensor_Tpm7.inlet) + annotation (Line( + points={{106,8},{110,8}}, + color={28,108,200}, + thickness=0.5)); + connect(fan.inlet, multiSensor_Tpm7.outlet) annotation (Line( + points={{140,8},{130,8}}, + color={28,108,200}, + thickness=0.5)); + connect(fan.flange, speed1.flange) + annotation (Line(points={{150,-2},{150,-40},{100,-40},{100,-80},{80,-80}}, + color={0,0,0})); + connect(pump.flange, speed.flange) + annotation (Line(points={{-36,10},{-36,-8}}, color={0,0,0})); + connect(speed1.w_ref, gain.y) annotation (Line(points={{58,-80},{41,-80}}, + color={0,0,127})); + connect(PID.y, showRealValue.numberPort) annotation (Line(points={{-139,-50},{-130,-50},{-130,-16},{-121.5,-16}}, + color={0,0,127})); + connect(PID.u_s, pump_speed.y) + annotation (Line(points={{-162,-50},{-170,-50},{-170,-20},{-161,-20}}, + color={0,0,127})); + connect(actual_heatPortTemp.y, PID.u_m) annotation (Line(points={{-159,-80},{-150,-80},{-150,-62}}, + color={0,0,127})); + connect(PID.y, gain1.u) + annotation (Line(points={{-139,-50},{-122,-50}}, color={0,0,127})); + connect(gain1.y, feedback.u1) + annotation (Line(points={{-99,-50},{-88,-50}}, color={0,0,127})); + connect(multiSensor_Tpm3.m_flow_out, feedback.u2) annotation (Line(points={{-72,16},{-80,16},{-80,-42}}, + color={0,0,127})); + connect(PI.y, speed.w_ref) + annotation (Line(points={{-39,-50},{-36,-50},{-36,-30}}, + color={0,0,127})); + connect(feedback.y, PI.u) + annotation (Line(points={{-71,-50},{-62,-50}}, color={0,0,127})); + connect(PID.y, gain.u) annotation (Line(points={{-139,-50},{-130,-50},{-130,-80},{18,-80}}, + color={0,0,127})); + connect(showRealValue2.numberPort, feedback.u1) annotation (Line(points={{-98.5,-30},{-92,-30},{-92,-50},{-88,-50}}, + color={0,0,127})); + connect(prescribedHeatFlow.Q_flow, combiTimeTable.y[1]) + annotation (Line(points={{-150,50},{-159,50}}, color={0,0,127})); + + connect(inletTFStoFluidPortMSL_eq.portMSL,tank. ports[1]) annotation (Line(points={{40,20},{27,20}}, color={0,127,255})); + connect(fluidPortMSLtoOutletTFS_eq.portMSL,tank. ports[2]) annotation (Line(points={{16.2,20},{29,20}}, color={0,127,255})); + connect(multiSensor_Tpm1.outlet, inletTFStoFluidPortMSL_eq.inletTFS) annotation (Line( + points={{68,20},{45.6,20}}, + color={28,108,200}, + thickness=0.5)); + connect(fluidPortMSLtoOutletTFS_eq.outletTFS, multiSensor_Tpm2.inlet) annotation (Line( + points={{11.2,20},{-6,20}}, + color={28,108,200}, + thickness=0.5)); + annotation ( + experiment( + StopTime=10000, + Tolerance=1e-6, + Interval=10, + __Dymola_Algorithm="Dassl"), + Icon(coordinateSystem(extent={{-100,-100},{100,100}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-180,-100},{180,100}})), + Documentation(info=" +

This cooling cycle is regulated to hit a temperature target. The load is a prescribed heatflow and comes from a table.

+


Owner: Niels Weber

+")); +end SimpleCoolingCycle_01_OK; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle_02MCV_NOK.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle_02MCV_NOK.mo new file mode 100644 index 00000000..f3da90e4 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/SimpleCoolingCycle_02MCV_NOK.mo @@ -0,0 +1,282 @@ +within ThermofluidStream.Interfaces.MSLplug.ByCode.Tests; +model SimpleCoolingCycle_02MCV_NOK "Basic cooling cycle with a load" +extends Modelica.Icons.Example; + + replaceable package Medium_liquid = Media.myMedia.Water.ConstantPropertyLiquidWater + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Liquid model" + annotation(choicesAllMatching = true); + + replaceable package Medium_air = ThermofluidStream.Media.myMedia.Air.DryAirNasa + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + "Air model" + annotation(choicesAllMatching = true); + + ThermofluidStream.HeatExchangers.CounterFlowNTU heatExchange_CounterFlowNTU( + redeclare package MediumA = Medium_air, + redeclare package MediumB = Medium_liquid, + A=10) annotation (Placement(transformation(extent={{86,4},{106,24}}))); + FlowControl.MCV mCV( + redeclare package Medium = Medium_liquid, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + massFlow_set_par=0.4) + annotation (Placement(transformation(extent={{-26,10},{-46,30}}))); + ThermofluidStream.Processes.ThermalConvectionPipe thermalConvectionPipe( + redeclare package Medium = Medium_liquid, + r=0.005, + l=1) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-80,50}))); + ThermofluidStream.Processes.FlowResistance flowResistance( + redeclare package Medium = Medium_liquid, + r=0.05, + l=1, + redeclare function pLoss = + ThermofluidStream.Processes.Internal.FlowResistance.linearQuadraticPressureLoss ( + k=1e5)) + annotation (Placement(transformation(extent={{80,70},{100,90}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1( + redeclare package Medium = Medium_liquid, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{82,20},{68,40}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2( + redeclare package Medium = Medium_liquid, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{-6,20},{-20,42}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3( + redeclare package Medium = Medium_liquid, + digits=2, + outputMassFlowRate=true, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{-52,20},{-72,0}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm4( + redeclare package Medium = Medium_liquid, + temperatureUnit="degC") + annotation (Placement(transformation(extent={{10,10},{-10,-10}}, + rotation=180, + origin={-10,90}))); + ThermofluidStream.Boundaries.Source source( + redeclare package Medium = Medium_air, + T0_par=283.15, + p0_par=101300) + annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={18,-10}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm5( + redeclare package Medium = Medium_air, + temperatureUnit="degC") + annotation (Placement( + transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={62,-2}))); + ThermofluidStream.Boundaries.Sink sink( + redeclare package Medium = Medium_air, + p0_par=101300) annotation (Placement( + transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={176,8}))); + Modelica.Mechanics.Rotational.Sources.Speed speed1 + annotation (Placement(transformation(extent={{60,-90},{80,-70}}))); + + ThermofluidStream.Processes.Fan fan( + redeclare package Medium = Medium_air, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + redeclare function dp_tau_fan = + Processes.Internal.TurboComponent.dp_tau_const_isentrop ( + omega_ref=100)) + annotation (Placement(transformation(extent={{140,-2},{160,18}}))); + Modelica.Blocks.Sources.RealExpression pump_speed(y=80 + 273.15) + annotation (Placement(transformation(extent={{-140,-30},{-160,-10}}))); + Modelica.Blocks.Sources.RealExpression fan_speed(y=400) + annotation (Placement(transformation(extent={{20,-60},{40,-40}}))); + Modelica.Thermal.HeatTransfer.Components.HeatCapacitor heatCapacitor(C=500, T(start=373.15, fixed=true)) + annotation (Placement(transformation(extent={{-120,50},{-100,70}}))); + Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow prescribedHeatFlow + annotation (Placement(transformation(extent={{-150,40},{-130,60}}))); + Modelica.Blocks.Sources.RealExpression heat_load(y=10000) + annotation (Placement(transformation(extent={{-180,80},{-160,100}}))); + inner ThermofluidStream.DropOfCommons dropOfCommons + annotation (Placement(transformation(extent={{160,80},{180,100}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm6( + redeclare package Medium = Medium_liquid, temperatureUnit="degC") + annotation (Placement(transformation(extent={{-10,10},{10,-10}}, + rotation=180, + origin={124,30}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm7( + redeclare package Medium = Medium_air, + temperatureUnit="degC") + annotation (Placement( + transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={120,-2}))); + Modelica.Blocks.Sources.RealExpression actual_heatPortTemp( + y=thermalConvectionPipe.heatPort.T) + annotation (Placement(transformation(extent={{-180,-90},{-160,-70}}))); + Modelica.Blocks.Interaction.Show.RealValue realValue( + use_numberPort=false, + number=thermalConvectionPipe.heatPort.T - 273.15) + annotation (Placement(transformation(extent={{-160,20},{-180,0}}))); + ThermofluidStream.Utilities.showRealValue showRealValue + annotation (Placement(transformation(extent={{-120,-26},{-100,-6}}))); + ThermofluidStream.Utilities.showRealValue showRealValue1( + use_numberPort=false, + description="eff", + number=heatExchange_CounterFlowNTU.effectiveness) + annotation (Placement(transformation(extent={{80,20},{100,40}}))); + Modelica.Blocks.Sources.CombiTimeTable combiTimeTable( + table=[0,5000; 2000,5000; + 2000.01,10000; 4000,10000; 4000.01,25000; 6000,25000; 6000.01,5000; 10000, + 5000]) + annotation (Placement(transformation(extent={{-180,40},{-160,60}}))); + Modelica.Blocks.Math.Gain gain(k=-3) + annotation (Placement(transformation(extent={{20,-90},{40,-70}}))); + Modelica.Blocks.Continuous.LimPID PID( + controllerType=Modelica.Blocks.Types.SimpleController.PI, + k=30, + Ti=2, + yMax=-5, + yMin=-5000) + annotation (Placement(transformation(extent={{-160,-60},{-140,-40}}))); + Modelica.Blocks.Math.Gain gain1(k=-0.001) + annotation (Placement(transformation(extent={{-120,-60},{-100,-40}}))); + Modelica.Blocks.Math.Feedback feedback + annotation (Placement(transformation(extent={{-90,-40},{-70,-60}}))); + Modelica.Blocks.Continuous.PI PI( + k=3000, + T=0.1, + initType=Modelica.Blocks.Types.Init.InitialState) + annotation (Placement(transformation(extent={{-60,-60},{-40,-40}}))); + ThermofluidStream.Utilities.showRealValue showRealValue2 + annotation (Placement(transformation(extent={{-100,-40},{-120,-20}}))); + ThermofluidStream.Utilities.Icons.DLRLogo dLRLogo annotation (Placement(transformation(extent={{144,-96},{180,-60}}))); + FluidPortMSLtoOutletTFS_eq fluidPortMSLtoOutletTFS_eq(redeclare package Medium = Medium_liquid) + annotation (Placement(transformation(extent={{18,16},{10,24}}))); + InletTFStoFluidPortMSL_eq inletTFStoFluidPortMSL_eq(redeclare package Medium = Medium_liquid) + annotation (Placement(transformation(extent={{46,16},{38,24}}))); + Modelica.Fluid.Vessels.OpenTank tank( + height(displayUnit="m") = 2, + crossArea(displayUnit="m2") = 0.01, + p_ambient=100000, + level_start(displayUnit="cm") = 0.1, + redeclare package Medium = Medium_liquid, + use_portsData=false, + nPorts=2) annotation (Placement(transformation(extent={{18,20},{38,40}}))); +equation + connect(multiSensor_Tpm1.inlet, heatExchange_CounterFlowNTU.outletB) + annotation (Line( + points={{82,20},{86,20}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm2.outlet, mCV.inlet) annotation (Line( + points={{-20,20},{-26,20}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.outlet, multiSensor_Tpm3.inlet) annotation (Line( + points={{-46,20},{-52,20}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm3.outlet, thermalConvectionPipe.inlet) annotation ( + Line( + points={{-72,20},{-80,20},{-80,40}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.outlet, multiSensor_Tpm4.inlet) annotation ( + Line( + points={{-80,60},{-80,80},{-20,80}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistance.inlet, multiSensor_Tpm4.outlet) annotation (Line( + points={{80,80},{0,80}}, + color={28,108,200}, + thickness=0.5)); + connect(source.outlet, multiSensor_Tpm5.inlet) annotation (Line( + points={{28,-10},{40,-10},{40,8},{52,8}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm5.outlet, heatExchange_CounterFlowNTU.inletA) + annotation (Line( + points={{72,8},{86,8}}, + color={28,108,200}, + thickness=0.5)); + connect(sink.inlet, fan.outlet) annotation (Line( + points={{166,8},{160,8}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.heatPort, heatCapacitor.port) + annotation (Line(points={{-90,50},{-110,50}}, color={191,0,0})); + connect(heatCapacitor.port, prescribedHeatFlow.port) + annotation (Line(points={{-110,50},{-130,50}}, color={191,0,0})); + connect(heatExchange_CounterFlowNTU.inletB, multiSensor_Tpm6.outlet) + annotation (Line( + points={{106,20},{114,20}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm6.inlet, flowResistance.outlet) annotation (Line( + points={{134,20},{140,20},{140,80},{100,80}}, + color={28,108,200}, + thickness=0.5)); + connect(heatExchange_CounterFlowNTU.outletA, multiSensor_Tpm7.inlet) + annotation (Line( + points={{106,8},{110,8}}, + color={28,108,200}, + thickness=0.5)); + connect(fan.inlet, multiSensor_Tpm7.outlet) annotation (Line( + points={{140,8},{130,8}}, + color={28,108,200}, + thickness=0.5)); + connect(fan.flange, speed1.flange) + annotation (Line(points={{150,-2},{150,-40},{100,-40},{100,-80},{80,-80}}, + color={0,0,0})); + connect(speed1.w_ref, gain.y) annotation (Line(points={{58,-80},{41,-80}}, + color={0,0,127})); + connect(PID.y, showRealValue.numberPort) annotation (Line(points={{-139,-50},{-130,-50},{-130,-16},{-121.5,-16}}, + color={0,0,127})); + connect(PID.u_s, pump_speed.y) + annotation (Line(points={{-162,-50},{-170,-50},{-170,-20},{-161,-20}}, + color={0,0,127})); + connect(actual_heatPortTemp.y, PID.u_m) annotation (Line(points={{-159,-80},{-150,-80},{-150,-62}}, + color={0,0,127})); + connect(PID.y, gain1.u) + annotation (Line(points={{-139,-50},{-122,-50}}, color={0,0,127})); + connect(gain1.y, feedback.u1) + annotation (Line(points={{-99,-50},{-88,-50}}, color={0,0,127})); + connect(multiSensor_Tpm3.m_flow_out, feedback.u2) annotation (Line(points={{-72,16},{-80,16},{-80,-42}}, + color={0,0,127})); + connect(feedback.y, PI.u) + annotation (Line(points={{-71,-50},{-62,-50}}, color={0,0,127})); + connect(PID.y, gain.u) annotation (Line(points={{-139,-50},{-130,-50},{-130,-80},{18,-80}}, + color={0,0,127})); + connect(showRealValue2.numberPort, feedback.u1) annotation (Line(points={{-98.5,-30},{-92,-30},{-92,-50},{-88,-50}}, + color={0,0,127})); + connect(prescribedHeatFlow.Q_flow, combiTimeTable.y[1]) + annotation (Line(points={{-150,50},{-159,50}}, color={0,0,127})); + + connect(inletTFStoFluidPortMSL_eq.portMSL,tank. ports[1]) annotation (Line(points={{40,20},{27,20}}, color={0,127,255})); + connect(fluidPortMSLtoOutletTFS_eq.portMSL,tank. ports[2]) annotation (Line(points={{16.2,20},{29,20}}, color={0,127,255})); + connect(multiSensor_Tpm1.outlet, inletTFStoFluidPortMSL_eq.inletTFS) annotation (Line( + points={{68,20},{45.6,20}}, + color={28,108,200}, + thickness=0.5)); + connect(fluidPortMSLtoOutletTFS_eq.outletTFS, multiSensor_Tpm2.inlet) annotation (Line( + points={{11.2,20},{-6,20}}, + color={28,108,200}, + thickness=0.5)); + annotation ( + experiment( + StopTime=10000, + Tolerance=1e-6, + Interval=10, + __Dymola_Algorithm="Dassl"), + Icon(coordinateSystem(extent={{-100,-100},{100,100}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-180,-100},{180,100}})), + Documentation(info=" +

This cooling cycle is regulated to hit a temperature target. The load is a prescribed heatflow and comes from a table.

+


Owner: Niels Weber

+")); +end SimpleCoolingCycle_02MCV_NOK; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_00_NOK.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_00_NOK.mo new file mode 100644 index 00000000..32a3cc3d --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_00_NOK.mo @@ -0,0 +1,192 @@ +within ThermofluidStream.Interfaces.MSLplug.ByCode.Tests; +model TargetTest_00_NOK + extends Modelica.Icons.Example; + + replaceable package Medium = ThermofluidStream.Media.myMedia.Water.StandardWaterOnePhase + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + annotation ( + choicesAllMatching=true); + + parameter Modelica.Units.NonSI.Temperature_degC T_SP=80 "Solar field outlet temperature setpoint" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC l_s=55 "Security maximum temperature threshold for production switching" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC hyst_prod_pre=5 "Temperature hysteresis for switches in between in production and out of production" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_SP=10 "Security margin deduced from the temperature setpoint to switch in production (compared with l_s and valuabe process temperature)." + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_min=5 "Minimum temperature difference supplied to the process" + annotation(Dialog(group = "Control")); + parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "nominal mass flow rate for regularisation" + annotation(Dialog(tab = "Advanced", group = "Regularisation parameters")); + parameter Boolean computeL=true "Compute L from r and l" annotation (Dialog(tab="Advanced", group="Flow inertance")); + + HeatExchangers.CounterFlowNTU pHEXSimplified( + redeclare package MediumA = Medium, + redeclare package MediumB = Medium, + A=10) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=-90, + origin={20,2}))); + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium, p0_par=101300) + annotation (Placement(transformation(extent={{56,30},{76,50}}))); + + ThermofluidStream.FlowControl.MCV mCV( + redeclare package Medium = Medium, massFlow_set_par=1) + annotation (Placement(transformation(extent={{50,-10},{30,-30}}))); + ThermofluidStream.FlowControl.MCV flowGenerator_SF( + redeclare package Medium = Medium, + m_flowStateSelect=StateSelect.prefer, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + m_flow_0=1, + massFlow_set_par=1, + dp_int(fixed=false)) + annotation (Placement(transformation(extent={{-30,-10},{-50,-30}}))); + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{76,-30},{56,-10}}))); + inner DropOfCommons dropOfCommons + annotation (Placement(transformation(extent={{-80,60},{-60,80}}))); + inner Modelica.Fluid.System system annotation (Placement(transformation(extent={{-100,60},{-80,80}}))); + Processes.ThermalConvectionPipe thermalConvectionPipe( + redeclare package Medium = Medium, + r=0.01, + l=1) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-60,10}))); + Boundaries.Reservoir reservoir(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{0,-30},{-20,-10}}))); + Processes.FlowResistance flowResistance( + redeclare package Medium = Medium, + r=0.1, + l=1, + redeclare function pLoss = ThermofluidStream.Processes.Internal.FlowResistance.linearQuadraticPressureLoss (k=10)) + annotation (Placement(transformation(extent={{-40,30},{-20,50}}))); + Modelica.Thermal.HeatTransfer.Components.HeatCapacitor heatCapacitor(C=500, T(start=373.15, fixed=true)) + annotation (Placement(transformation(extent={{-84,10},{-74,20}}))); + Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow prescribedHeatFlow + annotation (Placement(transformation(extent={{-92,6},{-84,14}}))); + Modelica.Blocks.Sources.CombiTimeTable combiTimeTable(table=[0,5000; 2000,5000; 2000.01,10000; 4000,10000; 4000.01,25000; 6000,25000; 6000.01,5000; 10000,5000]) + annotation (Placement(transformation(extent={{-120,0},{-100,20}}))); + +equation + + connect(mCV.outlet, pHEXSimplified.inletB) annotation (Line( + points={{30,-20},{26,-20},{26,-8}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.inlet, source.outlet) annotation (Line( + points={{50,-20},{56,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletA, reservoir.inlet) annotation (Line( + points={{14,-8},{14,-20},{0,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletB, sink.inlet) annotation (Line( + points={{26,12},{26,40},{56,40}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.outlet, flowResistance.inlet) annotation (Line( + points={{-60,20},{-60,40},{-40,40}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistance.outlet, pHEXSimplified.inletA) annotation (Line( + points={{-20,40},{14,40},{14,12}}, + color={28,108,200}, + thickness=0.5)); + connect(reservoir.outlet, flowGenerator_SF.inlet) annotation (Line( + points={{-20,-20},{-30,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.outlet, thermalConvectionPipe.inlet) annotation (Line( + points={{-50,-20},{-60,-20},{-60,0}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.heatPort,heatCapacitor. port) + annotation (Line(points={{-70,10},{-79,10}}, color={191,0,0})); + connect(heatCapacitor.port,prescribedHeatFlow. port) + annotation (Line(points={{-79,10},{-84,10}}, color={191,0,0})); + connect(prescribedHeatFlow.Q_flow,combiTimeTable. y[1]) + annotation (Line(points={{-92,10},{-99,10}}, color={0,0,127})); + annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + experiment( + StopTime=3600, + Interval=60, + __Dymola_Algorithm="Dassl"), + __Dymola_Commands( + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","weather.T_amb","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-5.0,90.0}, + grid=true, + colors={{28,108,200},{238,46,47},{217,67,180},{0,140,72},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"})} "Temp CS", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,697}, + y={"weather.T_amb","solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-10.0,90.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47},{217,67,180},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"}),createPlot( + id=1, + position={0,0,1614,697}, + y={"stratifiedTank_Diffuser.T_lay[1]","stratifiedTank_Diffuser.T_lay[3]","stratifiedTank_Diffuser.T_lay[5]","stratifiedTank_Diffuser.T_lay[7]","stratifiedTank_Diffuser.T_lay[9]", + "stratifiedTank_Diffuser.T_lay[11]","stratifiedTank_Diffuser.T_lay[13]","stratifiedTank_Diffuser.T_lay[15]","stratifiedTank_Diffuser.T_lay[17]","stratifiedTank_Diffuser.T_lay[19]", + "stratifiedTank_Diffuser.T_lay[20]"}, + range={0.0,195.0,10.0,80.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47},{0,140,72},{217,67,180},{0,0,0},{162,29,33},{244,125,35},{102,44,145},{28,108,200},{238,46,47},{0,140,72}}, + patterns={LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid, + LinePattern.Solid,LinePattern.Dash,LinePattern.Dash,LinePattern.Dash}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","degC","degC","degC","degC","degC","degC"})} "Températures CS et cuve", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"prod_switch.y","flowGenerator_SF.V_flow_out","flowGenerator_SF.V_flow_sp"}, + range={0.0,700000.0,-5.0,50.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"","m3/h","m3/h"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.L"}, + range={0.0,700000.0,-1000000.0,11000000.0}, + grid=true, + subPlot=202, + colors={{28,108,200}}, + timeUnit="s", + displayUnits={"1/m"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.dr","flowGenerator_SF.dr_set"}, + range={0.0,700000.0,-4.0,4.0}, + grid=true, + subPlot=201, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.p_in","flowGenerator_SF.p_out"}, + range={0.0,700000.0,0.5,4.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"})} "Inertance analysis")); +end TargetTest_00_NOK; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_01_NOK.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_01_NOK.mo new file mode 100644 index 00000000..6a7d959e --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_01_NOK.mo @@ -0,0 +1,198 @@ +within ThermofluidStream.Interfaces.MSLplug.ByCode.Tests; +model TargetTest_01_NOK + extends Modelica.Icons.Example; + + replaceable package Medium = ThermofluidStream.Media.myMedia.Water.StandardWaterOnePhase + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + annotation ( + choicesAllMatching=true); + + parameter Modelica.Units.NonSI.Temperature_degC T_SP=80 "Solar field outlet temperature setpoint" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC l_s=55 "Security maximum temperature threshold for production switching" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC hyst_prod_pre=5 "Temperature hysteresis for switches in between in production and out of production" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_SP=10 "Security margin deduced from the temperature setpoint to switch in production (compared with l_s and valuabe process temperature)." + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_min=5 "Minimum temperature difference supplied to the process" + annotation(Dialog(group = "Control")); + parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "nominal mass flow rate for regularisation" + annotation(Dialog(tab = "Advanced", group = "Regularisation parameters")); + parameter Boolean computeL=true "Compute L from r and l" annotation (Dialog(tab="Advanced", group="Flow inertance")); + + HeatExchangers.CounterFlowNTU pHEXSimplified( + redeclare package MediumA = Medium, + redeclare package MediumB = Medium, + A=10) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=-90, + origin={20,10}))); + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{56,30},{76,50}}))); + + ThermofluidStream.FlowControl.MCV mCV( + redeclare package Medium = Medium, + massFlow_set_par=1, + TC=10) + annotation (Placement(transformation(extent={{50,-10},{30,-30}}))); + ThermofluidStream.FlowControl.MCV flowGenerator_SF( + redeclare package Medium = Medium, + massFlow_set_par=10) + annotation (Placement(transformation(extent={{-30,-10},{-50,-30}}))); + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{80,-30},{60,-10}}))); + inner DropOfCommons dropOfCommons(L=1000) + annotation (Placement(transformation(extent={{-80,60},{-60,80}}))); + inner Modelica.Fluid.System system(g=0.0000001) + annotation (Placement(transformation(extent={{-100,60},{-80,80}}))); + Modelica.Blocks.Noise.UniformNoise heatScenario( + samplePeriod=60, + y_min=10, + y_max=95) annotation (Placement(transformation(extent={{-106,0},{-86,20}}))); + Processes.ThermalConvectionPipe thermalConvectionPipe( + redeclare package Medium = Medium, + r=0.2, + l=100) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-60,10}))); + Modelica.Thermal.HeatTransfer.Celsius.PrescribedTemperature + prescribedTemperature + annotation (Placement(transformation(extent={{-80,6},{-72,14}}))); + FluidPortMSLtoOutletTFS_eq fluidPortMSLtoOutletTFS_eq(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-18,-24},{-26,-16}}))); + InletTFStoFluidPortMSL_eq inletTFStoFluidPortMSL_eq(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{10,-24},{2,-16}}))); + Modelica.Fluid.Vessels.OpenTank tank( + height=1000, + crossArea=0.01, + p_ambient=100000, + level_start(displayUnit="cm") = 0.1, + redeclare package Medium = Medium, + use_portsData=false, + nPorts=2) annotation (Placement(transformation(extent={{-18,-20},{2,0}}))); +protected + parameter Medium.ThermodynamicState state_0_CS = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_CS = Medium.density(state_0_CS); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_CS = Medium.specificHeatCapacityCp(state_0_CS); + parameter Medium.ThermodynamicState state_0_cuve = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_cuve = Medium.density(state_0_cuve); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_cuve = Medium.specificHeatCapacityCp(state_0_cuve); + +equation + + connect(mCV.outlet, pHEXSimplified.inletB) annotation (Line( + points={{30,-20},{26,-20},{26,-4.44089e-15}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletB, sink.inlet) annotation (Line( + points={{26,20},{26,40},{56,40}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.inlet, source.outlet) annotation (Line( + points={{50,-20},{60,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.outlet, thermalConvectionPipe.inlet) annotation (Line( + points={{-50,-20},{-60,-20},{-60,0}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.outlet, pHEXSimplified.inletA) + annotation (Line( + points={{-60,20},{-60,40},{14,40},{14,20}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalConvectionPipe.heatPort, prescribedTemperature.port) annotation (Line(points={{-70,10},{-72,10}}, color={191,0,0})); + connect(flowGenerator_SF.inlet, fluidPortMSLtoOutletTFS_eq.outletTFS) annotation (Line( + points={{-30,-20},{-24.8,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletA, inletTFStoFluidPortMSL_eq.inletTFS) + annotation (Line( + points={{14,-2.66454e-15},{14,-20},{9.6,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(inletTFStoFluidPortMSL_eq.portMSL, tank.ports[1]) annotation (Line(points={{4,-20},{-9,-20}}, color={0,127,255})); + connect(fluidPortMSLtoOutletTFS_eq.portMSL, tank.ports[2]) annotation (Line(points={{-19.8,-20},{-7,-20}}, color={0,127,255})); + connect(prescribedTemperature.T, heatScenario.y) annotation (Line(points={{-80.8,10},{-85,10}}, color={0,0,127})); + annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + experiment( + StopTime=3600, + Interval=60, + __Dymola_Algorithm="Dassl"), + __Dymola_Commands( + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","weather.T_amb","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-5.0,90.0}, + grid=true, + colors={{28,108,200},{238,46,47},{217,67,180},{0,140,72},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"})} "Temp CS", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,697}, + y={"weather.T_amb","solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-10.0,90.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47},{217,67,180},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"}),createPlot( + id=1, + position={0,0,1614,697}, + y={"stratifiedTank_Diffuser.T_lay[1]","stratifiedTank_Diffuser.T_lay[3]","stratifiedTank_Diffuser.T_lay[5]","stratifiedTank_Diffuser.T_lay[7]","stratifiedTank_Diffuser.T_lay[9]", + "stratifiedTank_Diffuser.T_lay[11]","stratifiedTank_Diffuser.T_lay[13]","stratifiedTank_Diffuser.T_lay[15]","stratifiedTank_Diffuser.T_lay[17]","stratifiedTank_Diffuser.T_lay[19]", + "stratifiedTank_Diffuser.T_lay[20]"}, + range={0.0,195.0,10.0,80.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47},{0,140,72},{217,67,180},{0,0,0},{162,29,33},{244,125,35},{102,44,145},{28,108,200},{238,46,47},{0,140,72}}, + patterns={LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid, + LinePattern.Solid,LinePattern.Dash,LinePattern.Dash,LinePattern.Dash}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","degC","degC","degC","degC","degC","degC"})} "Températures CS et cuve", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"prod_switch.y","flowGenerator_SF.V_flow_out","flowGenerator_SF.V_flow_sp"}, + range={0.0,700000.0,-5.0,50.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"","m3/h","m3/h"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.L"}, + range={0.0,700000.0,-1000000.0,11000000.0}, + grid=true, + subPlot=202, + colors={{28,108,200}}, + timeUnit="s", + displayUnits={"1/m"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.dr","flowGenerator_SF.dr_set"}, + range={0.0,700000.0,-4.0,4.0}, + grid=true, + subPlot=201, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.p_in","flowGenerator_SF.p_out"}, + range={0.0,700000.0,0.5,4.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"})} "Inertance analysis")); +end TargetTest_01_NOK; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_02_NoFlow.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_02_NoFlow.mo new file mode 100644 index 00000000..6fefce47 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/TargetTest_02_NoFlow.mo @@ -0,0 +1,245 @@ +within ThermofluidStream.Interfaces.MSLplug.ByCode.Tests; +model TargetTest_02_NoFlow + extends Modelica.Icons.Example; + + replaceable package Medium = ThermofluidStream.Media.myMedia.Water.StandardWaterOnePhase + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + annotation ( + choicesAllMatching=true); + + parameter Modelica.Units.NonSI.Temperature_degC T_SP=80 "Solar field outlet temperature setpoint" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC l_s=55 "Security maximum temperature threshold for production switching" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC hyst_prod_pre=5 "Temperature hysteresis for switches in between in production and out of production" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_SP=10 "Security margin deduced from the temperature setpoint to switch in production (compared with l_s and valuabe process temperature)." + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_min=5 "Minimum temperature difference supplied to the process" + annotation(Dialog(group = "Control")); + parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "nominal mass flow rate for regularisation" + annotation(Dialog(tab = "Advanced", group = "Regularisation parameters")); + parameter Boolean computeL=true "Compute L from r and l" annotation (Dialog(tab="Advanced", group="Flow inertance")); + + HeatExchangers.CounterFlowNTU pHEXSimplified( + redeclare package MediumA = Medium, + redeclare package MediumB = Medium, + A=10) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=-90, + origin={20,-10}))); + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{56,10},{76,30}}))); + + ThermofluidStream.FlowControl.MCV mCV( + redeclare package Medium = Medium, + setpointFromInput=true, + massFlow_set_par=1, + TC=10) + annotation (Placement(transformation(extent={{50,-50},{30,-30}}))); + ThermofluidStream.FlowControl.MCV flowGenerator_SF( + redeclare package Medium = Medium, + massFlow_set_par=10, + TC=10) + annotation (Placement(transformation(extent={{-44,-30},{-64,-50}}))); + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{80,-50},{60,-30}}))); + inner DropOfCommons dropOfCommons(L=1000) + annotation (Placement(transformation(extent={{-80,60},{-60,80}}))); + inner Modelica.Fluid.System system annotation (Placement(transformation(extent={{-100,60},{-80,80}}))); + Modelica.Blocks.Noise.UniformNoise heatScenario( + samplePeriod=60, + y_min=10, + y_max=95) annotation (Placement(transformation(extent={{-114,-20},{-94,0}}))); + Modelica.Blocks.Noise.UniformNoise mFlowScenario( + samplePeriod=60, + y_min=0.001, + y_max=15) annotation (Placement(transformation(extent={{100,-30},{80,-10}}))); + Processes.ConductionElement conductionElement( + redeclare package Medium = Medium, + V=0.01, + resistanceFromAU=false) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-70,-10}))); + Modelica.Thermal.HeatTransfer.Celsius.PrescribedTemperature + prescribedTemperature + annotation (Placement(transformation(extent={{-88,-14},{-80,-6}}))); + FluidPortMSLtoOutletTFS_eq fluidPortMSLtoOutletTFS_eq(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-32,-44},{-40,-36}}))); + InletTFStoFluidPortMSL_eq inletTFStoFluidPortMSL_eq(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-4,-44},{-12,-36}}))); + Modelica.Fluid.Vessels.OpenTank tank( + height=1000, + crossArea=0.01, + p_ambient=100000, + level_start(displayUnit="cm") = 0.1, + redeclare package Medium = Medium, + use_portsData=false, + nPorts=2) annotation (Placement(transformation(extent={{-32,-40},{-12,-20}}))); + FlowControl.Switch switch(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-6,26},{6,14}}))); + Topology.JunctionT2 junctionT2_1(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{0,-46},{10,-34}}))); + Sensors.SingleSensorSelect singleSensorSelect( + redeclare package Medium = Medium, + quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.T_C, + outputValue=true) annotation (Placement(transformation(extent={{-56,20},{-36,40}}))); + Modelica.Blocks.Continuous.LimPID PID( + controllerType=Modelica.Blocks.Types.SimpleController.PI, + yMax=1, + yMin=0) annotation (Placement(transformation(extent={{-24,36},{-16,44}}))); + Modelica.Blocks.Sources.RealExpression stepoint(y=80) annotation (Placement(transformation(extent={{-46,32},{-34,48}}))); + Processes.FlowResistance flowResistance( + redeclare package Medium = Medium, + r=0.1, + l=1, + redeclare function pLoss = ThermofluidStream.Processes.Internal.FlowResistance.laminarPressureLoss) + annotation (Placement(transformation(extent={{-6,-6},{6,6}}, + rotation=90, + origin={-70,-30}))); +protected + parameter Medium.ThermodynamicState state_0_CS = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_CS = Medium.density(state_0_CS); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_CS = Medium.specificHeatCapacityCp(state_0_CS); + parameter Medium.ThermodynamicState state_0_cuve = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_cuve = Medium.density(state_0_cuve); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_cuve = Medium.specificHeatCapacityCp(state_0_cuve); + +equation + + connect(mCV.outlet, pHEXSimplified.inletB) annotation (Line( + points={{30,-40},{26,-40},{26,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletB, sink.inlet) annotation (Line( + points={{26,0},{26,20},{56,20}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.inlet, source.outlet) annotation (Line( + points={{50,-40},{60,-40}}, + color={28,108,200}, + thickness=0.5)); + connect(conductionElement.heatPort, prescribedTemperature.port) annotation (Line(points={{-79.8,-10},{-80,-10}}, color={191,0,0})); + connect(flowGenerator_SF.inlet, fluidPortMSLtoOutletTFS_eq.outletTFS) annotation (Line( + points={{-44,-40},{-38.8,-40}}, + color={28,108,200}, + thickness=0.5)); + connect(conductionElement.outlet, switch.inlet) annotation (Line( + points={{-70,0},{-70,20},{-6,20}}, + color={28,108,200}, + thickness=0.5)); + connect(switch.outletA, pHEXSimplified.inletA) annotation (Line( + points={{6,20},{14,20},{14,0}}, + color={28,108,200}, + thickness=0.5)); + connect(inletTFStoFluidPortMSL_eq.inletTFS, junctionT2_1.outlet) annotation (Line( + points={{-4.4,-40},{0,-40}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletA, junctionT2_1.inletB) annotation (Line( + points={{14,-20},{14,-40},{10,-40}}, + color={28,108,200}, + thickness=0.5)); + connect(switch.outletB, junctionT2_1.inletA) annotation (Line( + points={{0,14},{0,-30},{5,-30},{5,-34}}, + color={28,108,200}, + thickness=0.5)); + connect(mFlowScenario.y, mCV.setpoint_var) annotation (Line(points={{79,-20},{40,-20},{40,-32}}, color={0,0,127})); + connect(conductionElement.outlet, singleSensorSelect.inlet) + annotation (Line( + points={{-70,0},{-70,20},{-60,20},{-60,30},{-56,30}}, + color={28,108,200}, + thickness=0.5)); + connect(PID.y, switch.u) annotation (Line(points={{-15.6,40},{0,40},{0,24.8}}, color={0,0,127})); + connect(fluidPortMSLtoOutletTFS_eq.portMSL, tank.ports[1]) annotation (Line(points={{-33.8,-40},{-23,-40}}, color={0,127,255})); + connect(tank.ports[2], inletTFStoFluidPortMSL_eq.portMSL) annotation (Line(points={{-21,-40},{-10,-40}}, color={0,127,255})); + connect(prescribedTemperature.T, heatScenario.y) annotation (Line(points={{-88.8,-10},{-93,-10}}, color={0,0,127})); + connect(singleSensorSelect.value_out, PID.u_s) annotation (Line(points={{-36,30},{-28,30},{-28,40},{-24.8,40}}, color={0,0,127})); + connect(stepoint.y, PID.u_m) annotation (Line(points={{-33.4,40},{-32,40},{-32,35.2},{-20,35.2}}, color={0,0,127})); + connect(conductionElement.inlet, flowResistance.outlet) annotation (Line( + points={{-70,-20},{-70,-24}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.outlet, flowResistance.inlet) annotation (Line( + points={{-64,-40},{-70,-40},{-70,-36}}, + color={28,108,200}, + thickness=0.5)); + annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + experiment( + StopTime=3600, + Interval=60, + __Dymola_Algorithm="Dassl"), + __Dymola_Commands( + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","weather.T_amb","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-5.0,90.0}, + grid=true, + colors={{28,108,200},{238,46,47},{217,67,180},{0,140,72},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"})} "Temp CS", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,697}, + y={"weather.T_amb","solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-10.0,90.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47},{217,67,180},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"}),createPlot( + id=1, + position={0,0,1614,697}, + y={"stratifiedTank_Diffuser.T_lay[1]","stratifiedTank_Diffuser.T_lay[3]","stratifiedTank_Diffuser.T_lay[5]","stratifiedTank_Diffuser.T_lay[7]","stratifiedTank_Diffuser.T_lay[9]", + "stratifiedTank_Diffuser.T_lay[11]","stratifiedTank_Diffuser.T_lay[13]","stratifiedTank_Diffuser.T_lay[15]","stratifiedTank_Diffuser.T_lay[17]","stratifiedTank_Diffuser.T_lay[19]", + "stratifiedTank_Diffuser.T_lay[20]"}, + range={0.0,195.0,10.0,80.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47},{0,140,72},{217,67,180},{0,0,0},{162,29,33},{244,125,35},{102,44,145},{28,108,200},{238,46,47},{0,140,72}}, + patterns={LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid, + LinePattern.Solid,LinePattern.Dash,LinePattern.Dash,LinePattern.Dash}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","degC","degC","degC","degC","degC","degC"})} "Températures CS et cuve", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"prod_switch.y","flowGenerator_SF.V_flow_out","flowGenerator_SF.V_flow_sp"}, + range={0.0,700000.0,-5.0,50.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"","m3/h","m3/h"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.L"}, + range={0.0,700000.0,-1000000.0,11000000.0}, + grid=true, + subPlot=202, + colors={{28,108,200}}, + timeUnit="s", + displayUnits={"1/m"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.dr","flowGenerator_SF.dr_set"}, + range={0.0,700000.0,-4.0,4.0}, + grid=true, + subPlot=201, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.p_in","flowGenerator_SF.p_out"}, + range={0.0,700000.0,0.5,4.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"})} "Inertance analysis")); +end TargetTest_02_NoFlow; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/UnitTest_NoMixtureOnlyForNow_OK.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/UnitTest_NoMixtureOnlyForNow_OK.mo new file mode 100644 index 00000000..d4ceea32 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/UnitTest_NoMixtureOnlyForNow_OK.mo @@ -0,0 +1,254 @@ +within ThermofluidStream.Interfaces.MSLplug.ByCode.Tests; +model UnitTest_NoMixtureOnlyForNow_OK + extends Modelica.Icons.Example; + replaceable package Medium = ThermofluidStream.Media.myMedia.Water.WaterIF97_R1pT + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium annotation ( + choicesAllMatching=true); + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium, temperatureFromInput=true) + annotation ( + Placement(visible = true, transformation(origin={-36,80}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium, p0_par=101300) + annotation ( + Placement(visible = true, transformation(origin={70,80}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + FlowControl.MCV flowGenerator( + redeclare package Medium = Medium, setpointFromInput=true) + annotation (Placement(transformation(extent={{-18,90},{2,70}}))); + Modelica.Thermal.HeatTransfer.Celsius.ToKelvin toKelvin annotation (Placement( + transformation( + extent={{-5,5},{5,-5}}, + rotation=0, + origin={-59,89}))); + Modelica.Blocks.Math.Gain gain(k=1) annotation (Placement(transformation( + extent={{-4,-4},{4,4}}, + rotation=0, + origin={-70,60}))); + inner DropOfCommons dropOfCommons(L=1000) + annotation (Placement(transformation(extent={{-100,-100},{-80,-80}}))); + ThermofluidStream.Boundaries.Source source1(redeclare package Medium = Medium, temperatureFromInput=true) + annotation ( + Placement(visible = true, transformation(origin={-38,50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Fluid.Sources.FixedBoundary sink1(redeclare package Medium = Medium, + p=101300, + nPorts=1) + annotation (Placement(transformation(extent={{80,40},{60,60}}))); + InletTFStoFluidPortMSL_eq inletTFStoFluidPortMSL_eq(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{10,40},{30,60}}))); + FlowControl.MCV flowGenerator1( + redeclare package Medium = Medium, setpointFromInput=true) + annotation (Placement(transformation(extent={{-18,40},{2,60}}))); + Modelica.Fluid.Sources.MassFlowSource_T flowGenerator2( + redeclare package Medium = Medium, + use_m_flow_in=true, + use_T_in=true, + use_X_in=false, + nPorts=2) annotation (Placement(transformation(extent={{-28,10},{-8,30}}))); + FluidPortMSLtoOutletTFS_eq fluidPortMSLtoOutletTFS_eq(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{14,10},{34,30}}))); + ThermofluidStream.Boundaries.Sink sink2(redeclare package Medium = Medium, p0_par=101300) + annotation ( + Placement(visible = true, transformation(origin={70,20}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.RealExpression x_N2O2[2](y={0.8*exp(-time/1E4),1 - 0.8*exp(-time/1E4)}) annotation (Placement(transformation(extent={{-100,94},{-80,106}}))); + Modelica.Fluid.Sensors.Temperature temperature(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{34,60},{46,70}}))); + Modelica.Fluid.Sensors.Temperature temperature1(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-2,24},{10,34}}))); + Modelica.Blocks.Noise.UniformNoise mFlowScenario( + samplePeriod=60, + y_min=0.001, + y_max=15) annotation (Placement(transformation(extent={{-100,56},{-80,64}}))); + Modelica.Blocks.Noise.UniformNoise temperatureScenario( + samplePeriod=60, + y_min=10, + y_max=35) annotation (Placement(transformation(extent={{-100,84},{-80,94}}))); + Boundaries.Source source_FixedPressure( + redeclare package Medium = Medium, + pressureFromInput=true, + temperatureFromInput=true) annotation (Placement(visible=true, transformation( + origin={-36,-30}, + extent={{-10,-10},{10,10}}, + rotation=0))); +public + InletTFStoFluidPortMSL_eq inletTFStoFluidPortMSL_eq1(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-6,-38},{10,-22}}))); + Modelica.Fluid.Pipes.StaticPipe pipe_FixedPressure( + redeclare package Medium = Medium, + length=1, + diameter=0.1, + redeclare model FlowModel = Modelica.Fluid.Pipes.BaseClasses.FlowModels.NominalTurbulentPipeFlow (dp_nominal=100, m_flow_nominal=10)) + annotation (Placement(transformation(extent={{20,-40},{40,-20}}))); + Modelica.Fluid.Sources.FixedBoundary sink_FixedPressure( + redeclare package Medium = Medium, + use_p=true, + p(displayUnit="Pa"), + nPorts=1) annotation (Placement(transformation(extent={{100,-40},{80,-20}}))); + Modelica.Fluid.Sensors.Temperature T_FixedFlow1(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{60,-28},{72,-18}}))); + Boundaries.Source source_FixedPressure1( + redeclare package Medium = Medium, + pressureFromInput=true, + temperatureFromInput=true) annotation (Placement(visible=true, transformation( + origin={-36,-50}, + extent={{-10,-10},{10,10}}, + rotation=0))); +public + InletTFStoFluidPortMSL_eq inletTFStoFluidPortMSL_eq2(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{24,-58},{40,-42}}))); + Modelica.Fluid.Sources.FixedBoundary sink_FixedPressure1( + redeclare package Medium = Medium, + use_p=true, + p(displayUnit="Pa"), + nPorts=1) annotation (Placement(transformation(extent={{100,-60},{80,-40}}))); + Modelica.Fluid.Sensors.Temperature T_FixedFlow2(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{62,-48},{72,-38}}))); + Processes.FlowResistance flowResistance( + redeclare package Medium = Medium, + r=0.1, + l=1, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarPressureLoss) + annotation (Placement(transformation(extent={{-14,-60},{6,-40}}))); + Boundaries.Sink sink3(redeclare package Medium = Medium) + annotation ( + Placement(visible = true, transformation(origin={86,-80}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Fluid.Sources.Boundary_pT boundary( + redeclare package Medium = Medium, + use_p_in=true, + use_T_in=true, + use_X_in=false, + nPorts=1) annotation (Placement(transformation(extent={{-36,-90},{-16,-70}}))); + inner Modelica.Fluid.System system annotation (Placement(transformation(extent={{-100,-80},{-80,-60}}))); + Modelica.Blocks.Continuous.FirstOrder firstOrder(T=2) annotation (Placement(transformation( + extent={{-4,-4},{4,4}}, + rotation=-90, + origin={-78,-10}))); + Modelica.Fluid.Pipes.StaticPipe pipe_FixedPressure1( + redeclare package Medium = Medium, + length=1, + diameter=0.1, + redeclare model FlowModel = Modelica.Fluid.Pipes.BaseClasses.FlowModels.NominalTurbulentPipeFlow (dp_nominal=100, m_flow_nominal=10)) + annotation (Placement(transformation(extent={{-2,-90},{18,-70}}))); + FluidPortMSLtoOutletTFS_eq fluidPortMSLtoOutletTFS_eq1(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{32,-90},{52,-70}}))); + Modelica.Blocks.Continuous.FirstOrder firstOrder1(T=2) + annotation (Placement(transformation( + extent={{-4,-4},{4,4}}, + rotation=0, + origin={-60,60}))); + Modelica.Fluid.Sources.Boundary_pT boundary1( + redeclare package Medium = Medium, + use_p_in=true, + use_T_in=true, + use_X_in=false, + nPorts=1) annotation (Placement(transformation(extent={{-36,-110},{-16,-90}}))); + Boundaries.Sink sink4(redeclare package Medium = Medium) + annotation ( + Placement(visible = true, transformation(origin={86,-100}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + FluidPortMSLtoOutletTFS_eq fluidPortMSLtoOutletTFS_eq2(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-2,-110},{18,-90}}))); + Processes.FlowResistance flowResistance1( + redeclare package Medium = Medium, + r=0.1, + l=1, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarPressureLoss) + annotation (Placement(transformation(extent={{40,-110},{60,-90}}))); +protected + Modelica.Blocks.Math.Add add(k1=10) + annotation (Placement(transformation(extent={{-74,-38},{-66,-30}}))); + Modelica.Blocks.Sources.RealExpression pAtm(y=101325) + annotation (Placement(transformation( + extent={{-5.5,-5.5},{5.5,5.5}}, + rotation=0, + origin={-86.5,-36.5}))); +equation + connect(source.outlet, flowGenerator.inlet) annotation (Line( + points={{-26,80},{-18,80}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator.outlet, sink.inlet) annotation (Line( + points={{2,80},{60,80}}, + color={28,108,200}, + thickness=0.5)); + connect(source1.outlet, flowGenerator1.inlet) annotation (Line( + points={{-28,50},{-18,50}}, + color={28,108,200}, + thickness=0.5)); + connect(inletTFStoFluidPortMSL_eq.inletTFS, flowGenerator1.outlet) annotation (Line( + points={{11,50},{2,50}}, + color={28,108,200}, + thickness=0.5)); + connect(toKelvin.Kelvin, source1.T0_var) annotation (Line(points={{-53.5,89},{-53.5,50},{-40,50}}, + color={0,0,127})); + connect(toKelvin.Kelvin, source.T0_var) annotation (Line(points={{-53.5,89},{-53.5,80},{-38,80}}, + color={0,0,127})); + connect(toKelvin.Kelvin, flowGenerator2.T_in) annotation (Line(points={{-53.5,89},{-53.5,24},{-30,24}}, color={0,0,127})); + connect(x_N2O2.y, source.xi_var) annotation (Line(points={{-79,100},{-44,100},{-44,74},{-38,74}}, + color={0,0,127})); + connect(x_N2O2.y, flowGenerator2.X_in) annotation (Line(points={{-79,100},{-44,100},{-44,16},{-30,16}}, color={0,0,127})); + connect(x_N2O2.y, source1.xi_var) annotation (Line(points={{-79,100},{-44,100},{-44,44},{-40,44}}, + color={0,0,127})); + connect(mFlowScenario.y, gain.u) annotation (Line(points={{-79,60},{-74.8,60}}, color={0,0,127})); + connect(temperatureScenario.y, toKelvin.Celsius) annotation (Line(points={{-79,89},{-65,89}}, color={0,0,127})); + connect(source_FixedPressure.outlet, inletTFStoFluidPortMSL_eq1.inletTFS) + annotation (Line( + points={{-26,-30},{-5.2,-30}}, + color={28,108,200}, + thickness=0.5)); + connect(pipe_FixedPressure.port_b,sink_FixedPressure. ports[1]) + annotation (Line(points={{40,-30},{80,-30}}, color={0,127,255})); + connect(pAtm.y, add.u2) annotation (Line(points={{-80.45,-36.5},{-80.45,-36.4},{-74.8,-36.4}}, color={0,0,127})); + connect(add.y,source_FixedPressure. p0_var) + annotation (Line(points={{-65.6,-34},{-50,-34},{-50,-24},{-38,-24}}, color={0,0,127})); + connect(pipe_FixedPressure.port_b,T_FixedFlow1. port) + annotation (Line(points={{40,-30},{66,-30},{66,-28}}, color={0,127,255})); + connect(source_FixedPressure1.outlet,flowResistance. inlet) annotation (Line( + points={{-26,-50},{-14,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistance.outlet, inletTFStoFluidPortMSL_eq2.inletTFS) annotation (Line( + points={{6,-50},{24.8,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(toKelvin.Kelvin, source_FixedPressure.T0_var) annotation (Line(points={{-53.5,89},{-53.5,-30},{-38,-30}}, color={0,0,127})); + connect(toKelvin.Kelvin, source_FixedPressure1.T0_var) annotation (Line(points={{-53.5,89},{-53.5,-50},{-38,-50}}, color={0,0,127})); + connect(add.y, source_FixedPressure1.p0_var) annotation (Line(points={{-65.6,-34},{-50,-34},{-50,-44},{-38,-44}}, color={0,0,127})); + connect(add.y, boundary.p_in) annotation (Line(points={{-65.6,-34},{-50,-34},{-50,-72},{-38,-72}}, color={0,0,127})); + connect(toKelvin.Kelvin, boundary.T_in) annotation (Line(points={{-53.5,89},{-53.5,-76},{-38,-76}}, color={0,0,127})); + connect(x_N2O2.y, source_FixedPressure.xi_var) annotation (Line(points={{-79,100},{-44,100},{-44,-36},{-38,-36}}, color={0,0,127})); + connect(x_N2O2.y, source_FixedPressure1.xi_var) annotation (Line(points={{-79,100},{-44,100},{-44,-56},{-38,-56}}, color={0,0,127})); + connect(x_N2O2.y, boundary.X_in) annotation (Line(points={{-79,100},{-44,100},{-44,-84},{-38,-84}}, color={0,0,127})); + connect(mFlowScenario.y, firstOrder.u) annotation (Line(points={{-79,60},{-78,60},{-78,-5.2}}, color={0,0,127})); + connect(firstOrder.y, add.u1) annotation (Line(points={{-78,-14.4},{-78,-31.6},{-74.8,-31.6}}, color={0,0,127})); + connect(boundary.ports[1], pipe_FixedPressure1.port_a) annotation (Line(points={{-16,-80},{-2,-80}}, color={0,127,255})); + connect(fluidPortMSLtoOutletTFS_eq1.outletTFS, sink3.inlet) annotation (Line( + points={{49,-80},{76,-80}}, + color={28,108,200}, + thickness=0.5)); + connect(inletTFStoFluidPortMSL_eq.portMSL, sink1.ports[1]) annotation (Line(points={{25,50},{60,50}}, color={0,127,255})); + connect(inletTFStoFluidPortMSL_eq.portMSL, temperature.port) annotation (Line(points={{25,50},{40,50},{40,60}}, color={0,127,255})); + connect(inletTFStoFluidPortMSL_eq1.portMSL, pipe_FixedPressure.port_a) annotation (Line(points={{6,-30},{20,-30}}, color={0,127,255})); + connect(inletTFStoFluidPortMSL_eq2.portMSL, T_FixedFlow2.port) annotation (Line(points={{36,-50},{67,-50},{67,-48}}, color={0,127,255})); + connect(inletTFStoFluidPortMSL_eq2.portMSL, sink_FixedPressure1.ports[1]) annotation (Line(points={{36,-50},{80,-50}}, color={0,127,255})); + connect(pipe_FixedPressure1.port_b, fluidPortMSLtoOutletTFS_eq1.portMSL) annotation (Line(points={{18,-80},{36.5,-80}}, color={0,127,255})); + connect(flowGenerator2.ports[1], fluidPortMSLtoOutletTFS_eq.portMSL) annotation (Line(points={{-8,19.75},{6,19.75},{6,20},{18.5,20}}, color={0,127,255})); + connect(flowGenerator2.ports[2], temperature1.port) annotation (Line(points={{-8,20.25},{4,20.25},{4,24}}, color={0,127,255})); + connect(fluidPortMSLtoOutletTFS_eq.outletTFS, sink2.inlet) annotation (Line( + points={{31,20},{60,20}}, + color={28,108,200}, + thickness=0.5)); + connect(gain.y, firstOrder1.u) annotation (Line(points={{-65.6,60},{-64.8,60}}, color={0,0,127})); + connect(firstOrder1.y, flowGenerator2.m_flow_in) annotation (Line(points={{-55.6,60},{-50,60},{-50,28},{-28,28}}, color={0,0,127})); + connect(firstOrder1.y, flowGenerator.setpoint_var) annotation (Line(points={{-55.6,60},{-50,60},{-50,66},{-8,66},{-8,72}}, color={0,0,127})); + connect(firstOrder1.y, flowGenerator1.setpoint_var) annotation (Line(points={{-55.6,60},{-50,60},{-50,66},{-8,66},{-8,58}}, color={0,0,127})); + connect(add.y, boundary1.p_in) annotation (Line(points={{-65.6,-34},{-54,-34},{-54,-92},{-38,-92}}, color={0,0,127})); + connect(toKelvin.Kelvin, boundary1.T_in) annotation (Line(points={{-53.5,89},{-53.5,-96},{-38,-96}}, color={0,0,127})); + connect(flowResistance1.outlet, sink4.inlet) annotation (Line( + points={{60,-100},{76,-100}}, + color={28,108,200}, + thickness=0.5)); + connect(fluidPortMSLtoOutletTFS_eq2.outletTFS, flowResistance1.inlet) annotation (Line( + points={{15,-100},{40,-100}}, + color={28,108,200}, + thickness=0.5)); + connect(boundary1.ports[1], fluidPortMSLtoOutletTFS_eq2.portMSL) annotation (Line(points={{-16,-100},{2.5,-100}}, color={0,127,255})); + annotation (experiment(StopTime=3600, __Dymola_Algorithm="Dassl"), Diagram(graphics={ + Text( + extent={{-34,0},{58,-24}}, + textColor={217,67,180}, + textString="Pressure boundaries"), + Text( + extent={{-34,100},{50,88}}, + textColor={217,67,180}, + textString="Fixed m_flow")})); +end UnitTest_NoMixtureOnlyForNow_OK; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/package.mo b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/package.mo new file mode 100644 index 00000000..df0a6738 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/package.mo @@ -0,0 +1,8 @@ +within ThermofluidStream.Interfaces.MSLplug.ByCode; +package Tests "Tests for concepts implemented in the interfaces" +extends Modelica.Icons.ExamplesPackage; + +annotation (Documentation(info=" +

Tests for concepts implemented in the interfaces

+")); +end Tests; diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/package.order b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/package.order new file mode 100644 index 00000000..0fdfe2b0 --- /dev/null +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/Tests/package.order @@ -0,0 +1,7 @@ +UnitTest_NoMixtureOnlyForNow_OK +SimpleCoolingCycle +SimpleCoolingCycle_01_OK +SimpleCoolingCycle_02MCV_NOK +TargetTest_00_NOK +TargetTest_01_NOK +TargetTest_02_NoFlow diff --git a/ThermofluidStream/Interfaces/MSLplug/ByCode/package.order b/ThermofluidStream/Interfaces/MSLplug/ByCode/package.order index b288441f..2e8f70a3 100644 --- a/ThermofluidStream/Interfaces/MSLplug/ByCode/package.order +++ b/ThermofluidStream/Interfaces/MSLplug/ByCode/package.order @@ -1,2 +1,3 @@ InletTFStoFluidPortMSL_eq FluidPortMSLtoOutletTFS_eq +Tests diff --git a/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/TargetTest_10_NOK.mo b/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/TargetTest_10_NOK.mo new file mode 100644 index 00000000..30daeeb0 --- /dev/null +++ b/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/TargetTest_10_NOK.mo @@ -0,0 +1,260 @@ +within ThermofluidStream.Undirected.Interfaces.MSLplug.Tests; +model TargetTest_10_NOK + extends Modelica.Icons.Example; + + replaceable package Medium = ThermofluidStream.Media.myMedia.Water.StandardWaterOnePhase + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + annotation ( + choicesAllMatching=true); + + parameter Modelica.Units.NonSI.Temperature_degC T_SP=80 "Solar field outlet temperature setpoint" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC l_s=55 "Security maximum temperature threshold for production switching" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC hyst_prod_pre=5 "Temperature hysteresis for switches in between in production and out of production" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_SP=10 "Security margin deduced from the temperature setpoint to switch in production (compared with l_s and valuabe process temperature)." + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_min=5 "Minimum temperature difference supplied to the process" + annotation(Dialog(group = "Control")); + parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "nominal mass flow rate for regularisation" + annotation(Dialog(tab = "Advanced", group = "Regularisation parameters")); + parameter Boolean computeL=true "Compute L from r and l" annotation (Dialog(tab="Advanced", group="Flow inertance")); + + ThermofluidStream.HeatExchangers.CounterFlowNTU pHEXSimplified( + redeclare package MediumA = Medium, + redeclare package MediumB = Medium, + A=10) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=-90, + origin={6,10}))); + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{90,30},{110,50}}))); + + ThermofluidStream.FlowControl.MCV mCV( + redeclare package Medium = Medium, + setpointFromInput=true, + massFlow_set_par=1) + annotation (Placement(transformation(extent={{80,-30},{60,-10}}))); + ThermofluidStream.FlowControl.MCV flowGenerator_SF( + redeclare package Medium = Medium, massFlow_set_par=10) + annotation (Placement(transformation(extent={{-50,-10},{-70,-30}}))); + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{110,-30},{90,-10}}))); + inner DropOfCommons dropOfCommons(L=1000) + annotation (Placement(transformation(extent={{-80,60},{-60,80}}))); + inner Modelica.Fluid.System system annotation (Placement(transformation(extent={{-100,60},{-80,80}}))); + Modelica.Blocks.Noise.UniformNoise mFlowScenario( + samplePeriod=60, + y_min=0.001, + y_max=15) annotation (Placement(transformation(extent={{108,-10},{88,10}}))); + ThermofluidStream.Boundaries.Reservoir reservoir(redeclare package Medium = Medium, A_surf(displayUnit="m2")) + annotation (Placement(transformation(extent={{-24,-30},{-44,-10}}))); + Boundaries.Volume volume(redeclare package Medium = Medium, V_par=0.1) annotation (Placement(transformation(extent={{40,0},{60,20}}))); + Modelica.Blocks.Continuous.FirstOrder firstOrder(T=2) annotation (Placement(transformation(extent={{82,-4},{74,4}}))); + Topology.ConnectorInletOutletFore connectorInletOutletFore(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{34,34},{46,46}}))); + Topology.ConnectRearRear connectRearRear(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{42,-18},{62,2}}))); + Topology.ConnectorInletOutletFore connectorInletOutletFore1(redeclare package Medium = Medium) + annotation (Placement(transformation( + extent={{-6,-6},{6,6}}, + rotation=180, + origin={46,-20}))); + ThermofluidStream.FlowControl.MCV flowGenerator_SF1(redeclare package Medium = Medium, massFlow_set_par=10) + annotation (Placement(transformation(extent={{36,-10},{16,-30}}))); + Modelica.Blocks.Noise.UniformNoise heatScenario( + samplePeriod=60, + y_min=10, + y_max=95) annotation (Placement(transformation(extent={{-120,0},{-100,20}}))); + ThermofluidStream.Processes.ConductionElement conductionElement( + redeclare package Medium = Medium, + V=0.01, + resistanceFromAU=false, + k_par=500) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-76,10}))); + Modelica.Thermal.HeatTransfer.Celsius.PrescribedTemperature + prescribedTemperature + annotation (Placement(transformation(extent={{-94,6},{-86,14}}))); + ThermofluidStream.FlowControl.Switch switch( + redeclare package Medium = Medium, + m_flow_ref=10, + invertInput=true) annotation (Placement(transformation(extent={{-16,46},{-4,34}}))); + ThermofluidStream.Sensors.SingleSensorSelect singleSensorSelect( + redeclare package Medium = Medium, + quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.T_C, + outputValue=true) annotation (Placement(transformation(extent={{-62,40},{-42,60}}))); + Modelica.Blocks.Continuous.LimPID PID( + controllerType=Modelica.Blocks.Types.SimpleController.PI, + yMax=1, + yMin=0) annotation (Placement(transformation(extent={{-30,56},{-22,64}}))); + Modelica.Blocks.Sources.RealExpression stepoint(y=80) annotation (Placement(transformation(extent={{-52,52},{-40,68}}))); + ThermofluidStream.Topology.JunctionT2 junctionT2_1(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-14,-26},{-6,-14}}))); +protected + parameter Medium.ThermodynamicState state_0_CS = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_CS = Medium.density(state_0_CS); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_CS = Medium.specificHeatCapacityCp(state_0_CS); + parameter Medium.ThermodynamicState state_0_cuve = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_cuve = Medium.density(state_0_cuve); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_cuve = Medium.specificHeatCapacityCp(state_0_cuve); + +equation + + connect(mCV.inlet, source.outlet) annotation (Line( + points={{80,-20},{90,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.inlet, reservoir.outlet) annotation (Line( + points={{-50,-20},{-44,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(mFlowScenario.y, firstOrder.u) annotation (Line(points={{87,0},{82.8,0}}, color={0,0,127})); + connect(firstOrder.y, mCV.setpoint_var) annotation (Line(points={{73.6,0},{70,0},{70,-12}}, color={0,0,127})); + connect(connectRearRear.rear_b, volume.fore) annotation (Line( + points={{55,-8},{60,-8},{60,10}}, + color={28,108,200}, + thickness=0.5)); + connect(volume.rear, connectorInletOutletFore.fore) annotation (Line( + points={{40,10},{40,34}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.outlet, connectorInletOutletFore1.inlet) annotation (Line( + points={{60,-20},{52,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(connectorInletOutletFore1.fore, connectRearRear.rear_a) annotation (Line( + points={{46,-14},{46,-8},{49,-8}}, + color={28,108,200}, + thickness=0.5)); + connect(connectorInletOutletFore1.outlet, flowGenerator_SF1.inlet) annotation (Line( + points={{40,-20},{36,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF1.outlet, pHEXSimplified.inletB) + annotation (Line( + points={{16,-20},{12,-20},{12,-4.44089e-15}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletB, connectorInletOutletFore.inlet) annotation (Line( + points={{12,20},{12,40},{34,40}}, + color={28,108,200}, + thickness=0.5)); + connect(conductionElement.heatPort, prescribedTemperature.port) annotation (Line(points={{-85.8,10},{-86,10}}, color={191,0,0})); + connect(conductionElement.outlet, switch.inlet) annotation (Line( + points={{-76,20},{-76,40},{-16,40}}, + color={28,108,200}, + thickness=0.5)); + connect(switch.outletA, pHEXSimplified.inletA) annotation (Line( + points={{-4,40},{0,40},{0,20},{1.55431e-15,20}}, + color={28,108,200}, + thickness=0.5)); + connect(switch.outletB, junctionT2_1.inletA) annotation (Line( + points={{-10,34},{-10,-14}}, + color={28,108,200}, + thickness=0.5)); + connect(conductionElement.outlet, singleSensorSelect.inlet) + annotation (Line( + points={{-76,20},{-76,40},{-66,40},{-66,50},{-62,50}}, + color={28,108,200}, + thickness=0.5)); + connect(PID.y, switch.u) annotation (Line(points={{-21.6,60},{-10,60},{-10,44.8}}, color={0,0,127})); + connect(prescribedTemperature.T, heatScenario.y) annotation (Line(points={{-94.8,10},{-99,10}}, color={0,0,127})); + connect(pHEXSimplified.outletA, junctionT2_1.inletB) annotation (Line( + points={{0,-2.66454e-15},{0,-20},{-6,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(junctionT2_1.outlet, reservoir.inlet) annotation (Line( + points={{-14,-20},{-24,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.outlet, conductionElement.inlet) annotation (Line( + points={{-70,-20},{-76,-20},{-76,0}}, + color={28,108,200}, + thickness=0.5)); + connect(connectorInletOutletFore.outlet, sink.inlet) annotation (Line( + points={{46,40},{90,40}}, + color={28,108,200}, + thickness=0.5)); + connect(stepoint.y, PID.u_s) annotation (Line(points={{-39.4,60},{-30.8,60}}, color={0,0,127})); + connect(singleSensorSelect.value_out, PID.u_m) annotation (Line(points={{-42,50},{-26,50},{-26,55.2}}, color={0,0,127})); + annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + experiment( + StopTime=3600, + Interval=60, + __Dymola_Algorithm="Dassl"), + __Dymola_Commands( + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","weather.T_amb","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-5.0,90.0}, + grid=true, + colors={{28,108,200},{238,46,47},{217,67,180},{0,140,72},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"})} "Temp CS", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,697}, + y={"weather.T_amb","solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-10.0,90.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47},{217,67,180},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"}),createPlot( + id=1, + position={0,0,1614,697}, + y={"stratifiedTank_Diffuser.T_lay[1]","stratifiedTank_Diffuser.T_lay[3]","stratifiedTank_Diffuser.T_lay[5]","stratifiedTank_Diffuser.T_lay[7]","stratifiedTank_Diffuser.T_lay[9]", + "stratifiedTank_Diffuser.T_lay[11]","stratifiedTank_Diffuser.T_lay[13]","stratifiedTank_Diffuser.T_lay[15]","stratifiedTank_Diffuser.T_lay[17]","stratifiedTank_Diffuser.T_lay[19]", + "stratifiedTank_Diffuser.T_lay[20]"}, + range={0.0,195.0,10.0,80.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47},{0,140,72},{217,67,180},{0,0,0},{162,29,33},{244,125,35},{102,44,145},{28,108,200},{238,46,47},{0,140,72}}, + patterns={LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid, + LinePattern.Solid,LinePattern.Dash,LinePattern.Dash,LinePattern.Dash}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","degC","degC","degC","degC","degC","degC"})} "Températures CS et cuve", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"prod_switch.y","flowGenerator_SF.V_flow_out","flowGenerator_SF.V_flow_sp"}, + range={0.0,700000.0,-5.0,50.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"","m3/h","m3/h"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.L"}, + range={0.0,700000.0,-1000000.0,11000000.0}, + grid=true, + subPlot=202, + colors={{28,108,200}}, + timeUnit="s", + displayUnits={"1/m"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.dr","flowGenerator_SF.dr_set"}, + range={0.0,700000.0,-4.0,4.0}, + grid=true, + subPlot=201, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.p_in","flowGenerator_SF.p_out"}, + range={0.0,700000.0,0.5,4.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"})} "Inertance analysis")); +end TargetTest_10_NOK; diff --git a/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/TargetTest_12_NOK.mo b/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/TargetTest_12_NOK.mo new file mode 100644 index 00000000..1add964e --- /dev/null +++ b/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/TargetTest_12_NOK.mo @@ -0,0 +1,278 @@ +within ThermofluidStream.Undirected.Interfaces.MSLplug.Tests; +model TargetTest_12_NOK + extends Modelica.Icons.Example; + + replaceable package Medium = ThermofluidStream.Media.myMedia.Water.StandardWaterOnePhase + constrainedby ThermofluidStream.Media.myMedia.Interfaces.PartialMedium + annotation ( + choicesAllMatching=true); + + parameter Modelica.Units.NonSI.Temperature_degC T_SP=80 "Solar field outlet temperature setpoint" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC l_s=55 "Security maximum temperature threshold for production switching" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC hyst_prod_pre=5 "Temperature hysteresis for switches in between in production and out of production" + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_SP=10 "Security margin deduced from the temperature setpoint to switch in production (compared with l_s and valuabe process temperature)." + annotation(Dialog(group = "Control")); + parameter Modelica.Units.NonSI.Temperature_degC detlat_T_min=5 "Minimum temperature difference supplied to the process" + annotation(Dialog(group = "Control")); + parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "nominal mass flow rate for regularisation" + annotation(Dialog(tab = "Advanced", group = "Regularisation parameters")); + parameter Boolean computeL=true "Compute L from r and l" annotation (Dialog(tab="Advanced", group="Flow inertance")); + + ThermofluidStream.HeatExchangers.CounterFlowNTU pHEXSimplified( + redeclare package MediumA = Medium, + redeclare package MediumB = Medium, + A=10) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=-90, + origin={6,10}))); + ThermofluidStream.Boundaries.Sink sink(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{90,30},{110,50}}))); + + ThermofluidStream.FlowControl.MCV mCV( + redeclare package Medium = Medium, + setpointFromInput=true, + massFlow_set_par=1) + annotation (Placement(transformation(extent={{80,-30},{60,-10}}))); + ThermofluidStream.FlowControl.MCV flowGenerator_SF( + redeclare package Medium = Medium, massFlow_set_par=10) + annotation (Placement(transformation(extent={{-50,-10},{-70,-30}}))); + + ThermofluidStream.Boundaries.Source source(redeclare package Medium = Medium) + annotation (Placement(transformation(extent={{110,-30},{90,-10}}))); + inner DropOfCommons dropOfCommons(L=1000) + annotation (Placement(transformation(extent={{-80,60},{-60,80}}))); + inner Modelica.Fluid.System system annotation (Placement(transformation(extent={{-100,60},{-80,80}}))); + Modelica.Blocks.Noise.UniformNoise mFlowScenario( + samplePeriod=60, + y_min=0.001, + y_max=15) annotation (Placement(transformation(extent={{108,-10},{88,10}}))); + ThermofluidStream.Boundaries.Reservoir reservoir(redeclare package Medium = Medium, A_surf(displayUnit="m2")) + annotation (Placement(transformation(extent={{-24,-30},{-44,-10}}))); + ThermofluidStream.FlowControl.MCV mCV1( + redeclare package Medium = Medium, + setpointFromInput=true, + massFlow_set_par=1) + annotation (Placement(transformation(extent={{60,50},{80,30}}))); + Modelica.Blocks.Continuous.FirstOrder firstOrder(T=2) annotation (Placement(transformation(extent={{82,-4},{74,4}}))); + Topology.ConnectorInletOutletFore connectorInletOutletFore(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{40,34},{52,46}}))); + Topology.ConnectorInletOutletFore connectorInletOutletFore1(redeclare package Medium = Medium) + annotation (Placement(transformation( + extent={{-6,-6},{6,6}}, + rotation=180, + origin={46,-20}))); + ThermofluidStream.FlowControl.MCV flowGenerator_SF1(redeclare package Medium = Medium, massFlow_set_par=10) + annotation (Placement(transformation(extent={{36,-10},{16,-30}}))); + Modelica.Blocks.Noise.UniformNoise heatScenario( + samplePeriod=60, + y_min=10, + y_max=95) annotation (Placement(transformation(extent={{-120,0},{-100,20}}))); + ThermofluidStream.Processes.ConductionElement conductionElement( + redeclare package Medium = Medium, + V=0.01, + resistanceFromAU=false) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={-76,10}))); + Modelica.Thermal.HeatTransfer.Celsius.PrescribedTemperature + prescribedTemperature + annotation (Placement(transformation(extent={{-94,6},{-86,14}}))); + ThermofluidStream.FlowControl.Switch switch(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-16,46},{-4,34}}))); + ThermofluidStream.Sensors.SingleSensorSelect singleSensorSelect( + redeclare package Medium = Medium, + quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.T_C, + outputValue=true) annotation (Placement(transformation(extent={{-62,40},{-42,60}}))); + Modelica.Blocks.Continuous.LimPID PID( + controllerType=Modelica.Blocks.Types.SimpleController.PI, + yMax=1, + yMin=0) annotation (Placement(transformation(extent={{-30,56},{-22,64}}))); + Modelica.Blocks.Sources.RealExpression stepoint(y=80) annotation (Placement(transformation(extent={{-52,52},{-40,68}}))); + ThermofluidStream.Topology.JunctionT2 junctionT2_1(redeclare package Medium = Medium) annotation (Placement(transformation(extent={{-14,-26},{-6,-14}}))); + Modelica.Fluid.Vessels.ClosedVolume volume( + redeclare package Medium = Medium, + use_portsData=false, + V=0.1, + nPorts=2) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={32,10}))); + RearTFS_FluidPortMSL rearTFS_FluidPortMSL annotation (Placement(transformation( + extent={{-4,-4},{4,4}}, + rotation=-90, + origin={46,26}))); + RearTFS_FluidPortMSL rearTFS_FluidPortMSL1 annotation (Placement(transformation( + extent={{-4,-4},{4,4}}, + rotation=90, + origin={46,-4}))); +protected + parameter Medium.ThermodynamicState state_0_CS = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_CS = Medium.density(state_0_CS); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_CS = Medium.specificHeatCapacityCp(state_0_CS); + parameter Medium.ThermodynamicState state_0_cuve = Medium.setState_phX(Medium.p_default, Medium.h_default, Medium.X_default[1:Medium.nXi]); + parameter Modelica.Units.SI.Density rho_cuve = Medium.density(state_0_cuve); + parameter Modelica.Units.SI.SpecificHeatCapacity cp_cuve = Medium.specificHeatCapacityCp(state_0_cuve); + +equation + + connect(mCV.inlet, source.outlet) annotation (Line( + points={{80,-20},{90,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.inlet, reservoir.outlet) annotation (Line( + points={{-50,-20},{-44,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV1.outlet, sink.inlet) annotation (Line( + points={{80,40},{90,40}}, + color={28,108,200}, + thickness=0.5)); + connect(mFlowScenario.y, firstOrder.u) annotation (Line(points={{87,0},{82.8,0}}, color={0,0,127})); + connect(firstOrder.y, mCV.setpoint_var) annotation (Line(points={{73.6,0},{70,0},{70,-12}}, color={0,0,127})); + connect(firstOrder.y, mCV1.setpoint_var) annotation (Line(points={{73.6,0},{70,0},{70,32}}, color={0,0,127})); + connect(mCV1.inlet, connectorInletOutletFore.outlet) annotation (Line( + points={{60,40},{52,40}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.outlet, connectorInletOutletFore1.inlet) annotation (Line( + points={{60,-20},{52,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(connectorInletOutletFore1.outlet, flowGenerator_SF1.inlet) annotation (Line( + points={{40,-20},{36,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF1.outlet, pHEXSimplified.inletB) + annotation (Line( + points={{16,-20},{12,-20},{12,-4.44089e-15}}, + color={28,108,200}, + thickness=0.5)); + connect(pHEXSimplified.outletB, connectorInletOutletFore.inlet) annotation (Line( + points={{12,20},{12,40},{40,40}}, + color={28,108,200}, + thickness=0.5)); + connect(conductionElement.heatPort, prescribedTemperature.port) annotation (Line(points={{-85.8,10},{-86,10}}, color={191,0,0})); + connect(conductionElement.outlet, switch.inlet) annotation (Line( + points={{-76,20},{-76,40},{-16,40}}, + color={28,108,200}, + thickness=0.5)); + connect(switch.outletA, pHEXSimplified.inletA) annotation (Line( + points={{-4,40},{0,40},{0,20},{1.55431e-15,20}}, + color={28,108,200}, + thickness=0.5)); + connect(switch.outletB, junctionT2_1.inletA) annotation (Line( + points={{-10,34},{-10,-14}}, + color={28,108,200}, + thickness=0.5)); + connect(conductionElement.outlet, singleSensorSelect.inlet) + annotation (Line( + points={{-76,20},{-76,40},{-66,40},{-66,50},{-62,50}}, + color={28,108,200}, + thickness=0.5)); + connect(PID.y, switch.u) annotation (Line(points={{-21.6,60},{-10,60},{-10,44.8}}, color={0,0,127})); + connect(prescribedTemperature.T, heatScenario.y) annotation (Line(points={{-94.8,10},{-99,10}}, color={0,0,127})); + connect(pHEXSimplified.outletA, junctionT2_1.inletB) annotation (Line( + points={{0,-2.66454e-15},{0,-20},{-6,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(junctionT2_1.outlet, reservoir.inlet) annotation (Line( + points={{-14,-20},{-24,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(flowGenerator_SF.outlet, conductionElement.inlet) annotation (Line( + points={{-70,-20},{-76,-20},{-76,0}}, + color={28,108,200}, + thickness=0.5)); + connect(stepoint.y, PID.u_m) annotation (Line(points={{-39.4,60},{-38,60},{-38,52},{-26,52},{-26,55.2}}, color={0,0,127})); + connect(singleSensorSelect.value_out, PID.u_s) annotation (Line(points={{-42,50},{-36,50},{-36,60},{-30.8,60}}, color={0,0,127})); + connect(connectorInletOutletFore.fore, rearTFS_FluidPortMSL.rearTFS) annotation (Line( + points={{46,34},{46,30}}, + color={28,108,200}, + thickness=0.5)); + connect(rearTFS_FluidPortMSL1.rearTFS, connectorInletOutletFore1.fore) annotation (Line( + points={{46,-8},{46,-14}}, + color={28,108,200}, + thickness=0.5)); + connect(rearTFS_FluidPortMSL1.portMSL, volume.ports[1]) annotation (Line(points={{46,0},{46,9},{42,9}}, color={0,127,255})); + connect(rearTFS_FluidPortMSL.portMSL, volume.ports[2]) annotation (Line(points={{46,22},{46,11},{42,11}}, color={0,127,255})); + annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},{100,80}})), + experiment( + StopTime=3600, + Interval=60, + __Dymola_Algorithm="Dassl"), + __Dymola_Commands( + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","weather.T_amb","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-5.0,90.0}, + grid=true, + colors={{28,108,200},{238,46,47},{217,67,180},{0,140,72},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"})} "Temp CS", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,697}, + y={"weather.T_amb","solarField_V2.inlet.state.T","solarField_V2.outlet.state.T","solarField_V2.heatTransferElement_Solar_V2.T","solarField_V2.heatTransferElement_Solar_V2.T_in_eff", + "solarField_V2.inlet.m_flow"}, + range={0.0,195.0,-10.0,90.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47},{217,67,180},{102,44,145},{0,0,0}}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","kg/s"}),createPlot( + id=1, + position={0,0,1614,697}, + y={"stratifiedTank_Diffuser.T_lay[1]","stratifiedTank_Diffuser.T_lay[3]","stratifiedTank_Diffuser.T_lay[5]","stratifiedTank_Diffuser.T_lay[7]","stratifiedTank_Diffuser.T_lay[9]", + "stratifiedTank_Diffuser.T_lay[11]","stratifiedTank_Diffuser.T_lay[13]","stratifiedTank_Diffuser.T_lay[15]","stratifiedTank_Diffuser.T_lay[17]","stratifiedTank_Diffuser.T_lay[19]", + "stratifiedTank_Diffuser.T_lay[20]"}, + range={0.0,195.0,10.0,80.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47},{0,140,72},{217,67,180},{0,0,0},{162,29,33},{244,125,35},{102,44,145},{28,108,200},{238,46,47},{0,140,72}}, + patterns={LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid,LinePattern.Solid, + LinePattern.Solid,LinePattern.Dash,LinePattern.Dash,LinePattern.Dash}, + timeUnit="h", + displayUnits={"degC","degC","degC","degC","degC","degC","degC","degC","degC","degC","degC"})} "Températures CS et cuve", + executeCall(ensureSimulated=true) = {createPlot( + id=1, + position={0,0,1614,678}, + y={"prod_switch.y","flowGenerator_SF.V_flow_out","flowGenerator_SF.V_flow_sp"}, + range={0.0,700000.0,-5.0,50.0}, + grid=true, + subPlot=101, + colors={{0,140,72},{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"","m3/h","m3/h"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.L"}, + range={0.0,700000.0,-1000000.0,11000000.0}, + grid=true, + subPlot=202, + colors={{28,108,200}}, + timeUnit="s", + displayUnits={"1/m"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.dr","flowGenerator_SF.dr_set"}, + range={0.0,700000.0,-4.0,4.0}, + grid=true, + subPlot=201, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"}),createPlot( + id=1, + position={0,0,1614,678}, + y={"flowGenerator_SF.p_in","flowGenerator_SF.p_out"}, + range={0.0,700000.0,0.5,4.0}, + grid=true, + subPlot=102, + colors={{28,108,200},{238,46,47}}, + timeUnit="s", + displayUnits={"bar","bar"})} "Inertance analysis")); +end TargetTest_12_NOK; diff --git a/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/package.mo b/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/package.mo new file mode 100644 index 00000000..e23fd2f7 --- /dev/null +++ b/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/package.mo @@ -0,0 +1,8 @@ +within ThermofluidStream.Undirected.Interfaces.MSLplug; +package Tests "Tests for concepts implemented in the interfaces" +extends Modelica.Icons.ExamplesPackage; + +annotation (Documentation(info=" +

Tests for concepts implemented in the interfaces

+")); +end Tests; diff --git a/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/package.order b/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/package.order new file mode 100644 index 00000000..714256aa --- /dev/null +++ b/ThermofluidStream/Undirected/Interfaces/MSLplug/Tests/package.order @@ -0,0 +1,2 @@ +TargetTest_10_NOK +TargetTest_12_NOK diff --git a/ThermofluidStream/Undirected/Interfaces/MSLplug/package.order b/ThermofluidStream/Undirected/Interfaces/MSLplug/package.order index 5762021d..93cc6892 100644 --- a/ThermofluidStream/Undirected/Interfaces/MSLplug/package.order +++ b/ThermofluidStream/Undirected/Interfaces/MSLplug/package.order @@ -1,2 +1,3 @@ RearTFS_FluidPortMSL FluidPortMSL_ForeTFS +Tests