diff --git a/ThermofluidStream/Boundaries/Internal/PartialVolume.mo b/ThermofluidStream/Boundaries/Internal/PartialVolume.mo index a6685183..2e639afd 100644 --- a/ThermofluidStream/Boundaries/Internal/PartialVolume.mo +++ b/ThermofluidStream/Boundaries/Internal/PartialVolume.mo @@ -77,7 +77,6 @@ protected Medium.MassFraction Xi_in[Medium.nXi] = if noEvent(m_flow_in >= 0) then Medium.massFraction(state_in) else medium.Xi; Medium.ThermodynamicState state_out; - SI.Pressure p_out = Medium.pressure(state_out); // fix potential instabilities by setting the incoming enthalpy and mass fraction inlet ones, // effectiveley removing the mass-flow related parts of the differential equations for U and MXi SI.SpecificEnthalpy h_out = if noEvent(-m_flow_out >= 0) then Medium.specificEnthalpy(state_out) else medium.h; @@ -112,7 +111,7 @@ equation der(m_flow_in)*L = r_in - r - r_damping; der(m_flow_out)*L = r_out - r_damping; - r + p_in = p_out; + r + p_in = medium.p; der(M) = m_flow_in + m_flow_out; der(U_med) = W_v + Q_flow + h_in*m_flow_in + h_out*m_flow_out; diff --git a/ThermofluidStream/Boundaries/Internal/PartialVolumeM.mo b/ThermofluidStream/Boundaries/Internal/PartialVolumeM.mo new file mode 100644 index 00000000..847e00ec --- /dev/null +++ b/ThermofluidStream/Boundaries/Internal/PartialVolumeM.mo @@ -0,0 +1,193 @@ +within ThermofluidStream.Boundaries.Internal; +partial model PartialVolumeM "Partial parent class for Volumes with one inlet and M outlet" + replaceable package Medium = Media.myMedia.Interfaces.PartialMedium "Medium model" annotation ( + choicesAllMatching=true, Documentation(info=" +

Medium package used in the Volume. Make sure it is the same as the inlets and outlets the volume is connected to.

+")); + + parameter Integer M_outlets = 1 "Number if outlets"; + parameter Boolean useHeatport = false "If true heatport is added"; + parameter SI.Area A = 1 "Contact area of volume with medium" + annotation(Dialog(enable=useHeatport)); + parameter SI.CoefficientOfHeatTransfer U = 200 "Heat transfer coefficient to medium" + annotation(Dialog(enable=useHeatport)); + parameter Boolean initialize_pressure = true "If true: initialize Pressure" + annotation(Dialog(tab= "Initialization")); + parameter SI.Pressure p_start = Medium.p_default "Initial Pressure" + annotation(Dialog(tab= "Initialization", enable=initialize_pressure)); + parameter Boolean initialize_energy = true "Initialize specific inner energy with temperature or specific enthalpy condition" + annotation(Dialog(tab= "Initialization")); + parameter SI.Temperature T_start = Medium.T_default "Initial Temperature" + annotation(Dialog(tab= "Initialization", enable=initialize_energy and (not use_hstart))); + parameter Boolean use_hstart = false "True: spedific enthalpy contition instead of Temperature" + annotation(Dialog(tab= "Initialization", enable=initialize_energy)); + parameter SI.SpecificEnthalpy h_start = Medium.T_default "Initial specific enthalpy" + annotation(Dialog(tab= "Initialization", enable=initialize_energy and use_hstart)); + parameter Boolean initialize_Xi = true "If true: initialize mass fractions" + annotation(Dialog(tab= "Initialization")); + parameter Medium.MassFraction Xi_0[Medium.nXi] = Medium.X_default[1:Medium.nXi] "Initial mass fraction" + annotation(Dialog(tab= "Initialization", enable=initialize_Xi)); + parameter Utilities.Units.Inertance L = dropOfCommons.L "Inertance at inlet and outlet" + annotation (Dialog(tab="Advanced")); + parameter Real k_volume_damping(unit="1") = dropOfCommons.k_volume_damping "Damping factor multiplicator" + annotation(Dialog(tab="Advanced", group="Damping")); + parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative massflows" + annotation(Dialog(tab="Advanced")); + parameter Boolean usePreferredMediumStates=false "Use medium states instead of the ones differentiated in this component" + annotation(Dialog(tab="Advanced")); + + Interfaces.Inlet inlet(redeclare package Medium=Medium) + annotation (Placement(transformation(extent={{-120,-20},{-80,20}}))); + Interfaces.Outlet outlet[M_outlets](redeclare package Medium=Medium) + annotation (Placement(transformation(extent={{80,-20},{120,20}}))); + Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort(Q_flow=Q_flow, T=T_heatPort) if useHeatport + annotation (Placement(transformation(extent={{-10,-90},{10,-70}}))); + + Medium.BaseProperties medium(preferredMediumStates=usePreferredMediumStates); + + SI.Volume V; + + //setting the state is to prohibit dynamic state selection e.g. in VolumesDirectCoupling + SI.Mass M(stateSelect=if usePreferredMediumStates then StateSelect.default else StateSelect.always) = V*medium.d; + SI.Mass MXi[Medium.nXi](each stateSelect=if usePreferredMediumStates then StateSelect.default else StateSelect.always) = M*medium.Xi; + SI.Energy U_med(stateSelect=if usePreferredMediumStates then StateSelect.default else StateSelect.always) = M*medium.u; + + SI.HeatFlowRate Q_flow; + SI.Power W_v; + +protected + outer DropOfCommons dropOfCommons; + + SI.Pressure p_in = Medium.pressure(inlet.state); + // fix potential instabilities by setting the outgoing enthalpy and mass fraction to the medium state + SI.SpecificEnthalpy h_in = if noEvent(m_flow_in) >= 0 then Medium.specificEnthalpy(inlet.state) else medium.h; + Medium.MassFraction Xi_in[Medium.nXi] = if noEvent(m_flow_in) >= 0 then Medium.massFraction(inlet.state) else medium.Xi; + + Medium.ThermodynamicState state_out[M_outlets]; + SI.SpecificEnthalpy h_out[M_outlets]; + Medium.MassFraction Xi_out[Medium.nXi,M_outlets]; + + Real d(unit="1/(m.s)") = k_volume_damping*sqrt(abs(2*L/(V*max(density_derp_h, 1e-10)))) "Friction factor for coupled boundaries"; + SI.DerDensityByPressure density_derp_h "Partial derivative of density by pressure"; + SI.Pressure r_damping = d*der(M); + + SI.Pressure r; + + SI.Temperature T_heatPort; + + SI.MassFlowRate m_flow_in = inlet.m_flow; + SI.MassFlowRate m_flow_out[M_outlets] = outlet.m_flow; + +initial equation + if initialize_pressure then + medium.p=p_start; + end if; + + if initialize_energy then + if use_hstart then + medium.h = h_start; + else + medium.T=T_start; + end if; + end if; + + if initialize_Xi then + medium.Xi = Xi_0; + end if; + +equation + assert(m_flow_in > m_flow_assert, "Negative massflow at Volume inlet", dropOfCommons.assertionLevel); + for i in 1:M_outlets loop + assert(-m_flow_out[i] > m_flow_assert, "Positive massflow at Volume outlet", dropOfCommons.assertionLevel); + end for; + assert(M > 0, "Volumes might not become empty"); + + der(inlet.m_flow)*L = inlet.r - r - r_damping; + der(outlet.m_flow)*L = outlet.r - r_damping*ones(M_outlets); + + r + p_in = medium.p; + + for i in 1:M_outlets loop + // fix potential instabilities by setting the outgoing enthalpy and mass fraction to the medium state + + h_out[i] = if noEvent(-m_flow_out[i]) >= 0 then Medium.specificEnthalpy(state_out[i]) else medium.h; + Xi_out[:,i] = if noEvent(-m_flow_out[i] >= 0) then Medium.massFraction(state_out[i]) else medium.Xi; + end for; + + der(M) = inlet.m_flow + sum(outlet.m_flow); + der(U_med) = W_v + Q_flow + inlet.m_flow*h_in + sum(outlet.m_flow.*h_out); + der(MXi) = Xi_in*inlet.m_flow + Xi_out*outlet.m_flow; + + Q_flow = U*A*(T_heatPort - medium.T); + + outlet.state = state_out; + + if not useHeatport then + T_heatPort = medium.T; + end if; + + annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={ + Ellipse( + extent={{-56,76},{64,16}}, + lineColor={28,108,200}, + lineThickness=0.5, + fillColor={215,215,215}, + fillPattern=FillPattern.Solid, + pattern=LinePattern.None), + Rectangle( + extent={{-56,46},{64,-56}}, + lineColor={28,108,200}, + lineThickness=0.5, + fillColor={215,215,215}, + fillPattern=FillPattern.Solid, + pattern=LinePattern.None), + Ellipse( + extent={{-56,-28},{64,-88}}, + lineColor={28,108,200}, + lineThickness=0.5, + fillColor={215,215,215}, + fillPattern=FillPattern.Solid, + pattern=LinePattern.None), + Line( + points={{-100,0},{100,0}}, + color={28,108,200}, + thickness=0.5), + Ellipse( + extent={{-60,-20},{60,-80}}, + lineColor={28,108,200}, + lineThickness=0.5, + fillColor={170,213,255}, + fillPattern=FillPattern.Solid), + Rectangle( + extent={{-60,50},{60,-50}}, + lineColor={28,108,200}, + lineThickness=0.5, + fillColor={170,213,255}, + fillPattern=FillPattern.Solid, + pattern=LinePattern.None), + Ellipse( + extent={{-60,80},{60,20}}, + lineColor={28,108,200}, + lineThickness=0.5, + fillColor={170,213,255}, + fillPattern=FillPattern.Solid), + Line( + points={{-60,50},{-60,-52}}, + color={28,108,200}, + thickness=0.5), + Line( + points={{60,50},{60,-52}}, + color={28,108,200}, + thickness=0.5), Text( + extent={{68,48},{94,6}}, + lineColor={116,116,116}, + textString="%M_out")}), + Diagram(coordinateSystem(preserveAspectRatio=false)), + Documentation(info=" +

This is the partial parent class for unidirectional volumes with N inlets. It is partial and missing the number if inputs, as well as a equations for its volume or medium pressure and one for the volume change work performed.

+

Conceptually a Volume is a Sink and a Source. It therefore defines the Level of inertial pressure r in a closed loop and acts as a Loop breaker.

+

Volumes implement a damping term on the change of the stored mass to dampen out fast, otherwise undamped oscillations that appear when connecting volumes directly to other volumes or other boundaries (source, sink, boundary_fore, boundary_rear). With the damping term these oscillations will be still very fast, but dampend out, so a stiff solver might be able to handle them well. Damping is enabled by default and can be disabled by setting Advanced.k_volume_damping=0.

+

For to stability reasons, mass-flows in the wrong direction (fluid entering the outlet or exiting the inlet) is considered to have the enthalpy and mass-fractions of the medium in the volume. This results in a stable steady-state solution, since this method effectiveley removes the parts of the energy and mass-fraction differential equations, that are associated with mass-flows.

+

Per default the Volume has the two states energy and mass (U_med and M) and one state for each mass, as well as one state for each substance of the fluid (except the first one). These will be enforced to be states of the simulation, which can result in nonlinear systems of size one or two, but works very reliable. To get rid of these Systems the modeler can enable the flag 'usePreferredMediumStates' in the 'Advanced' tab. Then the volume uses the states prefered by the medium object, rather then the default ones, which can improve the nonlinear systems most of the time, but also might lead to larger nonlinear systems (e.g. in the Test 'VolumesDirectCoupling').

+")); +end PartialVolumeM; diff --git a/ThermofluidStream/Boundaries/Internal/PartialVolumeN.mo b/ThermofluidStream/Boundaries/Internal/PartialVolumeN.mo index c7633588..40b95908 100644 --- a/ThermofluidStream/Boundaries/Internal/PartialVolumeN.mo +++ b/ThermofluidStream/Boundaries/Internal/PartialVolumeN.mo @@ -6,7 +6,7 @@ partial model PartialVolumeN "Partial parent class for Volumes with N inlets and

Medium package used in the Volume. Make sure it is the same as the inlets and outlets the volume is connected to.

")); - parameter Integer N = 1 "Number if inputs"; + parameter Integer N = 1 "Number if inlets"; parameter Boolean useHeatport = false "If true heatport is added"; parameter SI.Area A = 1 "Contact area of volume with medium" annotation(Dialog(enable=useHeatport)); @@ -63,8 +63,10 @@ protected SI.SpecificEnthalpy h_in[N]; Medium.MassFraction Xi_in[Medium.nXi,N]; - SI.SpecificEnthalpy h_out = if noEvent(-m_flow_out) >= 0 then Medium.specificEnthalpy(medium.state) else medium.h; - Medium.MassFraction Xi_out[Medium.nXi] = if noEvent(-m_flow_out >= 0) then Medium.massFraction(medium.state) else medium.Xi; + Medium.ThermodynamicState state_out; + // fix potential instabilities by setting the outgoing enthalpy and mass fraction to the medium state + SI.SpecificEnthalpy h_out = if noEvent(-m_flow_out) >= 0 then Medium.specificEnthalpy(state_out) else medium.h; + Medium.MassFraction Xi_out[Medium.nXi] = if noEvent(-m_flow_out >= 0) then Medium.massFraction(state_out) else medium.Xi; Real d(unit="1/(m.s)") = k_volume_damping*sqrt(abs(2*L/(V*max(density_derp_h, 1e-10)))) "Friction factor for coupled boundaries"; SI.DerDensityByPressure density_derp_h "Partial derivative of density by pressure"; @@ -113,12 +115,12 @@ equation end for; der(M) = sum(inlet.m_flow) + sum(outlet.m_flow); - der(U_med) = W_v + Q_flow + sum(inlet.m_flow.*h_in) + outlet.m_flow*medium.h; - der(MXi) = Xi_in*inlet.m_flow + medium.Xi*outlet.m_flow; + der(U_med) = W_v + Q_flow + sum(inlet.m_flow.*h_in) + outlet.m_flow*h_out; + der(MXi) = Xi_in*inlet.m_flow + Xi_out*outlet.m_flow; Q_flow = U*A*(T_heatPort - medium.T); - outlet.state = medium.state; + outlet.state = state_out; if not useHeatport then T_heatPort = medium.T; diff --git a/ThermofluidStream/Boundaries/Internal/package.order b/ThermofluidStream/Boundaries/Internal/package.order index ec38f4f0..9bc398bb 100644 --- a/ThermofluidStream/Boundaries/Internal/package.order +++ b/ThermofluidStream/Boundaries/Internal/package.order @@ -1,3 +1,4 @@ PartialVolume PartialVolumeN +PartialVolumeM InitializationMethodsPhaseSeperator diff --git a/ThermofluidStream/Boundaries/PhaseSeparator2.mo b/ThermofluidStream/Boundaries/PhaseSeparator2.mo new file mode 100644 index 00000000..315a1703 --- /dev/null +++ b/ThermofluidStream/Boundaries/PhaseSeparator2.mo @@ -0,0 +1,99 @@ +within ThermofluidStream.Boundaries; +model PhaseSeparator2 "Phase separator with two outlets" + extends Boundaries.Internal.PartialVolumeM( + redeclare replaceable package Medium = + Media.myMedia.Interfaces.PartialTwoPhaseMedium, + useHeatport=false, + final initialize_energy=false, + final T_start=0, + final h_start=0, + final use_hstart=false, + final M_outlets=2); + + import Init = ThermofluidStream.Boundaries.Internal.InitializationMethodsPhaseSeperator; + + parameter SI.Volume V_par(displayUnit="l")=0.01 "Volume of phase seperator"; + parameter Real pipe1_low(unit="1", min=0, max=1) "Low end of pipe"; + parameter Real pipe1_high(unit="1", min=0, max=1) "High end of pipe"; + parameter Real pipe2_low(unit="1", min=0, max=1) "Low end of pipe"; + parameter Real pipe2_high(unit="1", min=0, max=1) "High end of pipe"; + parameter Boolean density_derp_h_from_media=false "EXPERIMENTAL: get density_derp_h from media model. The function is only implemented for some Media." + annotation(Dialog(tab="Advanced", group="Damping", enable=(k_volume_damping > 0))); + parameter SI.DerDensityByPressure density_derp_h_set = 1e-6 "Derivative of density by pressure upper bound; Approx. 1e-5 for air, 1e-7 for water" + annotation(Dialog(enable = ((k_volume_damping > 0) and not density_derp_h_from_media), tab="Advanced", group="Damping")); + parameter Init init_method = ThermofluidStream.Boundaries.Internal.InitializationMethodsPhaseSeperator.l "Initialization Method" + annotation(choicesAllMatching=true, Dialog(tab="Initialization")); + parameter SI.SpecificEnthalpy h_0 = Medium.h_default "Initial specific enthalpy" + annotation(Dialog(tab="Initialization", enable=(init_method==Init.h))); + parameter SI.Mass M_0 = 1 "Initial Mass" + annotation(Dialog(tab="Initialization", enable=(init_method==Init.M))); + parameter Real l_0(unit="1", min=0, max=1) = 0.5 "Initial liquid level" + annotation(Dialog(tab="Initialization", enable=(init_method==Init.l))); + parameter Real x_0(unit="kg/kg", min=0, max=1) = 0.5 "Initial vapor quality" + annotation(Dialog(tab="Initialization", enable=(init_method==Init.x))); + + //Variables to calculate h_pipe + Real liquid_level(unit="1") "level of liquid line"; + Real liquid_level_pipe1(unit="1") "level of liquid line in pipe1"; + Real liquid_level_pipe2(unit="1") "level of liquid line in pipe2"; + +protected + Medium.MassFraction x = (medium.h-h_bubble)/(h_dew - h_bubble) "Calculated vapor quality of medium that can go below zero and above one"; + SI.SpecificEnthalpy h_pipe1; + SI.SpecificEnthalpy h_pipe2; + + SI.Density d_liq = Medium.bubbleDensity(Medium.setSat_p(medium.p)) "bubble density at saturation"; + SI.Density d_gas = Medium.dewDensity(Medium.setSat_p(medium.p)) "dew density at saturation"; + + SI.SpecificEnthalpy h_bubble = Medium.bubbleEnthalpy(Medium.setSat_p(medium.p))-1 "Bubble Enthalpy of Medium"; + SI.SpecificEnthalpy h_dew = Medium.dewEnthalpy(Medium.setSat_p(medium.p))+1 "Dew Enthalpy of Medium"; + +initial equation + assert(pipe1_high > pipe1_low, "Upper pipe end must be higher then lower end.", AssertionLevel.error); + assert(pipe2_high > pipe2_low, "Upper pipe end must be higher then lower end.", AssertionLevel.error); + + if init_method == Init.h then + medium.h = h_0; + elseif init_method == Init.M then + x/d_gas+(1-x)/d_liq = V/M_0; + assert(x>=0 and x<=1, "Initialization by Mass might be inaccurate outside the two-phase region", AssertionLevel.warning); + elseif init_method == Init.l then + x = (d_gas*(1-l_0))/(d_liq*l_0+d_gas*(1-l_0)); + elseif init_method == Init.x then + x = x_0; + end if; + +equation + if density_derp_h_from_media then + density_derp_h = Medium.density_derp_h(medium.state); + else + density_derp_h = density_derp_h_set; + end if; + + V = V_par; + W_v = 0; + + liquid_level = max(0, min(1, M*(1-x)/d_liq/V)); + liquid_level_pipe1 = max(0, min(1, (liquid_level-pipe1_low)/(pipe1_high-pipe1_low))); + liquid_level_pipe2 = max(0, min(1, (liquid_level-pipe2_low)/(pipe2_high-pipe2_low))); + + h_pipe1 = smooth(1, + if x < 0 then medium.h + elseif x <= 1 then liquid_level_pipe1*h_bubble + (1-liquid_level_pipe1)*h_dew + else medium.h); + + h_pipe2 = smooth(1, + if x < 0 then medium.h + elseif x <= 1 then liquid_level_pipe2*h_bubble + (1-liquid_level_pipe2)*h_dew + else medium.h); + + state_out[1] = Medium.setState_phX(medium.p, h_pipe1, medium.Xi); + state_out[2] = Medium.setState_phX(medium.p, h_pipe2, medium.Xi); + + annotation (Icon(coordinateSystem(preserveAspectRatio=false)), + Diagram(coordinateSystem(preserveAspectRatio=false)), + Documentation(info=" +

This Volume is the parent class for Accumulator and Receiver models that seperate the two phases and are able and output gas, liquid or two-phase medium, dependin on its liquid level and the height of the outlet.

+

Since there is no formula to compute density_derp_h for this volume, a upper bound has to be set in the parameter density_derp_h_set. Alternativeley the derivative can be taken from the media model for all the media that implement the corresponding forumla by setting density_derp_h_from_media=true (default:false).

+")); +end PhaseSeparator2; diff --git a/ThermofluidStream/Boundaries/VolumeMix.mo b/ThermofluidStream/Boundaries/VolumeMix.mo index 3a09fc43..7d2c92ef 100644 --- a/ThermofluidStream/Boundaries/VolumeMix.mo +++ b/ThermofluidStream/Boundaries/VolumeMix.mo @@ -20,6 +20,8 @@ equation V = V_par; W_v = 0; + state_out = medium.state; + annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={ Text( extent={{-60,8},{60,-52}}, diff --git a/ThermofluidStream/Boundaries/package.order b/ThermofluidStream/Boundaries/package.order index 33eac734..f58afbf6 100644 --- a/ThermofluidStream/Boundaries/package.order +++ b/ThermofluidStream/Boundaries/package.order @@ -8,6 +8,7 @@ Volume VolumeFlex VolumeMix PhaseSeparator +PhaseSeparator2 Reservoir CreateState Tests diff --git a/ThermofluidStream/Examples/HeatPump.mo b/ThermofluidStream/Examples/HeatPump.mo index e5c1399e..3fd8e2b8 100644 --- a/ThermofluidStream/Examples/HeatPump.mo +++ b/ThermofluidStream/Examples/HeatPump.mo @@ -7,26 +7,32 @@ model HeatPump replaceable package Air = Media.myMedia.Air.DryAirNasa constrainedby Media.myMedia.Interfaces.PartialMedium "Air Medium" annotation(choicesAllMatching=true); - HeatExchangers.DiscretizedHEX condenser( - redeclare package MediumAir = Air, - redeclare package MediumRefrigerant = Medium, + HeatExchangers.DiscretizedCounterFlowHEX + condenser( + redeclare package MediumA = Air, + redeclare package MediumB = Medium, + redeclare model ConductionElementA = HeatExchangers.Internal.ConductionElementHEX, + redeclare model ConductionElementB = HeatExchangers.Internal.ConductionElementHEX_twoPhase, initializeMassFlow=false, nCells=10, A=10, V_Hex(displayUnit="l"), - k_wall=150) - annotation (Placement(transformation(extent={{-90,72},{-70,92}}))); - HeatExchangers.DiscretizedHEX evaporator( - redeclare package MediumAir = Air, - redeclare package MediumRefrigerant = Medium, + k_wall=150) annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=180, + origin={-80,82}))); + HeatExchangers.DiscretizedCounterFlowHEX + evaporator( + redeclare package MediumA = Air, + redeclare package MediumB = Medium, + redeclare model ConductionElementA = HeatExchangers.Internal.ConductionElementHEX, + redeclare model ConductionElementB = HeatExchangers.Internal.ConductionElementHEX_twoPhase, initializeMassFlow=false, nCells=10, A=10, V_Hex(displayUnit="l") = 0.001, - k_wall=150) - annotation (Placement(transformation( + k_wall=150) annotation (Placement(transformation( extent={{-10,-10},{10,10}}, - rotation=180, + rotation=0, origin={-80,-82}))); Processes.Compressor compressor( redeclare package Medium = Medium, @@ -258,19 +264,20 @@ model HeatPump ThermofluidStream.Utilities.showRealValue showRealValue( use_numberPort=false, description="COP", - number=condenser.Q_flow_air/max(0.00001, compressor.W_t)) annotation (Placement(transformation(extent={{80,-94},{154,-56}}))); + number=condenser.Q_flow_A/max(0.00001, compressor.W_t)) annotation (Placement(transformation(extent={{80,-94},{154,-56}}))); ThermofluidStream.Utilities.Icons.DLRLogo dLRLogo annotation (Placement(transformation(extent={{134,-156},{190,-100}}))); equation connect(source1.outlet, flowResistance2.inlet) annotation (Line( points={{-10,-120},{-30,-120}}, color={28,108,200}, thickness=0.5)); - connect(flowResistance2.outlet,evaporator. inletAir) annotation (Line( + connect(flowResistance2.outlet, evaporator.inletA) + annotation (Line( points={{-50,-120},{-60,-120},{-60,-90},{-70,-90}}, color={28,108,200}, thickness=0.5)); - connect(evaporator.outletAir, fan1.inlet) annotation (Line( - points={{-90.2,-90},{-100,-90}}, + connect(evaporator.outletA, fan1.inlet) annotation (Line( + points={{-90.2,-90},{-90,-90},{-90,-90},{-100,-90}}, color={28,108,200}, thickness=0.5)); connect(fan1.outlet, sink1.inlet) annotation (Line( @@ -281,12 +288,12 @@ equation points={{-140,90},{-120,90}}, color={28,108,200}, thickness=0.5)); - connect(flowResistance1.outlet,condenser. inletAir) annotation (Line( - points={{-100,90},{-90,90}}, + connect(flowResistance1.outlet, condenser.inletA) annotation (Line( + points={{-100,90},{-90,90},{-90,90},{-90,90}}, color={28,108,200}, thickness=0.5)); - connect(condenser.outletAir, fan.inlet) annotation (Line( - points={{-69.8,90},{-60,90}}, + connect(condenser.outletA, fan.inlet) annotation (Line( + points={{-69.8,90},{-70,90},{-70,90},{-60,90}}, color={28,108,200}, thickness=0.5)); connect(fan.outlet, sink.inlet) annotation (Line( @@ -296,8 +303,8 @@ equation connect(realExpression2.y, fan1.omega_input) annotation (Line(points={{-91,-110},{-110,-110},{-110,-100}}, color={0,0,127})); - connect(condenser.outletRef, receiver.inlet) annotation (Line( - points={{-90.2,74},{-120,74}}, + connect(condenser.outletB, receiver.inlet) annotation (Line( + points={{-90.2,74},{-94,74},{-94,74},{-120,74}}, color={28,108,200}, thickness=0.5)); connect(receiver.outlet, controlValve.inlet) annotation (Line( @@ -320,12 +327,12 @@ equation points={{-104,54},{-110,54},{-110,74},{-120,74}}, color={28,108,200}, thickness=0.5)); - connect(condenser.inletRef, singleFlowSensor.outlet) annotation (Line( - points={{-70,74},{-40,74}}, + connect(condenser.inletB, singleFlowSensor.outlet) annotation (Line( + points={{-70,74},{-66,74},{-66,74},{-40,74}}, color={28,108,200}, thickness=0.5)); - connect(evaporator.outletRef, accumulator.inlet) annotation (Line( - points={{-69.8,-74},{-40,-74}}, + connect(evaporator.outletB, accumulator.inlet) annotation (Line( + points={{-69.8,-74},{-66,-74},{-66,-74},{-40,-74}}, color={28,108,200}, thickness=0.5)); connect(multiSensor_Tp3.inlet, singleFlowSensor.outlet) annotation (Line( @@ -383,12 +390,12 @@ equation color={28,108,200}, thickness=0.5)); connect(const.y, PI.u_s) annotation (Line(points={{-71,0},{-88,0}}, color={0,0,127})); - connect(multiSensor_Tp.inlet,evaporator. inletRef) + connect(multiSensor_Tp.inlet, evaporator.inletB) annotation (Line( points={{-124,-54},{-130,-54},{-130,-74},{-90,-74}}, color={28,108,200}, thickness=0.5)); - connect(sensorVaporQuality6.inlet,evaporator. inletRef) + connect(sensorVaporQuality6.inlet, evaporator.inletB) annotation (Line( points={{-124,-44},{-130,-44},{-130,-74},{-90,-74}}, color={28,108,200}, @@ -398,7 +405,7 @@ equation points={{0,10},{0,74},{-20,74}}, color={28,108,200}, thickness=0.5)); - connect(controlValve.outlet,evaporator. inletRef) + connect(controlValve.outlet, evaporator.inletB) annotation (Line( points={{-160,-10},{-160,-74},{-90,-74}}, color={28,108,200}, diff --git a/ThermofluidStream/Examples/ReverseHeatPump.mo b/ThermofluidStream/Examples/ReverseHeatPump.mo index 347ac0e3..7ce1b8ad 100644 --- a/ThermofluidStream/Examples/ReverseHeatPump.mo +++ b/ThermofluidStream/Examples/ReverseHeatPump.mo @@ -26,28 +26,32 @@ model ReverseHeatPump extent={{-10,-10},{10,10}}, rotation=90, origin={0,14}))); - Undirected.HeatExchangers.DiscretizedHEX discretizedHEX( - redeclare package MediumAir = SecondaryMedium, - redeclare package MediumRefrigerant = RefrigerantMedium, - initRef=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.fore, + Undirected.HeatExchangers.DiscretizedCounterFlowHEX + discretizedHEX( + redeclare package MediumA = SecondaryMedium, + redeclare package MediumB = RefrigerantMedium, + redeclare model ConductionElementA = Undirected.HeatExchangers.Internal.ConductionElementHEX, + redeclare model ConductionElementB = Undirected.HeatExchangers.Internal.ConductionElementHEX_twoPhase, + init_B=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.fore, nCells=5, initializeMassFlow=false, - m_flow_0=0, k_wall=300) annotation (Placement(transformation( extent={{10,-10},{-10,10}}, - rotation=90, + rotation=270, origin={-76,92}))); - Undirected.HeatExchangers.DiscretizedHEX discretizedHEX1( - redeclare package MediumAir = SecondaryMedium, - redeclare package MediumRefrigerant = RefrigerantMedium, - initRef=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.rear, + Undirected.HeatExchangers.DiscretizedCounterFlowHEX + discretizedHEX1( + redeclare package MediumA = SecondaryMedium, + redeclare package MediumB = RefrigerantMedium, + redeclare model ConductionElementA = Undirected.HeatExchangers.Internal.ConductionElementHEX, + redeclare model ConductionElementB = Undirected.HeatExchangers.Internal.ConductionElementHEX_twoPhase, + init_B=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.rear, nCells=5, initializeMassFlow=false, - m_flow_0=0, k_wall=300) annotation (Placement(transformation( extent={{-10,10},{10,-10}}, - rotation=90, + rotation=270, origin={76,90}))); FlowControl.BasicControlValve valveCompressorOutletCooling( @@ -431,14 +435,6 @@ equation points={{0,0},{0,4}}, color={28,108,200}, thickness=0.5)); - connect(flowResistance.rear, discretizedHEX.foreAir) annotation (Line( - points={{-84,76},{-84,82}}, - color={28,108,200}, - thickness=0.5)); - connect(flowResistance1.fore, discretizedHEX1.rearAir) annotation (Line( - points={{84,74},{84,80}}, - color={28,108,200}, - thickness=0.5)); connect(TEVcooling.rear, receiver.fore) annotation (Line( points={{30,180},{10,180}}, color={28,108,200}, @@ -466,11 +462,6 @@ equation points={{-68,11},{-68,4}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX1.foreAir, multiSensor_Tpm2.rear) - annotation (Line( - points={{84,100},{84,104}}, - color={28,108,200}, - thickness=0.5)); connect(multiSensor_Tpm2.fore, boundaryFore1.rear) annotation (Line( points={{84,124},{84,134}}, @@ -489,11 +480,6 @@ equation points={{-84,148},{-84,136}}, color={28,108,200}, thickness=0.5)); - connect(multiSensor_Tpm1.fore, discretizedHEX.rearAir) - annotation (Line( - points={{-84,116},{-84,102}}, - color={28,108,200}, - thickness=0.5)); connect(limiter2.u,PI2. y) annotation (Line(points={{-113.2,178},{-124,178},{-124,167}},color={0,0,127})); connect(PI2.u,feedback2. y) annotation (Line(points={{-124,144},{-124,137}}, color={0,0,127})); @@ -510,21 +496,11 @@ equation connect(firstOrder.y, valveCompressorOutletHeating.u_in) annotation (Line(points={{-89,-6},{-84,-6},{-84,-24},{26,-24},{26,32}}, color={0,0,127})); connect(firstOrder.y, valveCompressorInletCooling.u_in) annotation (Line(points={{-89,-6},{-84,-6},{-84,-24},{40,-24},{40,-6},{60,-6}},color={0,0,127})); - connect(discretizedHEX.rearRef, twoPhaseSensorSelect1.fore) - annotation (Line( - points={{-68,82},{-68,76}}, - color={28,108,200}, - thickness=0.5)); connect(junctionRFFleft.foreB, twoPhaseSensorSelect1.rear) annotation (Line( points={{-68,50},{-68,56}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX1.foreRef, twoPhaseSensorSelect.rear) - annotation (Line( - points={{68,80},{68,76}}, - color={28,108,200}, - thickness=0.5)); connect(junctionRRF2_1.rearB, twoPhaseSensorSelect.fore) annotation (Line( points={{68,50},{68,56}}, @@ -561,21 +537,11 @@ equation points={{84,54},{96,54}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX.foreRef, multiSensor_Tpm5.rear) - annotation (Line( - points={{-68,102},{-68,110}}, - color={28,108,200}, - thickness=0.5)); connect(multiSensor_Tpm5.fore, TEVheating.rear) annotation (Line( points={{-68,130},{-68,180},{-50,180}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX1.rearRef, multiSensor_Tpm6.fore) - annotation (Line( - points={{68,100},{68,110}}, - color={28,108,200}, - thickness=0.5)); connect(multiSensor_Tpm6.rear, TEVcooling.fore) annotation (Line( points={{68,130},{68,180},{50,180}}, @@ -604,6 +570,42 @@ equation points={{-14,24},{0,24}}, color={28,108,200}, thickness=0.5)); + connect(discretizedHEX.rearA, multiSensor_Tpm1.fore) + annotation (Line( + points={{-84,102},{-84,116}}, + color={28,108,200}, + thickness=0.5)); + connect(discretizedHEX.foreA, flowResistance.rear) annotation (Line( + points={{-84,82},{-84,76}}, + color={28,108,200}, + thickness=0.5)); + connect(twoPhaseSensorSelect1.fore, discretizedHEX.rearB) + annotation (Line( + points={{-68,76},{-68,82}}, + color={28,108,200}, + thickness=0.5)); + connect(discretizedHEX.foreB, multiSensor_Tpm5.rear) + annotation (Line( + points={{-68,102.2},{-68,110},{-68,110}}, + color={28,108,200}, + thickness=0.5)); + connect(discretizedHEX1.rearB, multiSensor_Tpm6.fore) annotation (Line( + points={{68,100},{68,110}}, + color={28,108,200}, + thickness=0.5)); + connect(discretizedHEX1.foreB, twoPhaseSensorSelect.rear) + annotation (Line( + points={{68,79.8},{68,76}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistance1.fore, discretizedHEX1.rearA) annotation (Line( + points={{84,74},{84,80}}, + color={28,108,200}, + thickness=0.5)); + connect(discretizedHEX1.foreA, multiSensor_Tpm2.rear) annotation (Line( + points={{84,100},{84,104}}, + color={28,108,200}, + thickness=0.5)); annotation (Diagram(coordinateSystem(extent={{-260,-80},{180,220}}), graphics={ Polygon( points={{48,42},{48,160},{140,210},{140,42},{48,42}}, diff --git a/ThermofluidStream/Examples/Utilities/BoilerEspresso.mo b/ThermofluidStream/Examples/Utilities/BoilerEspresso.mo index 1299b59e..e0256f25 100644 --- a/ThermofluidStream/Examples/Utilities/BoilerEspresso.mo +++ b/ThermofluidStream/Examples/Utilities/BoilerEspresso.mo @@ -14,36 +14,39 @@ model BoilerEspresso parameter SI.ThermalConductance UA_heat = 200 "Heat transfer coefficient times contact area to medium to left Heatport"; parameter Medium.MassFraction x_0 = 0.05 "Initial vapor quality of steam."; + Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatport_heat "heatport to add heat" annotation(Placement(transformation(extent={{-20,-20}, {20,20}}, origin={-60,0}, rotation=0), iconTransformation(extent={{-10,-10}, {10,10}}, origin={-60,0}, rotation=0))); Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatport_HX "heatport to add heat" annotation(Placement(transformation(extent={{-20,-20}, {20,20}}, origin={60,0}, rotation=0), iconTransformation(extent={{-10,-10}, {10,10}}, origin={60,0}, rotation=0))); + Interfaces.Outlet steam_out(redeclare package Medium = Medium) "ontlet for steam" annotation (Placement(transformation( - extent={{-20,-20},{20,20}}, - origin={40,100}, - rotation=90), iconTransformation( - extent={{-20,-20},{20,20}}, - origin={40,100}, - rotation=90))); + extent={{-20,-20},{20,20}}, + origin={40,100}, + rotation=90), iconTransformation( + extent={{-20,-20},{20,20}}, + origin={40,100}, + rotation=90))); Interfaces.Outlet water_out(redeclare package Medium = Medium) "ontlet for hot water" - annotation (Placement(transformation( - extent={{-20,-20},{20,20}}, - origin={-60,100}, - rotation=90), iconTransformation( - extent={{-20,-20},{20,20}}, - origin={-40,100}, - rotation=90))); + annotation (Placement(transformation( + extent={{-20,-20},{20,20}}, + origin={-40,100}, + rotation=90), iconTransformation( + extent={{-20,-20},{20,20}}, + origin={-40,100}, + rotation=90))); Interfaces.Inlet inlet(redeclare package Medium=Medium) "inlet for fresh water" - annotation (Placement(transformation( - extent={{-20,-20},{20,20}}, - rotation=90, - origin={0,-100}), iconTransformation( - extent={{-20,-20},{20,20}}, - rotation=90, - origin={0,-100}))); + annotation (Placement(transformation( + extent={{-20,-20},{20,20}}, + rotation=90, + origin={0,-100}), iconTransformation( + extent={{-20,-20},{20,20}}, + rotation=90, + origin={0,-100}))); + Modelica.Blocks.Interfaces.RealOutput y_out(unit="") "Water level percentage []" annotation (Placement( transformation( @@ -57,46 +60,53 @@ model BoilerEspresso rotation=180, origin={-100,60}))); - Medium.BaseProperties medium(preferredMediumStates=true, u(stateSelect=StateSelect.always)) "Medium in boiler"; - Medium.MassFraction x = Medium.vapourQuality(medium.state) "vapour quality of medium in boiler"; - - SI.Mass m(stateSelect=StateSelect.always) "mass of fluid in boiler"; - SI.Energy U = m*medium.u; - -protected - outer DropOfCommons dropOfCommons; + Boundaries.PhaseSeparator2 phaseSeparator2_1( + redeclare package Medium = Medium, + useHeatport=true, + A=2e5, + U=2e5, + p_start=p_0, + V_par=V, + pipe1_low=0.05, + pipe1_high=0.1, + pipe2_low=0.9, + pipe2_high=0.95, + init_method=ThermofluidStream.Boundaries.Internal.InitializationMethodsPhaseSeperator.x, + x_0=x_0) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={0,0}))); -initial equation - medium.p = p_0; - x = x_0; + Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor(G=UA_heat) + annotation (Placement(transformation(extent={{-38,-10},{-18,10}}))); + Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor1(G=UA_HX) + annotation (Placement(transformation(extent={{20,-10},{40,10}}))); + Modelica.Blocks.Sources.RealExpression p(y=phaseSeparator2_1.medium.p) annotation (Placement(transformation(extent={{-50,50},{-70,70}}))); + Modelica.Blocks.Sources.RealExpression p1(y=phaseSeparator2_1.liquid_level) annotation (Placement(transformation(extent={{-50,-70},{-70,-50}}))); equation - assert( noEvent(steam_out.m_flow <= 0), "boiler massflow must be positive", dropOfCommons.assertionLevel); - assert( noEvent(water_out.m_flow <= 0), "boiler massflow must be positive", dropOfCommons.assertionLevel); - assert( noEvent(inlet.m_flow <= 0), "boiler massflow must be positive", dropOfCommons.assertionLevel); - assert( noEvent(0 m_flow_assert,"Negative massflow at Air inlet",dropOfCommons.assertionLevel); + assert(inletA.m_flow > m_flow_assert,"Negative massflow at Refigerant inlet",dropOfCommons.assertionLevel); + + //Summary record + summary.Tin_B =MediumB.temperature(inletB.state); + summary.Tin_A =MediumA.temperature(inletA.state); + summary.Tout_B =MediumB.temperature(outletB.state); + summary.Tout_A =MediumA.temperature(outletA.state); + summary.hin_B =MediumB.specificEnthalpy(inletB.state); + summary.hin_A =MediumA.specificEnthalpy(inletA.state); + summary.hout_B =MediumB.specificEnthalpy(outletB.state); + summary.hout_A =MediumA.specificEnthalpy(outletA.state); + summary.dT_A = summary.Tout_A - summary.Tin_A; + summary.dT_B = summary.Tout_B - summary.Tin_B; + summary.dh_A = summary.hout_A - summary.hin_A; + summary.dh_B = summary.hout_B - summary.hin_B; + + //Connecting equations (to interconnect pipes) + //Fluid Side B + connect(inletB, thermalElementB[1].inlet) annotation (Line(points={{-100,80},{-10,80}}, color={28,108,200})); + for i in 1:nCells-1 loop + connect(thermalElementB[i].outlet, thermalElementB[i + 1].inlet); + end for; + connect(thermalElementB[nCells].outlet, outletB) annotation (Line(points={{10,80},{102,80}}, color={28,108,200})); + + //Fluid Side A + connect(inletA, thermalElementA[1].inlet) annotation (Line(points={{100,-80},{10,-80}}, color={28,108,200})); + for i in 1:nCells-1 loop + connect(thermalElementA[i].outlet, thermalElementA[i + 1].inlet); + end for; + connect(thermalElementA[nCells].outlet, outletA) annotation (Line(points={{-10,-80},{-102,-80}}, color={28,108,200})); + + connect(thermalElementB.heatPort, thermalConductor.port_b) + annotation (Line(points={{0,70.2},{0,10}}, color={191,0,0})); + + for i in 1:nCells loop + connect(thermalElementA[i].heatPort, thermalConductor[nCells + 1 - i].port_a) + annotation (Line(points={{-6.66134e-16,-70.2},{-6.66134e-16,-10},{0,-10}}, color={191,0,0})); + end for; + + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), + graphics={ + Rectangle( + extent={{-100,100},{100,-100}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + radius=25), + Polygon(points={{-80,-92},{70,-92},{70,-62},{-80,-62},{-70,-52},{80,-52},{80,-82},{70,-92},{70,-62},{80,-52},{-70,-52},{-80,-62},{-80,-92}}, + lineColor={28,108,200}), + Line(points={{-40,-52},{-50,-62},{-50,-92}}, color={28,108,200}), + Line(points={{-10,-52},{-20,-62},{-20,-92}},color={28,108,200}), + Line(points={{20,-52},{10,-62},{10,-92}}, color={28,108,200}), + Line(points={{50,-52},{40,-62},{40,-92}}, color={28,108,200}), + Text( + extent={{-70,-72},{-58,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{52,-72},{64,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{20,-72},{32,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{-10,-72},{2,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-40,-72},{-28,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Polygon(points={{-80,56},{70,56},{70,86},{-80,86},{-70,96},{80,96},{80,66},{70,56},{70,86},{80,96},{-70,96},{-80,86},{-80,56}}, + lineColor = {28, + 108,200}), + Line(points={{-40,96},{-50,86},{-50,56}}, color={28,108,200}), + Line(points={{-10,96},{-20,86},{-20,56}}, color={28,108,200}), + Line(points={{20,96},{10,86},{10,56}}, color={28,108,200}), + Line(points={{50,96},{40,86},{40,56}}, color={28,108,200}), + Text( + extent={{50,76},{62,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{20,76},{32,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-10,76},{2,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-42,76},{-30,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{-72,76},{-60,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={1,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={57,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-65,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-3,-36}, + rotation=90), + Polygon(points={{-82,-16},{68,-16},{68,4},{-82,4},{-72,14},{78,14},{78,-6},{68,-16},{68,4},{78,14},{-72,14},{-82,4},{-82,-16}}, + lineColor = {188, + 36,38}), + Line(points={{-42,14},{-52,4},{-52,-16}}, color={188,36,38}), + Line(points={{-12,14},{-22,4},{-22,-16}}, color={188,36,38}), + Line(points={{18,14},{8,4},{8,-16}}, color={188,36,38}), + Line(points={{48,14},{38,4},{38,-16}}, color={188,36,38})}), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}})), + Documentation(info=" +

The counter-flow discretized heat exchanger uses a number of conduction elements (which is set by the parameter nCells) as discrete control volumes to exchange heat between two fluid streams.

+

For each side the elements are numbered 1 to nCells in the flow direction and the elements' heatports are connected via a thermal conductor that models the wall. The connections are ordered to result in a counter-flow configuration.

+

The conduction elements are computing a heat transfer coefficient between their heatport and the fluid contained. They are replaceable with a choice between a single-phase and a two-phase version, both can be further parametrized. Although the single-phase version works for two-phase media (not the other way around), using the two-phase one for two-phase media enables to set different heat transfer coefficients depending on the phase (liquid/gaseous/2-phase) state of the medium.

+

Note that since the model uses conductionElements as discrete control volumes that in turn assume quasi-stationary mass and therefore are part of a fluid stream rather than break it into two (like a full volume would), the same holds for both sides of the heat exchanger; they are part of a fluid stream and don't break it. The quasi-stationary mass assumption also implies that for (fast) changing masses/densities in any of the conduction elements the heat exchanger will (slightly) violate the conservation of energy. Furthermore, the conduction elements change their behavior for reversed mass-flow, therefore this model asserts for negative mass-flow with the level dropOfCommons.globalAssertionLevel.

+

The parameters A (heat transferring area), k_wall (heat transfer coefficient of the wall between the streams) and the heat transfer coefficients in the conduction elements scale the transferred heat (the middle only if the wall and the latter only of the heat transfer into a fluid is the choke of the heatflow).

+

The parameter V determines the amount of fluid in the heat exchanger and therefore the dynamic for non-steady states.

+

The initialization tab allows for a mass-flow initialization for both paths.

+

The Advanced tab allows to modify the massflow that triggers the reverse-massflow-assertion and has an option to enforce global conservation of energy. The latter is done by feeding back any energy the conduction elements accumulated over time, basically making it impossible to store energy in their fluid long-term. While this enforces long-term conservation of energy it changes the medium-/short-term dynamics of the system and is therefore disabled by default.

+")); +end DiscretizedCounterFlowHEX; diff --git a/ThermofluidStream/HeatExchangers/DiscretizedCounterFlowHEX_FR.mo b/ThermofluidStream/HeatExchangers/DiscretizedCounterFlowHEX_FR.mo new file mode 100644 index 00000000..9b81cfa0 --- /dev/null +++ b/ThermofluidStream/HeatExchangers/DiscretizedCounterFlowHEX_FR.mo @@ -0,0 +1,303 @@ +within ThermofluidStream.HeatExchangers; +model DiscretizedCounterFlowHEX_FR "Discretized Heat Exchanger for single- or two-phase working fluid with pressure drop" + + replaceable package MediumA = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium "Medium model side A" + annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); + replaceable package MediumB = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium "Medium model side B" + annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); + + replaceable model ConductionElementA = Internal.ConductionElementHEX + constrainedby Internal.PartialConductionElementHEX( + final A=A/nCells, + final V=V_Hex/nCells, + redeclare package Medium=MediumA, + final enforce_global_energy_conservation=enforce_global_energy_conservation) + "Heat transfer element model for side A" + annotation(choicesAllMatching=true, Dialog(group = "Medium definitions")); + replaceable model ConductionElementB = Internal.ConductionElementHEX + constrainedby Internal.PartialConductionElementHEX( + final A=A/nCells, + final V=V_Hex/nCells, + redeclare package Medium=MediumB, + final enforce_global_energy_conservation=enforce_global_energy_conservation) + "Heat transfer element model for side B" + annotation(choicesAllMatching=true, Dialog(group = "Medium definitions")); + + parameter Boolean initializeMassFlow=false "Initialize mass flow at inlets?" annotation(Dialog(tab = "Initialization", group = "Mass flow")); + parameter SI.MassFlowRate m_flow_0_A = 0 "Initial mass flow for side A" + annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); + parameter SI.MassFlowRate m_flow_0_B = 0 "Initial mass flow for side B" + annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); + parameter Integer nCells = 3 "Number of discretization elements"; + parameter Modelica.SIunits.Area A = 10 "Conductive area of heat exchanger" annotation(Dialog(group = "Heat transfer parameters")); + parameter Modelica.SIunits.Volume V_Hex = 0.001 "Volume for heat transfer calculation" annotation(Dialog(group = "Heat transfer parameters")); + parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative massflows" + annotation(Dialog(tab="Advanced")); + parameter Boolean enforce_global_energy_conservation = false "If true, exact global energy conservation is enforced by feeding back all energy stored locally back in the system" + annotation(Dialog(tab="Advanced")); + + parameter SI.Length l_A = 1 "Length of pipe A" + annotation(Dialog(group="laminar-turbolent flowRes")); + parameter SI.Length r_A = 0.01 "Radius of pipe A" + annotation(Dialog(group="laminar-turbolent flowRes")); + parameter SI.Length ks_A = 1e-7 "Roughness of pipe A" + annotation(Dialog(group="laminar-turbolent flowRes")); + parameter SI.Length l_B = 1 "Length of pipe B" + annotation(Dialog(group="laminar-turbolent flowRes")); + parameter SI.Length r_B = 0.01 "Radius of pipe B" + annotation(Dialog(group="laminar-turbolent flowRes")); + parameter SI.Length ks_B = 1e-7 "Roughness of pipe B" + annotation(Dialog(group="laminar-turbolent flowRes")); + + //Parameterization of HEX Wall + parameter Modelica.SIunits.CoefficientOfHeatTransfer k_wall = 100 "Coefficient of heat transfer for pipe wall" + annotation(Dialog(group = "Heat transfer parameters")); +protected + parameter Modelica.SIunits.ThermalConductance G = k_wall*A "Wall thermal conductance" annotation(Dialog(group = "Wall parameters")); + +public + ConductionElementB thermalElementB[nCells] + annotation (Placement(transformation(extent={{-10,90},{10,70}}))); + ConductionElementA thermalElementA[nCells] + annotation (Placement(transformation(extent={{10,-90},{-10,-70}}))); + Processes.FlowResistance flowResistanceA[nCells]( + redeclare package Medium = MediumA, + each r = r_A, + each l=l_A/nCells, + each computeL=false, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarTurbulentPressureLoss(each ks_input=ks_A)) + annotation (Placement(transformation(extent={{-10,-10},{10,10}},rotation=180,origin={-50,-80}))); + Processes.FlowResistance flowResistanceB[nCells]( + redeclare package Medium = MediumB, + each r = r_B, + each l=l_B/nCells, + each computeL=false, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarTurbulentPressureLoss(each ks_input=ks_B)) + annotation (Placement(transformation(extent={{40,70},{60,90}}))); + + Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor[nCells](each G=G/nCells) + annotation (Placement(transformation(extent={{-10,-10},{10,10}},rotation=90,origin={0,0}))); + Interfaces.Inlet inletB(redeclare package Medium = MediumB) annotation (Placement(transformation(extent={{-110,70},{-90,90}}))); + Interfaces.Outlet outletB(redeclare package Medium = MediumB) annotation (Placement(transformation(extent={{92,70},{112,90}}))); + Interfaces.Inlet inletA(redeclare package Medium = MediumA) annotation (Placement(transformation(extent={{110,-90},{90,-70}}))); + Interfaces.Outlet outletA(redeclare package Medium = MediumA) annotation (Placement(transformation(extent={{-92,-90},{-112,-70}}))); + + SI.HeatFlowRate Q_flow_A=sum(thermalElementA.heatPort.Q_flow); + SI.HeatFlowRate Q_flow_B=sum(thermalElementB.heatPort.Q_flow); + SI.Mass M_A=sum(thermalElementA.M); + SI.Mass M_B=sum(thermalElementB.M); + SI.Energy deltaE_system=sum(thermalElementA.deltaE_system) + sum(thermalElementB.deltaE_system); + + ThermofluidStream.HeatExchangers.Internal.DiscretizedHEXSummary summary "Summary record of Quantities"; + +protected + outer DropOfCommons dropOfCommons; + +initial equation + + if initializeMassFlow then + inletA.m_flow = m_flow_0_A; + inletB.m_flow = m_flow_0_B; + end if; + +equation + assert(inletB.m_flow > m_flow_assert,"Negative massflow at Air inlet",dropOfCommons.assertionLevel); + assert(inletA.m_flow > m_flow_assert,"Negative massflow at Refigerant inlet",dropOfCommons.assertionLevel); + + //Summary record + summary.Tin_B =MediumB.temperature(inletB.state); + summary.Tin_A =MediumA.temperature(inletA.state); + summary.Tout_B =MediumB.temperature(outletB.state); + summary.Tout_A =MediumA.temperature(outletA.state); + summary.hin_B =MediumB.specificEnthalpy(inletB.state); + summary.hin_A =MediumA.specificEnthalpy(inletA.state); + summary.hout_B =MediumB.specificEnthalpy(outletB.state); + summary.hout_A =MediumA.specificEnthalpy(outletA.state); + summary.dT_A = summary.Tout_A - summary.Tin_A; + summary.dT_B = summary.Tout_B - summary.Tin_B; + summary.dh_A = summary.hout_A - summary.hin_A; + summary.dh_B = summary.hout_B - summary.hin_B; + + //Connecting equations (to interconnect pipes) + //Fluid Side B + connect(inletB, thermalElementB[1].inlet) annotation (Line(points={{-100,80},{-10,80}}, color={28,108,200})); + connect(flowResistanceB.inlet, thermalElementB.outlet) + annotation (Line( + points={{40,80},{10,80}}, + color={28,108,200}, + thickness=0.5)); + for i in 1:nCells-1 loop + connect(flowResistanceB[i].outlet, thermalElementB[i + 1].inlet); + end for; + connect(flowResistanceB[nCells].outlet, outletB) + annotation (Line( + points={{60,80},{102,80}}, + color={28,108,200}, + thickness=0.5)); + + + //Fluid Side A + connect(inletA, thermalElementA[1].inlet) annotation (Line(points={{100,-80},{10,-80}}, color={28,108,200})); + connect(flowResistanceA.inlet, thermalElementA.outlet) + annotation (Line( + points={{-40,-80},{-10,-80}}, + color={28,108,200}, + thickness=0.5)); + for i in 1:nCells-1 loop + connect(thermalElementA[i].outlet, thermalElementA[i + 1].inlet); + end for; + connect(flowResistanceA[nCells].outlet, outletA) + annotation (Line( + points={{-60,-80},{-102,-80}}, + color={28,108,200}, + thickness=0.5)); + + //Thermal connection + connect(thermalElementB.heatPort, thermalConductor.port_b) + annotation (Line(points={{4.44089e-16,70.2},{4.44089e-16,40},{0,40},{0,10}}, color={191,0,0})); + for i in 1:nCells loop + connect(thermalElementA[i].heatPort, thermalConductor[nCells + 1 - i].port_a) + annotation (Line(points={{-6.66134e-16,-70.2},{-6.66134e-16,-10},{0,-10}}, color={191,0,0})); + end for; + + annotation ( + Icon( + coordinateSystem(preserveAspectRatio=true, + extent={{-100,-100},{100,100}}), + graphics={ + Rectangle( + extent={{-100,100},{100,-100}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + radius=25), + Polygon(points={{-80,-92},{70,-92},{70,-62},{-80,-62},{-70,-52},{80,-52},{80,-82},{70,-92},{70,-62},{80,-52},{-70,-52},{-80,-62},{-80,-92}}, + lineColor={28,108,200}), + Line(points={{-40,-52},{-50,-62},{-50,-92}}, color={28,108,200}), + Line(points={{-10,-52},{-20,-62},{-20,-92}},color={28,108,200}), + Line(points={{20,-52},{10,-62},{10,-92}}, color={28,108,200}), + Line(points={{50,-52},{40,-62},{40,-92}}, color={28,108,200}), + Text( + extent={{-70,-72},{-58,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{52,-72},{64,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{20,-72},{32,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{-10,-72},{2,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-40,-72},{-28,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Polygon(points={{-80,56},{70,56},{70,86},{-80,86},{-70,96},{80,96},{80,66},{70,56},{70,86},{80,96},{-70,96},{-80,86},{-80,56}}, + lineColor = {28, + 108,200}), + Line(points={{-40,96},{-50,86},{-50,56}}, color={28,108,200}), + Line(points={{-10,96},{-20,86},{-20,56}}, color={28,108,200}), + Line(points={{20,96},{10,86},{10,56}}, color={28,108,200}), + Line(points={{50,96},{40,86},{40,56}}, color={28,108,200}), + Text( + extent={{50,76},{62,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{20,76},{32,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-10,76},{2,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-42,76},{-30,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{-72,76},{-60,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={1,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={57,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-65,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-3,-36}, + rotation=90), + Polygon(points={{-82,-16},{68,-16},{68,4},{-82,4},{-72,14},{78,14},{78,-6},{68,-16},{68,4},{78,14},{-72,14},{-82,4},{-82,-16}}, + lineColor = {188, + 36,38}), + Line(points={{-42,14},{-52,4},{-52,-16}}, color={188,36,38}), + Line(points={{-12,14},{-22,4},{-22,-16}}, color={188,36,38}), + Line(points={{18,14},{8,4},{8,-16}}, color={188,36,38}), + Line(points={{48,14},{38,4},{38,-16}}, color={188,36,38})}), + Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}})), + Documentation(info=" +

The counter-flow discretized heat exchanger uses a number of conduction elements (which is set by the parameter nCells) as discrete control volumes to exchange heat between two fluid streams. This model differes from DiscretizedCounterFlowHEX by introducing flow-resistances after each control volume, but otherwise is the same, therefore consider the documentation of DiscretizedCounterFlowHEX.

+

The flowResistances are parametrized by the parameters in the group laminar-turbolent flowRes.

+")); +end DiscretizedCounterFlowHEX_FR; diff --git a/ThermofluidStream/HeatExchangers/DiscretizedCrossFlowHEX.mo b/ThermofluidStream/HeatExchangers/DiscretizedCrossFlowHEX.mo new file mode 100644 index 00000000..9f834dce --- /dev/null +++ b/ThermofluidStream/HeatExchangers/DiscretizedCrossFlowHEX.mo @@ -0,0 +1,297 @@ +within ThermofluidStream.HeatExchangers; +model DiscretizedCrossFlowHEX "Discretized Heat Exchanger for single- or two-phase working fluid without pressure drop" + + replaceable package MediumA = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium "Medium model side A" + annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); + replaceable package MediumB = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium "Medium model side B" + annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); + + replaceable model ConductionElementA = Internal.ConductionElementHEX + constrainedby Internal.PartialConductionElementHEX( + final A=A/nCells, + final V=V_Hex/nCells, + redeclare package Medium=MediumA, + final enforce_global_energy_conservation=enforce_global_energy_conservation) + "Heat transfer element model for side A" + annotation(choicesAllMatching=true, Dialog(group = "Medium definitions")); + replaceable model ConductionElementB = Internal.ConductionElementHEX + constrainedby Internal.PartialConductionElementHEX( + final A=A/nCells, + final V=V_Hex/nCells, + redeclare package Medium=MediumB, + final enforce_global_energy_conservation=enforce_global_energy_conservation) + "Heat transfer element model for side B" + annotation(choicesAllMatching=true, Dialog(group = "Medium definitions")); + + parameter Boolean initializeMassFlow=false "Initialize mass flow at inlets?" annotation(Dialog(tab = "Initialization", group = "Mass flow")); + parameter SI.MassFlowRate m_flow_0_A = 0 "Initial mass flow for side A" + annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); + parameter SI.MassFlowRate m_flow_0_B = 0 "Initial mass flow for side B" + annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); + parameter Integer nCells = 3 "Number of discretization elements"; + parameter Modelica.SIunits.Area A = 10 "Conductive area of heat exchanger" + annotation(Dialog(group = "Heat transfer parameters")); + parameter Modelica.SIunits.Volume V_Hex = 0.001 "Volume for heat transfer calculation" annotation(Dialog(group = "Heat transfer parameters")); + parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative massflows" + annotation(Dialog(tab="Advanced")); + parameter Boolean enforce_global_energy_conservation = false "If true, exact global energy conservation is enforced by feeding back all energy stored locally back in the system" + annotation(Dialog(tab="Advanced")); + + //Parameterization of HEX Wall + parameter Modelica.SIunits.CoefficientOfHeatTransfer k_wall = 100 "Coefficient of heat transfer for wall" + annotation(Dialog(group = "Heat transfer parameters")); +protected + parameter Modelica.SIunits.ThermalConductance G = k_wall*A "Wall thermal conductance" annotation(Dialog(group = "Wall parameters")); + +public + ConductionElementA thermalElementA[nCells] annotation (Placement(transformation(extent={{-10,90},{10,70}}))); + + ConductionElementB thermalElementB[nCells] annotation (Placement(transformation(extent={{10,-90},{-10,-70}}))); + + Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor[nCells](each G=G/nCells) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={0,0}))); + Interfaces.Inlet inletA(redeclare package Medium = MediumA) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=0, + origin={-98,80}), iconTransformation( + extent={{-10,-10},{10,10}}, + rotation=270, + origin={0,100}))); + Interfaces.Outlet outletA(redeclare package Medium = MediumA) annotation (Placement(transformation(extent={{92,70},{112,90}}), iconTransformation( + extent={{-10,-10},{10,10}}, + rotation=270, + origin={0,-100}))); + Interfaces.Inlet inletB(redeclare package Medium = MediumB) annotation (Placement(transformation(extent={{110,-90},{90,-70}}))); + Interfaces.Outlet outletB(redeclare package Medium = MediumB) annotation (Placement(transformation(extent={{-92,-90},{-112,-70}}))); + + SI.HeatFlowRate Q_flow_A=sum(thermalElementA.heatPort.Q_flow); + SI.HeatFlowRate Q_flow_B=sum(thermalElementB.heatPort.Q_flow); + SI.Mass M_A=sum(thermalElementA.M); + SI.Mass M_B=sum(thermalElementB.M); + SI.Energy deltaE_system=sum(thermalElementA.deltaE_system) + sum(thermalElementB.deltaE_system); + + ThermofluidStream.HeatExchangers.Internal.DiscretizedHEXSummary summary "Summary record of Quantities"; + + Processes.FlowResistance flowResistanceA[nCells]( + redeclare package Medium = MediumA, + each r(each displayUnit="mm") = 0.025, + each l=1, + redeclare function pLoss = Processes.Internal.FlowResistance.linearQuadraticPressureLoss (each k=50)) + annotation (Placement(transformation(extent={{20,70},{40,90}}))); + Topology.JunctionN junctionN(redeclare package Medium = MediumA, N=nCells) annotation (Placement(transformation(extent={{50,70},{70,90}}))); + Topology.SplitterN splitterN(redeclare package Medium = MediumA, N=nCells) annotation (Placement(transformation(extent={{-60,70},{-40,90}}))); +protected + outer DropOfCommons dropOfCommons; + +initial equation + + if initializeMassFlow then + inletB.m_flow = m_flow_0_B; + flowResistanceA.m_flow = m_flow_0_A/nCells*ones(nCells); + else + for i in 1:nCells-1 loop + flowResistanceA[i + 1].m_flow = flowResistanceA[1].m_flow; + end for; + end if; + +equation + assert(inletA.m_flow > m_flow_assert,"Negative massflow at Air inlet",dropOfCommons.assertionLevel); + assert(inletB.m_flow > m_flow_assert,"Negative massflow at Refigerant inlet",dropOfCommons.assertionLevel); + + //Summary record + summary.Tin_B =MediumB.temperature(inletB.state); + summary.Tin_A =MediumA.temperature(inletA.state); + summary.Tout_B =MediumB.temperature(outletB.state); + summary.Tout_A =MediumA.temperature(outletA.state); + summary.hin_B =MediumB.specificEnthalpy(inletB.state); + summary.hin_A =MediumA.specificEnthalpy(inletA.state); + summary.hout_B =MediumB.specificEnthalpy(outletB.state); + summary.hout_A =MediumA.specificEnthalpy(outletA.state); + summary.dT_A = summary.Tout_A - summary.Tin_A; + summary.dT_B = summary.Tout_B - summary.Tin_B; + summary.dh_A = summary.hout_A - summary.hin_A; + summary.dh_B = summary.hout_B - summary.hin_B; + + //Connecting equations (to interconnect pipes) + + //Fluid Side B + connect(inletB, thermalElementB[1].inlet) annotation (Line(points={{100,-80},{10,-80}}, color={28,108,200})); + for i in 1:nCells-1 loop + connect(thermalElementB[i].outlet, thermalElementB[i + 1].inlet); + end for; + connect(thermalElementB[nCells].outlet, outletB) annotation (Line(points={{-10,-80},{-102,-80}}, color={28,108,200})); + + connect(thermalElementB.heatPort, thermalConductor.port_a) + annotation (Line(points={{4.44089e-16,-70.2},{4.44089e-16,-40},{0,-40},{0,-10}}, color={191,0,0})); + connect(thermalElementA.heatPort, thermalConductor.port_b) + annotation (Line(points={{4.44089e-16,70.2},{4.44089e-16,40},{0,40},{0,10}}, color={191,0,0})); + + connect(inletA, splitterN.inlet) annotation (Line( + points={{-98,80},{-60,80}}, + color={28,108,200}, + thickness=0.5)); + connect(splitterN.outlets, thermalElementA.inlet) annotation (Line( + points={{-40,80},{-10,80}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalElementA.outlet, flowResistanceA.inlet) annotation (Line( + points={{10,80},{20,80}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistanceA.outlet, junctionN.inlets) annotation (Line( + points={{40,80},{50,80}}, + color={28,108,200}, + thickness=0.5)); + connect(junctionN.outlet, outletA) annotation (Line( + points={{70,80},{102,80}}, + color={28,108,200}, + thickness=0.5)); + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), + graphics={ + Rectangle( + extent={{-100,100},{100,-100}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + radius=25), + Polygon(points={{-80,-92},{70,-92},{70,-62},{-80,-62},{-70,-52},{80,-52},{80,-82},{70,-92},{70,-62},{80,-52},{-70,-52},{-80,-62},{-80,-92}}, + lineColor={28,108,200}), + Line(points={{-40,-52},{-50,-62},{-50,-92}}, color={28,108,200}), + Line(points={{-10,-52},{-20,-62},{-20,-92}},color={28,108,200}), + Line(points={{20,-52},{10,-62},{10,-92}}, color={28,108,200}), + Line(points={{50,-52},{40,-62},{40,-92}}, color={28,108,200}), + Text( + extent={{-70,-72},{-58,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{52,-72},{64,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{20,-72},{32,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{-10,-72},{2,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-40,-72},{-28,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Polygon(points={{-80,56},{70,56},{70,86},{-80,86},{-70,96},{80,96},{80,66},{70,56},{70,86},{80,96},{-70,96},{-80,86},{-80,56}}, + lineColor = {28, + 108,200}), + Line(points={{-40,96},{-50,86},{-50,56}}, color={28,108,200}), + Line(points={{-10,96},{-20,86},{-20,56}}, color={28,108,200}), + Line(points={{20,96},{10,86},{10,56}}, color={28,108,200}), + Line(points={{50,96},{40,86},{40,56}}, color={28,108,200}), + Text( + extent={{-72,76},{-60,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{-42,76},{-30,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-10,76},{2,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{20,76},{32,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{50,76},{62,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={1,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={57,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-65,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-3,-36}, + rotation=90), + Polygon(points={{-82,-16},{68,-16},{68,4},{-82,4},{-72,14},{78,14},{78,-6},{68,-16},{68,4},{78,14},{-72,14},{-82,4},{-82,-16}}, + lineColor = {188, + 36,38}), + Line(points={{-42,14},{-52,4},{-52,-16}}, color={188,36,38}), + Line(points={{-12,14},{-22,4},{-22,-16}}, color={188,36,38}), + Line(points={{18,14},{8,4},{8,-16}}, color={188,36,38}), + Line(points={{48,14},{38,4},{38,-16}}, color={188,36,38})}), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}})), + Documentation(info=" +

The cross-flow discretized heat exchanger uses a number of conduction elements (which is set by the parameter nCells) as discrete control volumes to exchange heat between two fluid streams.

+

Side A splits the fluid stream into nCells substreams that are parallel. The flow-resistance is chosen to be very small and only ensures numerical stability of the parallel streams. By default, it is a linear-quadratic flow resistance, so the massflows through each of the parallel streams is the same. If exchanged for flow-resistance that depends on media properties (e.g. a laminar-turbulent) the mass-flow on the paths will be different. For side B the elements are serial and numbered 1 to nCells in the flow direction. The elements' heatports are connected via a thermal conductor that models the wall. The connections are ordered to result in a cross-flow configuration.

+

The conduction elements are computing a heat transfer coefficient between their heatport and the fluid contained. They are replaceable with a choice between a single-phase and a two-phase version, both can be further parametrized. Although the single-phase version works for two-phase media (not the other way around), using the two-phase one for two-phase media enables to set different heat transfer coefficients depending on the phase (liquid/gaseous/2-phase) state of the medium.

+

Note that since the model uses conductionElements as discrete control volumes that in turn assume quasi-stationary mass and therefore are part of a fluid stream rather than break it into two (like a full volume would), the same holds for both sides of the heat exchanger; they are part of a fluid stream and don't break it. The quasi-stationary mass assumption also implies that for (fast) changing masses/densities in any of the conduction elements the heat exchanger will (slightly) violate the conservation of energy. Furthermore, the conduction elements change their behavior for reversed mass-flow, therefore this model asserts for negative mass-flow with the level dropOfCommons.globalAssertionLevel.

+

The parameters A (heat transferring area), k_wall (heat transfer coefficient of the wall between the streams) and the heat transfer coefficients in the conduction elements scale the transferred heat (the middle only if the wall and the latter only of the heat transfer into a fluid is the choke of the heatflow).

+

The parameter V determines the amount of fluid in the heat exchanger and therefore the dynamic for non-steady states.

+

The initialization tab allows for a mass-flow initialization for both paths.

+

The Advanced tab allows to modify the massflow that triggers the reverse-massflow-assertion and has an option to enforce global conservation of energy. The latter is done by feeding back any energy the conduction elements accumulated over time, basically making it impossible to store energy in their fluid long-term. While this enforces long-term conservation of energy it changes the medium-/short-term dynamics of the system and is therefore disabled by default.

+")); +end DiscretizedCrossFlowHEX; diff --git a/ThermofluidStream/HeatExchangers/DiscretizedCrossFlowHEX_FR.mo b/ThermofluidStream/HeatExchangers/DiscretizedCrossFlowHEX_FR.mo new file mode 100644 index 00000000..bd15e013 --- /dev/null +++ b/ThermofluidStream/HeatExchangers/DiscretizedCrossFlowHEX_FR.mo @@ -0,0 +1,323 @@ +within ThermofluidStream.HeatExchangers; +model DiscretizedCrossFlowHEX_FR "Discretized Heat Exchanger for single- or two-phase working fluid with pressure drop" + + replaceable package MediumA = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium "Medium model side A" + annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); + replaceable package MediumB = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium "Medium model side B" + annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); + + replaceable model ConductionElementA = Internal.ConductionElementHEX + constrainedby Internal.PartialConductionElementHEX( + final A=A/nCells, + final V=V_Hex/nCells, + redeclare package Medium=MediumA, + final enforce_global_energy_conservation=enforce_global_energy_conservation) + "Heat transfer element model for side A" + annotation(choicesAllMatching=true, Dialog(group = "Medium definitions")); + replaceable model ConductionElementB = Internal.ConductionElementHEX + constrainedby Internal.PartialConductionElementHEX( + final A=A/nCells, + final V=V_Hex/nCells, + redeclare package Medium=MediumB, + final enforce_global_energy_conservation=enforce_global_energy_conservation) + "Heat transfer element model for side B" + annotation(choicesAllMatching=true, Dialog(group = "Medium definitions")); + + parameter Boolean initializeMassFlow=false "Initialize mass flow at inlets?" annotation(Dialog(tab = "Initialization", group = "Mass flow")); + parameter SI.MassFlowRate m_flow_0_A = 0 "Initial mass flow side A" + annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); + parameter SI.MassFlowRate m_flow_0_B = 0 "Initial mass flow side B" + annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); + parameter Integer nCells = 3 "Number of discretization elements"; + parameter Modelica.SIunits.Area A = 10 "Conductive area of heat exchanger" annotation(Dialog(group = "Heat transfer parameters")); + parameter Modelica.SIunits.Volume V_Hex = 0.001 "Volume for heat transfer calculation" annotation(Dialog(group = "Heat transfer parameters")); + parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative massflows" + annotation(Dialog(tab="Advanced")); + parameter Boolean enforce_global_energy_conservation = false "If true, exact global energy conservation is enforced by feeding back all energy stored locally back in the system" + annotation(Dialog(tab="Advanced")); + + parameter SI.Length l_A = 1 "Length of pipe A" + annotation(Dialog(group="laminar-turbolent flowRes")); + parameter SI.Length r_A = 0.01 "Radius of pipe A" + annotation(Dialog(group="laminar-turbolent flowRes")); + parameter SI.Length ks_A = 1e-7 "Roughness of pipe A" + annotation(Dialog(group="laminar-turbolent flowRes")); + parameter SI.Length l_B = 1 "Length of pipe B" + annotation(Dialog(group="laminar-turbolent flowRes")); + parameter SI.Length r_B = 0.01 "Radius of pipe B" + annotation(Dialog(group="laminar-turbolent flowRes")); + parameter SI.Length ks_B = 1e-7 "Roughness of pipe B" + annotation(Dialog(group="laminar-turbolent flowRes")); + + //Parameterization of HEX Wall + parameter Modelica.SIunits.CoefficientOfHeatTransfer k_wall = 100 "Coefficient of heat transfer for pipe wall" + annotation(Dialog(group = "Heat transfer parameters")); +protected + parameter Modelica.SIunits.ThermalConductance G = k_wall*A "Wall thermal conductance" annotation(Dialog(group = "Wall parameters")); + +public + ConductionElementA thermalElementA[nCells] annotation (Placement(transformation(extent={{-10,90},{10,70}}))); + + ConductionElementB thermalElementB[nCells] annotation (Placement(transformation(extent={{10,-90},{-10,-70}}))); + + Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor[nCells](each G=G/nCells) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={0,0}))); + Interfaces.Inlet inletA(redeclare package Medium = MediumA) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=0, + origin={-98,80}), iconTransformation( + extent={{-10,-10},{10,10}}, + rotation=270, + origin={0,100}))); + Interfaces.Outlet outletA(redeclare package Medium = MediumA) annotation (Placement(transformation(extent={{92,70},{112,90}}), iconTransformation( + extent={{-10,-10},{10,10}}, + rotation=270, + origin={0,-100}))); + Interfaces.Inlet inletB(redeclare package Medium = MediumB) annotation (Placement(transformation(extent={{110,-90},{90,-70}}))); + Interfaces.Outlet outletB(redeclare package Medium = MediumB) annotation (Placement(transformation(extent={{-92,-90},{-112,-70}}))); + + SI.HeatFlowRate Q_flow_A=sum(thermalElementA.heatPort.Q_flow); + SI.HeatFlowRate Q_flow_B=sum(thermalElementB.heatPort.Q_flow); + SI.Mass M_A=sum(thermalElementA.M); + SI.Mass M_B=sum(thermalElementB.M); + SI.Energy deltaE_system=sum(thermalElementA.deltaE_system) + sum(thermalElementB.deltaE_system); + + ThermofluidStream.HeatExchangers.Internal.DiscretizedHEXSummary summary "Summary record of Quantities"; + + Processes.FlowResistance flowResistanceA[nCells]( + redeclare package Medium = MediumA, + each r(each displayUnit="mm") = r_A/nCells, + each l=l_A, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarTurbulentPressureLoss(each ks_input=ks_A)) + annotation (Placement(transformation(extent={{20,70},{40,90}}))); + Topology.JunctionN junctionN(redeclare package Medium = MediumA, N=nCells) annotation (Placement(transformation(extent={{50,70},{70,90}}))); + Topology.SplitterN splitterN(redeclare package Medium = MediumA, N=nCells) annotation (Placement(transformation(extent={{-60,70},{-40,90}}))); + Processes.FlowResistance flowResistanceB[nCells]( + redeclare package Medium = MediumB, + each r=r_B, + each l=l_B/nCells, + each computeL=false, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarTurbulentPressureLoss (each ks_input=ks_B)) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={-52,-80}))); +protected + outer DropOfCommons dropOfCommons; + +initial equation + + if initializeMassFlow then + inletB.m_flow = m_flow_0_B; + flowResistanceA.m_flow = m_flow_0_A/nCells*ones(nCells); + else + for i in 1:nCells-1 loop + flowResistanceA[i + 1].m_flow = flowResistanceA[1].m_flow; + end for; + end if; + +equation + assert(inletA.m_flow > m_flow_assert,"Negative massflow at Air inlet",dropOfCommons.assertionLevel); + assert(inletB.m_flow > m_flow_assert,"Negative massflow at Refigerant inlet",dropOfCommons.assertionLevel); + + //Summary record + summary.Tin_B =MediumB.temperature(inletB.state); + summary.Tin_A =MediumA.temperature(inletA.state); + summary.Tout_B =MediumB.temperature(outletB.state); + summary.Tout_A =MediumA.temperature(outletA.state); + summary.hin_B =MediumB.specificEnthalpy(inletB.state); + summary.hin_A =MediumA.specificEnthalpy(inletA.state); + summary.hout_B =MediumB.specificEnthalpy(outletB.state); + summary.hout_A =MediumA.specificEnthalpy(outletA.state); + summary.dT_A = summary.Tout_A - summary.Tin_A; + summary.dT_B = summary.Tout_B - summary.Tin_B; + summary.dh_A = summary.hout_A - summary.hin_A; + summary.dh_B = summary.hout_B - summary.hin_B; + + //Connecting equations (to interconnect pipes) + + //Fluid Side B + connect(inletB, thermalElementB[1].inlet) annotation (Line(points={{100,-80},{10,-80}}, color={28,108,200})); + connect(thermalElementB.outlet, flowResistanceB.inlet) + annotation (Line( + points={{-10,-80},{-42,-80}}, + color={28,108,200}, + thickness=0.5)); + for i in 1:nCells-1 loop + connect(flowResistanceB[i].outlet, thermalElementB[i + 1].inlet); + end for; + connect(flowResistanceB[1].outlet, outletB) + annotation (Line( + points={{-62,-80},{-82,-80},{-82,-80},{-102,-80}}, + color={28,108,200}, + thickness=0.5)); + + connect(thermalElementB.heatPort, thermalConductor.port_a) + annotation (Line(points={{4.44089e-16,-70.2},{4.44089e-16,-40},{0,-40},{0,-10}}, color={191,0,0})); + connect(thermalElementA.heatPort, thermalConductor.port_b) + annotation (Line(points={{4.44089e-16,70.2},{4.44089e-16,40},{0,40},{0,10}}, color={191,0,0})); + + connect(inletA, splitterN.inlet) annotation (Line( + points={{-98,80},{-60,80}}, + color={28,108,200}, + thickness=0.5)); + connect(splitterN.outlets, thermalElementA.inlet) annotation (Line( + points={{-40,80},{-10,80}}, + color={28,108,200}, + thickness=0.5)); + connect(thermalElementA.outlet, flowResistanceA.inlet) annotation (Line( + points={{10,80},{20,80}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistanceA.outlet, junctionN.inlets) annotation (Line( + points={{40,80},{50,80}}, + color={28,108,200}, + thickness=0.5)); + connect(junctionN.outlet, outletA) annotation (Line( + points={{70,80},{102,80}}, + color={28,108,200}, + thickness=0.5)); + + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), + graphics={ + Rectangle( + extent={{-100,100},{100,-100}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + radius=25), + Polygon(points={{-80,-92},{70,-92},{70,-62},{-80,-62},{-70,-52},{80,-52},{80,-82},{70,-92},{70,-62},{80,-52},{-70,-52},{-80,-62},{-80,-92}}, + lineColor={28,108,200}), + Line(points={{-40,-52},{-50,-62},{-50,-92}}, color={28,108,200}), + Line(points={{-10,-52},{-20,-62},{-20,-92}},color={28,108,200}), + Line(points={{20,-52},{10,-62},{10,-92}}, color={28,108,200}), + Line(points={{50,-52},{40,-62},{40,-92}}, color={28,108,200}), + Text( + extent={{-70,-72},{-58,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{52,-72},{64,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{20,-72},{32,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{-10,-72},{2,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-40,-72},{-28,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Polygon(points={{-80,56},{70,56},{70,86},{-80,86},{-70,96},{80,96},{80,66},{70,56},{70,86},{80,96},{-70,96},{-80,86},{-80,56}}, + lineColor = {28, + 108,200}), + Line(points={{-40,96},{-50,86},{-50,56}}, color={28,108,200}), + Line(points={{-10,96},{-20,86},{-20,56}}, color={28,108,200}), + Line(points={{20,96},{10,86},{10,56}}, color={28,108,200}), + Line(points={{50,96},{40,86},{40,56}}, color={28,108,200}), + Text( + extent={{-72,76},{-60,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{-42,76},{-30,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-10,76},{2,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{20,76},{32,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{50,76},{62,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={1,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={57,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-65,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-3,-36}, + rotation=90), + Polygon(points={{-82,-16},{68,-16},{68,4},{-82,4},{-72,14},{78,14},{78,-6},{68,-16},{68,4},{78,14},{-72,14},{-82,4},{-82,-16}}, + lineColor = {188, + 36,38}), + Line(points={{-42,14},{-52,4},{-52,-16}}, color={188,36,38}), + Line(points={{-12,14},{-22,4},{-22,-16}}, color={188,36,38}), + Line(points={{18,14},{8,4},{8,-16}}, color={188,36,38}), + Line(points={{48,14},{38,4},{38,-16}}, color={188,36,38})}), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}})), + Documentation(info=" +

The cross-flow discretized heat exchanger uses a number of conduction elements (which is set by the parameter nCells) as discrete control volumes to exchange heat between two fluid streams. This model differes from DiscretizedCrossFlowHEX by introducing flow-resistances after each control volume, but otherwise is the same, therefore consider the documentation of DiscretizedCrossFlowHEX.

+

The flowResistances are parametrized by the parameters in the group laminar-turbolent flowRes.

+")); +end DiscretizedCrossFlowHEX_FR; diff --git a/ThermofluidStream/HeatExchangers/DiscretizedHEX.mo b/ThermofluidStream/HeatExchangers/DiscretizedHEX.mo deleted file mode 100644 index b9a1caf6..00000000 --- a/ThermofluidStream/HeatExchangers/DiscretizedHEX.mo +++ /dev/null @@ -1,269 +0,0 @@ -within ThermofluidStream.HeatExchangers; -model DiscretizedHEX "Discretized Heat Exchanger for two-phase working fluid" - - replaceable package MediumAir = - ThermofluidStream.Media.myMedia.Interfaces.PartialMedium - "Medium model" annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); - replaceable package MediumRefrigerant = - ThermofluidStream.Media.myMedia.Interfaces.PartialTwoPhaseMedium - "Medium model" annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); - -// MediumRefrigerant.BaseProperties ref_out; -// -// SI.Pressure p_out_ref = MediumRefrigerant.pressure(outletRef.state); -// SI.Temperature T_out_ref = MediumRefrigerant.temperature(outletRef.state); - - parameter Boolean initializeMassFlow=false "Initialize mass flow at inlets?" annotation(Dialog(tab = "Initialization", group = "Mass flow")); - parameter SI.MassFlowRate m_flow_0 = 0.01 "Initial mass flow" annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); - parameter Integer nCells = 3 "Number of discretization elements"; - parameter Modelica.SIunits.Area A = 10 "Conductive area of heat exchanger" annotation(Dialog(group = "Heat transfer parameters")); - parameter Modelica.SIunits.Volume V_Hex = 0.001 "Volume for heat transfer calculation" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.CoefficientOfHeatTransfer U_nom = 3000 "Nominal coefficient of heat transfer for single-phase side" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.CoefficientOfHeatTransfer U_liq_nom = 700 "Nominal coefficient of heat transfer for liquid region" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.CoefficientOfHeatTransfer U_vap_nom = 500 "Nominal coefficient of heat transfer for vapour region" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.CoefficientOfHeatTransfer U_tp_nom = 1000 "Nominal coefficient of heat transfer for two-phase region" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.MassFlowRate m_flow_nom_ref = 0.3 "Nominal mass-flow rate working fluid" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.MassFlowRate m_flow_nom_air = 1.0 "Nominal mass-flow rate secondary fluid" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative massflows" - annotation(Dialog(tab="Advanced")); - parameter Boolean enforce_global_energy_conservation = false "If true, exact global energy conservation is enforced by feeding back all energy stored locally back in the system" - annotation(Dialog(tab="Advanced")); - - //Parameterization of HEX Wall - parameter Modelica.SIunits.CoefficientOfHeatTransfer k_wall = 100 "Coefficient of heat transfer for pipe wall" annotation(Dialog(group = "Wall parameters")); -protected - parameter Modelica.SIunits.ThermalConductance G = k_wall*A "Wall thermal conductance" annotation(Dialog(group = "Wall parameters")); - - -public - Internal.ConductionElementHEX thermalElementAir[nCells]( - redeclare package Medium = MediumAir, - each V(displayUnit="l") = V_Hex/nCells, - each enforce_global_energy_conservation=enforce_global_energy_conservation, - each A=A/nCells, - each U_nom=U_nom, - each m_flow_nom=m_flow_nom_air) - annotation (Placement(transformation(extent={{-10,90},{10,70}}))); - - Internal.ConductionElementHEX_twoPhase thermalElementRefrigerant[nCells]( - each V(displayUnit="l") = V_Hex/nCells, - each enforce_global_energy_conservation=enforce_global_energy_conservation, - each A=A/nCells, - each U_liq_nom=U_liq_nom, - each U_vap_nom=U_vap_nom, - each U_tp_nom=U_tp_nom, - each m_flow_nom=m_flow_nom_ref, - redeclare package Medium = MediumRefrigerant) annotation (Placement(transformation(extent={{10,-90},{-10,-70}}))); - - Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor[nCells](each G=G/nCells) - annotation (Placement(transformation( - extent={{-10,-10},{10,10}}, - rotation=90, - origin={0,0}))); - Interfaces.Inlet inletAir(redeclare package Medium = MediumAir) - annotation (Placement(transformation(extent={{-110,70},{-90,90}}))); - Interfaces.Outlet outletAir(redeclare package Medium = MediumAir) - annotation (Placement(transformation(extent={{92,70},{112,90}}))); - Interfaces.Inlet inletRef(redeclare package Medium = MediumRefrigerant) - annotation (Placement(transformation(extent={{110,-90},{90,-70}}))); - Interfaces.Outlet outletRef(redeclare package Medium = MediumRefrigerant) - annotation (Placement(transformation(extent={{-92,-90},{-112,-70}}))); - - SI.HeatFlowRate Q_flow_ref=sum(thermalElementRefrigerant.heatPort.Q_flow); - SI.HeatFlowRate Q_flow_air=sum(thermalElementAir.heatPort.Q_flow); - SI.Energy deltaE_system = sum(thermalElementAir.deltaE_system) + sum(thermalElementRefrigerant.deltaE_system); - SI.Mass M_ref = sum(thermalElementRefrigerant.M); - - Real x_in(unit="1") = thermalElementRefrigerant[1].x; - Real x_out(unit="1") = thermalElementRefrigerant[nCells].x; - - SI.SpecificEnthalpy dh_ref = MediumRefrigerant.specificEnthalpy(outletRef.state) - MediumRefrigerant.specificEnthalpy(inletRef.state); - SI.SpecificEnthalpy dh_air = MediumAir.specificEnthalpy(outletAir.state) - MediumAir.specificEnthalpy(inletAir.state); - - //SI.Temperature T_sat; - - ThermofluidStream.HeatExchangers.Internal.DiscretizedHEXSummary summary "Summary record of Quantities"; - -protected - outer DropOfCommons dropOfCommons; - -initial equation - - if initializeMassFlow then - inletRef.m_flow = m_flow_0; - inletAir.m_flow = m_flow_0; - else - end if; - -equation - assert(inletAir.m_flow > m_flow_assert, "Negative massflow at Air inlet", dropOfCommons.assertionLevel); - assert(inletRef.m_flow > m_flow_assert, "Negative massflow at Refigerant inlet", dropOfCommons.assertionLevel); - - -//Summary record - summary.Tin_air = MediumAir.temperature(inletAir.state); - summary.Tin_ref = MediumRefrigerant.temperature(inletRef.state); - summary.Tout_air = MediumAir.temperature(outletAir.state); - summary.Tout_ref = MediumRefrigerant.temperature(outletRef.state); - - summary.hin_air = MediumAir.specificEnthalpy(inletAir.state); - summary.hin_ref = MediumRefrigerant.specificEnthalpy(inletRef.state); - summary.hout_air = MediumAir.specificEnthalpy(outletAir.state); - summary.hout_ref = MediumRefrigerant.specificEnthalpy(outletRef.state); - - //Connecting equations (to interconnect pipes) - //Fluid Side A - connect(inletAir, thermalElementAir[1].inlet) annotation (Line(points={{-100,80},{-10,80}}, color={28,108,200})); - for i in 1:nCells-1 loop - connect(thermalElementAir[i].outlet, thermalElementAir[i + 1].inlet); - end for; - connect(thermalElementAir[nCells].outlet, outletAir) annotation (Line(points={{10,80},{10,80},{10,80},{102,80}}, color={28,108,200})); - - //Fluid Side B - connect(inletRef, thermalElementRefrigerant[1].inlet) annotation (Line(points={{100,-80},{10,-80}}, color={28,108,200})); - for i in 1:nCells-1 loop - connect(thermalElementRefrigerant[i].outlet, thermalElementRefrigerant[i + 1].inlet); - end for; - connect(thermalElementRefrigerant[nCells].outlet, outletRef) annotation (Line(points={{-10,-80},{-102,-80}}, color={28,108,200})); - - connect(thermalElementAir.heatPort, thermalConductor.port_b) annotation(Line(points={{4.44089e-16,70.2},{4.44089e-16,40},{0,40},{0,10}}, color={191,0,0})); - - for i in 1:nCells loop - connect(thermalElementRefrigerant[i].heatPort, thermalConductor[nCells+1-i].port_a) - annotation(Line(points={{-6.66134e-16,-70.2},{-6.66134e-16,-10},{0,-10}},color={191,0,0})); - end for; - - - annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), - graphics={ - Rectangle( - extent={{-100,100},{100,-100}}, - lineColor={28,108,200}, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - radius=25), - Polygon(points={{-80,-92},{70,-92},{70,-62},{-80,-62},{-70,-52},{80,-52},{80,-82},{70,-92},{70,-62},{80,-52},{-70,-52},{-80,-62},{-80,-92}}, - lineColor={5,188,185}), - Line(points={{-40,-52},{-50,-62},{-50,-92}}, color={5,188,185}), - Line(points={{-10,-52},{-20,-62},{-20,-92}},color={5,188,185}), - Line(points={{20,-52},{10,-62},{10,-92}}, color={5,188,185}), - Line(points={{50,-52},{40,-62},{40,-92}}, color={5,188,185}), - Text( - extent={{-70,-72},{-58,-84}}, - lineColor={5,188,185}, - pattern=LinePattern.Dash, - textString="N"), - Text( - extent={{52,-72},{64,-84}}, - lineColor={5,188,185}, - pattern=LinePattern.Dash, - textString="1"), - Text( - extent={{20,-72},{32,-84}}, - lineColor={5,188,185}, - pattern=LinePattern.Dash, - textString="2"), - Text( - extent={{-10,-72},{2,-84}}, - lineColor={5,188,185}, - pattern=LinePattern.Dash, - textString="..."), - Text( - extent={{-40,-72},{-28,-84}}, - lineColor={5,188,185}, - pattern=LinePattern.Dash, - textString="..."), - Polygon(points={{-80,56},{70,56},{70,86},{-80,86},{-70,96},{80,96},{80,66},{70,56},{70,86},{80,96},{-70,96},{-80,86},{-80,56}}, lineColor={28, - 108,200}), - Line(points={{-40,96},{-50,86},{-50,56}}, color={28,108,200}), - Line(points={{-10,96},{-20,86},{-20,56}}, color={28,108,200}), - Line(points={{20,96},{10,86},{10,56}}, color={28,108,200}), - Line(points={{50,96},{40,86},{40,56}}, color={28,108,200}), - Text( - extent={{50,76},{62,64}}, - lineColor={28,108,200}, - pattern=LinePattern.Dash, - textString="N"), - Text( - extent={{20,76},{32,64}}, - lineColor={28,108,200}, - pattern=LinePattern.Dash, - textString="..."), - Text( - extent={{-10,76},{2,64}}, - lineColor={28,108,200}, - pattern=LinePattern.Dash, - textString="..."), - Text( - extent={{-42,76},{-30,64}}, - lineColor={28,108,200}, - pattern=LinePattern.Dash, - textString="2"), - Text( - extent={{-72,76},{-60,64}}, - lineColor={28,108,200}, - pattern=LinePattern.Dash, - textString="1"), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={-61,36}, - rotation=270), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={1,36}, - rotation=270), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={61,36}, - rotation=270), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={57,-36}, - rotation=90), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={-65,-36}, - rotation=90), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={-3,-36}, - rotation=90), - Polygon(points={{-82,-16},{68,-16},{68,4},{-82,4},{-72,14},{78,14},{78,-6},{68,-16},{68,4},{78,14},{-72,14},{-82,4},{-82,-16}}, lineColor={188, - 36,38}), - Line(points={{-42,14},{-52,4},{-52,-16}}, color={188,36,38}), - Line(points={{-12,14},{-22,4},{-22,-16}}, color={188,36,38}), - Line(points={{18,14},{8,4},{8,-16}}, color={188,36,38}), - Line(points={{48,14},{38,4},{38,-16}}, color={188,36,38})}), - Diagram( - coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}))); -end DiscretizedHEX; diff --git a/ThermofluidStream/HeatExchangers/Internal/ConductionElementHEX.mo b/ThermofluidStream/HeatExchangers/Internal/ConductionElementHEX.mo index b92a3a05..46b866e4 100644 --- a/ThermofluidStream/HeatExchangers/Internal/ConductionElementHEX.mo +++ b/ThermofluidStream/HeatExchangers/Internal/ConductionElementHEX.mo @@ -1,25 +1,16 @@ within ThermofluidStream.HeatExchangers.Internal; -model ConductionElementHEX "Volume with quasisationary mass and heatport" - extends Processes.Internal.PartialConductionElement( - final init= Processes.Internal.InitializationMethodsCondElement.inlet, - final neglectPressureChanges=true); +model ConductionElementHEX "ConductionElement for single-phase fluids" + extends PartialConductionElementHEX; - parameter SI.Area A = 1 "Contact area of volume with medium"; - parameter SI.CoefficientOfHeatTransfer U_nom "Nominal coefficient of heat transfer"; - parameter SI.MassFlowRate m_flow_nom = 0.5 "Nominal mass-flow rate for heat transfer calculation"; + parameter SI.CoefficientOfHeatTransfer U_nom = 3000 "Nominal coefficient of heat transfer"; + parameter SI.MassFlowRate m_flow_nom = 1 "Nominal mass-flow rate for heat transfer calculation"; constant Real Re_exp(unit="1") = 0.8 "Reynolds-exponent for heat transfer calculation"; - constant SI.CoefficientOfHeatTransfer U_min = 1 "Minimum heat transfer coefficient for temperature adaption at zero massflow"; - -protected - SI.CoefficientOfHeatTransfer U "Heat transfer coefficient to medium"; equation //Estimation of heat transfer coefficient U = max(U_min, U_nom*(abs(m_flow/m_flow_nom))^Re_exp); - k = U*A; - annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)), Documentation(info=" diff --git a/ThermofluidStream/HeatExchangers/Internal/ConductionElementHEX_twoPhase.mo b/ThermofluidStream/HeatExchangers/Internal/ConductionElementHEX_twoPhase.mo index 4de9529b..2c93086a 100644 --- a/ThermofluidStream/HeatExchangers/Internal/ConductionElementHEX_twoPhase.mo +++ b/ThermofluidStream/HeatExchangers/Internal/ConductionElementHEX_twoPhase.mo @@ -1,31 +1,22 @@ within ThermofluidStream.HeatExchangers.Internal; -model ConductionElementHEX_twoPhase "Volume with quasisationary mass and heatport" - extends Processes.Internal.PartialConductionElement( - redeclare package Medium = TwoPhaseMedium, - final init= Processes.Internal.InitializationMethodsCondElement.inlet, - final neglectPressureChanges=true); +model ConductionElementHEX_twoPhase "ConductionElement for two-phase fluids" + extends PartialConductionElementHEX(redeclare package Medium = Media.myMedia.Interfaces.PartialTwoPhaseMedium); import Modelica.Math; - replaceable package TwoPhaseMedium = Media.myMedia.Interfaces.PartialTwoPhaseMedium - annotation(choicesAllMatching=true); + parameter SI.CoefficientOfHeatTransfer U_liq_nom = 700 "Nominal coefficient of heat transfer for liquid region"; + parameter SI.CoefficientOfHeatTransfer U_vap_nom = 500 "Nominal coefficient of heat transfer for vapour region"; + parameter SI.CoefficientOfHeatTransfer U_tp_nom = 1000 "Nominal coefficient of heat transfer for two-phase region"; - parameter SI.Area A "Contact area of volume with medium"; - parameter SI.CoefficientOfHeatTransfer U_liq_nom "Nominal coefficient of heat transfer for liquid region"; - parameter SI.CoefficientOfHeatTransfer U_vap_nom "Nominal coefficient of heat transfer for vapour region"; - parameter SI.CoefficientOfHeatTransfer U_tp_nom "Nominal coefficient of heat transfer for two-phase region"; - - parameter SI.MassFlowRate m_flow_nom = 0.5 "Nominal mass-flow rate for heat transfer calculation"; + parameter SI.MassFlowRate m_flow_nom = 0.3 "Nominal mass-flow rate for heat transfer calculation"; parameter SI.MassFraction delta_x = 0.05 "Value for interpolation width"; constant Real Re_exp_cond(unit="1") = 0.4 "Reynolds-Exponent for heat transfer calculation at condensation (Yan&Lin, 1999)"; constant Real Re_exp_evap(unit="1") = 0.5 "Reynolds-Exponent for heat transfer calculation at evaporation (Yan&Lin, 1999)"; - constant SI.CoefficientOfHeatTransfer U_min = 1 "Minimum heat transfer coefficient for temperature adaption at zero massflow"; Real x "Vapor quality calculated from enthalpies"; protected - SI.CoefficientOfHeatTransfer U "Heat transfer coefficient to medium"; SI.CoefficientOfHeatTransfer U_liq "Coefficient of heat transfer for liquid region"; SI.CoefficientOfHeatTransfer U_tp "Coefficient of heat transfer for two-phase region"; SI.CoefficientOfHeatTransfer U_vap "Coefficient of heat transfer for vapour region"; @@ -50,8 +41,6 @@ equation elseif x < 1 + delta_x then U_tp + 0.5*(U_vap - U_tp)*(1 + Math.sin((x - 1)*Modelica.Constants.pi/(2*delta_x))) else U_vap)); - k = U*A; - annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={ Line( points={{-100,0},{100,0}}, diff --git a/ThermofluidStream/HeatExchangers/Internal/DiscretizedHEXSummary.mo b/ThermofluidStream/HeatExchangers/Internal/DiscretizedHEXSummary.mo index b72949ec..386a7460 100644 --- a/ThermofluidStream/HeatExchangers/Internal/DiscretizedHEXSummary.mo +++ b/ThermofluidStream/HeatExchangers/Internal/DiscretizedHEXSummary.mo @@ -2,16 +2,22 @@ within ThermofluidStream.HeatExchangers.Internal; record DiscretizedHEXSummary "Summary Record for Discretized Heat Exchangers" //In- and outlet temperatures - SI.Temperature Tin_air "Temperature at air outlet"; - SI.Temperature Tout_air "Temperature at air outlet"; - SI.Temperature Tin_ref "Temperature at refrigerant inlet"; - SI.Temperature Tout_ref "Temperature at refrigerant outlet"; + SI.Temperature Tin_A "Temperature at A outlet"; + SI.Temperature Tout_A "Temperature at A outlet"; + SI.Temperature Tin_B "Temperature at B B"; + SI.Temperature Tout_B "Temperature at refrigerant outlet"; + + SI.Temperature dT_A "Temperature differnce A"; + SI.Temperature dT_B "Temperature differnce B"; //In- and outlet enthalpies - SI.SpecificEnthalpy hin_air "Enthalpy at air inlet"; - SI.SpecificEnthalpy hout_air "Enthalpy at air outlet"; - SI.SpecificEnthalpy hin_ref "Enthalpy at refrigerant inlet"; - SI.SpecificEnthalpy hout_ref "Enthalpy at refrigerant outlet"; + SI.SpecificEnthalpy hin_A "Enthalpy at A inlet"; + SI.SpecificEnthalpy hout_A "Enthalpy at A outlet"; + SI.SpecificEnthalpy hin_B "Enthalpy at B inlet"; + SI.SpecificEnthalpy hout_B "Enthalpy at B outlet"; + + SI.SpecificEnthalpy dh_A "Enthalpy differnce A"; + SI.SpecificEnthalpy dh_B "Enthalpy differnce B"; annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram( coordinateSystem(preserveAspectRatio=false))); diff --git a/ThermofluidStream/HeatExchangers/Internal/PartialConductionElementHEX.mo b/ThermofluidStream/HeatExchangers/Internal/PartialConductionElementHEX.mo new file mode 100644 index 00000000..3c30c181 --- /dev/null +++ b/ThermofluidStream/HeatExchangers/Internal/PartialConductionElementHEX.mo @@ -0,0 +1,16 @@ +within ThermofluidStream.HeatExchangers.Internal; +partial model PartialConductionElementHEX "Parent for CEs for discretizedHEX" + extends Processes.Internal.PartialConductionElement( + final init= Processes.Internal.InitializationMethodsCondElement.inlet, + final neglectPressureChanges=true); + + parameter SI.Area A = 1 "Contact area of volume with medium"; + + constant SI.CoefficientOfHeatTransfer U_min = 1 "Minimum heat transfer coefficient for temperature adaption at zero massflow"; + + SI.CoefficientOfHeatTransfer U "Heat transfer coefficient to medium"; +equation + k = U*A; + + annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false))); +end PartialConductionElementHEX; diff --git a/ThermofluidStream/HeatExchangers/Internal/package.order b/ThermofluidStream/HeatExchangers/Internal/package.order index f07b5cc8..3438cf12 100644 --- a/ThermofluidStream/HeatExchangers/Internal/package.order +++ b/ThermofluidStream/HeatExchangers/Internal/package.order @@ -1,3 +1,4 @@ +PartialConductionElementHEX ConductionElementHEX ConductionElementHEX_twoPhase DiscretizedHEXSummary diff --git a/ThermofluidStream/HeatExchangers/Tests/Condenser.mo b/ThermofluidStream/HeatExchangers/Tests/Condenser.mo index 3ea79318..da8b46fe 100644 --- a/ThermofluidStream/HeatExchangers/Tests/Condenser.mo +++ b/ThermofluidStream/HeatExchangers/Tests/Condenser.mo @@ -19,9 +19,8 @@ model Condenser origin={-142,10}))); ThermofluidStream.Boundaries.Sink sinkA( - redeclare package Medium = MediumAir, - pressureFromInput=true, - p0_par=100000) annotation (Placement(transformation(extent={{104,0},{124,20}}))); + redeclare package Medium = MediumAir, p0_par=90000) + annotation (Placement(transformation(extent={{104,0},{124,20}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm(redeclare package Medium = MediumAir, @@ -34,7 +33,6 @@ model Condenser ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1(redeclare package Medium = MediumAir, digits=3, - outputMassFlowRate=true, temperatureUnit="degC") annotation (Placement(transformation( extent={{10,10},{-10,-10}}, rotation=180, @@ -44,13 +42,12 @@ model Condenser redeclare package Medium = MediumRefrigerant, setEnthalpy=true, temperatureFromInput=false, - pressureFromInput=true, T0_par=283.15, - p0_par=200000, + p0_par=3200000, h0_par=450e3) annotation (Placement(transformation(extent={{10,-10},{-10,10}}, - rotation=270, - origin={82,-54}))); + rotation=90, + origin={10,110}))); ThermofluidStream.Boundaries.Sink sinkB( redeclare package Medium = MediumRefrigerant, @@ -58,60 +55,33 @@ model Condenser p0_par(displayUnit="bar") = 3000000) annotation (Placement(transformation(extent={{10,-10},{-10,10}}, rotation=90, - origin={-74,-52}))); + origin={10,-80}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2(redeclare package Medium = MediumRefrigerant, digits=3, temperatureUnit="degC") - annotation (Placement(transformation(extent={{-22,-6},{-42,-26}}))); - Modelica.Blocks.Sources.RealExpression refFlow_setPoint(y=0.3) - annotation (Placement(transformation(extent={{-10,-10},{10,10}}, - rotation=0, - origin={-12,-88}))); + annotation (Placement(transformation(extent={{10,10},{-10,-10}}, + rotation=90, + origin={20,-24}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3(redeclare package Medium = MediumRefrigerant, digits=3, - outputMassFlowRate=true, temperatureUnit="degC") - annotation (Placement(transformation(extent={{42,-6},{22,-26}}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint1(y=1) - annotation (Placement(transformation(extent={{100,36},{120,56}}))); - Modelica.Blocks.Continuous.PI PI( - k=10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - x_start=300, - y_start=30e5) - annotation (Placement(transformation(extent={{-10,-10},{10,10}}, - rotation=0, - origin={46,-88}))); - Modelica.Blocks.Math.Feedback feedback - annotation (Placement(transformation(extent={{-10,10},{10,-10}}, - rotation=0, - origin={22,-88}))); - Modelica.Blocks.Nonlinear.Limiter limiter(uMax=35e5, uMin=20e5) - annotation (Placement(transformation(extent={{-6,-6},{6,6}}, - rotation=0, - origin={70,-88}))); - Modelica.Blocks.Continuous.PI PI1( - k=-10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{162,36},{182,56}}))); - Modelica.Blocks.Math.Feedback feedback1 - annotation (Placement(transformation(extent={{132,36},{152,56}}))); + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=90, + origin={0,44}))); inner DropOfCommons dropOfCommons - annotation (Placement(transformation(extent={{132,-64},{152,-44}}))); - Modelica.Blocks.Nonlinear.Limiter limiter1(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{196,12},{184,24}}))); - ThermofluidStream.HeatExchangers.DiscretizedHEX condenser( + annotation (Placement(transformation(extent={{212,-94},{232,-74}}))); + DiscretizedCrossFlowHEX condenser( + redeclare package MediumA = MediumAir, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementA = Internal.ConductionElementHEX, + redeclare model ConductionElementB = Internal.ConductionElementHEX_twoPhase, initializeMassFlow=true, - m_flow_0=0, nCells=20, - redeclare package MediumAir = MediumAir, - redeclare package MediumRefrigerant = MediumRefrigerant, - k_wall=150) annotation (Placement(transformation(extent={{-10,-8},{10,12}}))); + k_wall=150) annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=90, + origin={2,10}))); Processes.FlowResistance flowResistanceA( redeclare package Medium = MediumAir, m_flow_0=0.5, @@ -132,37 +102,42 @@ model Condenser annotation (Placement(transformation( extent={{-10,-10},{10,10}}, rotation=270, - origin={-74,-26}))); + origin={10,-54}))); Sensors.SingleSensorSelect singleSensorSelect(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) - annotation (Placement(transformation(extent={{-22,-42},{-42,-22}}))); + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=90, + origin={42,-24}))); Sensors.SingleSensorSelect singleSensorSelect1(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) - annotation (Placement(transformation(extent={{24,-40},{44,-20}}))); + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=270, + origin={-14,44}))); Sensors.TwoPhaseSensorSelect sensorVaporQuality(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) - annotation (Placement(transformation(extent={{-22,-54},{-42,-34}}))); + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=90, + origin={34,-24}))); Sensors.TwoPhaseSensorSelect sensorVaporQuality1(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) - annotation (Placement(transformation(extent={{24,-54},{44,-34}}))); + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=270, + origin={-22,44}))); + FlowControl.MCV mCV( + redeclare package Medium = MediumAir, + m_flow_0=0, + massFlow_set_par=1) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={84,10}))); + FlowControl.MCV mCV1( + redeclare package Medium = MediumRefrigerant, + m_flow_0=1, + massFlow_set_par=0.3) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=90, + origin={10,84}))); equation - connect(sinkA.inlet, multiSensor_Tpm1.outlet) annotation (Line( - points={{104,10},{64,10}}, - color={28,108,200}, - thickness=0.5)); - connect(feedback.y, PI.u) - annotation (Line(points={{31,-88},{34,-88}}, color={0,0,127})); - connect(PI1.u, feedback1.y) - annotation (Line(points={{160,46},{151,46}}, color={0,0,127})); - connect(feedback1.u1, airFlow_setPoint1.y) - annotation (Line(points={{134,46},{121,46}}, color={0,0,127})); - connect(feedback1.u2, multiSensor_Tpm1.m_flow_out) - annotation (Line(points={{142,38},{142,14},{64,14}}, color={0,0,127})); - connect(sinkA.p0_var, limiter1.y) - annotation (Line(points={{116,10},{180,10},{180,18},{183.4,18}}, - color={0,0,127})); - connect(PI1.y, limiter1.u) annotation (Line(points={{183,46},{200,46},{200,18}, - {197.2,18}}, color={0,0,127})); connect(sourceA.outlet, flowResistanceA.inlet) annotation (Line( points={{-132,10},{-82,10}}, color={28,108,200}, @@ -171,59 +146,67 @@ equation points={{-46,10},{-62,10}}, color={28,108,200}, thickness=0.5)); - connect(multiSensor_Tpm3.outlet, condenser.inletRef) annotation (Line( - points={{22,-6},{14,-6},{14,-6},{10,-6}}, + connect(sinkB.inlet, flowResistanceB.outlet) annotation (Line( + points={{10,-70},{10,-64}}, color={28,108,200}, thickness=0.5)); - connect(condenser.outletRef, multiSensor_Tpm2.inlet) annotation (Line( - points={{-10.2,-6},{-14,-6},{-14,-6},{-22,-6}}, + connect(flowResistanceB.inlet, multiSensor_Tpm2.outlet) annotation (Line( + points={{10,-44},{10,-34}}, color={28,108,200}, thickness=0.5)); - connect(condenser.inletAir, multiSensor_Tpm.outlet) annotation (Line( - points={{-10,10},{-16,10},{-16,10},{-24,10}}, + connect(singleSensorSelect1.inlet, multiSensor_Tpm3.inlet) + annotation (Line( + points={{-14,54},{-14,60},{10,60},{10,54}}, color={28,108,200}, thickness=0.5)); - connect(condenser.outletAir, multiSensor_Tpm1.inlet) annotation (Line( - points={{10.2,10},{26,10},{26,10},{44,10}}, + connect(sensorVaporQuality1.inlet, multiSensor_Tpm3.inlet) + annotation (Line( + points={{-22,54},{-22,60},{10,60},{10,54}}, color={28,108,200}, thickness=0.5)); - connect(sinkB.inlet, flowResistanceB.outlet) annotation (Line( - points={{-74,-42},{-74,-36}}, + connect(sensorVaporQuality.inlet, multiSensor_Tpm2.inlet) + annotation (Line( + points={{34,-14},{34,-6},{10,-6},{10,-14}}, color={28,108,200}, thickness=0.5)); - connect(flowResistanceB.inlet, multiSensor_Tpm2.outlet) annotation (Line( - points={{-74,-16},{-74,-6},{-42,-6}}, + connect(singleSensorSelect.inlet, multiSensor_Tpm2.inlet) + annotation (Line( + points={{42,-14},{42,-6},{10,-6},{10,-14}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm.outlet, condenser.inletA) annotation (Line( + points={{-24,10},{-8,10}}, + color={28,108,200}, + thickness=0.5)); + connect(condenser.outletA, multiSensor_Tpm1.inlet) + annotation (Line( + points={{12,10},{28.2,10},{28.2,10},{44,10}}, + color={28,108,200}, + thickness=0.5)); + connect(condenser.outletB, multiSensor_Tpm2.inlet) annotation (Line( + points={{10,-0.2},{10,-14}}, color={28,108,200}, thickness=0.5)); - connect(sourceB.outlet, multiSensor_Tpm3.inlet) annotation (Line( - points={{82,-44},{82,-6},{42,-6}}, + connect(condenser.inletB, multiSensor_Tpm3.outlet) annotation (Line( + points={{10,20},{10,34}}, color={28,108,200}, thickness=0.5)); - connect(multiSensor_Tpm3.m_flow_out, feedback.u2) - annotation (Line(points={{22,-10},{8,-10},{8,-80},{22,-80}}, - color={0,0,127})); - connect(PI.y, limiter.u) - annotation (Line(points={{57,-88},{62.8,-88}}, color={0,0,127})); - connect(refFlow_setPoint.y, feedback.u1) - annotation (Line(points={{-1,-88},{14,-88}}, color={0,0,127})); - connect(singleSensorSelect.inlet, condenser.outletRef) annotation (Line( - points={{-22,-32},{-18,-32},{-18,-6},{-10.2,-6}}, + connect(sourceB.outlet, mCV1.inlet) annotation (Line( + points={{10,100},{10,94}}, color={28,108,200}, thickness=0.5)); - connect(singleSensorSelect1.inlet, condenser.inletRef) annotation (Line( - points={{24,-30},{16,-30},{16,-6},{10,-6}}, + connect(mCV1.outlet, multiSensor_Tpm3.inlet) annotation (Line( + points={{10,74},{10,54}}, color={28,108,200}, thickness=0.5)); - connect(sensorVaporQuality.inlet, condenser.outletRef) annotation (Line( - points={{-22,-44},{-18,-44},{-18,-6},{-10.2,-6}}, + connect(sinkA.inlet, mCV.outlet) annotation (Line( + points={{104,10},{94,10}}, color={28,108,200}, thickness=0.5)); - connect(sensorVaporQuality1.inlet, condenser.inletRef) annotation (Line( - points={{24,-44},{16,-44},{16,-6},{10,-6}}, + connect(mCV.inlet, multiSensor_Tpm1.outlet) annotation (Line( + points={{74,10},{64,10}}, color={28,108,200}, thickness=0.5)); - connect(limiter.y, sourceB.p0_var) - annotation (Line(points={{76.6,-88},{88,-88},{88,-56}}, color={0,0,127})); annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio= false, extent={{-160,-100},{220,100}})), experiment( diff --git a/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU.mo b/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU.mo index 4ffd56e2..50a061d6 100644 --- a/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU.mo +++ b/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU.mo @@ -18,9 +18,8 @@ model CounterFlowNTU origin={-126,-20}))); ThermofluidStream.Boundaries.Sink sinkA( - redeclare package Medium = MediumA, - pressureFromInput=true, - p0_par=100000) annotation (Placement(transformation(extent={{116,-30},{136,-10}}))); + redeclare package Medium = MediumA, p0_par=MediumA.p_default - 1e4) + annotation (Placement(transformation(extent={{116,-30},{136,-10}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm(redeclare package Medium = MediumA, @@ -33,7 +32,6 @@ model CounterFlowNTU ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1(redeclare package Medium = MediumA, digits=3, - outputMassFlowRate=true, temperatureUnit="degC") annotation (Placement(transformation( extent={{10,-10},{-10,10}}, rotation=180, @@ -46,44 +44,18 @@ model CounterFlowNTU p0_par=100000) annotation (Placement(transformation(extent={{136,10},{116,30}}))); ThermofluidStream.Boundaries.Sink sinkB( - redeclare package Medium = MediumB, - pressureFromInput=true, - p0_par=100000) + redeclare package Medium = MediumB, p0_par=90000) annotation (Placement(transformation(extent={{-118,10},{-138,30}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2(redeclare package Medium = - MediumB, outputMassFlowRate=true, + MediumB, temperatureUnit="degC") - annotation (Placement(transformation(extent={{-56,20},{-76,40}}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint(y=1) - annotation (Placement(transformation(extent={{-42,50},{-62,70}}))); + annotation (Placement(transformation(extent={{-74,20},{-94,40}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3(redeclare package Medium = MediumB, outputMassFlowRate=false, temperatureUnit="degC") annotation (Placement(transformation(extent={{66,20},{46,40}}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint1(y=0.3) - annotation (Placement(transformation(extent={{56,-70},{76,-50}}))); - Modelica.Blocks.Continuous.PI PI( - k=-10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{-102,50},{-122,70}}))); - Modelica.Blocks.Math.Feedback feedback - annotation (Placement(transformation(extent={{-72,50},{-92,70}}))); - Modelica.Blocks.Nonlinear.Limiter limiter(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{-132,54},{-144,66}}))); - Modelica.Blocks.Continuous.PI PI1( - k=-10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{118,-70},{138,-50}}))); - Modelica.Blocks.Math.Feedback feedback1 - annotation (Placement(transformation(extent={{88,-50},{108,-70}}))); inner DropOfCommons dropOfCommons annotation (Placement(transformation(extent={{-156,-98},{-136,-78}}))); - Modelica.Blocks.Nonlinear.Limiter limiter1(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{148,-26},{136,-14}}))); HeatExchangers.CounterFlowNTU counterFlowNTU( redeclare package MediumA = MediumA, redeclare package MediumB = MediumB, @@ -105,43 +77,26 @@ model CounterFlowNTU Processes.Internal.FlowResistance.laminarTurbulentPressureLoss ( material=ThermofluidStream.Processes.Internal.Material.steel)) annotation (Placement(transformation(extent={{-100,-30},{-80,-10}}))); + FlowControl.MCV mCV( + redeclare package Medium = MediumB, + m_flow_0=0, + massFlow_set_par=1) annotation (Placement(transformation(extent={{-40,10},{-60,30}}))); + FlowControl.MCV mCV1( + redeclare package Medium = MediumA, + m_flow_0=1, + massFlow_set_par=0.3) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={88,-20}))); equation - connect(sinkA.inlet, multiSensor_Tpm1.outlet) annotation (Line( - points={{116,-20},{70,-20}}, - color={28,108,200}, - thickness=0.5)); connect(sinkB.inlet, multiSensor_Tpm2.outlet) annotation (Line( - points={{-118,20},{-76,20}}, + points={{-118,20},{-94,20}}, color={28,108,200}, thickness=0.5)); - connect(airFlow_setPoint.y, feedback.u1) - annotation (Line(points={{-63,60},{-74,60}}, color={0,0,127})); - connect(multiSensor_Tpm2.m_flow_out, feedback.u2) - annotation (Line(points={{-76,24},{-82,24},{-82,52}}, color={0,0,127})); - connect(feedback.y, PI.u) - annotation (Line(points={{-91,60},{-100,60}}, color={0,0,127})); - connect(PI.y, limiter.u) - annotation (Line(points={{-123,60},{-130.8,60}}, color={0,0,127})); - connect(limiter.y,sinkB. p0_var) annotation (Line(points={{-144.6,60},{-152, - 60},{-152,20},{-130,20}}, color={0,0,127})); - connect(PI1.u, feedback1.y) - annotation (Line(points={{116,-60},{107,-60}}, color={0,0,127})); - connect(feedback1.u1, airFlow_setPoint1.y) - annotation (Line(points={{90,-60},{77,-60}}, color={0,0,127})); - connect(feedback1.u2, multiSensor_Tpm1.m_flow_out) - annotation (Line(points={{98,-52},{98,-24},{70,-24}}, color={0,0,127})); - connect(sinkA.p0_var, limiter1.y) - annotation (Line(points={{128,-20},{135.4,-20}}, color={0,0,127})); - connect(PI1.y, limiter1.u) annotation (Line(points={{139,-60},{156,-60},{156, - -20},{149.2,-20}}, color={0,0,127})); connect(multiSensor_Tpm3.outlet, counterFlowNTU.inletB) annotation (Line( points={{46,20},{28,20},{28,8},{11.2,8}}, color={28,108,200}, thickness=0.5)); - connect(counterFlowNTU.outletB, multiSensor_Tpm2.inlet) annotation (Line( - points={{-11,8},{-28,8},{-28,20},{-56,20}}, - color={28,108,200}, - thickness=0.5)); connect(multiSensor_Tpm.outlet, counterFlowNTU.inletA) annotation (Line( points={{-34,-20},{-28,-20},{-28,-4},{-11.2,-4}}, color={28,108,200}, @@ -166,6 +121,23 @@ equation points={{66,20},{80,20}}, color={28,108,200}, thickness=0.5)); + connect(counterFlowNTU.outletB, mCV.inlet) + annotation (Line( + points={{-11,8},{-28,8},{-28,20},{-40,20}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.outlet, multiSensor_Tpm2.inlet) annotation (Line( + points={{-60,20},{-74,20}}, + color={28,108,200}, + thickness=0.5)); + connect(sinkA.inlet, mCV1.outlet) annotation (Line( + points={{116,-20},{98,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV1.inlet, multiSensor_Tpm1.outlet) annotation (Line( + points={{78,-20},{70,-20}}, + color={28,108,200}, + thickness=0.5)); annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio= false, extent={{-160,-100},{160,100}})), experiment( diff --git a/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU_parallel.mo b/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU_parallel.mo index 3a0eae16..7f76feac 100644 --- a/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU_parallel.mo +++ b/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU_parallel.mo @@ -18,14 +18,12 @@ model CounterFlowNTU_parallel origin={-132,-20}))); ThermofluidStream.Boundaries.Sink sinkA( - redeclare package Medium = MediumA, - pressureFromInput=true, - p0_par=100000) annotation (Placement(transformation(extent={{110,-30},{130,-10}}))); + redeclare package Medium = MediumA, p0_par=MediumA.p_default - 1e4) + annotation (Placement(transformation(extent={{110,-30},{130,-10}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1(redeclare package Medium = MediumA, digits=3, - outputMassFlowRate=true, temperatureUnit="degC") annotation (Placement(transformation( extent={{10,-10},{-10,10}}, rotation=180, @@ -34,10 +32,9 @@ model CounterFlowNTU_parallel ThermofluidStream.Boundaries.Source sourceB( redeclare package Medium = MediumB, temperatureFromInput=false, - pressureFromInput=true, T0_par=293.15, - p0_par=100000) - annotation (Placement(transformation(extent={{130,10},{110,30}}))); + p0_par=150000) + annotation (Placement(transformation(extent={{148,10},{128,30}}))); ThermofluidStream.Boundaries.Sink sinkB( redeclare package Medium = MediumB, pressureFromInput=false, @@ -48,37 +45,12 @@ model CounterFlowNTU_parallel outputMassFlowRate=false, temperatureUnit="degC") annotation (Placement(transformation(extent={{-100,20},{-120,40}}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint(y=1) - annotation (Placement(transformation(extent={{102,42},{122,62}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3(redeclare package Medium = MediumB, - outputMassFlowRate=true, temperatureUnit="degC") - annotation (Placement(transformation(extent={{90,20},{70,40}}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint1(y=0.3) - annotation (Placement(transformation(extent={{52,-70},{72,-50}}))); - Modelica.Blocks.Continuous.PI PI( - k=10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{174,10},{154,30}}))); - Modelica.Blocks.Math.Feedback feedback - annotation (Placement(transformation(extent={{126,42},{146,62}}))); - Modelica.Blocks.Nonlinear.Limiter limiter(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{148,14},{136,26}}))); - Modelica.Blocks.Continuous.PI PI1( - k=-10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{114,-70},{134,-50}}))); - Modelica.Blocks.Math.Feedback feedback1 - annotation (Placement(transformation(extent={{84,-50},{104,-70}}))); + annotation (Placement(transformation(extent={{116,20},{96,40}}))); inner DropOfCommons dropOfCommons annotation (Placement(transformation(extent={{-158,-92},{-138,-72}}))); - Modelica.Blocks.Nonlinear.Limiter limiter1(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{142,-26},{130,-14}}))); HeatExchangers.CounterFlowNTU counterFlowNTU( redeclare package MediumA = MediumA, redeclare package MediumB = MediumB, @@ -113,29 +85,15 @@ model CounterFlowNTU_parallel rotation=180, origin={-96,88}))); Boundaries.Sink sinkA2( - redeclare package Medium = MediumA, - pressureFromInput=true, - p0_par=100000) annotation (Placement(transformation(extent={{48,50},{68,70}}))); + redeclare package Medium = MediumA, p0_par=MediumA.p_default - 1e4) + annotation (Placement(transformation(extent={{54,50},{74,70}}))); Sensors.MultiSensor_Tpm multiSensor_Tpm6( redeclare package Medium = MediumA, digits=3, - outputMassFlowRate=true, temperatureUnit="degC") annotation (Placement(transformation( extent={{10,10},{-10,-10}}, rotation=180, - origin={18,70}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint2(y=0.3) - annotation (Placement(transformation(extent={{-10,108},{10,88}}))); - Modelica.Blocks.Continuous.PI PI2( - k=-10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{52,108},{72,88}}))); - Modelica.Blocks.Math.Feedback feedback2 - annotation (Placement(transformation(extent={{22,88},{42,108}}))); - Modelica.Blocks.Nonlinear.Limiter limiter2(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{80,54},{68,66}}))); + origin={10,70}))); Sensors.MultiSensor_Tpm multiSensor_Tpm7( redeclare package Medium = MediumB, outputMassFlowRate=false, @@ -194,65 +152,48 @@ model CounterFlowNTU_parallel l=1, redeclare function pLoss = Processes.Internal.FlowResistance.laminarTurbulentPressureLoss ( material=ThermofluidStream.Processes.Internal.Material.steel)) - annotation (Placement(transformation(extent={{-112,-30},{-92,-10}}))); + annotation (Placement(transformation(extent={{-110,-30},{-90,-10}}))); + FlowControl.MCV mCV( + redeclare package Medium = MediumB, + m_flow_0=0, + massFlow_set_par=1) annotation (Placement(transformation(extent={{86,10},{66,30}}))); + FlowControl.MCV mCV1( + redeclare package Medium = MediumA, + m_flow_0=1, + massFlow_set_par=0.3) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={48,-20}))); + FlowControl.MCV mCV2( + redeclare package Medium = MediumA, + m_flow_0=1, + massFlow_set_par=0.3) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={38,60}))); equation connect(sinkA.inlet, multiSensor_Tpm1.outlet) annotation (Line( points={{110,-20},{90,-20}}, color={28,108,200}, thickness=0.5)); connect(sourceB.outlet, multiSensor_Tpm3.inlet) annotation (Line( - points={{110,20},{90,20}}, + points={{128,20},{116,20}}, color={28,108,200}, thickness=0.5)); - connect(PI.y, limiter.u) - annotation (Line(points={{153,20},{149.2,20}}, color={0,0,127})); - connect(PI1.u, feedback1.y) - annotation (Line(points={{112,-60},{103,-60}}, color={0,0,127})); - connect(feedback1.u1, airFlow_setPoint1.y) - annotation (Line(points={{86,-60},{73,-60}}, color={0,0,127})); - connect(feedback1.u2, multiSensor_Tpm1.m_flow_out) - annotation (Line(points={{94,-52},{94,-24},{90,-24}}, color={0,0,127})); - connect(sinkA.p0_var, limiter1.y) - annotation (Line(points={{122,-20},{129.4,-20}}, color={0,0,127})); - connect(PI1.y, limiter1.u) annotation (Line(points={{135,-60},{146,-60},{146,-20},{143.2, - -20}}, color={0,0,127})); connect(multiSensor_Tpm5.outlet, counterFlowNTU.inletA) annotation (Line( points={{-64,-20},{-60,-20},{-60,-4},{-39.2,-4}}, color={28,108,200}, thickness=0.5)); - connect(multiSensor_Tpm3.outlet, splitterT1_1.inlet) annotation (Line( - points={{70,20},{56,20}}, - color={28,108,200}, - thickness=0.5)); connect(multiSensor_Tpm2.inlet, junctionT1_1.outlet) annotation (Line( points={{-100,20},{-94,20}}, color={28,108,200}, thickness=0.5)); - connect(counterFlowNTU.outletA, multiSensor_Tpm1.inlet) annotation (Line( - points={{-17,-4},{16,-4},{16,-20},{70,-20}}, - color={28,108,200}, - thickness=0.5)); connect(sourceA2.outlet, multiSensor_Tpm4.inlet) annotation (Line( points={{-118,78},{-106,78}}, color={28,108,200}, thickness=0.5)); - connect(sinkA2.inlet, multiSensor_Tpm6.outlet) annotation (Line( - points={{48,60},{28,60}}, - color={28,108,200}, - thickness=0.5)); - connect(PI2.u,feedback2. y) - annotation (Line(points={{50,98},{41,98}}, color={0,0,127})); - connect(feedback2.u1,airFlow_setPoint2. y) - annotation (Line(points={{24,98},{11,98}}, color={0,0,127})); - connect(feedback2.u2,multiSensor_Tpm6. m_flow_out) - annotation (Line(points={{32,90},{30,90},{30,64},{28,64}}, - color={0,0,127})); - connect(sinkA2.p0_var, limiter2.y) - annotation (Line(points={{60,60},{67.4,60}}, color={0,0,127})); - connect(PI2.y,limiter2. u) annotation (Line(points={{73,98},{90,98},{90,60},{ - 81.2,60}}, color={0,0,127})); connect(counterFlowNTU1.outletA, multiSensor_Tpm6.inlet) annotation (Line( - points={{-17,44},{-2,44},{-2,60},{8,60}}, + points={{-17,44},{-2,44},{-2,60},{-1.77636e-15,60}}, color={28,108,200}, thickness=0.5)); connect(splitterT1_1.outletA, multiSensor_Tpm7.inlet) annotation (Line( @@ -279,15 +220,6 @@ equation points={{-70,8},{-84,8},{-84,10}}, color={28,108,200}, thickness=0.5)); - connect(limiter.y, sourceB.p0_var) annotation (Line(points={{135.4,20},{128,20},{128,26},{122,26}}, - color={0,0,127})); - connect(feedback.u1, airFlow_setPoint.y) - annotation (Line(points={{128,52},{123,52}}, color={0,0,127})); - connect(multiSensor_Tpm3.m_flow_out, feedback.u2) annotation (Line(points={{70,24}, - {64,24},{64,40},{136,40},{136,44}}, - color={0,0,127})); - connect(feedback.y, PI.u) - annotation (Line(points={{145,52},{186,52},{186,20},{176,20}}, color={0,0,127})); connect(sinkB.inlet, flowResistanceB2.outlet) annotation (Line( points={{-150,20},{-146,20}}, color={28,108,200}, @@ -321,11 +253,36 @@ equation color={28,108,200}, thickness=0.5)); connect(sourceA.outlet,flowResistanceA. inlet) annotation (Line( - points={{-122,-20},{-112,-20}}, + points={{-122,-20},{-110,-20}}, color={28,108,200}, thickness=0.5)); connect(multiSensor_Tpm5.inlet,flowResistanceA. outlet) annotation (Line( - points={{-84,-20},{-92,-20}}, + points={{-84,-20},{-90,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(counterFlowNTU.outletA, mCV1.inlet) + annotation (Line( + points={{-17,-4},{16,-4},{16,-20},{38,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV1.outlet, multiSensor_Tpm1.inlet) annotation (Line( + points={{58,-20},{70,-20}}, + color={28,108,200}, + thickness=0.5)); + connect(sinkA2.inlet, mCV2.outlet) annotation (Line( + points={{54,60},{48,60}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV2.inlet, multiSensor_Tpm6.outlet) annotation (Line( + points={{28,60},{20,60}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm3.outlet, mCV.inlet) annotation (Line( + points={{96,20},{86,20}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.outlet, splitterT1_1.inlet) annotation (Line( + points={{66,20},{56,20}}, color={28,108,200}, thickness=0.5)); annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio= diff --git a/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU_serial.mo b/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU_serial.mo index 9acb2485..362ff0cc 100644 --- a/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU_serial.mo +++ b/ThermofluidStream/HeatExchangers/Tests/CounterFlowNTU_serial.mo @@ -18,19 +18,16 @@ model CounterFlowNTU_serial origin={-140,-20}))); ThermofluidStream.Boundaries.Sink sinkA( - redeclare package Medium = MediumA, - pressureFromInput=true, - p0_par=100000) annotation (Placement(transformation(extent={{110,-30},{130, - -10}}))); + redeclare package Medium = MediumA, p0_par=MediumA.p_default - 1e4) + annotation (Placement(transformation(extent={{136,-14},{156,6}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1(redeclare package Medium = MediumA, digits=3, - outputMassFlowRate=true, temperatureUnit="degC") annotation (Placement(transformation( extent={{10,-10},{-10,10}}, rotation=180, - origin={80,-30}))); + origin={64,-14}))); ThermofluidStream.Boundaries.Source sourceB( redeclare package Medium = MediumB, @@ -39,44 +36,18 @@ model CounterFlowNTU_serial p0_par=100000) annotation (Placement(transformation(extent={{158,10},{138,30}}))); ThermofluidStream.Boundaries.Sink sinkB( - redeclare package Medium = MediumB, - pressureFromInput=true, - p0_par=100000) - annotation (Placement(transformation(extent={{-110,10},{-130,30}}))); + redeclare package Medium = MediumB, p0_par=90000) + annotation (Placement(transformation(extent={{-128,-2},{-148,18}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2(redeclare package Medium = - MediumB, outputMassFlowRate=true, + MediumB, temperatureUnit="degC") - annotation (Placement(transformation(extent={{-70,20},{-90,40}}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint(y=1) - annotation (Placement(transformation(extent={{-44,50},{-64,70}}))); + annotation (Placement(transformation(extent={{-50,8},{-70,28}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3(redeclare package Medium = MediumB, outputMassFlowRate=false, temperatureUnit="degC") annotation (Placement(transformation(extent={{90,20},{70,40}}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint1(y=0.3) - annotation (Placement(transformation(extent={{52,-70},{72,-50}}))); - Modelica.Blocks.Continuous.PI PI( - k=-10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{-112,50},{-132,70}}))); - Modelica.Blocks.Math.Feedback feedback - annotation (Placement(transformation(extent={{-84,50},{-104,70}}))); - Modelica.Blocks.Nonlinear.Limiter limiter(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{-140,54},{-152,66}}))); - Modelica.Blocks.Continuous.PI PI1( - k=-10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{114,-70},{134,-50}}))); - Modelica.Blocks.Math.Feedback feedback1 - annotation (Placement(transformation(extent={{84,-50},{104,-70}}))); inner DropOfCommons dropOfCommons annotation (Placement(transformation(extent={{-158,-92},{-138,-72}}))); - Modelica.Blocks.Nonlinear.Limiter limiter1(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{142,-26},{130,-14}}))); HeatExchangers.CounterFlowNTU counterFlowNTU( redeclare package MediumA = MediumA, redeclare package MediumB = MediumB, @@ -120,35 +91,18 @@ model CounterFlowNTU_serial redeclare function pLoss = Processes.Internal.FlowResistance.laminarTurbulentPressureLoss ( material=ThermofluidStream.Processes.Internal.Material.steel)) annotation (Placement(transformation(extent={{130,10},{110,30}}))); + FlowControl.MCV mCV( + redeclare package Medium = MediumB, + m_flow_0=0, + massFlow_set_par=1) annotation (Placement(transformation(extent={{-78,-2},{-98,18}}))); + FlowControl.MCV mCV1( + redeclare package Medium = MediumA, + m_flow_0=1, + massFlow_set_par=0.3) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={92,-4}))); equation - connect(sinkA.inlet, multiSensor_Tpm1.outlet) annotation (Line( - points={{110,-20},{90,-20}}, - color={28,108,200}, - thickness=0.5)); - connect(sinkB.inlet, multiSensor_Tpm2.outlet) annotation (Line( - points={{-110,20},{-90,20}}, - color={28,108,200}, - thickness=0.5)); - connect(airFlow_setPoint.y, feedback.u1) - annotation (Line(points={{-65,60},{-86,60}}, color={0,0,127})); - connect(multiSensor_Tpm2.m_flow_out, feedback.u2) - annotation (Line(points={{-90,24},{-94,24},{-94,52}}, color={0,0,127})); - connect(feedback.y, PI.u) - annotation (Line(points={{-103,60},{-110,60}},color={0,0,127})); - connect(PI.y, limiter.u) - annotation (Line(points={{-133,60},{-138.8,60}}, color={0,0,127})); - connect(limiter.y,sinkB. p0_var) annotation (Line(points={{-152.6,60},{-156, - 60},{-156,20},{-122,20}}, color={0,0,127})); - connect(PI1.u, feedback1.y) - annotation (Line(points={{112,-60},{103,-60}}, color={0,0,127})); - connect(feedback1.u1, airFlow_setPoint1.y) - annotation (Line(points={{86,-60},{73,-60}}, color={0,0,127})); - connect(feedback1.u2, multiSensor_Tpm1.m_flow_out) - annotation (Line(points={{94,-52},{94,-24},{90,-24}}, color={0,0,127})); - connect(sinkA.p0_var, limiter1.y) - annotation (Line(points={{122,-20},{129.4,-20}}, color={0,0,127})); - connect(PI1.y, limiter1.u) annotation (Line(points={{135,-60},{146,-60},{146, - -20},{143.2,-20}}, color={0,0,127})); connect(multiSensor_Tpm4.outlet, counterFlowNTU.inletB) annotation (Line( points={{-10,8},{-16.8,8}}, color={28,108,200}, @@ -170,7 +124,7 @@ equation color={28,108,200}, thickness=0.5)); connect(counterFlowNTU.outletB, multiSensor_Tpm2.inlet) annotation (Line( - points={{-39,8},{-60,8},{-60,20},{-70,20}}, + points={{-39,8},{-50,8}}, color={28,108,200}, thickness=0.5)); connect(multiSensor_Tpm3.outlet, counterFlowNTU1.inletB) annotation (Line( @@ -178,7 +132,7 @@ equation color={28,108,200}, thickness=0.5)); connect(counterFlowNTU1.outletA, multiSensor_Tpm1.inlet) annotation (Line( - points={{39,-4},{60,-4},{60,-20},{70,-20}}, + points={{39,-4},{54,-4}}, color={28,108,200}, thickness=0.5)); connect(sourceA.outlet, flowResistanceA.inlet) annotation (Line( @@ -197,6 +151,22 @@ equation points={{90,20},{110,20}}, color={28,108,200}, thickness=0.5)); + connect(sinkA.inlet, mCV1.outlet) annotation (Line( + points={{136,-4},{102,-4}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV1.inlet, multiSensor_Tpm1.outlet) annotation (Line( + points={{82,-4},{74,-4}}, + color={28,108,200}, + thickness=0.5)); + connect(sinkB.inlet, mCV.outlet) annotation (Line( + points={{-128,8},{-98,8}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.inlet, multiSensor_Tpm2.outlet) annotation (Line( + points={{-78,8},{-70,8}}, + color={28,108,200}, + thickness=0.5)); annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio= false, extent={{-160,-100},{160,100}})), experiment( diff --git a/ThermofluidStream/HeatExchangers/Tests/CrossFlowNTU.mo b/ThermofluidStream/HeatExchangers/Tests/CrossFlowNTU.mo index 86e0f2d5..dfe486cc 100644 --- a/ThermofluidStream/HeatExchangers/Tests/CrossFlowNTU.mo +++ b/ThermofluidStream/HeatExchangers/Tests/CrossFlowNTU.mo @@ -18,9 +18,8 @@ model CrossFlowNTU origin={-126,0}))); ThermofluidStream.Boundaries.Sink sinkA( - redeclare package Medium = MediumA, - pressureFromInput=true, - p0_par=100000) annotation (Placement(transformation(extent={{116,-10},{136, + redeclare package Medium = MediumA, p0_par=MediumA.p_default - 1e4) + annotation (Placement(transformation(extent={{116,-10},{136, 10}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm(redeclare package Medium = @@ -34,11 +33,10 @@ model CrossFlowNTU ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1(redeclare package Medium = MediumA, digits=3, - outputMassFlowRate=true, temperatureUnit="degC") annotation (Placement(transformation( extent={{10,-10},{-10,10}}, rotation=180, - origin={60,-10}))); + origin={42,-10}))); ThermofluidStream.Boundaries.Source sourceB( redeclare package Medium = MediumB, @@ -50,50 +48,24 @@ model CrossFlowNTU origin={0,94}))); ThermofluidStream.Boundaries.Sink sinkB( - redeclare package Medium = MediumB, - pressureFromInput=true, - p0_par=100000) + redeclare package Medium = MediumB, p0_par=90000) annotation (Placement(transformation(extent={{10,-10},{-10,10}}, rotation=90, - origin={0,-54}))); + origin={0,-84}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2(redeclare package Medium = - MediumB, outputMassFlowRate=true, + MediumB, temperatureUnit="degC") annotation (Placement(transformation(extent={{10,-10},{-10,10}}, rotation=90, origin={-10,-24}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint(y=1) - annotation (Placement(transformation(extent={{-110,-82},{-90,-62}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3(redeclare package Medium = MediumB, outputMassFlowRate=false, temperatureUnit="degC") annotation (Placement(transformation(extent={{10,-10},{-10,10}}, rotation=90, origin={-10,32}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint1(y=0.3) - annotation (Placement(transformation(extent={{56,-50},{76,-30}}))); - Modelica.Blocks.Continuous.PI PI( - k=-10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{-52,-82},{-32,-62}}))); - Modelica.Blocks.Math.Feedback feedback - annotation (Placement(transformation(extent={{-82,-62},{-62,-82}}))); - Modelica.Blocks.Nonlinear.Limiter limiter(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{-24,-78},{-12,-66}}))); - Modelica.Blocks.Continuous.PI PI1( - k=-10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{118,-50},{138,-30}}))); - Modelica.Blocks.Math.Feedback feedback1 - annotation (Placement(transformation(extent={{88,-30},{108,-50}}))); inner DropOfCommons dropOfCommons annotation (Placement(transformation(extent={{-156,-98},{-136,-78}}))); - Modelica.Blocks.Nonlinear.Limiter limiter1(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{148,-6},{136,6}}))); HeatExchangers.CrossFlowNTU crossFlowNTU( redeclare package MediumA = MediumA, redeclare package MediumB = MediumB, @@ -118,25 +90,21 @@ model CrossFlowNTU rotation=90, origin={0,64}))); + FlowControl.MCV mCV( + redeclare package Medium = MediumB, + m_flow_0=0, + massFlow_set_par=1) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=90, + origin={0,-54}))); + FlowControl.MCV mCV1( + redeclare package Medium = MediumA, + m_flow_0=1, + massFlow_set_par=0.3) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={82,0}))); equation - connect(sinkA.inlet, multiSensor_Tpm1.outlet) annotation (Line( - points={{116,0},{70,0}}, - color={28,108,200}, - thickness=0.5)); - connect(sinkB.inlet, multiSensor_Tpm2.outlet) annotation (Line( - points={{4.44089e-16,-44},{0,-44},{0,-34}}, - color={28,108,200}, - thickness=0.5)); - connect(PI1.u, feedback1.y) - annotation (Line(points={{116,-40},{107,-40}}, color={0,0,127})); - connect(feedback1.u1, airFlow_setPoint1.y) - annotation (Line(points={{90,-40},{77,-40}}, color={0,0,127})); - connect(feedback1.u2, multiSensor_Tpm1.m_flow_out) - annotation (Line(points={{98,-32},{98,-4},{70,-4}}, color={0,0,127})); - connect(sinkA.p0_var, limiter1.y) - annotation (Line(points={{128,0},{135.4,0}}, color={0,0,127})); - connect(PI1.y, limiter1.u) annotation (Line(points={{139,-40},{156,-40},{156, - 0},{149.2,0}}, color={0,0,127})); connect(multiSensor_Tpm3.outlet, crossFlowNTU.inletB) annotation (Line( points={{0,22},{0,10}}, color={28,108,200}, @@ -150,19 +118,9 @@ equation color={28,108,200}, thickness=0.5)); connect(crossFlowNTU.outletA, multiSensor_Tpm1.inlet) annotation (Line( - points={{10,0},{28,0},{28,1.77636e-15},{50,1.77636e-15}}, + points={{10,0},{28,0},{28,1.77636e-15},{32,1.77636e-15}}, color={28,108,200}, thickness=0.5)); - connect(PI.y, limiter.u) - annotation (Line(points={{-31,-72},{-25.2,-72}}, color={0,0,127})); - connect(limiter.y, sinkB.p0_var) - annotation (Line(points={{-11.4,-72},{0,-72},{0,-56}}, color={0,0,127})); - connect(PI.u, feedback.y) - annotation (Line(points={{-54,-72},{-63,-72}}, color={0,0,127})); - connect(multiSensor_Tpm2.m_flow_out, feedback.u2) annotation (Line(points={{-4,-34}, - {-4,-40},{-72,-40},{-72,-64}}, color={0,0,127})); - connect(feedback.u1, airFlow_setPoint.y) - annotation (Line(points={{-80,-72},{-89,-72}}, color={0,0,127})); connect(sourceA.outlet, flowResistanceA.inlet) annotation (Line( points={{-116,-1.11022e-15},{-104,-1.11022e-15},{-104,0},{-92,0}}, color={28,108,200}, @@ -179,6 +137,25 @@ equation points={{0,42},{0,54},{-6.66134e-16,54}}, color={28,108,200}, thickness=0.5)); + connect(sinkB.inlet, mCV.outlet) + annotation (Line( + points={{0,-74},{0,-69},{-6.66134e-16,-69},{-6.66134e-16,-64}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.inlet, multiSensor_Tpm2.outlet) + annotation (Line( + points={{6.66134e-16,-44},{6.66134e-16,-39},{0,-39},{0,-34}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm1.outlet, mCV1.inlet) + annotation (Line( + points={{52,-1.77636e-15},{62,-1.77636e-15},{62,0},{72,0}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV1.outlet, sinkA.inlet) annotation (Line( + points={{92,0},{116,0}}, + color={28,108,200}, + thickness=0.5)); annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio= false, extent={{-160,-100},{160,100}})), experiment( diff --git a/ThermofluidStream/HeatExchangers/Tests/ElementTwoPhase.mo b/ThermofluidStream/HeatExchangers/Tests/ElementTwoPhase.mo index 59d9a1f3..a75462a6 100644 --- a/ThermofluidStream/HeatExchangers/Tests/ElementTwoPhase.mo +++ b/ThermofluidStream/HeatExchangers/Tests/ElementTwoPhase.mo @@ -7,12 +7,14 @@ model ElementTwoPhase Internal.ConductionElementHEX_twoPhase conductionElementHEX_twoPhase( m_flow_0=0.5, - redeclare package TwoPhaseMedium = MediumRefrigerant, V(displayUnit="l") = 0.0005, A=10, U_liq_nom=700, U_vap_nom=500, - U_tp_nom=1000) annotation (Placement(transformation(extent={{-10,70},{10,90}}))); + U_tp_nom=1000, + m_flow_nom=0.5, + redeclare package Medium = MediumRefrigerant) + annotation (Placement(transformation(extent={{-10,70},{10,90}}))); Boundaries.Sink sink(redeclare package Medium = MediumRefrigerant, pressureFromInput=false, @@ -33,12 +35,14 @@ model ElementTwoPhase annotation (Placement(transformation(extent={{-70,70},{-50,90}}))); Internal.ConductionElementHEX_twoPhase conductionElementHEX_twoPhase1( m_flow_0=0.5, - redeclare package TwoPhaseMedium = MediumRefrigerant, V(displayUnit="l") = 0.0005, A=10, U_liq_nom=700, U_vap_nom=500, - U_tp_nom=750) annotation (Placement(transformation(extent={{-10,-40},{10,-20}}))); + U_tp_nom=750, + m_flow_nom=0.5, + redeclare package Medium = MediumRefrigerant) + annotation (Placement(transformation(extent={{-10,-40},{10,-20}}))); Boundaries.Sink sink1( redeclare package Medium = MediumRefrigerant, pressureFromInput=false, @@ -242,9 +246,9 @@ equation annotation (Line(points={{-62,50},{-70,50},{-70,80},{-62,80}}, color={0,0,127})); connect(prescribedTemperature1.T, prescribedTemperature.T) annotation (Line(points={{-42,-60},{-68,-60},{-68,-10},{-42,-10}}, color={0,0,127})); - annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-120,-120},{120,120}})), - Diagram( - coordinateSystem(preserveAspectRatio=false, extent={{-120,-120},{120,120}})), + annotation ( + Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}})), + Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-120,-120},{120,120}})), experiment(StopTime=60, Tolerance=1e-6, Interval=0.06, __Dymola_Algorithm="Dassl"), Documentation(info="

Owner: Niels Weber

")); diff --git a/ThermofluidStream/HeatExchangers/Tests/Evaporator.mo b/ThermofluidStream/HeatExchangers/Tests/Evaporator.mo index ef81fd9f..a2e78bbd 100644 --- a/ThermofluidStream/HeatExchangers/Tests/Evaporator.mo +++ b/ThermofluidStream/HeatExchangers/Tests/Evaporator.mo @@ -19,9 +19,8 @@ model Evaporator origin={110,-6}))); ThermofluidStream.Boundaries.Sink sinkA( - redeclare package Medium = MediumAir, - pressureFromInput=true, - p0_par=100000) annotation (Placement(transformation(extent={{-46,-16},{-66,4}}))); + redeclare package Medium = MediumAir, p0_par=150000) + annotation (Placement(transformation(extent={{-74,-16},{-94,4}}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm(redeclare package Medium = MediumAir, @@ -34,7 +33,6 @@ model Evaporator ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1(redeclare package Medium = MediumAir, digits=3, - outputMassFlowRate=true, temperatureUnit="degC") annotation (Placement(transformation( extent={{-10,-10},{10,10}}, rotation=180, @@ -44,9 +42,8 @@ model Evaporator redeclare package Medium = MediumRefrigerant, setEnthalpy=true, temperatureFromInput=false, - pressureFromInput=true, T0_par=283.15, - p0_par=200000, + p0_par=500000, h0_par=300e3) annotation (Placement(transformation(extent={{-10,-10},{10,10}}, rotation=270, @@ -64,59 +61,28 @@ model Evaporator digits=3, temperatureUnit="degC") annotation (Placement(transformation(extent={{24,10},{44,30}}))); - Modelica.Blocks.Sources.RealExpression refFlow_setPoint(y=0.2) - annotation (Placement(transformation(extent={{10,10},{-10,-10}}, - rotation=0, - origin={26,84}))); ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3(redeclare package Medium = MediumRefrigerant, digits=3, - outputMassFlowRate=true, temperatureUnit="degC") annotation (Placement(transformation(extent={{-40,10},{-20,30}}))); - Modelica.Blocks.Sources.RealExpression airFlow_setPoint1(y=1) - annotation (Placement(transformation(extent={{-162,0},{-142,20}}))); - Modelica.Blocks.Continuous.PI PI( - k=10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - x_start=40, - y_start=4e5) - annotation (Placement(transformation(extent={{10,10},{-10,-10}}, - rotation=0, - origin={-34,84}))); - Modelica.Blocks.Math.Feedback feedback - annotation (Placement(transformation(extent={{10,-10},{-10,10}}, - rotation=0, - origin={-4,84}))); - Modelica.Blocks.Nonlinear.Limiter limiter(uMax=10e5, uMin=1e5) - annotation (Placement(transformation(extent={{6,6},{-6,-6}}, - rotation=90, - origin={-60,72}))); - Modelica.Blocks.Continuous.PI PI1( - k=-10000, - T=0.1, - initType=Modelica.Blocks.Types.Init.InitialOutput, - y_start=1e5) - annotation (Placement(transformation(extent={{-108,-16},{-88,4}}))); - Modelica.Blocks.Math.Feedback feedback1 - annotation (Placement(transformation(extent={{-136,-16},{-116,4}}))); inner DropOfCommons dropOfCommons annotation (Placement(transformation(extent={{132,-64},{152,-44}}))); - Modelica.Blocks.Nonlinear.Limiter limiter1(uMax=5e5, uMin=100) - annotation (Placement(transformation(extent={{-78,-12},{-66,0}}))); - ThermofluidStream.HeatExchangers.DiscretizedHEX evaporator( + DiscretizedCounterFlowHEX evaporator( + redeclare package MediumA = MediumAir, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementA = Internal.ConductionElementHEX (U_nom=4000), + redeclare model ConductionElementB = Internal.ConductionElementHEX_twoPhase ( + U_liq_nom=1000, + U_vap_nom=1400, + U_tp_nom=3000), initializeMassFlow=true, - m_flow_0=0, nCells=20, - redeclare package MediumAir = MediumAir, - redeclare package MediumRefrigerant = MediumRefrigerant, A=10, - k_wall=250, - U_nom=4000, - U_liq_nom=1000, - U_vap_nom=1400, - U_tp_nom=3000) annotation (Placement(transformation(extent={{10,12},{-10,-8}}))); + k_wall=250) annotation (Placement(transformation( + extent={{10,10},{-10,-10}}, + rotation=180, + origin={2,2}))); Processes.FlowResistance flowResistanceA( redeclare package Medium = MediumAir, m_flow_0=1, @@ -149,20 +115,18 @@ model Evaporator Sensors.TwoPhaseSensorSelect sensorVaporQuality1(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) annotation (Placement(transformation(extent={{24,-8},{44,12}}))); + FlowControl.MCV mCV( + redeclare package Medium = MediumAir, + m_flow_0=0, + massFlow_set_par=1) annotation (Placement(transformation(extent={{-44,-16},{-64,4}}))); + FlowControl.MCV mCV1( + redeclare package Medium = MediumRefrigerant, + m_flow_0=1, + massFlow_set_par=0.2) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=90, + origin={-60,30}))); equation - connect(sinkA.inlet, multiSensor_Tpm1.outlet) annotation (Line( - points={{-46,-6},{-34,-6}}, - color={28,108,200}, - thickness=0.5)); - connect(feedback.y, PI.u) - annotation (Line(points={{-13,84},{-22,84}}, color={0,0,127})); - connect(PI1.u, feedback1.y) - annotation (Line(points={{-110,-6},{-117,-6}}, color={0,0,127})); - connect(feedback1.u1, airFlow_setPoint1.y) - annotation (Line(points={{-134,-6},{-140,-6},{-140,10},{-141,10}}, - color={0,0,127})); - connect(PI1.y, limiter1.u) annotation (Line(points={{-87,-6},{-79.2,-6}}, - color={0,0,127})); connect(sourceA.outlet, flowResistanceA.inlet) annotation (Line( points={{100,-6},{88,-6}}, color={28,108,200}, @@ -179,58 +143,58 @@ equation points={{62,22},{62,10},{44,10}}, color={28,108,200}, thickness=0.5)); - connect(sourceB.outlet, multiSensor_Tpm3.inlet) annotation (Line( - points={{-60,50},{-60,10},{-40,10}}, - color={28,108,200}, - thickness=0.5)); - connect(PI.y, limiter.u) - annotation (Line(points={{-45,84},{-60,84},{-60,79.2}}, - color={0,0,127})); - connect(multiSensor_Tpm.outlet, evaporator.inletAir) annotation (Line( - points={{36,-6},{10,-6}}, + connect(multiSensor_Tpm.outlet, evaporator.inletA) + annotation (Line( + points={{36,-6},{18,-6},{18,-6},{12,-6}}, color={28,108,200}, thickness=0.5)); - connect(evaporator.outletAir, multiSensor_Tpm1.inlet) + connect(evaporator.outletA, multiSensor_Tpm1.inlet) annotation (Line( - points={{-10.2,-6},{-14,-6}}, + points={{-8.2,-6},{-8.2,-6},{-6,-6},{-14,-6}}, color={28,108,200}, thickness=0.5)); - connect(sinkA.p0_var, limiter1.y) - annotation (Line(points={{-58,-6},{-65.4,-6}}, color={0,0,127})); - connect(multiSensor_Tpm1.m_flow_out, feedback1.u2) annotation (Line(points={{-34,-10}, - {-42,-10},{-42,-76},{-126,-76},{-126,-14}}, color={0,0,127})); - connect(evaporator.outletRef, multiSensor_Tpm2.inlet) annotation (Line( - points={{10.2,10},{24,10}}, + connect(evaporator.outletB, multiSensor_Tpm2.inlet) annotation (Line( + points={{12.2,10},{24,10}}, color={28,108,200}, thickness=0.5)); - connect(multiSensor_Tpm3.outlet, evaporator.inletRef) annotation (Line( - points={{-20,10},{-10,10}}, + connect(multiSensor_Tpm3.outlet, evaporator.inletB) annotation (Line( + points={{-20,10},{-8,10}}, color={28,108,200}, thickness=0.5)); - connect(multiSensor_Tpm3.m_flow_out, feedback.u2) - annotation (Line(points={{-20,14},{-4,14},{-4,76}}, color={0,0,127})); - connect(feedback.u1, refFlow_setPoint.y) - annotation (Line(points={{4,84},{15,84}}, color={0,0,127})); - connect(sourceB.p0_var, limiter.y) - annotation (Line(points={{-54,62},{-60,62},{-60,65.4}}, color={0,0,127})); - connect(singleSensorSelect.inlet, evaporator.outletRef) + connect(singleSensorSelect.inlet, evaporator.outletB) annotation (Line( - points={{24,34},{20,34},{20,10},{10.2,10}}, + points={{24,34},{20,34},{20,10},{12.2,10}}, color={28,108,200}, thickness=0.5)); - connect(singleSensorSelect1.inlet, evaporator.inletRef) + connect(singleSensorSelect1.inlet, evaporator.inletB) annotation (Line( - points={{-20,34},{-16,34},{-16,10},{-10,10}}, + points={{-20,34},{-16,34},{-16,10},{-8,10}}, color={28,108,200}, thickness=0.5)); - connect(sensorVaporQuality.inlet, evaporator.inletRef) + connect(sensorVaporQuality.inlet, evaporator.inletB) annotation (Line( - points={{-20,2},{-12,2},{-12,10},{-10,10}}, + points={{-20,2},{-12,2},{-12,10},{-8,10}}, color={28,108,200}, thickness=0.5)); - connect(sensorVaporQuality1.inlet, evaporator.outletRef) + connect(sensorVaporQuality1.inlet, evaporator.outletB) annotation (Line( - points={{24,2},{14,2},{14,10},{10.2,10}}, + points={{24,2},{14,2},{14,10},{12.2,10}}, + color={28,108,200}, + thickness=0.5)); + connect(sinkA.inlet, mCV.outlet) annotation (Line( + points={{-74,-6},{-64,-6}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.inlet, multiSensor_Tpm1.outlet) annotation (Line( + points={{-44,-6},{-34,-6}}, + color={28,108,200}, + thickness=0.5)); + connect(sourceB.outlet, mCV1.inlet) annotation (Line( + points={{-60,50},{-60,40}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV1.outlet, multiSensor_Tpm3.inlet) annotation (Line( + points={{-60,20},{-60,10},{-40,10}}, color={28,108,200}, thickness=0.5)); annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio= diff --git a/ThermofluidStream/HeatExchangers/Tests/FlowRes.mo b/ThermofluidStream/HeatExchangers/Tests/FlowRes.mo new file mode 100644 index 00000000..6a1736a0 --- /dev/null +++ b/ThermofluidStream/HeatExchangers/Tests/FlowRes.mo @@ -0,0 +1,738 @@ +within ThermofluidStream.HeatExchangers.Tests; +model FlowRes + + replaceable package MediumAir = Media.myMedia.Air.MoistAir + constrainedby Media.myMedia.Interfaces.PartialMedium annotation(choicesAllMatching = true); + + replaceable package MediumRefrigerant = Media.XRGMedia.R1234yf_ph + constrainedby Media.myMedia.Interfaces.PartialMedium annotation(choicesAllMatching = true); + + extends Modelica.Icons.Example; + + parameter Integer nCells = 10; + + ThermofluidStream.Boundaries.Source sourceA(redeclare package Medium = + MediumAir, + T0_par=303.15, + p0_par=200000) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={-50,34}))); + + ThermofluidStream.Boundaries.Sink sinkA( + redeclare package Medium = MediumAir, + pressureFromInput=false, + p0_par=100000) annotation (Placement(transformation(extent={{-202,24},{-222,44}}))); + + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm(redeclare package Medium = + MediumAir, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") annotation ( + Placement(transformation( + extent={{11,10},{-11,-10}}, + rotation=0, + origin={-93,24}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm1(redeclare package Medium = + MediumAir, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={-146,24}))); + + ThermofluidStream.Boundaries.Source sourceB( + redeclare package Medium = MediumRefrigerant, + setEnthalpy=true, + temperatureFromInput=false, + T0_par=283.15, + p0_par=400000, + h0_par=300e3) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=0, + origin={-182,50}))); + + ThermofluidStream.Boundaries.Sink sinkB( + redeclare package Medium = MediumRefrigerant, + pressureFromInput=false, + p0_par(displayUnit="bar") = 300000) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=0, + origin={-26,50}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2(redeclare package Medium = + MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{-98,50},{-78,70}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3(redeclare package Medium = + MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{-162,50},{-142,70}}))); + inner DropOfCommons dropOfCommons + annotation (Placement(transformation(extent={{-10,-10},{10,10}}))); + DiscretizedCounterFlowHEX evaporator( + redeclare package MediumA = MediumAir, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementA = Internal.ConductionElementHEX (U_nom=4000), + redeclare model ConductionElementB = Internal.ConductionElementHEX_twoPhase ( + U_liq_nom=1000, + U_vap_nom=1400, + U_tp_nom=3000), + nCells=nCells, + A=10, + k_wall=250) annotation (Placement(transformation( + extent={{10,10},{-10,-10}}, + rotation=180, + origin={-120,42}))); + + Sensors.SingleSensorSelect singleSensorSelect(redeclare package Medium = + MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{-98,64},{-78,84}}))); + Sensors.SingleSensorSelect singleSensorSelect1(redeclare package Medium = + MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{-142,64},{-162,84}}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality(redeclare package Medium = + MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{-142,74},{-162,94}}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality1(redeclare package Medium = + MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{-98,74},{-78,94}}))); + FlowControl.MCV mCV( + redeclare package Medium = MediumRefrigerant, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + m_flow_0=0, + massFlow_set_par=0.2) annotation (Placement(transformation(extent={{-68,40},{-48,60}}))); + FlowControl.MCV mCV1( + redeclare package Medium = MediumAir, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + m_flow_0=0, + massFlow_set_par=1) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={-186,34}))); + Boundaries.Source sourceA1( + redeclare package Medium = MediumAir, + T0_par=303.15, + p0_par=200000) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={-48,-66}))); + Boundaries.Sink sinkA1( + redeclare package Medium = MediumAir, + pressureFromInput=false, + p0_par=100000) annotation (Placement(transformation(extent={{-200,-76},{-220,-56}}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm4( + redeclare package Medium = MediumAir, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") annotation ( + Placement(transformation( + extent={{11,10},{-11,-10}}, + rotation=0, + origin={-91,-76}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm5( + redeclare package Medium = MediumAir, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={-144,-76}))); + Boundaries.Source sourceB1( + redeclare package Medium = MediumRefrigerant, + setEnthalpy=true, + temperatureFromInput=false, + T0_par=283.15, + p0_par=400000, + h0_par=300e3) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=0, + origin={-180,-50}))); + Boundaries.Sink sinkB1( + redeclare package Medium = MediumRefrigerant, + pressureFromInput=false, + p0_par(displayUnit="bar") = 300000) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=0, + origin={-24,-50}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm6( + redeclare package Medium = MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{-96,-50},{-76,-30}}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm7( + redeclare package Medium = MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{-160,-50},{-140,-30}}))); + DiscretizedCounterFlowHEX_FR + evaporator1( + redeclare package MediumA = MediumAir, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementA = Internal.ConductionElementHEX (U_nom=4000), + redeclare model ConductionElementB = Internal.ConductionElementHEX_twoPhase ( + U_liq_nom=1000, + U_vap_nom=1400, + U_tp_nom=3000), + nCells=nCells, + A=10, + l_A=nCells*10, + r_A=0.03, + l_B=nCells*10, + r_B=0.03, + k_wall=250) annotation (Placement(transformation( + extent={{10,10},{-10,-10}}, + rotation=180, + origin={-118,-58}))); + Sensors.SingleSensorSelect singleSensorSelect2(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{-96,-36},{-76,-16}}))); + Sensors.SingleSensorSelect singleSensorSelect3(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{-140,-36},{-160,-16}}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality2(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{-140,-26},{-160,-6}}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality3(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{-96,-26},{-76,-6}}))); + FlowControl.MCV mCV2( + redeclare package Medium = MediumRefrigerant, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + m_flow_0=0, + massFlow_set_par=0.2) annotation (Placement(transformation(extent={{-66,-60},{-46,-40}}))); + FlowControl.MCV mCV3( + redeclare package Medium = MediumAir, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + m_flow_0=0, + massFlow_set_par=1) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={-184,-66}))); + Boundaries.Source sourceA2( + redeclare package Medium = MediumAir, + T0_par=311.15, + p0_par=100000) + annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={46,42}))); + Boundaries.Sink sinkA2(redeclare package Medium = MediumAir, p0_par=90000) + annotation (Placement(transformation(extent={{200,32},{220,52}}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm8( + redeclare package Medium = MediumAir, + temperatureUnit="degC", + pressureUnit="bar") annotation ( + Placement(transformation( + extent={{-11,-10},{11,10}}, + rotation=0, + origin={99,52}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm9( + redeclare package Medium = MediumAir, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") annotation (Placement(transformation( + extent={{10,10},{-10,-10}}, + rotation=180, + origin={154,52}))); + Boundaries.Source sourceB2( + redeclare package Medium = MediumRefrigerant, + setEnthalpy=true, + temperatureFromInput=false, + T0_par=283.15, + p0_par=3200000, + h0_par=450e3) + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=0, + origin={188,94}))); + Boundaries.Sink sinkB2( + redeclare package Medium = MediumRefrigerant, + pressureFromInput=false, + p0_par(displayUnit="bar") = 3000000) + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=0, + origin={56,14}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm10( + redeclare package Medium = MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{-10,10},{10,-10}}, + rotation=180, + origin={114,24}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm11( + redeclare package Medium = MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=90, + origin={122,76}))); + DiscretizedCrossFlowHEX condenser( + redeclare package MediumA = MediumAir, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementA = Internal.ConductionElementHEX, + redeclare model ConductionElementB = Internal.ConductionElementHEX_twoPhase, + initializeMassFlow=true, + nCells=nCells, + k_wall=150) annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=90, + origin={124,42}))); + Processes.FlowResistance flowResistanceA( + redeclare package Medium = MediumAir, + m_flow_0=0.5, + r=0.05, + l=1, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarTurbulentPressureLoss (material=ThermofluidStream.Processes.Internal.Material.steel)) + annotation (Placement(transformation(extent={{62,32},{82,52}}))); + Processes.FlowResistance flowResistanceB( + redeclare package Medium = MediumRefrigerant, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.none, + m_flow_0=0.3, + r=0.05, + l=1, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarTurbulentPressureLoss (material=ThermofluidStream.Processes.Internal.Material.steel)) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={88,14}))); + Sensors.SingleSensorSelect singleSensorSelect4(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=180, + origin={150,22}))); + Sensors.SingleSensorSelect singleSensorSelect5(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=270, + origin={108,76}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality4(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=180, + origin={150,14}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality5(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=270, + origin={100,76}))); + FlowControl.MCV mCV4( + redeclare package Medium = MediumAir, + m_flow_0=0, + massFlow_set_par=1) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={180,42}))); + FlowControl.MCV mCV5( + redeclare package Medium = MediumRefrigerant, + m_flow_0=1, + massFlow_set_par=0.3) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=0, + origin={156,94}))); + Boundaries.Source sourceA3( + redeclare package Medium = MediumAir, + T0_par=311.15, + p0_par=100000) + annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={28,-62}))); + Boundaries.Sink sinkA3(redeclare package Medium = MediumAir, p0_par=90000) + annotation (Placement(transformation(extent={{182,-72},{202,-52}}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm12( + redeclare package Medium = MediumAir, + temperatureUnit="degC", + pressureUnit="bar") annotation ( + Placement(transformation( + extent={{-11,-10},{11,10}}, + rotation=0, + origin={81,-52}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm13( + redeclare package Medium = MediumAir, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") annotation (Placement(transformation( + extent={{10,10},{-10,-10}}, + rotation=180, + origin={136,-52}))); + Boundaries.Source sourceB3( + redeclare package Medium = MediumRefrigerant, + setEnthalpy=true, + temperatureFromInput=false, + T0_par=283.15, + p0_par=3200000, + h0_par=450e3) + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=0, + origin={170,-10}))); + Boundaries.Sink sinkB3( + redeclare package Medium = MediumRefrigerant, + pressureFromInput=false, + p0_par(displayUnit="bar") = 3000000) + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=0, + origin={38,-90}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm14( + redeclare package Medium = MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{-10,10},{10,-10}}, + rotation=180, + origin={96,-80}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm15( + redeclare package Medium = MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=90, + origin={104,-28}))); + DiscretizedCrossFlowHEX_FR condenser1( + redeclare package MediumA = MediumAir, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementA = Internal.ConductionElementHEX, + redeclare model ConductionElementB = Internal.ConductionElementHEX_twoPhase, + initializeMassFlow=true, + nCells=nCells, + l_A=10, + r_A=nCells*0.01, + l_B=nCells*10, + r_B=0.003, + k_wall=150) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={106,-62}))); + Processes.FlowResistance flowResistanceA1( + redeclare package Medium = MediumAir, + m_flow_0=0.5, + r=0.05, + l=1, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarTurbulentPressureLoss (material=ThermofluidStream.Processes.Internal.Material.steel)) + annotation (Placement(transformation(extent={{44,-72},{64,-52}}))); + Processes.FlowResistance flowResistanceB1( + redeclare package Medium = MediumRefrigerant, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.none, + m_flow_0=0.3, + r=0.05, + l=1, + redeclare function pLoss = Processes.Internal.FlowResistance.laminarTurbulentPressureLoss (material=ThermofluidStream.Processes.Internal.Material.steel)) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={70,-90}))); + Sensors.SingleSensorSelect singleSensorSelect6(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=180, + origin={132,-82}))); + Sensors.SingleSensorSelect singleSensorSelect7(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=270, + origin={90,-28}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality6(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=180, + origin={132,-90}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality7(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=270, + origin={82,-28}))); + FlowControl.MCV mCV6( + redeclare package Medium = MediumAir, + m_flow_0=0, + massFlow_set_par=1) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=180, + origin={162,-62}))); + FlowControl.MCV mCV7( + redeclare package Medium = MediumRefrigerant, + m_flow_0=1, + massFlow_set_par=0.3) annotation (Placement(transformation( + extent={{10,-10},{-10,10}}, + rotation=0, + origin={138,-10}))); +equation + connect(sourceB.outlet, multiSensor_Tpm3.inlet) annotation (Line( + points={{-172,50},{-162,50}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm.outlet, evaporator.inletA) + annotation (Line( + points={{-104,34},{-110,34}}, + color={28,108,200}, + thickness=0.5)); + connect(evaporator.outletA, multiSensor_Tpm1.inlet) + annotation (Line( + points={{-130.2,34},{-136,34}}, + color={28,108,200}, + thickness=0.5)); + connect(evaporator.outletB, multiSensor_Tpm2.inlet) annotation (Line( + points={{-109.8,50},{-98,50}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm3.outlet, evaporator.inletB) annotation (Line( + points={{-142,50},{-130,50}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect.inlet, evaporator.outletB) + annotation (Line( + points={{-98,74},{-102,74},{-102,50},{-109.8,50}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect1.inlet, evaporator.inletB) + annotation (Line( + points={{-142,74},{-138,74},{-138,50},{-130,50}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality.inlet, evaporator.inletB) + annotation (Line( + points={{-142,84},{-134,84},{-134,50},{-130,50}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality1.inlet, evaporator.outletB) + annotation (Line( + points={{-98,84},{-108,84},{-108,50},{-109.8,50}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.inlet, multiSensor_Tpm2.outlet) annotation (Line( + points={{-68,50},{-78,50}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.outlet, sinkB.inlet) annotation (Line( + points={{-48,50},{-36,50}}, + color={28,108,200}, + thickness=0.5)); + connect(sourceA.outlet, multiSensor_Tpm.inlet) annotation (Line( + points={{-60,34},{-82,34}}, + color={28,108,200}, + thickness=0.5)); + connect(sinkA.inlet, mCV1.outlet) annotation (Line( + points={{-202,34},{-196,34}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV1.inlet, multiSensor_Tpm1.outlet) annotation (Line( + points={{-176,34},{-156,34}}, + color={28,108,200}, + thickness=0.5)); + connect(sourceB1.outlet, multiSensor_Tpm7.inlet) annotation (Line( + points={{-170,-50},{-160,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm4.outlet, evaporator1.inletA) annotation (Line( + points={{-102,-66},{-108,-66}}, + color={28,108,200}, + thickness=0.5)); + connect(evaporator1.outletA, multiSensor_Tpm5.inlet) + annotation (Line( + points={{-128.2,-66},{-134,-66}}, + color={28,108,200}, + thickness=0.5)); + connect(evaporator1.outletB, multiSensor_Tpm6.inlet) + annotation (Line( + points={{-107.8,-50},{-96,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm7.outlet, evaporator1.inletB) + annotation (Line( + points={{-140,-50},{-128,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect2.inlet, evaporator1.outletB) + annotation (Line( + points={{-96,-26},{-100,-26},{-100,-50},{-107.8,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect3.inlet, evaporator1.inletB) + annotation (Line( + points={{-140,-26},{-136,-26},{-136,-50},{-128,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality2.inlet, evaporator1.inletB) + annotation (Line( + points={{-140,-16},{-132,-16},{-132,-50},{-128,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality3.inlet, evaporator1.outletB) + annotation (Line( + points={{-96,-16},{-106,-16},{-106,-50},{-107.8,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV2.inlet, multiSensor_Tpm6.outlet) annotation (Line( + points={{-66,-50},{-76,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV2.outlet, sinkB1.inlet) annotation (Line( + points={{-46,-50},{-34,-50}}, + color={28,108,200}, + thickness=0.5)); + connect(sourceA1.outlet, multiSensor_Tpm4.inlet) annotation (Line( + points={{-58,-66},{-80,-66}}, + color={28,108,200}, + thickness=0.5)); + connect(sinkA1.inlet, mCV3.outlet) annotation (Line( + points={{-200,-66},{-194,-66}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV3.inlet, multiSensor_Tpm5.outlet) annotation (Line( + points={{-174,-66},{-154,-66}}, + color={28,108,200}, + thickness=0.5)); + connect(sourceA2.outlet, flowResistanceA.inlet) annotation (Line( + points={{56,42},{62,42}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm8.inlet, flowResistanceA.outlet) annotation (Line( + points={{88,42},{82,42}}, + color={28,108,200}, + thickness=0.5)); + connect(sinkB2.inlet, flowResistanceB.outlet) annotation (Line( + points={{66,14},{78,14}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistanceB.inlet, multiSensor_Tpm10.outlet) + annotation (Line( + points={{98,14},{104,14}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect5.inlet, multiSensor_Tpm11.inlet) + annotation (Line( + points={{108,86},{108,92},{132,92},{132,86}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality5.inlet, multiSensor_Tpm11.inlet) + annotation (Line( + points={{100,86},{100,92},{132,92},{132,86}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality4.inlet, multiSensor_Tpm10.inlet) + annotation (Line( + points={{140,14},{124,14}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect4.inlet, multiSensor_Tpm10.inlet) + annotation (Line( + points={{140,22},{132,22},{132,14},{124,14}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm8.outlet, condenser.inletA) annotation (Line( + points={{110,42},{114,42}}, + color={28,108,200}, + thickness=0.5)); + connect(condenser.outletA,multiSensor_Tpm9. inlet) + annotation (Line( + points={{134,42},{144,42}}, + color={28,108,200}, + thickness=0.5)); + connect(condenser.outletB, multiSensor_Tpm10.inlet) + annotation (Line( + points={{132,31.8},{132,14},{124,14}}, + color={28,108,200}, + thickness=0.5)); + connect(condenser.inletB, multiSensor_Tpm11.outlet) annotation (Line( + points={{132,52},{132,66}}, + color={28,108,200}, + thickness=0.5)); + connect(sourceB2.outlet, mCV5.inlet) annotation (Line( + points={{178,94},{166,94}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV5.outlet, multiSensor_Tpm11.inlet) + annotation (Line( + points={{146,94},{132,94},{132,86}}, + color={28,108,200}, + thickness=0.5)); + connect(sinkA2.inlet, mCV4.outlet) annotation (Line( + points={{200,42},{190,42}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV4.inlet, multiSensor_Tpm9.outlet) annotation (Line( + points={{170,42},{164,42}}, + color={28,108,200}, + thickness=0.5)); + connect(sourceA3.outlet, flowResistanceA1.inlet) annotation (Line( + points={{38,-62},{44,-62}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm12.inlet, flowResistanceA1.outlet) + annotation (Line( + points={{70,-62},{64,-62}}, + color={28,108,200}, + thickness=0.5)); + connect(sinkB3.inlet, flowResistanceB1.outlet) annotation (Line( + points={{48,-90},{60,-90}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistanceB1.inlet, multiSensor_Tpm14.outlet) + annotation (Line( + points={{80,-90},{86,-90}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect7.inlet, multiSensor_Tpm15.inlet) + annotation (Line( + points={{90,-18},{90,-12},{114,-12},{114,-18}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality7.inlet, multiSensor_Tpm15.inlet) + annotation (Line( + points={{82,-18},{82,-12},{114,-12},{114,-18}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality6.inlet, multiSensor_Tpm14.inlet) + annotation (Line( + points={{122,-90},{106,-90}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect6.inlet, multiSensor_Tpm14.inlet) + annotation (Line( + points={{122,-82},{114,-82},{114,-90},{106,-90}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm12.outlet, condenser1.inletA) annotation (Line( + points={{92,-62},{96,-62}}, + color={28,108,200}, + thickness=0.5)); + connect(condenser1.outletA, multiSensor_Tpm13.inlet) + annotation (Line( + points={{116,-62},{120,-62},{120,-62},{126,-62}}, + color={28,108,200}, + thickness=0.5)); + connect(condenser1.outletB, multiSensor_Tpm14.inlet) + annotation (Line( + points={{114,-72.2},{114,-90},{106,-90}}, + color={28,108,200}, + thickness=0.5)); + connect(condenser1.inletB, multiSensor_Tpm15.outlet) + annotation (Line( + points={{114,-52},{114,-38}}, + color={28,108,200}, + thickness=0.5)); + connect(sourceB3.outlet, mCV7.inlet) annotation (Line( + points={{160,-10},{148,-10}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV7.outlet, multiSensor_Tpm15.inlet) + annotation (Line( + points={{128,-10},{114,-10},{114,-18}}, + color={28,108,200}, + thickness=0.5)); + connect(sinkA3.inlet, mCV6.outlet) annotation (Line( + points={{182,-62},{172,-62}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV6.inlet, multiSensor_Tpm13.outlet) annotation (Line( + points={{152,-62},{146,-62}}, + color={28,108,200}, + thickness=0.5)); + annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio= + false, extent={{-160,-100},{160,100}})), + experiment( + StopTime=10, + Tolerance=1e-6, + Interval=0.01, + __Dymola_Algorithm="Dassl"), + Documentation(info=" +

Owner: Niels Weber

+")); +end FlowRes; diff --git a/ThermofluidStream/HeatExchangers/Tests/Recuperator.mo b/ThermofluidStream/HeatExchangers/Tests/Recuperator.mo new file mode 100644 index 00000000..6c1e41b0 --- /dev/null +++ b/ThermofluidStream/HeatExchangers/Tests/Recuperator.mo @@ -0,0 +1,188 @@ +within ThermofluidStream.HeatExchangers.Tests; +model Recuperator + extends Modelica.Icons.Example; + + replaceable package MediumRefrigerant = Media.myMedia.R134a.R134a_ph + constrainedby Media.myMedia.Interfaces.PartialMedium + annotation(choicesAllMatching = true); + + + ThermofluidStream.Boundaries.Source sourceB( + redeclare package Medium = MediumRefrigerant, + setEnthalpy=true, + temperatureFromInput=false, + pressureFromInput=false, + T0_par=283.15, + p0_par=500000, + h0_par=300e3) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=0, + origin={-92,10}))); + + ThermofluidStream.Boundaries.Sink sinkB( + redeclare package Medium = MediumRefrigerant, + pressureFromInput=false, + p0_par(displayUnit="bar") = 400000) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=180, + origin={-60,-6}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm2(redeclare package Medium = + MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{24,10},{44,30}}))); + ThermofluidStream.Sensors.MultiSensor_Tpm multiSensor_Tpm3(redeclare package Medium = + MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{-40,10},{-20,30}}))); + inner DropOfCommons dropOfCommons + annotation (Placement(transformation(extent={{132,-64},{152,-44}}))); + DiscretizedCounterFlowHEX evaporator( + redeclare package MediumA = MediumRefrigerant, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementA = Internal.ConductionElementHEX_twoPhase, + redeclare model ConductionElementB = Internal.ConductionElementHEX_twoPhase, + initializeMassFlow=false, + nCells=20, + A=10, + k_wall=250) annotation (Placement(transformation(extent={{10,12},{-10,-8}}))); + + FlowControl.PCV pCV( + redeclare package Medium = MediumRefrigerant, + m_flow_0=0.3, + pressure_set_par=50000) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=270, + origin={68,0}))); + Sensors.SingleSensorSelect singleSensorSelect(redeclare package Medium = + MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{24,44},{44,24}}))); + Sensors.SingleSensorSelect singleSensorSelect1(redeclare package Medium = + MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{-20,44},{-40,24}}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality(redeclare package Medium = + MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{-20,32},{-40,52}}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality1(redeclare package Medium = + MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{24,32},{44,52}}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm1( + redeclare package Medium = MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{-22,-6},{-42,-26}}))); + Sensors.SingleSensorSelect singleSensorSelect2(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{-22,-18},{-42,-38}}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality2(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{-22,-46},{-42,-26}}))); + Sensors.MultiSensor_Tpm multiSensor_Tpm4( + redeclare package Medium = MediumRefrigerant, + digits=3, + temperatureUnit="degC", + pressureUnit="bar") + annotation (Placement(transformation(extent={{44,-6},{24,-26}}))); + Sensors.SingleSensorSelect singleSensorSelect3(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.Quantities.h_Jpkg) + annotation (Placement(transformation(extent={{44,-28},{24,-48}}))); + Sensors.TwoPhaseSensorSelect sensorVaporQuality3(redeclare package Medium = MediumRefrigerant, quantity=ThermofluidStream.Sensors.Internal.Types.TwoPhaseQuantities.x_kgpkg) + annotation (Placement(transformation(extent={{44,-40},{24,-20}}))); + FlowControl.MCV mCV( + redeclare package Medium = MediumRefrigerant, + initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, + m_flow_0=0.2, + massFlow_set_par=0.2) annotation (Placement(transformation(extent={{-76,0},{-56,20}}))); +equation + connect(pCV.inlet, multiSensor_Tpm2.outlet) + annotation (Line( + points={{68,10},{68,16},{50,16},{50,10},{44,10}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality1.inlet, multiSensor_Tpm2.inlet) + annotation (Line( + points={{24,42},{20,42},{20,10},{24,10}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect.inlet, multiSensor_Tpm2.inlet) + annotation (Line( + points={{24,34},{20,34},{20,10},{24,10}}, + color={28,108,200}, + thickness=0.5)); + connect(pCV.outlet, multiSensor_Tpm4.inlet) + annotation (Line( + points={{68,-10},{68,-14},{52,-14},{52,-6},{44,-6}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm4.outlet, evaporator.inletB) annotation (Line( + points={{24,-6},{10,-6}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality3.inlet, multiSensor_Tpm4.inlet) + annotation (Line( + points={{44,-30},{52,-30},{52,-6},{44,-6}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect3.inlet, multiSensor_Tpm4.inlet) + annotation (Line( + points={{44,-38},{52,-38},{52,-6},{44,-6}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm1.inlet, evaporator.outletB) annotation (Line( + points={{-22,-6},{-10.2,-6}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect2.inlet, evaporator.outletB) + annotation (Line( + points={{-22,-28},{-18,-28},{-18,-6},{-10.2,-6}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality2.inlet, evaporator.outletB) + annotation (Line( + points={{-22,-36},{-18,-36},{-18,-6},{-10.2,-6}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm1.outlet, sinkB.inlet) + annotation (Line( + points={{-42,-6},{-46,-6},{-46,-6},{-50,-6}}, + color={28,108,200}, + thickness=0.5)); + connect(sourceB.outlet, mCV.inlet) annotation (Line( + points={{-82,10},{-76,10}}, + color={28,108,200}, + thickness=0.5)); + connect(mCV.outlet, multiSensor_Tpm3.inlet) annotation (Line( + points={{-56,10},{-40,10}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm3.outlet, evaporator.inletA) annotation (Line( + points={{-20,10},{-10,10}}, + color={28,108,200}, + thickness=0.5)); + connect(evaporator.outletA, multiSensor_Tpm2.inlet) annotation (Line( + points={{10.2,10},{24,10}}, + color={28,108,200}, + thickness=0.5)); + connect(singleSensorSelect1.inlet, evaporator.inletA) + annotation (Line( + points={{-20,34},{-16,34},{-16,10},{-10,10}}, + color={28,108,200}, + thickness=0.5)); + connect(sensorVaporQuality.inlet, evaporator.inletA) + annotation (Line( + points={{-20,42},{-16,42},{-16,10},{-10,10}}, + color={28,108,200}, + thickness=0.5)); + annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio= + false, extent={{-160,-100},{160,100}})), + experiment( + StopTime=10, + Tolerance=1e-6, + Interval=0.01, + __Dymola_Algorithm="Dassl"), + Documentation(info=" +


Owner: Michael Meißner

+")); +end Recuperator; diff --git a/ThermofluidStream/HeatExchangers/Tests/package.order b/ThermofluidStream/HeatExchangers/Tests/package.order index 8f3bbe82..3e359ad6 100644 --- a/ThermofluidStream/HeatExchangers/Tests/package.order +++ b/ThermofluidStream/HeatExchangers/Tests/package.order @@ -7,3 +7,5 @@ CrossFlowNTU_zeroMassFlow Condenser Evaporator ElementTwoPhase +Recuperator +FlowRes diff --git a/ThermofluidStream/HeatExchangers/package.order b/ThermofluidStream/HeatExchangers/package.order index fb7c0d3a..6afadb9f 100644 --- a/ThermofluidStream/HeatExchangers/package.order +++ b/ThermofluidStream/HeatExchangers/package.order @@ -1,5 +1,8 @@ CounterFlowNTU CrossFlowNTU -DiscretizedHEX +DiscretizedCrossFlowHEX +DiscretizedCounterFlowHEX +DiscretizedCrossFlowHEX_FR +DiscretizedCounterFlowHEX_FR Tests Internal diff --git a/ThermofluidStream/Media/Tests/TestXRGMedia.mo b/ThermofluidStream/Media/Tests/TestXRGMedia.mo index ef2865a5..0ebfc052 100644 --- a/ThermofluidStream/Media/Tests/TestXRGMedia.mo +++ b/ThermofluidStream/Media/Tests/TestXRGMedia.mo @@ -4,18 +4,34 @@ model TestXRGMedia "Test for five XRG Media with various components" inner DropOfCommons dropOfCommons(assertionLevel = AssertionLevel.warning) annotation (Placement(transformation(extent={{-130,-68},{-110,-48}}))); - HeatExchangers.DiscretizedHEX discretizedHEX(redeclare package MediumAir = XRGMedia.R134a_ph, redeclare package MediumRefrigerant = - XRGMedia.NH3_ph, - initializeMassFlow=true, - m_flow_0=0) annotation (Placement(transformation(extent={{-28,62},{-8,82}}))); - HeatExchangers.DiscretizedHEX discretizedHEX1(redeclare package MediumAir = XRGMedia.NH3_ph, redeclare package MediumRefrigerant = - XRGMedia.CO2_ph, - initializeMassFlow=false) - annotation (Placement(transformation(extent={{40,46},{20,66}}))); - HeatExchangers.DiscretizedHEX discretizedHEX2(redeclare package MediumAir = XRGMedia.CO2_ph, redeclare package MediumRefrigerant = - XRGMedia.R134a_ph, - initializeMassFlow=true, - m_flow_0=0) annotation (Placement(transformation(extent={{-28,30},{-8,50}}))); + HeatExchangers.DiscretizedCounterFlowHEX + discretizedHEX( + redeclare package MediumA = XRGMedia.R134a_ph, + redeclare package MediumB = XRGMedia.NH3_ph, + redeclare model ConductionElementA = HeatExchangers.Internal.ConductionElementHEX, + redeclare model ConductionElementB = HeatExchangers.Internal.ConductionElementHEX_twoPhase, + initializeMassFlow=true) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=180, + origin={-18,72}))); + HeatExchangers.DiscretizedCounterFlowHEX + discretizedHEX1( + redeclare package MediumA = XRGMedia.NH3_ph, + redeclare package MediumB = XRGMedia.CO2_ph, + redeclare model ConductionElementA = HeatExchangers.Internal.ConductionElementHEX, + redeclare model ConductionElementB = HeatExchangers.Internal.ConductionElementHEX_twoPhase, + initializeMassFlow=false) annotation (Placement(transformation(extent={{10,-10},{-10,10}}, + rotation=180, + origin={30,56}))); + HeatExchangers.DiscretizedCounterFlowHEX + discretizedHEX2( + redeclare package MediumA = XRGMedia.CO2_ph, + redeclare package MediumB = XRGMedia.R134a_ph, + redeclare model ConductionElementB = HeatExchangers.Internal.ConductionElementHEX_twoPhase, + initializeMassFlow=true) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=180, + origin={-18,40}))); HeatExchangers.CounterFlowNTU counterFlowNTU( redeclare package MediumA = XRGMedia.R1234yf_ph, redeclare package MediumB = XRGMedia.R134a_ph, @@ -28,10 +44,15 @@ model TestXRGMedia "Test for five XRG Media with various components" p_start=200000, V_par=0.1) annotation (Placement(transformation(extent={{102,54},{82,74}}))); Boundaries.Sink sink1(redeclare package Medium = XRGMedia.NH3_ph) annotation (Placement(transformation(extent={{-38,54},{-58,74}}))); - HeatExchangers.DiscretizedHEX discretizedHEX4(redeclare package MediumAir = XRGMedia.R1234yf_ph, redeclare package MediumRefrigerant = - XRGMedia.R134a_ph, - initializeMassFlow=true, - m_flow_0=0) annotation (Placement(transformation(extent={{-44,-2},{-24,18}}))); + HeatExchangers.DiscretizedCounterFlowHEX + discretizedHEX4( + redeclare package MediumA = XRGMedia.R1234yf_ph, + redeclare package MediumB = XRGMedia.R134a_ph, + redeclare model ConductionElementB = HeatExchangers.Internal.ConductionElementHEX_twoPhase, + initializeMassFlow=true) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=180, + origin={-34,8}))); Boundaries.Sink sink2(redeclare package Medium = XRGMedia.CO2_ph) annotation (Placement(transformation(extent={{84,38},{104,58}}))); Boundaries.Source source1(redeclare package Medium = XRGMedia.CO2_ph, p0_par=130000) annotation (Placement(transformation(extent={{-86,38},{-66,58}}))); @@ -159,30 +180,28 @@ model TestXRGMedia "Test for five XRG Media with various components" rotation=180, origin={86,32}))); equation - connect(discretizedHEX.inletRef, discretizedHEX1.outletAir) + connect(discretizedHEX.inletB, discretizedHEX1.outletA) annotation (Line( - points={{-8,64},{19.8,64}}, + points={{-8,64},{12,64},{12,64},{19.8,64}}, color={28,108,200}, thickness=0.5)); - connect(source.outlet, discretizedHEX.inletAir) annotation (Line( - points={{-54,80},{-28,80}}, + connect(source.outlet, discretizedHEX.inletA) annotation (Line( + points={{-54,80},{-36,80},{-36,80},{-28,80}}, color={28,108,200}, thickness=0.5)); - connect(sink1.inlet, discretizedHEX.outletRef) annotation (Line( + connect(sink1.inlet, discretizedHEX.outletB) annotation (Line( points={{-38,64},{-28.2,64}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX1.inletRef, volumeFlex.outlet) annotation (Line( + connect(discretizedHEX1.inletB, volumeFlex.outlet) annotation (Line( points={{20,48},{16,48}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX2.outletAir, volumeFlex.inlet) - annotation (Line( - points={{-7.8,48},{-4,48}}, + connect(discretizedHEX2.outletA, volumeFlex.inlet) annotation (Line( + points={{-7.8,48},{-12,48},{-12,48},{-4,48}}, color={28,108,200}, thickness=0.5)); - connect(receiver.inlet, discretizedHEX2.outletRef) - annotation (Line( + connect(receiver.inlet, discretizedHEX2.outletB) annotation (Line( points={{-36,32},{-28.2,32}}, color={28,108,200}, thickness=0.5)); @@ -190,18 +209,17 @@ equation points={{82,64},{72,64}}, color={28,108,200}, thickness=0.5)); - connect(flowResistance1.outlet, discretizedHEX1.inletAir) - annotation (Line( - points={{52,64},{40,64}}, + connect(flowResistance1.outlet, discretizedHEX1.inletA) annotation (Line( + points={{52,64},{42,64},{42,64},{40,64}}, color={28,108,200}, thickness=0.5)); connect(source1.outlet, flowResistance2.inlet) annotation (Line( points={{-66,48},{-60,48}}, color={28,108,200}, thickness=0.5)); - connect(flowResistance2.outlet, discretizedHEX2.inletAir) + connect(flowResistance2.outlet, discretizedHEX2.inletA) annotation (Line( - points={{-40,48},{-28,48}}, + points={{-40,48},{-30,48},{-30,48},{-28,48}}, color={28,108,200}, thickness=0.5)); connect(sink2.inlet, flowResistance3.outlet) annotation (Line( @@ -213,9 +231,9 @@ equation points={{66,0},{44,0}}, color={28,108,200}, thickness=0.5)); - connect(conductionElement.outlet, discretizedHEX4.inletRef) + connect(conductionElement.outlet, discretizedHEX4.inletB) annotation (Line( - points={{24,0},{-24,0}}, + points={{24,0},{-10,0},{-10,-1.77636e-15},{-24,-1.77636e-15}}, color={28,108,200}, thickness=0.5)); connect(flowResistance5.outlet, junctionT2_1.inletA) @@ -223,20 +241,20 @@ equation points={{-128,32},{-132,32},{-132,10}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX4.outletRef, junctionT2_1.inletB) + connect(discretizedHEX4.outletB, junctionT2_1.inletB) annotation (Line( - points={{-44.2,0},{-122,0}}, + points={{-44.2,0},{-72,0},{-72,0},{-122,0}}, color={28,108,200}, thickness=0.5)); connect(junctionT2_1.outlet, sink3.inlet) annotation (Line( points={{-142,0},{-156,0}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX4.outletAir, nozzle.inlet) annotation (Line( - points={{-23.8,16},{-14,16}}, + connect(discretizedHEX4.outletA, nozzle.inlet) annotation (Line( + points={{-23.8,16},{-24,16},{-24,16},{-14,16}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX.outletAir, splitterT2_1.inlet) + connect(discretizedHEX.outletA, splitterT2_1.inlet) annotation (Line( points={{-7.8,80},{142,80},{142,42}}, color={28,108,200}, @@ -246,9 +264,9 @@ equation points={{142,22},{142,0},{86,0}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX1.outletRef, flowResistance3.inlet) + connect(discretizedHEX1.outletB, flowResistance3.inlet) annotation (Line( - points={{40.2,48},{58,48}}, + points={{40.2,48},{38,48},{38,48},{58,48}}, color={28,108,200}, thickness=0.5)); connect(dynamicPressureOutflow.outlet, flowResistance6.inlet) @@ -260,9 +278,9 @@ equation points={{112,16},{100,16}}, color={28,108,200}, thickness=0.5)); - connect(dynamicPressureInflow.outlet, discretizedHEX4.inletAir) + connect(dynamicPressureInflow.outlet, discretizedHEX4.inletA) annotation (Line( - points={{-54,16},{-44,16}}, + points={{-54,16},{-44,16},{-44,16},{-44,16}}, color={28,108,200}, thickness=0.5)); connect(source2.outlet, dynamicPressureInflow.inlet) @@ -303,7 +321,7 @@ equation points={{132,32},{96,32}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX2.inletRef, counterFlowNTU.outletB) + connect(discretizedHEX2.inletB, counterFlowNTU.outletB) annotation (Line( points={{-8,32},{6,32},{6,30},{19,30}}, color={28,108,200}, diff --git a/ThermofluidStream/Processes/Internal/PartialConductionElement.mo b/ThermofluidStream/Processes/Internal/PartialConductionElement.mo index d3403720..437c1726 100644 --- a/ThermofluidStream/Processes/Internal/PartialConductionElement.mo +++ b/ThermofluidStream/Processes/Internal/PartialConductionElement.mo @@ -3,7 +3,7 @@ partial model PartialConductionElement "Element with quasi-stationary mass and h extends Interfaces.SISOFlow(final clip_p_out=false); parameter SI.Volume V(displayUnit="l")=0.001 "Volume of the element"; - parameter Internal.InitializationMethodsCondElement init=Internal.InitializationMethodsCondElement.inlet "Initialization method for h" + parameter Internal.InitializationMethodsCondElement init=ThermofluidStream.Processes.Internal.InitializationMethodsCondElement.inlet "Initialization method for h" annotation (Dialog(tab="Initialization", group="Enthalpy")); parameter Medium.Temperature T_0 = Medium.T_default "Initial Temperature" annotation(Dialog(tab="Initialization", group="Enthalpy", enable=(init == Internal.InitializationMethodsCondElement.T))); @@ -73,7 +73,11 @@ equation //neglegt V*der(p), since p might not be smooth -> to notice a difference der(p) must be about 1e7 Pa/s. see documentation/information M*der(h) = Q_flow + m_flow*(h_in_norm - h)+ (if enforce_global_energy_conservation then deltaE_system/T_e else 0); end if; - der(deltaE_system) = Q_flow + m_flow*(h_in_norm - h); + if enforce_global_energy_conservation then + der(deltaE_system) = Q_flow + m_flow*(h_in_norm - h); + else + deltaE_system = 0; + end if; Q_flow = k*(T_heatPort - T); diff --git a/ThermofluidStream/Resources/ConversionSkripts/convert0_2_1to0_3_0.mos b/ThermofluidStream/Resources/ConversionSkripts/convert0_2_1to0_3_0.mos new file mode 100644 index 00000000..90b8fac7 --- /dev/null +++ b/ThermofluidStream/Resources/ConversionSkripts/convert0_2_1to0_3_0.mos @@ -0,0 +1,33 @@ +// changes to the heat discretized exchanger +convertClass("ThermofluidStream.HeatExchangers.DiscretizedHEX","ThermofluidStream.HeatExchangers.DiscretizedCounterFlowHEX"); +convertElement("ThermofluidStream.HeatExchangers.DiscretizedHEX","inletAir","inletB"); +convertElement("ThermofluidStream.HeatExchangers.DiscretizedHEX","outletAir","outletB"); +convertElement("ThermofluidStream.HeatExchangers.DiscretizedHEX","inletRef","inletA"); +convertElement("ThermofluidStream.HeatExchangers.DiscretizedHEX","outletRef","outletA"); +convertElement("ThermofluidStream.HeatExchangers.DiscretizedHEX","MediumAir","MediumB"); +convertElement("ThermofluidStream.HeatExchangers.DiscretizedHEX","MediumRefrigerant","MediumA"); +convertElement("ThermofluidStream.HeatExchangers.DiscretizedHEX","Q_flow_ref","Q_flow_A"); +convertElement("ThermofluidStream.HeatExchangers.DiscretizedHEX","Q_flow_air","Q_flow_B"); +convertElement("ThermofluidStream.HeatExchangers.DiscretizedHEX","M_ref","M_B"); +convertModifiers("ThermofluidStream.HeatExchangers.DiscretizedHEX",{"m_flow_0"},{"m_flow_0_A=%m_flow_0%", "m_flow_0_B=%m_flow_0%"},false); +convertModifiers("ThermofluidStream.HeatExchangers.DiscretizedHEX",fill("",0),{"redeclare model ConductionElementA = ThermofluidStream.HeatExchangers.Internal.ConductionElementHEX_twoPhase","redeclare model ConductionElementB = ThermofluidStream.HeatExchangers.Internal.ConductionElementHEX"} ,false); +convertModifiers("ThermofluidStream.HeatExchangers.DiscretizedHEX",{"U_nom", "U_liq_nom", "U_vap_nom", "U_tp_nom", "m_flow_nom_ref", "m_flow_nom_air"},{"ConductionElementA(U_liq_nom=%U_liq_nom%, U_vap_nom=%U_vap_nom%, U_tp_nom=%U_tp_nom%, m_flow_nom=%m_flow_nom_ref%)", "ConductionElementB(m_flow_nom=%m_flow_nom_air%, U_nom=%U_nom%)"} ,true); +// changes to the undi discretized heat exchanger +convertClass("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX","ThermofluidStream.Undirected.HeatExchangers.DiscretizedCounterFlowHEX"); +convertElement("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX","rearAir","rearB"); +convertElement("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX","foreAir","foreB"); +convertElement("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX","rearRef","rearA"); +convertElement("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX","foreRef","foreA"); +convertElement("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX","MediumAir","MediumB"); +convertElement("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX","MediumRefrigerant","MediumA"); +convertElement("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX","Q_flow_ref","Q_flow_A"); +convertElement("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX","Q_flow_air","Q_flow_B"); +convertElement("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX","M_ref","M_B"); +convertModifiers("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX",{"m_flow_0"},{"m_flow_0_A=%m_flow_0%", "m_flow_0_B=%m_flow_0%"},false); +convertModifiers("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX",{"initRef"},{"init_A=%initRef%", "init_B=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.rear"},false); +convertModifiers("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX",{"h0"},{"h0_A=%h0%"},false); +convertModifiers("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX",fill("",0),{"redeclare model ConductionElementA = ThermofluidStream.Undirected.HeatExchangers.Internal.ConductionElementHEX_twoPhase","redeclare model ConductionElementB = ThermofluidStream.Undirected.HeatExchangers.Internal.ConductionElementHEX"} ,false); +convertModifiers("ThermofluidStream.Undirected.HeatExchangers.DiscretizedHEX",{"U_nom", "U_liq_nom", "U_vap_nom", "U_tp_nom", "m_flow_nom_ref", "m_flow_nom_air"},{"ConductionElementA(U_liq_nom=%U_liq_nom%, U_vap_nom=%U_vap_nom%, U_tp_nom=%U_tp_nom%, m_flow_nom=%m_flow_nom_ref%)", "ConductionElementB(m_flow_nom=%m_flow_nom_air%, U_nom=%U_nom%)"} ,true); + + + diff --git a/ThermofluidStream/Undirected/Boundaries/Internal/PartialVolume.mo b/ThermofluidStream/Undirected/Boundaries/Internal/PartialVolume.mo index 472c460c..8bb071d9 100644 --- a/ThermofluidStream/Undirected/Boundaries/Internal/PartialVolume.mo +++ b/ThermofluidStream/Undirected/Boundaries/Internal/PartialVolume.mo @@ -40,10 +40,10 @@ partial model PartialVolume "Partial parent class for Volumes with one fore and Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort(Q_flow=Q_flow, T=T_heatPort) if useHeatport annotation (Placement(transformation(extent={{-10,-90},{10,-70}}))); - Interfaces.Rear rear(redeclare package Medium=Medium, m_flow=m_flow_rear, r=r_rear_port, state_rearwards=state_out, state_forwards=state_in_rear) if useRear + Interfaces.Rear rear(redeclare package Medium=Medium, m_flow=m_flow_rear, r=r_rear_port, state_rearwards=state_out_rear, state_forwards=state_in_rear) if useRear annotation (Placement(transformation(extent={{-120,-20},{-80,20}}), iconTransformation(extent={{-120,-20},{-80,20}}))); - Interfaces.Fore fore(redeclare package Medium=Medium, m_flow=m_flow_fore, r=r_fore_port, state_forwards=state_out, state_rearwards=state_in_fore) if useFore + Interfaces.Fore fore(redeclare package Medium=Medium, m_flow=m_flow_fore, r=r_fore_port, state_forwards=state_out_fore, state_rearwards=state_in_fore) if useFore annotation (Placement(transformation(extent={{80,-20},{120,20}}), iconTransformation(extent={{80,-20},{120,20}}))); @@ -65,18 +65,20 @@ protected SI.Temperature T_heatPort; //if port.m_flow > 0 -> it is sink (r=medium.p-p_in) else it is source (r=0) - SI.Pressure r_rear_intern = ThermofluidStream.Undirected.Internal.regStep( m_flow_rear, p_out - Medium.pressure(state_in_rear), 0, m_flow_reg); - SI.Pressure r_fore_intern = ThermofluidStream.Undirected.Internal.regStep( m_flow_fore, p_out - Medium.pressure(state_in_fore), 0, m_flow_reg); + SI.Pressure r_rear_intern = ThermofluidStream.Undirected.Internal.regStep( m_flow_rear, medium.p - Medium.pressure(state_in_rear), 0, m_flow_reg); + SI.Pressure r_fore_intern = ThermofluidStream.Undirected.Internal.regStep( m_flow_fore, medium.p - Medium.pressure(state_in_fore), 0, m_flow_reg); // dont regstep variables that are only in der(state), to increase accuracy - SI.EnthalpyFlowRate H_flow_rear = (if m_flow_rear >= 0 then Medium.specificEnthalpy(state_in_rear) else h_out) * m_flow_rear; - SI.EnthalpyFlowRate H_flow_fore = (if m_flow_fore >= 0 then Medium.specificEnthalpy(state_in_fore) else h_out) * m_flow_fore; - SI.MassFlowRate Xi_flow_rear[Medium.nXi] = (if m_flow_rear >= 0 then Medium.massFraction(state_in_rear) else Xi_out) * m_flow_rear; - SI.MassFlowRate Xi_flow_fore[Medium.nXi] = (if m_flow_fore >= 0 then Medium.massFraction(state_in_fore) else Xi_out) * m_flow_fore; - - Medium.ThermodynamicState state_out; - SI.SpecificEnthalpy h_out = Medium.specificEnthalpy(state_out); - Medium.MassFraction Xi_out[Medium.nXi] = Medium.massFraction(state_out); - SI.Pressure p_out = Medium.pressure(state_out); + SI.EnthalpyFlowRate H_flow_rear = (if m_flow_rear >= 0 then Medium.specificEnthalpy(state_in_rear) else h_out_rear) * m_flow_rear; + SI.EnthalpyFlowRate H_flow_fore = (if m_flow_fore >= 0 then Medium.specificEnthalpy(state_in_fore) else h_out_fore) * m_flow_fore; + SI.MassFlowRate Xi_flow_rear[Medium.nXi] = (if m_flow_rear >= 0 then Medium.massFraction(state_in_rear) else Xi_out_rear) * m_flow_rear; + SI.MassFlowRate Xi_flow_fore[Medium.nXi] = (if m_flow_fore >= 0 then Medium.massFraction(state_in_fore) else Xi_out_fore) * m_flow_fore; + + Medium.ThermodynamicState state_out_rear; + SI.SpecificEnthalpy h_out_rear = Medium.specificEnthalpy(state_out_rear); + Medium.MassFraction Xi_out_rear[Medium.nXi] = Medium.massFraction(state_out_rear); + Medium.ThermodynamicState state_out_fore; + SI.SpecificEnthalpy h_out_fore = Medium.specificEnthalpy(state_out_fore); + Medium.MassFraction Xi_out_fore[Medium.nXi] = Medium.massFraction(state_out_fore); Real d(unit="1/(m.s)") = k_volume_damping*sqrt(abs(2*L/(V*max(density_derp_h, 1e-10)))) "Friction factor for coupled boundaries"; SI.DerDensityByPressure density_derp_h "Partial derivative of density by pressure"; diff --git a/ThermofluidStream/Undirected/Boundaries/Internal/PartialVolumeN.mo b/ThermofluidStream/Undirected/Boundaries/Internal/PartialVolumeN.mo index 4ed7c0c7..e3194383 100644 --- a/ThermofluidStream/Undirected/Boundaries/Internal/PartialVolumeN.mo +++ b/ThermofluidStream/Undirected/Boundaries/Internal/PartialVolumeN.mo @@ -64,6 +64,10 @@ protected SI.Temperature T_heatPort; + + Medium.ThermodynamicState state_out_rear[N_rear]; + Medium.ThermodynamicState state_out_fore[N_fore]; + SI.Pressure r_rear[N_rear]; SI.Pressure r_fore[N_fore]; SI.SpecificEnthalpy h_rear[N_rear]; @@ -107,8 +111,8 @@ equation 0, m_flow_reg); // dont regstep variables that are only in der(state), to increase accuracy - h_rear[i] = if rear[i].m_flow >= 0 then Medium.specificEnthalpy(rear[i].state_forwards) else medium.h; - Xi_rear[:, i] = if rear[i].m_flow >= 0 then Medium.massFraction(rear[i].state_forwards) else medium.Xi; + h_rear[i] = if rear[i].m_flow >= 0 then Medium.specificEnthalpy(rear[i].state_forwards) else Medium.specificEnthalpy(state_out_rear[i]); + Xi_rear[:, i] = if rear[i].m_flow >= 0 then Medium.massFraction(rear[i].state_forwards) else Medium.massFraction(state_out_rear[i]); rear[i].state_rearwards = medium.state; end for; @@ -119,8 +123,8 @@ equation 0, m_flow_reg); // dont regstep variables that are only in der(state), to increase accuracy - h_fore[i] = if fore[i].m_flow >= 0 then Medium.specificEnthalpy(fore[i].state_rearwards) else medium.h; - Xi_fore[:, i] = if fore[i].m_flow >= 0 then Medium.massFraction(fore[i].state_rearwards) else medium.Xi; + h_fore[i] = if fore[i].m_flow >= 0 then Medium.specificEnthalpy(fore[i].state_rearwards) else Medium.specificEnthalpy(state_out_fore[i]); + Xi_fore[:, i] = if fore[i].m_flow >= 0 then Medium.massFraction(fore[i].state_rearwards) else Medium.massFraction(state_out_fore[i]); fore[i].state_forwards = medium.state; end for; diff --git a/ThermofluidStream/Undirected/Boundaries/PhaseSeparator.mo b/ThermofluidStream/Undirected/Boundaries/PhaseSeparator.mo index de1006ff..d4b12da3 100644 --- a/ThermofluidStream/Undirected/Boundaries/PhaseSeparator.mo +++ b/ThermofluidStream/Undirected/Boundaries/PhaseSeparator.mo @@ -76,7 +76,9 @@ equation if x < 0 then medium.h elseif x <= 1 then liquid_level_pipe*h_bubble + (1-liquid_level_pipe)*h_dew else medium.h); - state_out = Medium.setState_phX(medium.p, h_pipe, medium.Xi); + + state_out_fore = Medium.setState_phX(medium.p, h_pipe, medium.Xi); + state_out_rear = state_out_fore; annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)), diff --git a/ThermofluidStream/Undirected/Boundaries/Reservoir.mo b/ThermofluidStream/Undirected/Boundaries/Reservoir.mo index 509dab69..6692bec9 100644 --- a/ThermofluidStream/Undirected/Boundaries/Reservoir.mo +++ b/ThermofluidStream/Undirected/Boundaries/Reservoir.mo @@ -38,7 +38,8 @@ equation p_env = p_env_par; end if; - state_out = medium.state; + state_out_rear = medium.state; + state_out_fore = medium.state; annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={ Ellipse( diff --git a/ThermofluidStream/Undirected/Boundaries/Tests/TestVolumes.mo b/ThermofluidStream/Undirected/Boundaries/Tests/TestVolumes.mo index 6e0a82d7..15557f45 100644 --- a/ThermofluidStream/Undirected/Boundaries/Tests/TestVolumes.mo +++ b/ThermofluidStream/Undirected/Boundaries/Tests/TestVolumes.mo @@ -2,18 +2,15 @@ within ThermofluidStream.Undirected.Boundaries.Tests; model TestVolumes "Test for undirected Volumes" extends Modelica.Icons.Example; - replaceable package Medium = Media.myMedia.Air.SimpleAir - constrainedby Media.myMedia.Interfaces.PartialMedium - "Medium package" + replaceable package Medium = Media.myMedia.Air.SimpleAir constrainedby Media.myMedia.Interfaces.PartialMedium "Medium package" annotation (Documentation(info=" -

Medium package used in the Test.

-")); +

Medium package used in the Test.

+ ")); - package MediumMix = Media.myMedia.IdealGases.MixtureGases.CombustionAir - "Medium package" + package MediumMix = Media.myMedia.IdealGases.MixtureGases.CombustionAir "Medium package" annotation (Documentation(info=" -

Medium package used in the Test of the MixVolumes.

-")); +

Medium package used in the Test of the MixVolumes.

+ ")); inner DropOfCommons dropOfCommons annotation (Placement(transformation(extent={{140,-12},{160,8}}))); diff --git a/ThermofluidStream/Undirected/Boundaries/Volume.mo b/ThermofluidStream/Undirected/Boundaries/Volume.mo index a2d0b7f2..0d997676 100644 --- a/ThermofluidStream/Undirected/Boundaries/Volume.mo +++ b/ThermofluidStream/Undirected/Boundaries/Volume.mo @@ -20,7 +20,8 @@ equation V = V_par; W_v = 0; - state_out = medium.state; + state_out_rear = medium.state; + state_out_fore = medium.state; annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)), Documentation(info=" diff --git a/ThermofluidStream/Undirected/Boundaries/VolumeFlex.mo b/ThermofluidStream/Undirected/Boundaries/VolumeFlex.mo index 51983309..c22fc477 100644 --- a/ThermofluidStream/Undirected/Boundaries/VolumeFlex.mo +++ b/ThermofluidStream/Undirected/Boundaries/VolumeFlex.mo @@ -12,7 +12,8 @@ equation medium.p = p_ref + K*(V/V_ref-1); W_v = 0; - state_out = medium.state; + state_out_rear = medium.state; + state_out_fore = medium.state; annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={ Line( diff --git a/ThermofluidStream/Undirected/Boundaries/VolumeMix.mo b/ThermofluidStream/Undirected/Boundaries/VolumeMix.mo index 1f7d2441..5a83d729 100644 --- a/ThermofluidStream/Undirected/Boundaries/VolumeMix.mo +++ b/ThermofluidStream/Undirected/Boundaries/VolumeMix.mo @@ -20,6 +20,14 @@ equation V = V_par; W_v = 0; + for i in 1:N_rear loop + state_out_rear[i] = medium.state; + end for; + + for i in 1:N_fore loop + state_out_fore[i] = medium.state; + end for; + annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={ Text( extent={{-60,8},{60,-52}}, diff --git a/ThermofluidStream/Undirected/HeatExchangers/DiscretizedCounterFlowHEX.mo b/ThermofluidStream/Undirected/HeatExchangers/DiscretizedCounterFlowHEX.mo new file mode 100644 index 00000000..42f9c8a5 --- /dev/null +++ b/ThermofluidStream/Undirected/HeatExchangers/DiscretizedCounterFlowHEX.mo @@ -0,0 +1,284 @@ +within ThermofluidStream.Undirected.HeatExchangers; +model DiscretizedCounterFlowHEX "Discretized heat exchanger for single- or two-phase fluids without pressure drop" + + replaceable package MediumA = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium "Medium model side A" + annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); + replaceable package MediumB = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium "Medium model side B" + annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); + + replaceable model ConductionElementA = Internal.ConductionElementHEX constrainedby Internal.PartialConductionElementHEX( + final A=A/nCells, + final V=V_Hex/nCells, + redeclare package Medium = MediumA, + final enforce_global_energy_conservation=enforce_global_energy_conservation, + final init=init_A, + final h_0= h0_A) + "Heat transfer element model for side A" + annotation(choicesAllMatching=true, Dialog(group = "Medium definitions")); + replaceable model ConductionElementB = Internal.ConductionElementHEX constrainedby Internal.PartialConductionElementHEX( + final A=A/nCells, + final V=V_Hex/nCells, + redeclare package Medium = MediumB, + final enforce_global_energy_conservation=enforce_global_energy_conservation, + final init=init_B, + final h_0= h0_B) + "Heat transfer element model for side B" + annotation(choicesAllMatching=true, Dialog(group = "Medium definitions")); + + parameter Boolean initializeMassFlow=false "Initialize mass flow at inlets?" annotation(Dialog(tab = "Initialization", group = "Mass flow")); + parameter SI.MassFlowRate m_flow_0_A = 0 "Initial mass flow for side A" + annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); + parameter SI.MassFlowRate m_flow_0_B = 0 "Initial mass flow for side B" + annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); + parameter ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement init_A=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h + "Initialization method for h side A)" + annotation (Dialog(tab="Initialization", group="Enthalpy"), + choices( + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h "h0", + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.rear "rear", + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.fore "fore")); + parameter SI.SpecificEnthalpy h0_A = MediumA.h_default "Initial enthalpy side A" + annotation(Dialog(tab = "Initialization", group = "Enthalpy", enable=(init_A == ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h))); + parameter ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement init_B=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h + "Initialization method for h side B" + annotation (Dialog(tab="Initialization", group="Enthalpy"), + choices( + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h "h0", + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.rear "rear", + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.fore "fore")); + parameter SI.SpecificEnthalpy h0_B = MediumB.h_default "Initial enthalpy side B" + annotation(Dialog(tab = "Initialization", group = "Enthalpy", enable=(init_B == ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h))); + parameter Integer nCells = 3 "Number of discretization elements"; + parameter Modelica.SIunits.Area A = 10 "Conductive area of heat exchanger" annotation(Dialog(group = "Heat transfer parameters")); + parameter Modelica.SIunits.Volume V_Hex = 0.001 "Volume for heat transfer calculation" annotation(Dialog(group = "Heat transfer parameters")); + parameter Boolean enforce_global_energy_conservation = false "If true, exact global energy conservation is enforced by feeding back all energy stored locally back in the system" + annotation(Dialog(tab="Advanced")); + parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "Regularization massflow to switch between positive- and negative-massflow model" + annotation(Dialog(tab="Advanced")); + + //Parameterization of HEX Wall + parameter Modelica.SIunits.CoefficientOfHeatTransfer k_wall = 100 "Coefficient of heat transfer for wall" + annotation(Dialog(group = "Heat transfer parameters")); +protected + parameter Modelica.SIunits.ThermalConductance G = k_wall*A "Wall thermal conductance" annotation(Dialog(group = "Wall parameters")); + +public + ConductionElementB thermalElementB[nCells] + annotation (Placement(transformation(extent={{-10,90},{10,70}}))); + + ConductionElementA thermalElementA[nCells] + annotation (Placement(transformation(extent={{10,-90},{-10,-70}}))); + + Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor[nCells](each G=G/nCells) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={0,0}))); + Interfaces.Rear rearB(redeclare package Medium = MediumB) annotation (Placement(transformation(extent={{-110,70},{-90,90}}))); + Interfaces.Fore foreB(redeclare package Medium = MediumB) annotation (Placement(transformation(extent={{92,70},{112,90}}))); + Interfaces.Rear rearA(redeclare package Medium = MediumA) annotation (Placement(transformation(extent={{110,-90},{90,-70}}))); + Interfaces.Fore foreA(redeclare package Medium = MediumA) annotation (Placement(transformation(extent={{-90,-90},{-110,-70}}))); + + SI.HeatFlowRate Q_flow_A=sum(thermalElementA.heatPort.Q_flow); + SI.HeatFlowRate Q_flow_B=sum(thermalElementB.heatPort.Q_flow); + SI.MassFlowRate m_flow_A=rearB.m_flow; + SI.MassFlowRate m_flow_B=rearA.m_flow; + SI.Mass M_A=sum(thermalElementA.M); + SI.Mass M_B=sum(thermalElementB.M); + SI.Energy deltaE_system=sum(thermalElementA.deltaE_system) + sum(thermalElementB.deltaE_system); + + ThermofluidStream.HeatExchangers.Internal.DiscretizedHEXSummary summary "Summary record of Quantities"; + +protected + outer DropOfCommons dropOfCommons; + +initial equation + + if initializeMassFlow then + rearA.m_flow = m_flow_0_A; + rearB.m_flow = m_flow_0_B; + end if; + +equation + //Summary record + summary.Tin_A =Undirected.Internal.regStep(m_flow_A,MediumA.temperature(rearA.state_forwards),MediumA.temperature(foreA.state_rearwards),m_flow_reg); + summary.Tin_B = Undirected.Internal.regStep(m_flow_B, MediumB.temperature(rearB.state_forwards), MediumB.temperature(foreB.state_rearwards), m_flow_reg); + summary.Tout_A =Undirected.Internal.regStep(m_flow_A,MediumA.temperature(foreA.state_forwards),MediumA.temperature(rearA.state_rearwards),m_flow_reg); + summary.Tout_B = Undirected.Internal.regStep(m_flow_B, MediumB.temperature(foreB.state_forwards), MediumB.temperature(rearB.state_rearwards), m_flow_reg); + summary.hin_A =Undirected.Internal.regStep(m_flow_A,MediumA.specificEnthalpy(rearA.state_forwards),MediumA.specificEnthalpy(foreA.state_rearwards),m_flow_reg); + summary.hin_B = Undirected.Internal.regStep(m_flow_B, MediumB.specificEnthalpy(rearB.state_forwards), MediumB.specificEnthalpy(foreB.state_rearwards), m_flow_reg); + summary.hout_A =Undirected.Internal.regStep(m_flow_A,MediumA.specificEnthalpy(foreA.state_forwards),MediumA.specificEnthalpy(rearA.state_rearwards),m_flow_reg); + summary.hout_B = Undirected.Internal.regStep(m_flow_B, MediumB.specificEnthalpy(foreB.state_forwards), MediumB.specificEnthalpy(rearB.state_rearwards), m_flow_reg); + summary.dT_A = summary.Tout_A - summary.Tin_A; + summary.dT_B = summary.Tout_B - summary.Tin_B; + summary.dh_A = summary.hout_A - summary.hin_A; + summary.dh_B = summary.hout_B - summary.hin_B; + + //Connecting equations (to interconnect pipes) + //Fluid Side B + connect(rearB, thermalElementB[1].rear) annotation (Line(points={{-100,80},{-10,80}}, color={28,108,200})); + for i in 1:nCells-1 loop + connect(thermalElementB[i].fore, thermalElementB[i + 1].rear); + end for; + connect(thermalElementB[nCells].fore, foreB) annotation (Line(points={{10,80},{102,80}}, color={28,108,200})); + + //Fluid Side A + connect(rearA, thermalElementA[1].rear) annotation (Line(points={{100,-80},{10,-80}}, color={28,108,200})); + for i in 1:nCells-1 loop + connect(thermalElementA[i].fore, thermalElementA[i + 1].rear); + end for; + connect(thermalElementA[nCells].fore,foreA) annotation (Line(points={{-10,-80},{-100,-80}}, color={28,108,200})); + + connect(thermalElementB.heatPort, thermalConductor.port_b) + annotation (Line(points={{0,70.2},{0,10}}, color={191,0,0})); + + for i in 1:nCells loop + connect(thermalElementA[i].heatPort, thermalConductor[nCells + 1 - i].port_a) + annotation (Line(points={{-6.66134e-16,-70.2},{-6.66134e-16,-10},{0,-10}}, color={191,0,0})); + end for; + + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), + graphics={ + Rectangle( + extent={{-100,100},{100,-100}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + radius=25), + Polygon(points={{-80,-92},{70,-92},{70,-62},{-80,-62},{-70,-52},{80,-52},{80,-82},{70,-92},{70,-62},{80,-52},{-70,-52},{-80,-62},{-80,-92}}, + lineColor={28,108,200}), + Line(points={{-40,-52},{-50,-62},{-50,-92}}, color={28,108,200}), + Line(points={{-10,-52},{-20,-62},{-20,-92}},color={28,108,200}), + Line(points={{20,-52},{10,-62},{10,-92}}, color={28,108,200}), + Line(points={{50,-52},{40,-62},{40,-92}}, color={28,108,200}), + Text( + extent={{-70,-72},{-58,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{52,-72},{64,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{20,-72},{32,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{-10,-72},{2,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-40,-72},{-28,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Polygon(points={{-80,56},{70,56},{70,86},{-80,86},{-70,96},{80,96},{80,66},{70,56},{70,86},{80,96},{-70,96},{-80,86},{-80,56}}, + lineColor = {28, + 108,200}), + Line(points={{-40,96},{-50,86},{-50,56}}, color={28,108,200}), + Line(points={{-10,96},{-20,86},{-20,56}}, color={28,108,200}), + Line(points={{20,96},{10,86},{10,56}}, color={28,108,200}), + Line(points={{50,96},{40,86},{40,56}}, color={28,108,200}), + Text( + extent={{50,76},{62,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{20,76},{32,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-10,76},{2,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-42,76},{-30,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{-72,76},{-60,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={1,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={57,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-65,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-3,-36}, + rotation=90), + Polygon(points={{-82,-16},{68,-16},{68,4},{-82,4},{-72,14},{78,14},{78,-6},{68,-16},{68,4},{78,14},{-72,14},{-82,4},{-82,-16}}, + lineColor = {188, + 36,38}), + Line(points={{-42,14},{-52,4},{-52,-16}}, color={188,36,38}), + Line(points={{-12,14},{-22,4},{-22,-16}}, color={188,36,38}), + Line(points={{18,14},{8,4},{8,-16}}, color={188,36,38}), + Line(points={{48,14},{38,4},{38,-16}}, color={188,36,38})}), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}})), + Documentation(info=" +

The undirected counter-flow discretized heat exchanger uses a number of conduction elements (which is set by the parameter nCells) as discrete control volumes to exchange heat between two fluid streams.

+

For each side the elements are numbered 1 to nCells from rear to fore and the elements' heatports are connected via a thermal conductor that models the wall. The connections are ordered to result in a counter-flow configuration.

+

The conduction elements are computing a heat transfer coefficient between their heatport and the fluid contained. They are replaceable with a choice between a single-phase and a two-phase version, both can be further parametrized. Although the single-phase version works for two-phase media (not the other way around), using the two-phase one for two-phase media enables to set different heat transfer coefficients depending on the phase (liquid/gaseous/2-phase) state of the medium.

+

Note that since the model uses conductionElements as discrete control volumes that in turn assume quasi-stationary mass and therefore are part of a fluid stream rather than break it into two (like a full volume would), the same holds for both sides of the heat exchanger; they are part of a fluid stream and don't break it. The quasi-stationary mass assumption also implies that for (fast) changing masses/densities in any of the conduction elements the heat exchanger will (slightly) violate the conservation of energy.

+

The parameters A (heat transferring area), k_wall (heat transfer coefficient of the wall between the streams) and the heat transfer coefficients in the conduction elements scale the transferred heat (the middle only if the wall and the latter only of the heat transfer into a fluid is the choke of the heatflow).

+

The parameter V determines the amount of fluid in the heat exchanger and therefore the dynamic for non-steady states.

+

The initialization tab allows for a mass-flow initialization for both paths, as well as to determine from which direction the enthalpy in the control volumes should be initialized (fore/rear), or if it should start with a given enthalpy. The other option is to initialize the enthalpy with a given value.

+

The Advanced tab allows to influence the massflow regularization for near zero massflows and has an option to enforce global conservation of energy. The latter is done by feeding back any energy the conduction elements accumulated over time, basically making it impossible to store energy in their fluid long-term. While this enforces long-term conservation of energy it changes the medium-/short-term dynamics of the system and is therefore disabled by default.

+")); +end DiscretizedCounterFlowHEX; diff --git a/ThermofluidStream/Undirected/HeatExchangers/DiscretizedCrossFlowHEX.mo b/ThermofluidStream/Undirected/HeatExchangers/DiscretizedCrossFlowHEX.mo new file mode 100644 index 00000000..bd70d249 --- /dev/null +++ b/ThermofluidStream/Undirected/HeatExchangers/DiscretizedCrossFlowHEX.mo @@ -0,0 +1,321 @@ +within ThermofluidStream.Undirected.HeatExchangers; +model DiscretizedCrossFlowHEX "Discretized Heat Exchanger for single- or two-phase working fluid without pressure drop" + + replaceable package MediumA = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium "Medium model side A" + annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); + replaceable package MediumB = ThermofluidStream.Media.myMedia.Interfaces.PartialMedium "Medium model side B" + annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); + + replaceable model ConductionElementA = Internal.ConductionElementHEX constrainedby Internal.PartialConductionElementHEX( + final A=A/nCells, + final V=V_Hex/nCells, + redeclare package Medium = MediumA, + final enforce_global_energy_conservation=enforce_global_energy_conservation, + final init=init_A, + final h_0= h0_A) + "Heat transfer element model for side A" + annotation(choicesAllMatching=true, Dialog(group = "Medium definitions")); + replaceable model ConductionElementB = Internal.ConductionElementHEX constrainedby Internal.PartialConductionElementHEX( + final A=A/nCells, + final V=V_Hex/nCells, + redeclare package Medium = MediumB, + final enforce_global_energy_conservation=enforce_global_energy_conservation, + final init=init_B, + final h_0= h0_B) + "Heat transfer element model for side B" + annotation(choicesAllMatching=true, Dialog(group = "Medium definitions")); + + parameter Boolean initializeMassFlow=false "Initialize mass flow at inlets?" annotation(Dialog(tab = "Initialization", group = "Mass flow")); + parameter SI.MassFlowRate m_flow_0_A = 0 "Initial mass flow for side A" + annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); + parameter SI.MassFlowRate m_flow_0_B = 0 "Initial mass flow for side B" + annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); + parameter ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement init_A=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h + "Initialization method for h side A)" + annotation (Dialog(tab="Initialization", group="Enthalpy"), + choices( + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h "h0", + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.rear "rear", + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.fore "fore")); + parameter SI.SpecificEnthalpy h0_A = MediumA.h_default "Initial enthalpy side A" + annotation(Dialog(tab = "Initialization", group = "Enthalpy", enable=(init_A == ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h))); + parameter ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement init_B=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h + "Initialization method for h side B" + annotation (Dialog(tab="Initialization", group="Enthalpy"), + choices( + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h "h0", + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.rear "rear", + choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.fore "fore")); + parameter SI.SpecificEnthalpy h0_B = MediumB.h_default "Initial enthalpy side B" + annotation(Dialog(tab = "Initialization", group = "Enthalpy", enable=(init_B == ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h))); + parameter Integer nCells = 3 "Number of discretization elements"; + parameter Modelica.SIunits.Area A = 10 "Conductive area of heat exchanger" + annotation(Dialog(group = "Heat transfer parameters")); + parameter Modelica.SIunits.Volume V_Hex = 0.001 "Volume for heat transfer calculation" annotation(Dialog(group = "Heat transfer parameters")); + parameter Boolean enforce_global_energy_conservation = false "If true, exact global energy conservation is enforced by feeding back all energy stored locally back in the system" + annotation(Dialog(tab="Advanced")); + parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "Regularization massflow to switch between positive- and negative-massflow model" + annotation(Dialog(tab="Advanced")); + + //Parameterization of HEX Wall + parameter Modelica.SIunits.CoefficientOfHeatTransfer k_wall = 100 "Coefficient of heat transfer for wall" + annotation(Dialog(group = "Heat transfer parameters")); +protected + parameter Modelica.SIunits.ThermalConductance G = k_wall*A "Wall thermal conductance" annotation(Dialog(group = "Wall parameters")); + +public + ConductionElementA thermalElementA[nCells] annotation (Placement(transformation(extent={{-10,90},{10,70}}))); + + ConductionElementB thermalElementB[nCells] annotation (Placement(transformation(extent={{10,-90},{-10,-70}}))); + + Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor[nCells](each G=G/nCells) + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=90, + origin={0,0}))); + Interfaces.Rear rearA(redeclare package Medium = MediumA) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=0, + origin={-98,80}), iconTransformation( + extent={{-10,-10},{10,10}}, + rotation=270, + origin={0,100}))); + Interfaces.Fore foreA(redeclare package Medium = MediumA) annotation (Placement(transformation(extent={{92,70},{112,90}}), iconTransformation( + extent={{-10,-10},{10,10}}, + rotation=270, + origin={0,-100}))); + Interfaces.Rear rearB(redeclare package Medium = MediumB) annotation (Placement(transformation(extent={{110,-90},{90,-70}}))); + Interfaces.Fore foreB(redeclare package Medium = MediumB) annotation (Placement(transformation(extent={{-90,-90},{-110,-70}}))); + + SI.HeatFlowRate Q_flow_A=sum(thermalElementA.heatPort.Q_flow); + SI.HeatFlowRate Q_flow_B=sum(thermalElementB.heatPort.Q_flow); + SI.MassFlowRate m_flow_A=rearA.m_flow; + SI.MassFlowRate m_flow_B=rearB.m_flow; + SI.Mass M_A=sum(thermalElementA.M); + SI.Mass M_B=sum(thermalElementB.M); + SI.Energy deltaE_system=sum(thermalElementA.deltaE_system) + sum(thermalElementB.deltaE_system); + + ThermofluidStream.HeatExchangers.Internal.DiscretizedHEXSummary summary "Summary record of Quantities"; + + Processes.FlowResistance flowResistanceA[nCells]( + redeclare package Medium = MediumA, + each r(each displayUnit="mm") = 0.025, + each l=1, + redeclare function pLoss = ThermofluidStream.Processes.Internal.FlowResistance.linearQuadraticPressureLoss (each k=50)) + annotation (Placement(transformation(extent={{20,70},{40,90}}))); + Topology.JunctionMN junctionMN(redeclare package Medium = MediumA, + N=1, + M=nCells) + annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=0, + origin={-50,80}))); + Topology.JunctionMN junctionMN1(redeclare package Medium = MediumA, N=nCells) + annotation (Placement(transformation(extent={{56,70},{76,90}}))); +protected + outer DropOfCommons dropOfCommons; + +initial equation + + if initializeMassFlow then + rearB.m_flow = m_flow_0_B; + flowResistanceA.m_flow = m_flow_0_A/nCells*ones(nCells); + else + for i in 1:nCells-1 loop + flowResistanceA[i + 1].m_flow = flowResistanceA[1].m_flow; + end for; + end if; + +equation + //Summary record + summary.Tin_A =Undirected.Internal.regStep(m_flow_A,MediumA.temperature(rearA.state_forwards),MediumA.temperature(foreA.state_rearwards),m_flow_reg); + summary.Tin_B = Undirected.Internal.regStep(m_flow_B, MediumB.temperature(rearB.state_forwards), MediumB.temperature(foreB.state_rearwards), m_flow_reg); + summary.Tout_A =Undirected.Internal.regStep(m_flow_A,MediumA.temperature(foreA.state_forwards),MediumA.temperature(rearA.state_rearwards),m_flow_reg); + summary.Tout_B = Undirected.Internal.regStep(m_flow_B, MediumB.temperature(foreB.state_forwards), MediumB.temperature(rearB.state_rearwards), m_flow_reg); + summary.hin_A =Undirected.Internal.regStep(m_flow_A,MediumA.specificEnthalpy(rearA.state_forwards),MediumA.specificEnthalpy(foreA.state_rearwards),m_flow_reg); + summary.hin_B = Undirected.Internal.regStep(m_flow_B, MediumB.specificEnthalpy(rearB.state_forwards), MediumB.specificEnthalpy(foreB.state_rearwards), m_flow_reg); + summary.hout_A =Undirected.Internal.regStep(m_flow_A,MediumA.specificEnthalpy(foreA.state_forwards),MediumA.specificEnthalpy(rearA.state_rearwards),m_flow_reg); + summary.hout_B = Undirected.Internal.regStep(m_flow_B, MediumB.specificEnthalpy(foreB.state_forwards), MediumB.specificEnthalpy(rearB.state_rearwards), m_flow_reg); + summary.dT_A = summary.Tout_A - summary.Tin_A; + summary.dT_B = summary.Tout_B - summary.Tin_B; + summary.dh_A = summary.hout_A - summary.hin_A; + summary.dh_B = summary.hout_B - summary.hin_B; + + //Connecting equations (to interconnect pipes) + + //Fluid Side B + connect(rearB, thermalElementB[1].rear) annotation (Line(points={{100,-80},{10,-80}}, color={28,108,200})); + for i in 1:nCells-1 loop + connect(thermalElementB[i].fore, thermalElementB[i + 1].rear); + end for; + connect(thermalElementB[nCells].fore, foreB) annotation (Line(points={{-10,-80},{-100,-80}}, color={28,108,200})); + + connect(thermalElementB.heatPort, thermalConductor.port_a) + annotation (Line(points={{4.44089e-16,-70.2},{4.44089e-16,-40},{0,-40},{0,-10}}, color={191,0,0})); + connect(thermalElementA.heatPort, thermalConductor.port_b) + annotation (Line(points={{4.44089e-16,70.2},{4.44089e-16,40},{0,40},{0,10}}, color={191,0,0})); + + //Fluid side A + connect(junctionMN1.fores[1], foreA) annotation (Line( + points={{76,80},{76,80},{102,80}}, + color={28,108,200}, + thickness=0.5)); + connect(junctionMN.rears[1], rearA) annotation (Line( + points={{-60,80},{-60,80},{-98,80}}, + color={28,108,200}, + thickness=0.5)); + connect(junctionMN.fores, thermalElementA.rear) annotation (Line( + points={{-40,80},{-30,80},{-30,80},{-10,80}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistanceA.rear, thermalElementA.fore) annotation (Line( + points={{20,80},{10,80}}, + color={28,108,200}, + thickness=0.5)); + connect(flowResistanceA.fore, junctionMN1.rears) + annotation (Line(points={{40,80},{56,80}},color={28,108,200},thickness=0.5)); + + annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), + graphics={ + Rectangle( + extent={{-100,100},{100,-100}}, + lineColor={28,108,200}, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + radius=25), + Polygon(points={{-80,-92},{70,-92},{70,-62},{-80,-62},{-70,-52},{80,-52},{80,-82},{70,-92},{70,-62},{80,-52},{-70,-52},{-80,-62},{-80,-92}}, + lineColor={28,108,200}), + Line(points={{-40,-52},{-50,-62},{-50,-92}}, color={28,108,200}), + Line(points={{-10,-52},{-20,-62},{-20,-92}},color={28,108,200}), + Line(points={{20,-52},{10,-62},{10,-92}}, color={28,108,200}), + Line(points={{50,-52},{40,-62},{40,-92}}, color={28,108,200}), + Text( + extent={{-70,-72},{-58,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{52,-72},{64,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{20,-72},{32,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{-10,-72},{2,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-40,-72},{-28,-84}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Polygon(points={{-80,56},{70,56},{70,86},{-80,86},{-70,96},{80,96},{80,66},{70,56},{70,86},{80,96},{-70,96},{-80,86},{-80,56}}, + lineColor = {28, + 108,200}), + Line(points={{-40,96},{-50,86},{-50,56}}, color={28,108,200}), + Line(points={{-10,96},{-20,86},{-20,56}}, color={28,108,200}), + Line(points={{20,96},{10,86},{10,56}}, color={28,108,200}), + Line(points={{50,96},{40,86},{40,56}}, color={28,108,200}), + Text( + extent={{-72,76},{-60,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="N"), + Text( + extent={{-42,76},{-30,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{-10,76},{2,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="..."), + Text( + extent={{20,76},{32,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="2"), + Text( + extent={{50,76},{62,64}}, + lineColor={28,108,200}, + pattern=LinePattern.Dash, + textString="1"), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={1,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={61,36}, + rotation=270), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={57,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-65,-36}, + rotation=90), + Text( + extent={{-8,41},{8,-41}}, + lineColor={188,36,38}, + lineThickness=0.5, + fillColor={255,255,255}, + fillPattern=FillPattern.Solid, + textString="«", + origin={-3,-36}, + rotation=90), + Polygon(points={{-82,-16},{68,-16},{68,4},{-82,4},{-72,14},{78,14},{78,-6},{68,-16},{68,4},{78,14},{-72,14},{-82,4},{-82,-16}}, + lineColor = {188, + 36,38}), + Line(points={{-42,14},{-52,4},{-52,-16}}, color={188,36,38}), + Line(points={{-12,14},{-22,4},{-22,-16}}, color={188,36,38}), + Line(points={{18,14},{8,4},{8,-16}}, color={188,36,38}), + Line(points={{48,14},{38,4},{38,-16}}, color={188,36,38})}), + Diagram( + coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}})), + Documentation(info=" +

The undirected cross-flow discretized heat exchanger uses a number of conduction elements (which is set by the parameter nCells) as discrete control volumes to exchange heat between two fluid streams.

+

Side A splits the fluid stream into nCells substreams that are parallel. The flow-resistance is chosen to be very small and only ensures numerical stability of the parallel streams. By default, it is a linear-quadratic flow resistance, so the massflows through each of the parallel streams is the same. If exchanged for flow-resistance that depends on media properties (e.g. a laminar-turbulent) the mass-flow on the paths will be different. For side B the elements are serial and numbered 1 to nCells in from rear to fore. The elements' heatports are connected via a thermal conductor that models the wall. The connections are ordered to result in a cross-flow configuration.

+

The conduction elements are computing a heat transfer coefficient between their heatport and the fluid contained. They are replaceable with a choice between a single-phase and a two-phase version, both can be further parametrized. Although the single-phase version works for two-phase media (not the other way around), using the two-phase one for two-phase media enables to set different heat transfer coefficients depending on the phase (liquid/gaseous/2-phase) state of the medium.

+

Note that since the model uses conductionElements as discrete control volumes that in turn assume quasi-stationary mass and therefore are part of a fluid stream rather than break it into two (like a full volume would), the same holds for both sides of the heat exchanger; they are part of a fluid stream and don't break it. The quasi-stationary mass assumption also implies that for (fast) changing masses/densities in any of the conduction elements the heat exchanger will (slightly) violate the conservation of energy.

+

The parameters A (heat transferring area), k_wall (heat transfer coefficient of the wall between the streams) and the heat transfer coefficients in the conduction elements scale the transferred heat (the middle only if the wall and the latter only of the heat transfer into a fluid is the choke of the heatflow).

+

The parameter V determines the amount of fluid in the heat exchanger and therefore the dynamic for non-steady states.

+

The initialization tab allows for a mass-flow initialization for both paths, as well as to determine from which direction the enthalpy in the control volumes should be initialized (fore/rear), or if it should start with a given enthalpy. The other option is to initialize the enthalpy with a given value.

+

The Advanced tab allows to influence the massflow regularization for near zero massflows and has an option to enforce global conservation of energy. The latter is done by feeding back any energy the conduction elements accumulated over time, basically making it impossible to store energy in their fluid long-term. While this enforces long-term conservation of energy it changes the medium-/short-term dynamics of the system and is therefore disabled by default.

+")); +end DiscretizedCrossFlowHEX; diff --git a/ThermofluidStream/Undirected/HeatExchangers/DiscretizedHEX.mo b/ThermofluidStream/Undirected/HeatExchangers/DiscretizedHEX.mo deleted file mode 100644 index 6baff1e0..00000000 --- a/ThermofluidStream/Undirected/HeatExchangers/DiscretizedHEX.mo +++ /dev/null @@ -1,258 +0,0 @@ -within ThermofluidStream.Undirected.HeatExchangers; -model DiscretizedHEX - - replaceable package MediumAir = - ThermofluidStream.Media.myMedia.Interfaces.PartialMedium - "Medium model" annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); - - replaceable package MediumRefrigerant = - ThermofluidStream.Media.myMedia.Interfaces.PartialTwoPhaseMedium - "Medium model" annotation (choicesAllMatching=true, Dialog(group = "Medium definitions")); - - parameter ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement initRef=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h - "Initialization method for h (refrigerant side)" - annotation (Dialog(tab="Initialization", group="Enthalpy"), - choices( - choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h "h0", - choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.rear "rear", - choice=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.fore "fore")); - - parameter SI.SpecificEnthalpy h0 = MediumRefrigerant.h_default "Initial enthalpy" - annotation(Dialog(tab = "Initialization", group = "Enthalpy", enable=(initRef == ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h))); - parameter Integer nCells = 3 "Number of discretization elements"; - parameter Modelica.SIunits.Area A = 10 "Conductive area of heat exchanger" annotation(Dialog(group = "Heat transfer parameters")); - parameter Modelica.SIunits.Volume V_Hex = 0.001 "Volume for heat transfer calculation" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.CoefficientOfHeatTransfer U_nom = 3000 "Nominal coefficient of heat transfer for single-phase side" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.CoefficientOfHeatTransfer U_liq_nom = 700 "Nominal coefficient of heat transfer for liquid region" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.CoefficientOfHeatTransfer U_vap_nom = 500 "Nominal coefficient of heat transfer for vapour region" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.CoefficientOfHeatTransfer U_tp_nom = 1000 "Nominal coefficient of heat transfer for two-phase region" annotation(Dialog(group = "Heat transfer parameters")); - parameter Boolean initializeMassFlow = false "Initialize mass flow at inlets?" annotation(Dialog(tab = "Initialization", group = "Mass flow")); - parameter SI.MassFlowRate m_flow_0 = 0.01 "Initial mass flow" annotation(Dialog(tab = "Initialization", group = "Mass flow", enable = initializeMassFlow)); - parameter SI.MassFlowRate m_flow_nom_ref = 0.3 "Nominal mass-flow rate working fluid" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.MassFlowRate m_flow_nom_air = 1.0 "Nominal mass-flow rate secondary fluid" annotation(Dialog(group = "Heat transfer parameters")); - parameter SI.MassFlowRate m_flow_reg = dropOfCommons.m_flow_reg "Regularization massflow to switch between positive- and negative-massflow model" - annotation(Dialog(tab="Advanced")); - parameter Boolean enforce_global_energy_conservation = false "If true, exact global energy conservation is enforced by feeding back all energy stored locally back in the system" - annotation(Dialog(tab="Advanced")); - -//Parameterization of HEX Wall - parameter Modelica.SIunits.CoefficientOfHeatTransfer k_wall = 100 "Coefficient of heat transfer for pipe wall" annotation(Dialog(group = "Wall parameters")); -protected - parameter Modelica.SIunits.ThermalConductance G = k_wall*A "Wall thermal conductance" annotation(Dialog(group = "Wall parameters")); - - -public - Interfaces.Fore foreAir(redeclare package Medium = MediumAir) annotation (Placement(transformation(extent={{90,70},{110,90}}))); - Interfaces.Fore foreRef(redeclare package Medium = MediumRefrigerant) annotation (Placement(transformation(extent={{-110,-90},{-90,-70}}))); - Interfaces.Rear rearAir(redeclare package Medium = MediumAir) annotation (Placement(transformation(extent={{-110,70},{-90,90}}))); - Interfaces.Rear rearRef(redeclare package Medium = MediumRefrigerant) annotation (Placement(transformation(extent={{90,-90},{110,-70}}))); - Internal.ConductionElementHEX conductionElementAir[nCells]( - redeclare package Medium = MediumAir, - each V=V_Hex/nCells, - each enforce_global_energy_conservation=enforce_global_energy_conservation, - each A=A/nCells, - each U_nom=U_nom, - each m_flow_nom=m_flow_nom_air) - annotation (Placement(transformation(extent={{-10,90},{10,70}}))); - Internal.ConductionElementHEX_twoPhase conductionElementRefrigerant[nCells]( - each init=initRef, - each enforce_global_energy_conservation=enforce_global_energy_conservation, - each U_liq_nom=U_liq_nom, - each U_vap_nom=U_vap_nom, - each U_tp_nom=U_tp_nom, - each m_flow_nom=m_flow_nom_ref, - each h_0 = h0, - redeclare package Medium = MediumRefrigerant, - each V=V_Hex/nCells, - each A=A/nCells) - annotation (Placement(transformation(extent={{10,-90},{-10,-70}}))); - - Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor[nCells](each G=G/nCells) - annotation (Placement(transformation( - extent={{-10,-10},{10,10}}, - rotation=90, - origin={0,0}))); - - SI.HeatFlowRate Q_flow_Air=sum(conductionElementAir.heatPort.Q_flow); - SI.HeatFlowRate Q_flow_Ref=sum(conductionElementRefrigerant.heatPort.Q_flow); - SI.Energy deltaE_system = sum(conductionElementAir.deltaE_system) + sum(conductionElementRefrigerant.deltaE_system); - SI.Mass M_ref = sum(conductionElementRefrigerant.M); - - //Relevant variables - SI.SpecificEnthalpy h_out_ref = Undirected.Internal.regStep( rearRef.m_flow, - MediumRefrigerant.specificEnthalpy(foreRef.state_forwards), MediumRefrigerant.specificEnthalpy(rearRef.state_rearwards), m_flow_reg); - SI.SpecificEnthalpy h_out_air = Undirected.Internal.regStep( rearAir.m_flow, - MediumAir.specificEnthalpy(foreAir.state_forwards), MediumAir.specificEnthalpy(rearAir.state_rearwards), m_flow_reg); - SI.Temperature T_out_ref = Undirected.Internal.regStep( rearRef.m_flow, - MediumRefrigerant.temperature(foreRef.state_forwards), MediumRefrigerant.temperature(rearRef.state_rearwards), m_flow_reg); - SI.Temperature T_out_air = Undirected.Internal.regStep( rearAir.m_flow, - MediumAir.temperature(foreAir.state_forwards), MediumAir.temperature(rearAir.state_rearwards), m_flow_reg); - -protected - outer DropOfCommons dropOfCommons; - -initial equation - if initializeMassFlow then - foreAir.m_flow = m_flow_0; - foreRef.m_flow = m_flow_0; - else - end if; -equation - - //Connection equations (to interconnect segments) - //Fluid Side A - connect(rearAir, conductionElementAir[1].rear) annotation (Line(points={{-100,80},{-10,80}}, color={28,108,200})); - for i in 1:nCells-1 loop - connect(conductionElementAir[i].fore, conductionElementAir[i + 1].rear); - end for; - connect(conductionElementAir[nCells].fore, foreAir) annotation (Line(points={{10,80},{100,80}}, color={28,108,200})); - - //Fluid Side B - connect(rearRef, conductionElementRefrigerant[1].rear) annotation (Line(points={{100,-80},{10,-80}}, color={28,108,200})); - for i in 1:nCells-1 loop - connect(conductionElementRefrigerant[i].fore, conductionElementRefrigerant[i + 1].rear); - end for; - connect(conductionElementRefrigerant[nCells].fore, foreRef) annotation (Line(points={{-10,-80},{-100,-80}}, color={28,108,200})); - - for i in 1:nCells loop - connect(conductionElementAir[i].heatPort, thermalConductor[i].port_b) annotation(Line(points={{4.44089e-16,70.2},{4.44089e-16,40},{0,40},{0,10}}, color={191,0,0})); - end for; - - for i in 1:nCells loop - connect(conductionElementRefrigerant[i].heatPort, thermalConductor[nCells + 1 - i].port_a) annotation(Line(points={{-6.66134e-16,-70.2},{ - -6.66134e-16,-10},{0,-10}}, color={191,0,0})); - end for; - - annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), - graphics={ - Rectangle( - extent={{-100,100},{100,-100}}, - lineColor={28,108,200}, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - radius=25), - Polygon(points={{-80,-92},{70,-92},{70,-62},{-80,-62},{-70,-52},{80,-52},{80,-82},{70,-92},{70,-62},{80,-52},{-70,-52},{-80,-62},{-80,-92}}, - lineColor={5,188,185}), - Line(points={{-40,-52},{-50,-62},{-50,-92}}, color={5,188,185}), - Line(points={{-10,-52},{-20,-62},{-20,-92}},color={5,188,185}), - Line(points={{20,-52},{10,-62},{10,-92}}, color={5,188,185}), - Line(points={{50,-52},{40,-62},{40,-92}}, color={5,188,185}), - Text( - extent={{-70,-72},{-58,-84}}, - lineColor={5,188,185}, - pattern=LinePattern.Dash, - textString="N"), - Text( - extent={{52,-72},{64,-84}}, - lineColor={5,188,185}, - pattern=LinePattern.Dash, - textString="1"), - Text( - extent={{20,-72},{32,-84}}, - lineColor={5,188,185}, - pattern=LinePattern.Dash, - textString="2"), - Text( - extent={{-10,-72},{2,-84}}, - lineColor={5,188,185}, - pattern=LinePattern.Dash, - textString="..."), - Text( - extent={{-40,-72},{-28,-84}}, - lineColor={5,188,185}, - pattern=LinePattern.Dash, - textString="..."), - Polygon(points={{-80,56},{70,56},{70,86},{-80,86},{-70,96},{80,96},{80,66},{70,56},{70,86},{80,96},{-70,96},{-80,86},{-80,56}}, lineColor={28, - 108,200}), - Line(points={{-40,96},{-50,86},{-50,56}}, color={28,108,200}), - Line(points={{-10,96},{-20,86},{-20,56}}, color={28,108,200}), - Line(points={{20,96},{10,86},{10,56}}, color={28,108,200}), - Line(points={{50,96},{40,86},{40,56}}, color={28,108,200}), - Text( - extent={{50,76},{62,64}}, - lineColor={28,108,200}, - pattern=LinePattern.Dash, - textString="N"), - Text( - extent={{20,76},{32,64}}, - lineColor={28,108,200}, - pattern=LinePattern.Dash, - textString="..."), - Text( - extent={{-10,76},{2,64}}, - lineColor={28,108,200}, - pattern=LinePattern.Dash, - textString="..."), - Text( - extent={{-42,76},{-30,64}}, - lineColor={28,108,200}, - pattern=LinePattern.Dash, - textString="2"), - Text( - extent={{-72,76},{-60,64}}, - lineColor={28,108,200}, - pattern=LinePattern.Dash, - textString="1"), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={-61,36}, - rotation=270), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={1,36}, - rotation=270), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={61,36}, - rotation=270), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={57,-36}, - rotation=90), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={-65,-36}, - rotation=90), - Text( - extent={{-8,41},{8,-41}}, - lineColor={188,36,38}, - lineThickness=0.5, - fillColor={255,255,255}, - fillPattern=FillPattern.Solid, - textString="«", - origin={-3,-36}, - rotation=90), - Polygon(points={{-82,-16},{68,-16},{68,4},{-82,4},{-72,14},{78,14},{78,-6},{68,-16},{68,4},{78,14},{-72,14},{-82,4},{-82,-16}}, lineColor={188, - 36,38}), - Line(points={{-42,14},{-52,4},{-52,-16}}, color={188,36,38}), - Line(points={{-12,14},{-22,4},{-22,-16}}, color={188,36,38}), - Line(points={{18,14},{8,4},{8,-16}}, color={188,36,38}), - Line(points={{48,14},{38,4},{38,-16}}, color={188,36,38})}), - Diagram( - coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}))); -end DiscretizedHEX; diff --git a/ThermofluidStream/Undirected/HeatExchangers/Internal/ConductionElementHEX.mo b/ThermofluidStream/Undirected/HeatExchangers/Internal/ConductionElementHEX.mo index e8fc5c50..a2b3931f 100644 --- a/ThermofluidStream/Undirected/HeatExchangers/Internal/ConductionElementHEX.mo +++ b/ThermofluidStream/Undirected/HeatExchangers/Internal/ConductionElementHEX.mo @@ -1,17 +1,11 @@ within ThermofluidStream.Undirected.HeatExchangers.Internal; -model ConductionElementHEX "Volume with quasisationary mass and heatport" - extends Processes.Internal.PartialConductionElement( - final neglectPressureChanges=true); +model ConductionElementHEX "ConductionElement for single-phase fluids" + extends PartialConductionElementHEX; - parameter SI.Area A = 1 "Contact area of element with medium"; - parameter SI.CoefficientOfHeatTransfer U_nom "Heat transfer coefficient to medium"; - parameter SI.MassFlowRate m_flow_nom = 1.0 "Nominal mass-flow rate for heat transfer calculation" annotation(Dialog(group = "Heat transfer parameters")); + parameter SI.CoefficientOfHeatTransfer U_nom = 3000 "Heat transfer coefficient to medium"; + parameter SI.MassFlowRate m_flow_nom = 1 "Nominal mass-flow rate for heat transfer calculation" annotation(Dialog(group = "Heat transfer parameters")); -protected constant Real Re_exp = 0.8 "Reynolds-exponent for heat transfer calculation"; - constant SI.CoefficientOfHeatTransfer U_min = 1 "Minimum heat transfer coefficient for temperature adaption at zero massflow"; - - SI.CoefficientOfHeatTransfer U "Heat transfer coefficient to medium"; initial equation assert(init <> Processes.Internal.InitializationMethodsCondElement.port, "This initialization will lead to large nonlinear equation systems. Please choose 'T0', 'h0', 'rear' or 'fore'."); @@ -20,8 +14,6 @@ equation //Estimation of heat transfer coefficient U = max(U_min, U_nom*(abs(m_flow/m_flow_nom))^Re_exp); - k = U*A; - annotation (Dialog(tab="Initialization", group="Enthalpy"), Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)), diff --git a/ThermofluidStream/Undirected/HeatExchangers/Internal/ConductionElementHEX_twoPhase.mo b/ThermofluidStream/Undirected/HeatExchangers/Internal/ConductionElementHEX_twoPhase.mo index 95823c29..9b0cb1b4 100644 --- a/ThermofluidStream/Undirected/HeatExchangers/Internal/ConductionElementHEX_twoPhase.mo +++ b/ThermofluidStream/Undirected/HeatExchangers/Internal/ConductionElementHEX_twoPhase.mo @@ -1,31 +1,22 @@ within ThermofluidStream.Undirected.HeatExchangers.Internal; -model ConductionElementHEX_twoPhase "Volume with quasisationary mass and heatport" - extends Processes.Internal.PartialConductionElement( - redeclare package Medium = TwoPhaseMedium, - init= Processes.Internal.InitializationMethodsCondElement.h, - final neglectPressureChanges=true); +model ConductionElementHEX_twoPhase "ConductionElement for two-phase fluids" + extends PartialConductionElementHEX(redeclare replaceable package Medium = Media.myMedia.Interfaces.PartialTwoPhaseMedium); import Modelica.Math; - replaceable package TwoPhaseMedium = Media.myMedia.Interfaces.PartialTwoPhaseMedium - annotation(choicesAllMatching=true); + parameter SI.CoefficientOfHeatTransfer U_liq_nom = 700 "Nominal coefficient of heat transfer for liquid region"; + parameter SI.CoefficientOfHeatTransfer U_vap_nom = 500 "Nominal coefficient of heat transfer for vapour region"; + parameter SI.CoefficientOfHeatTransfer U_tp_nom = 1000 "Nominal coefficient of heat transfer for two-phase region"; - parameter SI.Area A = 1 "Contact area of element with medium"; - parameter SI.CoefficientOfHeatTransfer U_liq_nom "Nominal coefficient of heat transfer for liquid region"; - parameter SI.CoefficientOfHeatTransfer U_vap_nom "Nominal coefficient of heat transfer for vapour region"; - parameter SI.CoefficientOfHeatTransfer U_tp_nom "Nominal coefficient of heat transfer for two-phase region"; - - parameter SI.MassFlowRate m_flow_nom = 0.5 "Nominal mass-flow rate for heat transfer calculation"; + parameter SI.MassFlowRate m_flow_nom = 0.3 "Nominal mass-flow rate for heat transfer calculation"; parameter SI.MassFraction delta_x = 0.05 "Value for interpolation width"; - constant Real Re_exp_cond = 0.4 "Reynolds-Exponent for heat transfer calculation at condensation (Yan&Lin, 1999)"; - constant Real Re_exp_evap = 0.5 "Reynolds-Exponent for heat transfer calculation at evaporation (Yan&Lin, 1999)"; - constant SI.CoefficientOfHeatTransfer U_min = 1 "Minimum heat transfer coefficient for temperature adaption at zero massflow"; + constant Real Re_exp_cond(unit="1") = 0.4 "Reynolds-Exponent for heat transfer calculation at condensation (Yan&Lin, 1999)"; + constant Real Re_exp_evap(unit="1") = 0.5 "Reynolds-Exponent for heat transfer calculation at evaporation (Yan&Lin, 1999)"; Real x "Vapor quality calculated from enthalpies"; protected - SI.CoefficientOfHeatTransfer U "Heat transfer coefficient to medium"; SI.CoefficientOfHeatTransfer U_liq "Coefficient of heat transfer for liquid region"; SI.CoefficientOfHeatTransfer U_tp "Coefficient of heat transfer for two-phase region"; SI.CoefficientOfHeatTransfer U_vap "Coefficient of heat transfer for vapour region"; @@ -53,8 +44,6 @@ equation elseif x < 1 + delta_x then U_tp + 0.5*(U_vap - U_tp)*(1 + Math.sin((x - 1)*Modelica.Constants.pi/(2*delta_x))) else U_vap)); - k = U*A; - annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={ Line( points={{0,100},{0,-30}}, diff --git a/ThermofluidStream/Undirected/HeatExchangers/Internal/PartialConductionElementHEX.mo b/ThermofluidStream/Undirected/HeatExchangers/Internal/PartialConductionElementHEX.mo new file mode 100644 index 00000000..072eea6e --- /dev/null +++ b/ThermofluidStream/Undirected/HeatExchangers/Internal/PartialConductionElementHEX.mo @@ -0,0 +1,14 @@ +within ThermofluidStream.Undirected.HeatExchangers.Internal; +partial model PartialConductionElementHEX "Parent for CEs for discretizedHEX" + extends Processes.Internal.PartialConductionElement(final neglectPressureChanges=true); + + parameter SI.Area A = 1 "Contact area of volume with medium"; + + constant SI.CoefficientOfHeatTransfer U_min = 1 "Minimum heat transfer coefficient for temperature adaption at zero massflow"; + + SI.CoefficientOfHeatTransfer U "Heat transfer coefficient to medium"; +equation + k = U*A; + + annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false))); +end PartialConductionElementHEX; diff --git a/ThermofluidStream/Undirected/HeatExchangers/Internal/package.order b/ThermofluidStream/Undirected/HeatExchangers/Internal/package.order index bbe4d047..dd61cd23 100644 --- a/ThermofluidStream/Undirected/HeatExchangers/Internal/package.order +++ b/ThermofluidStream/Undirected/HeatExchangers/Internal/package.order @@ -1,2 +1,3 @@ ConductionElementHEX ConductionElementHEX_twoPhase +PartialConductionElementHEX diff --git a/ThermofluidStream/Undirected/HeatExchangers/Tests/ConductionElementTwoPhase.mo b/ThermofluidStream/Undirected/HeatExchangers/Tests/ConductionElementTwoPhase.mo index 497e141f..9dc32940 100644 --- a/ThermofluidStream/Undirected/HeatExchangers/Tests/ConductionElementTwoPhase.mo +++ b/ThermofluidStream/Undirected/HeatExchangers/Tests/ConductionElementTwoPhase.mo @@ -5,8 +5,9 @@ model ConductionElementTwoPhase package MediumRefrigerant = Media.myMedia.R134a.R134a_ph; Internal.ConductionElementHEX_twoPhase conductionElementHEX_twoPhase( - redeclare package TwoPhaseMedium = MediumRefrigerant, + redeclare package Medium = MediumRefrigerant, V(displayUnit="l") = 0.001, + init=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h, A=10, U_liq_nom=700, U_vap_nom=500, diff --git a/ThermofluidStream/Undirected/HeatExchangers/Tests/TestDiscretizedHEX.mo b/ThermofluidStream/Undirected/HeatExchangers/Tests/TestDiscretizedHEX.mo index 10234dd3..2fac4a4e 100644 --- a/ThermofluidStream/Undirected/HeatExchangers/Tests/TestDiscretizedHEX.mo +++ b/ThermofluidStream/Undirected/HeatExchangers/Tests/TestDiscretizedHEX.mo @@ -59,14 +59,18 @@ model TestDiscretizedHEX offset=0.3, startTime=15) annotation (Placement(transformation(extent={{-40,-58},{-20,-38}}))); Modelica.Blocks.Sources.Constant const1(k=1e5) annotation (Placement(transformation(extent={{-120,14},{-100,34}}))); - DiscretizedHEX discretizedHEX( - redeclare package MediumAir = MediumAir, - redeclare package MediumRefrigerant = MediumRefrigerant, + DiscretizedCounterFlowHEX discretizedHEX( + redeclare package MediumA = MediumAir, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementA = Internal.ConductionElementHEX, + redeclare model ConductionElementB = Internal.ConductionElementHEX_twoPhase, nCells=10, V_Hex(displayUnit="m3"), initializeMassFlow=false, - k_wall=300) - annotation (Placement(transformation(extent={{-14,6},{6,26}}))); + k_wall=300) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={-4,16}))); Processes.FlowResistance flowResistanceB( redeclare package Medium = MediumRefrigerant, initM_flow=ThermofluidStream.Utilities.Types.InitializationMethods.state, @@ -126,14 +130,6 @@ model TestDiscretizedHEX offset=30e5, startTime=15) annotation (Placement(transformation(extent={{-134,-50},{-114,-30}}))); equation - connect(discretizedHEX.rearAir, multiSensor_Tpm.fore) annotation (Line( - points={{-14,24},{-22,24}}, - color={28,108,200}, - thickness=0.5)); - connect(discretizedHEX.foreAir, multiSensor_Tpm1.rear) annotation (Line( - points={{6,24},{18,24}}, - color={28,108,200}, - thickness=0.5)); connect(boundary_rear.p0_var, const1.y) annotation (Line(points={{-88,30},{-94,30},{-94,24},{-99,24}}, color={0,0,127})); connect(boundary_fore1.rear, flowResistanceB.fore) annotation (Line( @@ -151,14 +147,6 @@ equation points={{92,-8},{66,-8},{66,8},{38,8}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEX.rearRef, multiSensor_Tpm2.fore) annotation (Line( - points={{6,8},{18,8}}, - color={28,108,200}, - thickness=0.5)); - connect(discretizedHEX.foreRef, multiSensor_Tpm3.rear) annotation (Line( - points={{-14,8},{-24,8}}, - color={28,108,200}, - thickness=0.5)); connect(multiSensor_Tpm3.fore, flowResistanceB.rear) annotation (Line( points={{-44,8},{-52,8}}, color={28,108,200}, @@ -184,6 +172,22 @@ equation connect(boundary_fore1.p0_var, ramp3.y) annotation (Line(points={{-102,-34},{-108,-34},{-108,-40},{-113,-40}}, color={0,0,127})); connect(ramp2.y, feedback1.u1) annotation (Line(points={{-1,64},{24,64},{24,56},{40,56}}, color={0,0,127})); connect(feedback.u1, ramp1.y) annotation (Line(points={{0,-48},{-19,-48}}, color={0,0,127})); + connect(discretizedHEX.foreB, multiSensor_Tpm3.rear) annotation (Line( + points={{-14.2,8},{-24,8}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm.fore, discretizedHEX.rearA) annotation (Line( + points={{-22,24},{-14,24}}, + color={28,108,200}, + thickness=0.5)); + connect(discretizedHEX.foreA, multiSensor_Tpm1.rear) annotation (Line( + points={{6,24},{18,24}}, + color={28,108,200}, + thickness=0.5)); + connect(multiSensor_Tpm2.fore, discretizedHEX.rearB) annotation (Line( + points={{18,8},{6,8}}, + color={28,108,200}, + thickness=0.5)); annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)), experiment(StopTime=40, Tolerance=1e-6, Interval=0.04, __Dymola_Algorithm="Dassl"), Documentation(info=" diff --git a/ThermofluidStream/Undirected/HeatExchangers/Tests/TestDiscretizedHEXvsDir.mo b/ThermofluidStream/Undirected/HeatExchangers/Tests/TestDiscretizedHEXvsDir.mo index 08e2af37..59652d6b 100644 --- a/ThermofluidStream/Undirected/HeatExchangers/Tests/TestDiscretizedHEXvsDir.mo +++ b/ThermofluidStream/Undirected/HeatExchangers/Tests/TestDiscretizedHEXvsDir.mo @@ -62,14 +62,18 @@ model TestDiscretizedHEXvsDir duration=1, offset=0.3, startTime=15) annotation (Placement(transformation(extent={{-34,126},{-14,146}}))); - DiscretizedHEX discretizedHEXUndir( - redeclare package MediumAir = MediumAir, - redeclare package MediumRefrigerant = MediumRefrigerant, + DiscretizedCounterFlowHEX discretizedHEXUndir( + redeclare package MediumA = MediumAir, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementA = Internal.ConductionElementHEX, + redeclare model ConductionElementB = Internal.ConductionElementHEX_twoPhase, nCells=10, V_Hex(displayUnit="m3"), initializeMassFlow=true, - m_flow_0=0, - k_wall=300) annotation (Placement(transformation(extent={{-12,190},{8,210}}))); + k_wall=300) annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={-2,200}))); Processes.FlowResistance flowResistanceB( redeclare package Medium = MediumRefrigerant, m_flow_0=0, @@ -206,13 +210,16 @@ model TestDiscretizedHEXvsDir annotation (Placement(transformation(extent={{-134,-74},{-114,-54}}))); Modelica.Blocks.Nonlinear.Limiter limiter3(uMax=5e5, uMin=100) annotation (Placement(transformation(extent={{-76,-70},{-64,-58}}))); - ThermofluidStream.HeatExchangers.DiscretizedHEX evaporator( + ThermofluidStream.HeatExchangers.DiscretizedCounterFlowHEX + evaporator( + redeclare package MediumA = MediumAir, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementB = ThermofluidStream.HeatExchangers.Internal.ConductionElementHEX_twoPhase, initializeMassFlow=true, - m_flow_0=0, nCells=10, - redeclare package MediumAir = MediumAir, - redeclare package MediumRefrigerant = MediumRefrigerant, - k_wall=300) annotation (Placement(transformation(extent={{12,-46},{-8,-66}}))); + k_wall=300) annotation (Placement(transformation(extent={{10,10},{-10,-10}}, + rotation=180, + origin={2,-56}))); ThermofluidStream.Processes.FlowResistance flowResistanceA1( redeclare package Medium = MediumAir, m_flow_0=1, @@ -338,13 +345,16 @@ model TestDiscretizedHEXvsDir annotation (Placement(transformation(extent={{68,-140},{88,-120}}))); Modelica.Blocks.Nonlinear.Limiter limiter5(uMax=5e5, uMin=100) annotation (Placement(transformation(extent={{140,-172},{128,-160}}))); - ThermofluidStream.HeatExchangers.DiscretizedHEX condenser( + ThermofluidStream.HeatExchangers.DiscretizedCounterFlowHEX + condenser( + redeclare package MediumA = MediumAir, + redeclare package MediumB = MediumRefrigerant, + redeclare model ConductionElementB = ThermofluidStream.HeatExchangers.Internal.ConductionElementHEX_twoPhase, initializeMassFlow=true, - m_flow_0=0, nCells=10, - redeclare package MediumAir = MediumAir, - redeclare package MediumRefrigerant = MediumRefrigerant, - k_wall=300) annotation (Placement(transformation(extent={{-12,-184},{8,-164}}))); + k_wall=300) annotation (Placement(transformation(extent={{-10,-10},{10,10}}, + rotation=180, + origin={-2,-174}))); ThermofluidStream.Processes.FlowResistance flowResistanceA2( redeclare package Medium = MediumAir, m_flow_0=0.5, @@ -387,16 +397,6 @@ model TestDiscretizedHEXvsDir offset=1, startTime=15) annotation (Placement(transformation(extent={{-6,234},{14,254}}))); equation - connect(discretizedHEXUndir.rearAir, multiSensor_Tpm.fore) - annotation (Line( - points={{-12,208},{-20,208}}, - color={28,108,200}, - thickness=0.5)); - connect(discretizedHEXUndir.foreAir, multiSensor_Tpm1.rear) - annotation (Line( - points={{8,208},{20,208}}, - color={28,108,200}, - thickness=0.5)); connect(boundary_fore1.rear, flowResistanceB.fore) annotation (Line( points={{-88,144},{-82,144},{-82,192},{-70,192}}, color={28,108,200}, @@ -414,16 +414,6 @@ equation points={{94,176},{68,176},{68,192},{40,192}}, color={28,108,200}, thickness=0.5)); - connect(discretizedHEXUndir.rearRef, multiSensor_Tpm2.fore) - annotation (Line( - points={{8,192},{20,192}}, - color={28,108,200}, - thickness=0.5)); - connect(discretizedHEXUndir.foreRef, multiSensor_Tpm3.rear) - annotation (Line( - points={{-12,192},{-22,192}}, - color={28,108,200}, - thickness=0.5)); connect(multiSensor_Tpm3.fore, flowResistanceB.rear) annotation (Line( points={{-42,192},{-50,192}}, color={28,108,200}, @@ -486,11 +476,11 @@ equation color={28,108,200}, thickness=0.5)); connect(PI2.y, limiter2.u) annotation (Line(points={{-43,16},{-58,16},{-58,5.2}}, color={0,0,127})); - connect(multiSensor_Tpm4.outlet, evaporator.inletAir) annotation (Line( - points={{38,-64},{12,-64}}, + connect(multiSensor_Tpm4.outlet, evaporator.inletA) annotation (Line( + points={{38,-64},{20,-64},{20,-64},{12,-64}}, color={28,108,200}, thickness=0.5)); - connect(evaporator.outletAir,multiSensor_Tpm5. inlet) + connect(evaporator.outletA, multiSensor_Tpm5.inlet) annotation (Line( points={{-8.2,-64},{-12,-64}}, color={28,108,200}, @@ -500,11 +490,11 @@ equation color={0,0,127})); connect(multiSensor_Tpm5.m_flow_out,feedback3. u2) annotation (Line(points={{-32,-68},{-42,-68},{-42,-82},{-124,-82},{-124,-72}}, color={0,0,127})); - connect(evaporator.outletRef,multiSensor_Tpm6. inlet) annotation (Line( + connect(evaporator.outletB, multiSensor_Tpm6.inlet) annotation (Line( points={{12.2,-48},{26,-48}}, color={28,108,200}, thickness=0.5)); - connect(multiSensor_Tpm7.outlet,evaporator. inletRef) annotation (Line( + connect(multiSensor_Tpm7.outlet, evaporator.inletB) annotation (Line( points={{-18,-48},{-8,-48}}, color={28,108,200}, thickness=0.5)); @@ -512,22 +502,22 @@ equation connect(feedback2.u1, refFlow_setPoint1.y) annotation (Line(points={{4,16},{15,16}}, color={0,0,127})); connect(sourceB.p0_var, limiter2.y) annotation (Line(points={{-52,-18},{-52,-14},{-58,-14},{-58,-8.6}}, color={0,0,127})); - connect(singleSensorSelect.inlet,evaporator. outletRef) + connect(singleSensorSelect.inlet, evaporator.outletB) annotation (Line( points={{26,-24},{22,-24},{22,-48},{12.2,-48}}, color={28,108,200}, thickness=0.5)); - connect(singleSensorSelect1.inlet,evaporator. inletRef) + connect(singleSensorSelect1.inlet, evaporator.inletB) annotation (Line( points={{-18,-24},{-14,-24},{-14,-48},{-8,-48}}, color={28,108,200}, thickness=0.5)); - connect(sensorVaporQuality.inlet,evaporator. inletRef) + connect(sensorVaporQuality.inlet, evaporator.inletB) annotation (Line( points={{-18,-56},{-10,-56},{-10,-48},{-8,-48}}, color={28,108,200}, thickness=0.5)); - connect(sensorVaporQuality1.inlet,evaporator. outletRef) + connect(sensorVaporQuality1.inlet, evaporator.outletB) annotation (Line( points={{26,-56},{16,-56},{16,-48},{12.2,-48}}, color={28,108,200}, @@ -556,23 +546,22 @@ equation points={{-48,-166},{-64,-166}}, color={28,108,200}, thickness=0.5)); - connect(multiSensor_Tpm11.outlet, condenser.inletRef) - annotation (Line( + connect(multiSensor_Tpm11.outlet, condenser.inletB) annotation (Line( points={{20,-182},{8,-182}}, color={28,108,200}, thickness=0.5)); - connect(condenser.outletRef, multiSensor_Tpm10.inlet) + connect(condenser.outletB, multiSensor_Tpm10.inlet) annotation (Line( points={{-12.2,-182},{-24,-182}}, color={28,108,200}, thickness=0.5)); - connect(condenser.inletAir, multiSensor_Tpm8.outlet) + connect(condenser.inletA, multiSensor_Tpm8.outlet) annotation (Line( - points={{-12,-166},{-26,-166}}, + points={{-12,-166},{-14,-166},{-14,-166},{-26,-166}}, color={28,108,200}, thickness=0.5)); - connect(condenser.outletAir,multiSensor_Tpm9. inlet) annotation (Line( - points={{8.2,-166},{42,-166}}, + connect(condenser.outletA, multiSensor_Tpm9.inlet) annotation (Line( + points={{8.2,-166},{20,-166},{20,-166},{42,-166}}, color={28,108,200}, thickness=0.5)); connect(sinkB1.inlet, flowResistanceB2.outlet) annotation (Line( @@ -592,27 +581,45 @@ equation connect(multiSensor_Tpm11.m_flow_out, feedback4.u2) annotation (Line(points={{20,-186},{6,-186},{6,-236},{20,-236}}, color={0,0,127})); connect(PI4.y, limiter4.u) annotation (Line(points={{55,-244},{60.8,-244}}, color={0,0,127})); connect(refFlow_setPoint2.y, feedback4.u1) annotation (Line(points={{-3,-244},{12,-244}}, color={0,0,127})); - connect(singleSensorSelect2.inlet, condenser.outletRef) + connect(singleSensorSelect2.inlet, condenser.outletB) annotation (Line( points={{-24,-208},{-20,-208},{-20,-182},{-12.2,-182}}, color={28,108,200}, thickness=0.5)); - connect(singleSensorSelect3.inlet,condenser. inletRef) annotation (Line( + connect(singleSensorSelect3.inlet, condenser.inletB) + annotation (Line( points={{22,-206},{14,-206},{14,-182},{8,-182}}, color={28,108,200}, thickness=0.5)); - connect(sensorVaporQuality2.inlet, condenser.outletRef) + connect(sensorVaporQuality2.inlet, condenser.outletB) annotation (Line( points={{-24,-220},{-20,-220},{-20,-182},{-12.2,-182}}, color={28,108,200}, thickness=0.5)); - connect(sensorVaporQuality3.inlet,condenser. inletRef) annotation (Line( + connect(sensorVaporQuality3.inlet, condenser.inletB) + annotation (Line( points={{22,-220},{14,-220},{14,-182},{8,-182}}, color={28,108,200}, thickness=0.5)); connect(limiter4.y, sourceB1.p0_var) annotation (Line(points={{74.6,-244},{86,-244},{86,-208}}, color={0,0,127})); connect(rampPressure.y, boundary_rear.p0_var) annotation (Line(points={{-113,196},{-96,196},{-96,214},{-86,214}}, color={0,0,127})); connect(feedback1.u1, rampMassflow.y) annotation (Line(points={{42,240},{28,240},{28,244},{15,244}}, color={0,0,127})); + connect(discretizedHEXUndir.rearA, multiSensor_Tpm.fore) annotation (Line( + points={{-12,208},{-20,208}}, + color={28,108,200}, + thickness=0.5)); + connect(discretizedHEXUndir.foreB, multiSensor_Tpm3.rear) annotation (Line( + points={{-12.2,192},{-22,192}}, + color={28,108,200}, + thickness=0.5)); + connect(discretizedHEXUndir.rearB, multiSensor_Tpm2.fore) annotation (Line( + points={{8,192},{20,192}}, + color={28,108,200}, + thickness=0.5)); + connect(discretizedHEXUndir.foreA, multiSensor_Tpm1.rear) annotation (Line( + points={{8,208},{20,208}}, + color={28,108,200}, + thickness=0.5)); annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-280,-300},{260,300}}), graphics={ Rectangle(extent={{-208,-104},{170,-280}}, lineColor={28,108,200}), diff --git a/ThermofluidStream/Undirected/HeatExchangers/package.order b/ThermofluidStream/Undirected/HeatExchangers/package.order index ba55eddc..4042e880 100644 --- a/ThermofluidStream/Undirected/HeatExchangers/package.order +++ b/ThermofluidStream/Undirected/HeatExchangers/package.order @@ -1,3 +1,4 @@ -DiscretizedHEX +DiscretizedCrossFlowHEX +DiscretizedCounterFlowHEX Tests Internal diff --git a/ThermofluidStream/Undirected/Processes/Internal/PartialConductionElement.mo b/ThermofluidStream/Undirected/Processes/Internal/PartialConductionElement.mo index 66eef1ae..fe386b1b 100644 --- a/ThermofluidStream/Undirected/Processes/Internal/PartialConductionElement.mo +++ b/ThermofluidStream/Undirected/Processes/Internal/PartialConductionElement.mo @@ -3,12 +3,12 @@ partial model PartialConductionElement "Partial volume with quasisationary mass extends Interfaces.SISOBiFlow(final clip_p_out=false); parameter SI.Volume V = 1 "Volume of the element"; - parameter Internal.InitializationMethodsCondElement init=Internal.InitializationMethodsCondElement.rear "Initialization method for h" + parameter ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement init=ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.rear "Initialization method for h" annotation (Dialog(tab="Initialization", group="Enthalpy")); parameter SI.Temperature T_0 = Medium.T_default "Initial Temperature" - annotation(Dialog(tab="Initialization", group="Enthalpy", enable=(init == .ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.T))); + annotation(Dialog(tab="Initialization", group="Enthalpy", enable=(init == ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.T))); parameter SI.SpecificEnthalpy h_0 = Medium.h_default "Initial specific enthalpy" - annotation(Dialog(tab="Initialization", group="Enthalpy", enable=(init == .ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h))); + annotation(Dialog(tab="Initialization", group="Enthalpy", enable=(init == ThermofluidStream.Undirected.Processes.Internal.InitializationMethodsCondElement.h))); parameter SI.Density rho_min = dropOfCommons.rho_min "Minimal density" annotation(Dialog(tab="Advanced")); parameter Boolean neglectPressureChanges = true "Neglect pressure changes in energy equation" @@ -78,7 +78,11 @@ equation //neglegt V*der(p), since p might not be smooth -> to notice a difference der(p) must be about 1e7 Pa/s. see documentation/information M*der(h) = Q_flow + abs(m_flow)*(h_in - h_out) + (if enforce_global_energy_conservation then deltaE_system/T_e else 0); end if; - der(deltaE_system) = Q_flow + abs(m_flow)*(h_in - h_out); + if enforce_global_energy_conservation then + der(deltaE_system) = Q_flow + abs(m_flow)*(h_in - h_out); + else + deltaE_system = 0; + end if; Q_flow = k*(T_heatPort - T); diff --git a/ThermofluidStream/Undirected/Topology/JunctionMN.mo b/ThermofluidStream/Undirected/Topology/JunctionMN.mo index 5ec7f536..17bf04ca 100644 --- a/ThermofluidStream/Undirected/Topology/JunctionMN.mo +++ b/ThermofluidStream/Undirected/Topology/JunctionMN.mo @@ -98,13 +98,13 @@ equation fillPattern=FillPattern.Solid, lineThickness=0.5), Text( - extent={{-100,20},{-60,60}}, + extent={{60,20},{100,60}}, lineColor={175,175,175}, fillColor={255,255,255}, fillPattern=FillPattern.Solid, textString="%M"), Text( - extent={{60,20},{100,60}}, + extent={{-100,20},{-60,60}}, lineColor={175,175,175}, fillColor={255,255,255}, fillPattern=FillPattern.Solid, diff --git a/ThermofluidStream/package.mo b/ThermofluidStream/package.mo index 71817bc5..11f5d88e 100644 --- a/ThermofluidStream/package.mo +++ b/ThermofluidStream/package.mo @@ -5,8 +5,13 @@ package ThermofluidStream "Library for the Modelling of Thermofluid Streams" import SI = Modelica.SIunits; annotation ( - version="0.2.1", + version="0.3.0", uses(Modelica(version="3.2.3")), + conversion( + from( + version="0.2.1", + to="0.3.0", + script="modelica://ThermofluidStream/Resources/ConversionSkripts/convert0_2_1to0_3_0.mos")), Documentation(info=" ", revisions="