Extends from Modelica.Fluid.Icons.BaseClassLibrary (Icon for library).
Name | Description |
---|---|
PartialDynamicFourPortTransformer | Partial model transporting two fluid streams between four ports with storing mass or energy |
PartialStaticFourPortHeatMassTransfer | Partial model transporting two fluid streams between four ports without storing mass or energy |
PartialStaticFourPortInterface | Partial model transporting fluid between two ports without storing mass or energy |
PartialFourPort | Partial model with four ports |
FourPortFlowResistanceParameters | Parameters for flow resistance for models with four ports |
PartialDynamicTwoPortTransformer | Partial model transporting one fluid stream with storing mass or energy |
PartialStaticTwoPortHeatMassTransfer | Partial model transporting fluid between two ports without storing mass or energy |
PartialStaticTwoPortInterface | Partial model transporting fluid between two ports without storing mass or energy |
TwoPortFlowResistanceParameters | Parameters for flow resistance for models with two ports |
PartialLumpedVolume | Lumped volume with mass and energy balance |
This component transports two fluid streams between four ports. It provides the basic model for implementing a dynamic heat exchanger. It is used by HeatExchangers.BaseClasses.HexElement. The variable names follow the conventions used in Modelica.Fluid.HeatExchangers.BasicHX.
Extends from Buildings.Fluid.Interfaces.PartialStaticFourPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters (Parameters for flow resistance for models with four ports).
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium1 | PartialMedium | Medium 1 in the component | |
replaceable package Medium2 | PartialMedium | Medium 2 in the component | |
MixingVolumeDryAir | vol2 | redeclare Buildings.Fluid.Mi... | Volume for fluid 2 |
Nominal condition | |||
MassFlowRate | m1_flow_nominal | Nominal mass flow rate [kg/s] | |
MassFlowRate | m2_flow_nominal | Nominal mass flow rate [kg/s] | |
Pressure | dp1_nominal | Pressure [Pa] | |
Pressure | dp2_nominal | Pressure [Pa] | |
Time | tau1 | 60 | Time constant at nominal flow [s] |
Time | tau2 | 60 | Time constant at nominal flow [s] |
Initialization | |||
MassFlowRate | m1_flow.start | 0 | Mass flow rate from port_a1 to port_b1 (m1_flow > 0 is design flow direction) [kg/s] |
Pressure | dp1.start | 0 | Pressure difference between port_a1 and port_b1 [Pa] |
MassFlowRate | m2_flow.start | 0 | Mass flow rate from port_a2 to port_b2 (m2_flow > 0 is design flow direction) [kg/s] |
Pressure | dp2.start | 0 | Pressure difference between port_a2 and port_b2 [Pa] |
Assumptions | |||
Boolean | allowFlowReversal1 | system.allowFlowReversal | = true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b) |
Boolean | allowFlowReversal2 | system.allowFlowReversal | = true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b) |
Initialization | |||
SpecificEnthalpy | h_outflow_a1_start | Medium1.h_default | Start value for enthalpy flowing out of port a1 [J/kg] |
SpecificEnthalpy | h_outflow_b1_start | Medium1.h_default | Start value for enthalpy flowing out of port b1 [J/kg] |
SpecificEnthalpy | h_outflow_a2_start | Medium2.h_default | Start value for enthalpy flowing out of port a2 [J/kg] |
SpecificEnthalpy | h_outflow_b2_start | Medium2.h_default | Start value for enthalpy flowing out of port b2 [J/kg] |
Advanced | |||
MassFlowRate | m1_flow_small | 1E-4*m1_flow_nominal | Small mass flow rate for regularization of zero flow [kg/s] |
MassFlowRate | m2_flow_small | 1E-4*m2_flow_nominal | Small mass flow rate for regularization of zero flow [kg/s] |
Diagnostics | |||
Boolean | show_V_flow | false | = true, if volume flow rate at inflowing port is computed |
Boolean | show_T | false | = true, if actual temperature at port is computed (may lead to events) |
Flow resistance | |||
Medium 1 | |||
Boolean | computeFlowResistance1 | true | =true, compute flow resistance. Set to false to assume no friction |
Boolean | from_dp1 | false | = true, use m_flow = f(dp) else dp = f(m_flow) |
Boolean | linearizeFlowResistance1 | false | = true, use linear relation between m_flow and dp for any flow rate |
Real | deltaM1 | 0.1 | Fraction of nominal flow rate where flow transitions to laminar |
Medium 2 | |||
Boolean | computeFlowResistance2 | true | =true, compute flow resistance. Set to false to assume no friction |
Boolean | from_dp2 | false | = true, use m_flow = f(dp) else dp = f(m_flow) |
Boolean | linearizeFlowResistance2 | false | = true, use linear relation between m_flow and dp for any flow rate |
Real | deltaM2 | 0.1 | Fraction of nominal flow rate where flow transitions to laminar |
Type | Name | Description |
---|---|---|
FluidPort_a | port_a1 | Fluid connector a1 (positive design flow direction is from port_a1 to port_b1) |
FluidPort_b | port_b1 | Fluid connector b1 (positive design flow direction is from port_a1 to port_b1) |
FluidPort_a | port_a2 | Fluid connector a2 (positive design flow direction is from port_a2 to port_b2) |
FluidPort_b | port_b2 | Fluid connector b2 (positive design flow direction is from port_a2 to port_b2) |
partial model PartialDynamicFourPortTransformer "Partial model transporting two fluid streams between four ports with storing mass or energy" extends Buildings.Fluid.Interfaces.PartialStaticFourPortInterface; extends Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters( final computeFlowResistance1=true, final computeFlowResistance2=true); import Modelica.Constants;Buildings.Fluid.MixingVolumes.MixingVolume vol1( redeclare package Medium = Medium1, nPorts = 2, V=m1_flow_nominal*tau1/rho1_nominal, medium(T(stateSelect=StateSelect.always)), final use_HeatTransfer=true, redeclare model HeatTransfer = Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.IdealHeatTransfer) "Volume for fluid 1"; replaceable Buildings.Fluid.MixingVolumes.MixingVolumeDryAir vol2( redeclare package Medium = Medium2, nPorts = 2, V=m2_flow_nominal*tau2/rho2_nominal, final use_HeatTransfer=true, redeclare model HeatTransfer = Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.IdealHeatTransfer(surfaceAreas={1})) constrainedby Buildings.Fluid.MixingVolumes.BaseClasses.PartialMixingVolumeWaterPort "Volume for fluid 2"; parameter Modelica.SIunits.Time tau1 = 60 "Time constant at nominal flow"; parameter Modelica.SIunits.Time tau2 = 60 "Time constant at nominal flow"; Modelica.SIunits.HeatFlowRate Q1_flow= if vol1.use_HeatTransfer then sum(vol1.heatPort.Q_flow) else 0 "Heat flow rate into medium 1"; Modelica.SIunits.HeatFlowRate Q2_flow= if vol2.use_HeatTransfer then sum(vol2.heatPort.Q_flow) else 0 "Heat flow rate into medium 2"; protected parameter Medium1.ThermodynamicState sta1_nominal=Medium1.setState_pTX( T=Medium1.T_default, p=Medium1.p_default, X=Medium1.X_default); parameter Modelica.SIunits.Density rho1_nominal=Medium1.density(sta1_nominal) "Density, used to compute fluid volume"; parameter Medium2.ThermodynamicState sta2_nominal=Medium2.setState_pTX( T=Medium2.T_default, p=Medium2.p_default, X=Medium2.X_default); parameter Modelica.SIunits.Density rho2_nominal=Medium2.density(sta2_nominal) "Density, used to compute fluid volume";public FixedResistances.FixedResistanceDpM preDro1( redeclare package Medium = Medium1, final use_dh=false, final m_flow_nominal=m1_flow_nominal, final deltaM=deltaM1, final allowFlowReversal=allowFlowReversal1, final m_flow_small=m1_flow_small, final show_T=false, final show_V_flow=show_V_flow, final from_dp=from_dp1, final linearized=linearizeFlowResistance1, final dp_nominal=dp1_nominal, final dh=1, final ReC=4000) "Pressure drop model for fluid 1"; FixedResistances.FixedResistanceDpM preDro2( redeclare package Medium = Medium2, final use_dh=false, final m_flow_nominal=m2_flow_nominal, final deltaM=deltaM2, final allowFlowReversal=allowFlowReversal2, final m_flow_small=m2_flow_small, final show_T=false, final show_V_flow=show_V_flow, final from_dp=from_dp2, final linearized=linearizeFlowResistance2, final dp_nominal=dp2_nominal, final dh=1, final ReC=4000) "Pressure drop model for fluid 2"; equation assert(vol1.use_HeatTransfer == true, "Wrong parameter for vol1."); assert(vol2.use_HeatTransfer == true, "Wrong parameter for vol2.");connect(vol1.ports[2], port_b1); connect(vol2.ports[2], port_b2); connect(port_a1, preDro1.port_a); connect(preDro1.port_b, vol1.ports[1]); connect(port_a2, preDro2.port_a); connect(preDro2.port_b, vol2.ports[1]); end PartialDynamicFourPortTransformer;
This component transports two fluid streams between four ports, without storing mass or energy. It is similar to Buildings.Fluid.Interfaces.PartialStaticTwoPortHeatMassTransfer, but it has four ports instead of two. See the documentation of Buildings.Fluid.Interfaces.PartialStaticTwoPortHeatMassTransfer for how to use this partial model.
Extends from Buildings.Fluid.Interfaces.PartialStaticFourPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters (Parameters for flow resistance for models with four ports).
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium1 | PartialMedium | Medium 1 in the component | |
replaceable package Medium2 | PartialMedium | Medium 2 in the component | |
Nominal condition | |||
MassFlowRate | m1_flow_nominal | Nominal mass flow rate [kg/s] | |
MassFlowRate | m2_flow_nominal | Nominal mass flow rate [kg/s] | |
Pressure | dp1_nominal | Pressure [Pa] | |
Pressure | dp2_nominal | Pressure [Pa] | |
Initialization | |||
MassFlowRate | m1_flow.start | 0 | Mass flow rate from port_a1 to port_b1 (m1_flow > 0 is design flow direction) [kg/s] |
Pressure | dp1.start | 0 | Pressure difference between port_a1 and port_b1 [Pa] |
MassFlowRate | m2_flow.start | 0 | Mass flow rate from port_a2 to port_b2 (m2_flow > 0 is design flow direction) [kg/s] |
Pressure | dp2.start | 0 | Pressure difference between port_a2 and port_b2 [Pa] |
Assumptions | |||
Boolean | allowFlowReversal1 | system.allowFlowReversal | = true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b) |
Boolean | allowFlowReversal2 | system.allowFlowReversal | = true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b) |
Initialization | |||
SpecificEnthalpy | h_outflow_a1_start | Medium1.h_default | Start value for enthalpy flowing out of port a1 [J/kg] |
SpecificEnthalpy | h_outflow_b1_start | Medium1.h_default | Start value for enthalpy flowing out of port b1 [J/kg] |
SpecificEnthalpy | h_outflow_a2_start | Medium2.h_default | Start value for enthalpy flowing out of port a2 [J/kg] |
SpecificEnthalpy | h_outflow_b2_start | Medium2.h_default | Start value for enthalpy flowing out of port b2 [J/kg] |
Advanced | |||
MassFlowRate | m1_flow_small | 1E-4*m1_flow_nominal | Small mass flow rate for regularization of zero flow [kg/s] |
MassFlowRate | m2_flow_small | 1E-4*m2_flow_nominal | Small mass flow rate for regularization of zero flow [kg/s] |
Diagnostics | |||
Boolean | show_V_flow | false | = true, if volume flow rate at inflowing port is computed |
Boolean | show_T | false | = true, if actual temperature at port is computed (may lead to events) |
Flow resistance | |||
Medium 1 | |||
Boolean | computeFlowResistance1 | (dp1_nominal > Modelica.Cons... | =true, compute flow resistance. Set to false to assume no friction |
Boolean | from_dp1 | false | = true, use m_flow = f(dp) else dp = f(m_flow) |
Boolean | linearizeFlowResistance1 | false | = true, use linear relation between m_flow and dp for any flow rate |
Real | deltaM1 | 0.1 | Fraction of nominal flow rate where flow transitions to laminar |
Medium 2 | |||
Boolean | computeFlowResistance2 | (dp2_nominal > Modelica.Cons... | =true, compute flow resistance. Set to false to assume no friction |
Boolean | from_dp2 | false | = true, use m_flow = f(dp) else dp = f(m_flow) |
Boolean | linearizeFlowResistance2 | false | = true, use linear relation between m_flow and dp for any flow rate |
Real | deltaM2 | 0.1 | Fraction of nominal flow rate where flow transitions to laminar |
Type | Name | Description |
---|---|---|
FluidPort_a | port_a1 | Fluid connector a1 (positive design flow direction is from port_a1 to port_b1) |
FluidPort_b | port_b1 | Fluid connector b1 (positive design flow direction is from port_a1 to port_b1) |
FluidPort_a | port_a2 | Fluid connector a2 (positive design flow direction is from port_a2 to port_b2) |
FluidPort_b | port_b2 | Fluid connector b2 (positive design flow direction is from port_a2 to port_b2) |
partial model PartialStaticFourPortHeatMassTransfer "Partial model transporting two fluid streams between four ports without storing mass or energy" extends Buildings.Fluid.Interfaces.PartialStaticFourPortInterface; extends Buildings.Fluid.Interfaces.FourPortFlowResistanceParameters( final computeFlowResistance1=(dp1_nominal > Modelica.Constants.eps), final computeFlowResistance2=(dp2_nominal > Modelica.Constants.eps)); import Modelica.Constants; Modelica.SIunits.HeatFlowRate Q1_flow "Heat transfered into the medium 1"; Medium1.MassFlowRate mXi1_flow[Medium1.nXi] "Mass flow rates of independent substances added to the medium 1"; Modelica.SIunits.HeatFlowRate Q2_flow "Heat transfered into the medium 2"; Medium2.MassFlowRate mXi2_flow[Medium2.nXi] "Mass flow rates of independent substances added to the medium 2"; protected constant Boolean sensibleOnly1 "Set to true if sensible exchange only for medium 1"; constant Boolean sensibleOnly2 "Set to true if sensible exchange only for medium 2"; equation // Energy balance (no storage, no heat loss/gain) port_a1.m_flow*port_a1.h_outflow + port_b1.m_flow*inStream(port_b1.h_outflow) = -Q1_flow; port_a1.m_flow*port_b1.h_outflow + port_b1.m_flow*inStream(port_a1.h_outflow) = Q1_flow; port_a2.m_flow*port_a2.h_outflow + port_b2.m_flow*inStream(port_b2.h_outflow) = -Q2_flow; port_a2.m_flow*port_b2.h_outflow + port_b2.m_flow*inStream(port_a2.h_outflow) = Q2_flow; // Mass balance (no storage) port_a1.m_flow + port_b1.m_flow = -sum(mXi1_flow); port_a2.m_flow + port_b2.m_flow = -sum(mXi2_flow); if sensibleOnly1 then port_a1.Xi_outflow = inStream(port_b1.Xi_outflow); port_b1.Xi_outflow = inStream(port_a1.Xi_outflow); else port_a1.m_flow*port_a1.Xi_outflow + port_b1.m_flow*inStream(port_b1.Xi_outflow) = -mXi1_flow; port_a1.m_flow*port_b1.Xi_outflow + port_b1.m_flow*inStream(port_a1.Xi_outflow) = mXi1_flow; end if; if sensibleOnly2 then port_a2.Xi_outflow = inStream(port_b2.Xi_outflow); port_b2.Xi_outflow = inStream(port_a2.Xi_outflow); else port_a2.m_flow*port_a2.Xi_outflow + port_b2.m_flow*inStream(port_b2.Xi_outflow) = -mXi2_flow; port_a2.m_flow*port_b2.Xi_outflow + port_b2.m_flow*inStream(port_a2.Xi_outflow) = mXi2_flow; end if; // Transport of trace substances port_a1.C_outflow = inStream(port_b1.C_outflow); port_b1.C_outflow = inStream(port_a1.C_outflow); port_a2.C_outflow = inStream(port_b2.C_outflow); port_b2.C_outflow = inStream(port_a2.C_outflow); // Pressure drop calculation // Medium 1 if computeFlowResistance1 then if from_dp1 then m1_flow = Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp( dp=dp1, k=m1_flow_nominal/sqrt(dp1_nominal), m_flow_turbulent=deltaM1 * m1_flow_nominal, linearized=linearizeFlowResistance1); else dp1 = Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow( m_flow=m1_flow, k=m1_flow_nominal/sqrt(dp1_nominal), m_flow_turbulent=deltaM1 * m1_flow_nominal, linearized=linearizeFlowResistance1); end if; else dp1 = 0; end if; // Medium 2 if computeFlowResistance2 then if from_dp2 then m2_flow = Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp( dp=dp2, k=m2_flow_nominal/sqrt(dp2_nominal), m_flow_turbulent=deltaM2 * m2_flow_nominal, linearized=linearizeFlowResistance2); else dp2 = Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow( m_flow=m2_flow, k=m2_flow_nominal/sqrt(dp2_nominal), m_flow_turbulent=deltaM2 * m2_flow_nominal, linearized=linearizeFlowResistance2); end if; else dp2 = 0; end if;end PartialStaticFourPortHeatMassTransfer;
This component defines the interface for models that transport two fluid streams between four ports. It is similar to Buildings.Fluid.Interfaces.PartialStaticTwoPortInterface, but it has four ports instead of two.
The model is used by other models in this package that add heat transfer, mass transfer and pressure drop equations.
Extends from Buildings.Fluid.Interfaces.PartialFourPort (Partial model with four ports).
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium1 | PartialMedium | Medium 1 in the component | |
replaceable package Medium2 | PartialMedium | Medium 2 in the component | |
Nominal condition | |||
MassFlowRate | m1_flow_nominal | Nominal mass flow rate [kg/s] | |
MassFlowRate | m2_flow_nominal | Nominal mass flow rate [kg/s] | |
Assumptions | |||
Boolean | allowFlowReversal1 | system.allowFlowReversal | = true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b) |
Boolean | allowFlowReversal2 | system.allowFlowReversal | = true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b) |
Initialization | |||
SpecificEnthalpy | h_outflow_a1_start | Medium1.h_default | Start value for enthalpy flowing out of port a1 [J/kg] |
SpecificEnthalpy | h_outflow_b1_start | Medium1.h_default | Start value for enthalpy flowing out of port b1 [J/kg] |
SpecificEnthalpy | h_outflow_a2_start | Medium2.h_default | Start value for enthalpy flowing out of port a2 [J/kg] |
SpecificEnthalpy | h_outflow_b2_start | Medium2.h_default | Start value for enthalpy flowing out of port b2 [J/kg] |
Advanced | |||
MassFlowRate | m1_flow_small | 1E-4*m1_flow_nominal | Small mass flow rate for regularization of zero flow [kg/s] |
MassFlowRate | m2_flow_small | 1E-4*m2_flow_nominal | Small mass flow rate for regularization of zero flow [kg/s] |
Diagnostics | |||
Boolean | show_V_flow | false | = true, if volume flow rate at inflowing port is computed |
Boolean | show_T | false | = true, if actual temperature at port is computed (may lead to events) |
partial model PartialStaticFourPortInterface "Partial model transporting fluid between two ports without storing mass or energy" import Modelica.Constants; extends Buildings.Fluid.Interfaces.PartialFourPort( port_a1( m_flow(min = if allowFlowReversal1 then -Constants.inf else 0)), port_b1( m_flow(max = if allowFlowReversal1 then +Constants.inf else 0)), port_a2( m_flow(min = if allowFlowReversal2 then -Constants.inf else 0)), port_b2( m_flow(max = if allowFlowReversal2 then +Constants.inf else 0))); parameter Modelica.SIunits.MassFlowRate m1_flow_nominal(min=0) "Nominal mass flow rate"; parameter Modelica.SIunits.MassFlowRate m2_flow_nominal(min=0) "Nominal mass flow rate"; parameter Medium1.MassFlowRate m1_flow_small(min=0) = 1E-4*m1_flow_nominal "Small mass flow rate for regularization of zero flow"; parameter Medium2.MassFlowRate m2_flow_small(min=0) = 1E-4*m2_flow_nominal "Small mass flow rate for regularization of zero flow"; // Diagnostics parameter Boolean show_V_flow = false "= true, if volume flow rate at inflowing port is computed"; parameter Boolean show_T = false "= true, if actual temperature at port is computed (may lead to events)"; public Modelica.SIunits.VolumeFlowRate V1_flow= m1_flow/Modelica.Fluid.Utilities.regStep(m1_flow, Medium1.density(state_a1_inflow), Medium1.density(state_b1_inflow), m1_flow_small) if show_V_flow "Volume flow rate at inflowing port (positive when flow from port_a1 to port_b1)"; Modelica.SIunits.VolumeFlowRate V2_flow= m2_flow/Modelica.Fluid.Utilities.regStep(m2_flow, Medium2.density(state_a2_inflow), Medium2.density(state_b2_inflow), m2_flow_small) if show_V_flow "Volume flow rate at inflowing port (positive when flow from port_a2 to port_b2)"; Medium1.MassFlowRate m1_flow(start=0) "Mass flow rate from port_a1 to port_b1 (m1_flow > 0 is design flow direction)"; Modelica.SIunits.Pressure dp1(start=0, displayUnit="Pa") "Pressure difference between port_a1 and port_b1"; Medium2.MassFlowRate m2_flow(start=0) "Mass flow rate from port_a2 to port_b2 (m2_flow > 0 is design flow direction)"; Modelica.SIunits.Pressure dp2(start=0, displayUnit="Pa") "Pressure difference between port_a2 and port_b2"; Medium1.ThermodynamicState sta_a1= Medium1.setState_phX(port_a1.p, actualStream(port_a1.h_outflow), actualStream(port_a1.Xi_outflow)) if show_T "Medium properties in port_a1"; Medium1.ThermodynamicState sta_b1= Medium1.setState_phX(port_b1.p, actualStream(port_b1.h_outflow), actualStream(port_b1.Xi_outflow)) if show_T "Medium properties in port_b1"; Medium2.ThermodynamicState sta_a2= Medium2.setState_phX(port_a2.p, actualStream(port_a2.h_outflow), actualStream(port_a2.Xi_outflow)) if show_T "Medium properties in port_a2"; Medium2.ThermodynamicState sta_b2= Medium2.setState_phX(port_b2.p, actualStream(port_b2.h_outflow), actualStream(port_b2.Xi_outflow)) if show_T "Medium properties in port_b2"; protected Medium1.ThermodynamicState state_a1_inflow= Medium1.setState_phX(port_a1.p, inStream(port_a1.h_outflow), inStream(port_a1.Xi_outflow)) "state for medium inflowing through port_a1"; Medium1.ThermodynamicState state_b1_inflow= Medium1.setState_phX(port_b1.p, inStream(port_b1.h_outflow), inStream(port_b1.Xi_outflow)) "state for medium inflowing through port_b1"; Medium2.ThermodynamicState state_a2_inflow= Medium2.setState_phX(port_a2.p, inStream(port_a2.h_outflow), inStream(port_a2.Xi_outflow)) "state for medium inflowing through port_a2"; Medium2.ThermodynamicState state_b2_inflow= Medium2.setState_phX(port_b2.p, inStream(port_b2.h_outflow), inStream(port_b2.Xi_outflow)) "state for medium inflowing through port_b2"; equation // Design direction of mass flow rate m1_flow = port_a1.m_flow; m2_flow = port_a2.m_flow; // Pressure difference between ports dp1 = port_a1.p - port_b1.p; dp2 = port_a2.p - port_b2.p;end PartialStaticFourPortInterface;
This partial model defines an interface for components with two ports. The treatment of the design flow direction and of flow reversal are predefined based on the parameter allowFlowReversal.
This partial model is identical to Modelica.Fluid.Interfaces.PartialTwoPort, except that it has four ports.
Type | Name | Default | Description |
---|---|---|---|
Assumptions | |||
Boolean | allowFlowReversal1 | system.allowFlowReversal | = true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b) |
Boolean | allowFlowReversal2 | system.allowFlowReversal | = true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b) |
Initialization | |||
SpecificEnthalpy | h_outflow_a1_start | Medium1.h_default | Start value for enthalpy flowing out of port a1 [J/kg] |
SpecificEnthalpy | h_outflow_b1_start | Medium1.h_default | Start value for enthalpy flowing out of port b1 [J/kg] |
SpecificEnthalpy | h_outflow_a2_start | Medium2.h_default | Start value for enthalpy flowing out of port a2 [J/kg] |
SpecificEnthalpy | h_outflow_b2_start | Medium2.h_default | Start value for enthalpy flowing out of port b2 [J/kg] |
Type | Name | Description |
---|---|---|
FluidPort_a | port_a1 | Fluid connector a1 (positive design flow direction is from port_a1 to port_b1) |
FluidPort_b | port_b1 | Fluid connector b1 (positive design flow direction is from port_a1 to port_b1) |
FluidPort_a | port_a2 | Fluid connector a2 (positive design flow direction is from port_a2 to port_b2) |
FluidPort_b | port_b2 | Fluid connector b2 (positive design flow direction is from port_a2 to port_b2) |
partial model PartialFourPort "Partial model with four ports" import Modelica.Constants; outer Modelica.Fluid.System system "System wide properties"; replaceable package Medium1 = Modelica.Media.Interfaces.PartialMedium "Medium 1 in the component"; replaceable package Medium2 = Modelica.Media.Interfaces.PartialMedium "Medium 2 in the component"; parameter Boolean allowFlowReversal1 = system.allowFlowReversal "= true to allow flow reversal in medium 1, false restricts to design direction (port_a -> port_b)"; parameter Boolean allowFlowReversal2 = system.allowFlowReversal "= true to allow flow reversal in medium 2, false restricts to design direction (port_a -> port_b)"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_a1_start = Medium1.h_default "Start value for enthalpy flowing out of port a1"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_b1_start = Medium1.h_default "Start value for enthalpy flowing out of port b1"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_a2_start = Medium2.h_default "Start value for enthalpy flowing out of port a2"; parameter Modelica.SIunits.SpecificEnthalpy h_outflow_b2_start = Medium2.h_default "Start value for enthalpy flowing out of port b2";Modelica.Fluid.Interfaces.FluidPort_a port_a1( redeclare package Medium = Medium1, m_flow(min=if allowFlowReversal1 then -Constants.inf else 0), h_outflow(nominal=1E5, start=h_outflow_a1_start), Xi_outflow(nominal=0.01)) "Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)"; Modelica.Fluid.Interfaces.FluidPort_b port_b1( redeclare package Medium = Medium1, m_flow(max=if allowFlowReversal1 then +Constants.inf else 0), h_outflow(nominal=1E5, start=h_outflow_b2_start), Xi_outflow(nominal=0.01)) "Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)"; Modelica.Fluid.Interfaces.FluidPort_a port_a2( redeclare package Medium = Medium2, m_flow(min=if allowFlowReversal2 then -Constants.inf else 0), h_outflow(nominal=1E5,start=h_outflow_a2_start), Xi_outflow(nominal=0.01)) "Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)"; Modelica.Fluid.Interfaces.FluidPort_b port_b2( redeclare package Medium = Medium2, m_flow(max=if allowFlowReversal2 then +Constants.inf else 0), h_outflow(nominal=1E5, start=h_outflow_b2_start), Xi_outflow(nominal=0.01)) "Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)"; end PartialFourPort;
Type | Name | Default | Description |
---|---|---|---|
Nominal condition | |||
Pressure | dp1_nominal | Pressure [Pa] | |
Pressure | dp2_nominal | Pressure [Pa] | |
Flow resistance | |||
Medium 1 | |||
Boolean | computeFlowResistance1 | true | =true, compute flow resistance. Set to false to assume no friction |
Boolean | from_dp1 | false | = true, use m_flow = f(dp) else dp = f(m_flow) |
Boolean | linearizeFlowResistance1 | false | = true, use linear relation between m_flow and dp for any flow rate |
Real | deltaM1 | 0.1 | Fraction of nominal flow rate where flow transitions to laminar |
Medium 2 | |||
Boolean | computeFlowResistance2 | true | =true, compute flow resistance. Set to false to assume no friction |
Boolean | from_dp2 | false | = true, use m_flow = f(dp) else dp = f(m_flow) |
Boolean | linearizeFlowResistance2 | false | = true, use linear relation between m_flow and dp for any flow rate |
Real | deltaM2 | 0.1 | Fraction of nominal flow rate where flow transitions to laminar |
record FourPortFlowResistanceParameters "Parameters for flow resistance for models with four ports" parameter Boolean computeFlowResistance1 = true "=true, compute flow resistance. Set to false to assume no friction"; parameter Boolean from_dp1 = false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.Pressure dp1_nominal(min=0, displayUnit="Pa") "Pressure"; parameter Boolean linearizeFlowResistance1 = false "= true, use linear relation between m_flow and dp for any flow rate"; parameter Real deltaM1 = 0.1 "Fraction of nominal flow rate where flow transitions to laminar"; parameter Boolean computeFlowResistance2 = true "=true, compute flow resistance. Set to false to assume no friction"; parameter Boolean from_dp2 = false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.Pressure dp2_nominal(min=0, displayUnit="Pa") "Pressure"; parameter Boolean linearizeFlowResistance2 = false "= true, use linear relation between m_flow and dp for any flow rate"; parameter Real deltaM2 = 0.1 "Fraction of nominal flow rate where flow transitions to laminar";end FourPortFlowResistanceParameters;
This component transports one fluid stream. It provides the basic model for implementing a dynamic heater such as a boiler. It is used by Buildings.Fluid.Boilers.BoilerPolynomial. The variable names follow the conventions used in Modelica.Fluid.HeatExchangers.BasicHX.
Extends from Buildings.Fluid.Interfaces.PartialStaticTwoPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters (Parameters for flow resistance for models with two ports).
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium | PartialMedium | Medium in the component | |
Nominal condition | |||
MassFlowRate | m_flow_nominal | Nominal mass flow rate [kg/s] | |
Pressure | dp_nominal | Pressure [Pa] | |
Time | tau | 300 | Time constant at nominal flow [s] |
Initialization | |||
MassFlowRate | m_flow.start | 0 | Mass flow rate from port_a to port_b (m_flow > 0 is design flow direction) [kg/s] |
Pressure | dp.start | 0 | Pressure difference between port_a and port_b [Pa] |
Assumptions | |||
Boolean | allowFlowReversal | system.allowFlowReversal | = true to allow flow reversal, false restricts to design direction (port_a -> port_b) |
Dynamics | |||
Dynamics | energyDynamics | system.energyDynamics | Formulation of energy balance |
Dynamics | massDynamics | energyDynamics | Formulation of mass balance |
Advanced | |||
MassFlowRate | m_flow_small | 1E-4*m_flow_nominal | Small mass flow rate for regularization of zero flow [kg/s] |
Diagnostics | |||
Boolean | show_V_flow | false | = true, if volume flow rate at inflowing port is computed |
Boolean | show_T | false | = true, if actual temperature at port is computed (may lead to events) |
Flow resistance | |||
Boolean | computeFlowResistance | true | =true, compute flow resistance. Set to false to assume no friction |
Boolean | from_dp | false | = true, use m_flow = f(dp) else dp = f(m_flow) |
Boolean | linearizeFlowResistance | false | = true, use linear relation between m_flow and dp for any flow rate |
Real | deltaM | 0.1 | Fraction of nominal flow rate where flow transitions to laminar |
Initialization | |||
AbsolutePressure | p_start | Medium.p_default | Start value of pressure [Pa] |
Boolean | use_T_start | true | = true, use T_start, otherwise h_start |
Temperature | T_start | if use_T_start then system.T... | Start value of temperature [K] |
SpecificEnthalpy | h_start | if use_T_start then Medium.s... | Start value of specific enthalpy [J/kg] |
MassFraction | X_start[Medium.nX] | Medium.X_default | Start value of mass fractions m_i/m [kg/kg] |
ExtraProperty | C_start[Medium.nC] | fill(0, Medium.nC) | Start value of trace substances |
Type | Name | Description |
---|---|---|
FluidPort_a | port_a | Fluid connector a (positive design flow direction is from port_a to port_b) |
FluidPort_b | port_b | Fluid connector b (positive design flow direction is from port_a to port_b) |
partial model PartialDynamicTwoPortTransformer "Partial model transporting one fluid stream with storing mass or energy" extends Buildings.Fluid.Interfaces.PartialStaticTwoPortInterface; extends Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters( final computeFlowResistance=true); import Modelica.Constants;Buildings.Fluid.MixingVolumes.MixingVolume vol( redeclare package Medium = Medium, nPorts = 2, V=m_flow_nominal*tau/rho_nominal, final use_HeatTransfer=true, redeclare model HeatTransfer = Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.IdealHeatTransfer, final energyDynamics=energyDynamics, final massDynamics=massDynamics, final p_start=p_start, final use_T_start=use_T_start, final T_start=T_start, final h_start=h_start, final X_start=X_start, final C_start=C_start) "Volume for fluid stream"; parameter Modelica.SIunits.Time tau = 300 "Time constant at nominal flow"; // Assumptions parameter Modelica.Fluid.Types.Dynamics energyDynamics=system.energyDynamics "Formulation of energy balance"; parameter Modelica.Fluid.Types.Dynamics massDynamics=energyDynamics "Formulation of mass balance"; final parameter Modelica.Fluid.Types.Dynamics substanceDynamics=massDynamics "Formulation of substance balance"; final parameter Modelica.Fluid.Types.Dynamics traceDynamics=massDynamics "Formulation of trace substance balance"; // Initialization parameter Medium.AbsolutePressure p_start = Medium.p_default "Start value of pressure"; parameter Boolean use_T_start = true "= true, use T_start, otherwise h_start"; parameter Medium.Temperature T_start= if use_T_start then system.T_start else Medium.temperature_phX(p_start,h_start,X_start) "Start value of temperature"; parameter Medium.SpecificEnthalpy h_start= if use_T_start then Medium.specificEnthalpy_pTX(p_start, T_start, X_start) else Medium.h_default "Start value of specific enthalpy"; parameter Medium.MassFraction X_start[Medium.nX] = Medium.X_default "Start value of mass fractions m_i/m"; parameter Medium.ExtraProperty C_start[Medium.nC]( quantity=Medium.extraPropertiesNames)=fill(0, Medium.nC) "Start value of trace substances";Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor temSen( T(final quantity="ThermodynamicTemperature", final unit = "K", displayUnit = "degC", min=0)) "Temperature sensor of metal"; protected parameter Medium.ThermodynamicState sta_nominal=Medium.setState_pTX( T=Medium.T_default, p=Medium.p_default, X=Medium.X_default); parameter Modelica.SIunits.Density rho_nominal=Medium.density(sta_nominal) "Density, used to compute fluid volume";public Buildings.Fluid.FixedResistances.FixedResistanceDpM preDro( redeclare package Medium = Medium, final use_dh=false, final m_flow_nominal=m_flow_nominal, final deltaM=deltaM, final allowFlowReversal=allowFlowReversal, final m_flow_small=m_flow_small, final show_T=false, final show_V_flow=show_V_flow, final from_dp=from_dp, final linearized=linearizeFlowResistance, final dp_nominal=dp_nominal) "Pressure drop model"; equation assert(vol.use_HeatTransfer == true, "Wrong parameter for vol.");connect(temSen.port, vol.heatPort); connect(vol.ports[2], port_b); connect(port_a, preDro.port_a); connect(preDro.port_b, vol.ports[1]); end PartialDynamicTwoPortTransformer;
This component transports fluid between its two ports, without storing mass or energy. It is based on Modelica.Fluid.Interfaces.PartialTwoPortTransport but it does use a different implementation for handling reverse flow because in this component, mass flow rate can be added or removed from the medium.
Depending on the parameter settings, this component computes pressure drop due to flow friction. The pressure drop is defined by a quadratic function that goes through the point (m_flow_nominal, dp_nominal). At |m_flow| < deltaM * m_flow_nominal, the pressure drop vs. flow relation is linearized. If the parameter linearizeFlowResistance is set to true, then the whole pressure drop vs. flow resistance curve is linearized.
When using this partial component, an equation for the energy and mass balances need to be added, such as
mWat_flow = u * m_flow_nominal; Q_flow = Medium.enthalpyOfLiquid(TWat) * mWat_flow; for i in 1:Medium.nXi loop mXi_flow[i] = if ( i == Medium.Water) then mWat_flow else 0; end for;
Extends from Buildings.Fluid.Interfaces.PartialStaticTwoPortInterface (Partial model transporting fluid between two ports without storing mass or energy), Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters (Parameters for flow resistance for models with two ports).
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium | PartialMedium | Medium in the component | |
Nominal condition | |||
MassFlowRate | m_flow_nominal | Nominal mass flow rate [kg/s] | |
Pressure | dp_nominal | Pressure [Pa] | |
Initialization | |||
MassFlowRate | m_flow.start | 0 | Mass flow rate from port_a to port_b (m_flow > 0 is design flow direction) [kg/s] |
Pressure | dp.start | 0 | Pressure difference between port_a and port_b [Pa] |
Assumptions | |||
Boolean | allowFlowReversal | system.allowFlowReversal | = true to allow flow reversal, false restricts to design direction (port_a -> port_b) |
Advanced | |||
MassFlowRate | m_flow_small | 1E-4*m_flow_nominal | Small mass flow rate for regularization of zero flow [kg/s] |
Diagnostics | |||
Boolean | show_V_flow | false | = true, if volume flow rate at inflowing port is computed |
Boolean | show_T | false | = true, if actual temperature at port is computed (may lead to events) |
Flow resistance | |||
Boolean | computeFlowResistance | (dp_nominal > Modelica.Const... | =true, compute flow resistance. Set to false to assume no friction |
Boolean | from_dp | false | = true, use m_flow = f(dp) else dp = f(m_flow) |
Boolean | linearizeFlowResistance | false | = true, use linear relation between m_flow and dp for any flow rate |
Real | deltaM | 0.1 | Fraction of nominal flow rate where flow transitions to laminar |
Type | Name | Description |
---|---|---|
FluidPort_a | port_a | Fluid connector a (positive design flow direction is from port_a to port_b) |
FluidPort_b | port_b | Fluid connector b (positive design flow direction is from port_a to port_b) |
partial model PartialStaticTwoPortHeatMassTransfer "Partial model transporting fluid between two ports without storing mass or energy" extends Buildings.Fluid.Interfaces.PartialStaticTwoPortInterface( showDesignFlowDirection = false); extends Buildings.Fluid.Interfaces.TwoPortFlowResistanceParameters( final computeFlowResistance=(dp_nominal > Modelica.Constants.eps)); import Modelica.Constants; Modelica.SIunits.HeatFlowRate Q_flow "Heat transfered into the medium"; Medium.MassFlowRate mXi_flow[Medium.nXi] "Mass flow rates of independent substances added to the medium"; protected constant Boolean sensibleOnly "Set to true if sensible exchange only"; equation // Energy balance (no storage, no heat loss/gain) port_a.m_flow*port_a.h_outflow + port_b.m_flow*inStream(port_b.h_outflow) = -Q_flow; port_a.m_flow*port_b.h_outflow + port_b.m_flow*inStream(port_a.h_outflow) = Q_flow; // Mass balance (no storage) port_a.m_flow + port_b.m_flow = -sum(mXi_flow); // Species balance, mXi_flow is ignored by this model if sensibleOnly then port_a.Xi_outflow = inStream(port_b.Xi_outflow); port_b.Xi_outflow = inStream(port_a.Xi_outflow); else port_a.m_flow*port_a.Xi_outflow + port_b.m_flow*inStream(port_b.Xi_outflow) = -mXi_flow; port_a.m_flow*port_b.Xi_outflow + port_b.m_flow*inStream(port_a.Xi_outflow) = mXi_flow; end if; // Transport of trace substances port_a.C_outflow = inStream(port_b.C_outflow); port_b.C_outflow = inStream(port_a.C_outflow); // Pressure drop calculation if computeFlowResistance then if from_dp then m_flow = Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp( dp=dp, k=m_flow_nominal/sqrt(dp_nominal), m_flow_turbulent=deltaM * m_flow_nominal, linearized=linearizeFlowResistance); else dp = Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow( m_flow=m_flow, k=m_flow_nominal/sqrt(dp_nominal), m_flow_turbulent=deltaM * m_flow_nominal, linearized=linearizeFlowResistance); end if; else dp = 0; end if;end PartialStaticTwoPortHeatMassTransfer;
This component defines the interface for models that transports a fluid between two ports. It is similar to Modelica.Fluid.Interfaces.PartialTwoPortTransport, but it does not include the species balance
port_b.Xi_outflow = inStream(port_a.Xi_outflow);Thus, it can be used as a base class for a heat and mass transfer component
The model is used by other models in this package that add heat transfer, mass transfer and pressure drop equations. See for example Buildings.Fluid.Interfaces.PartialStaticTwoPortHeatMassTransfer.
Extends from Modelica.Fluid.Interfaces.PartialTwoPort (Partial component with two ports).
Type | Name | Default | Description |
---|---|---|---|
replaceable package Medium | PartialMedium | Medium in the component | |
Nominal condition | |||
MassFlowRate | m_flow_nominal | Nominal mass flow rate [kg/s] | |
Assumptions | |||
Boolean | allowFlowReversal | system.allowFlowReversal | = true to allow flow reversal, false restricts to design direction (port_a -> port_b) |
Advanced | |||
MassFlowRate | m_flow_small | 1E-4*m_flow_nominal | Small mass flow rate for regularization of zero flow [kg/s] |
Diagnostics | |||
Boolean | show_V_flow | false | = true, if volume flow rate at inflowing port is computed |
Boolean | show_T | false | = true, if actual temperature at port is computed (may lead to events) |
partial model PartialStaticTwoPortInterface "Partial model transporting fluid between two ports without storing mass or energy" import Modelica.Constants; extends Modelica.Fluid.Interfaces.PartialTwoPort( port_a(p(start=Medium.p_default, nominal=Medium.p_default)), port_b(p(start=Medium.p_default, nominal=Medium.p_default))); parameter Medium.MassFlowRate m_flow_nominal(min=0) "Nominal mass flow rate"; parameter Medium.MassFlowRate m_flow_small(min=0) = 1E-4*m_flow_nominal "Small mass flow rate for regularization of zero flow"; // Diagnostics parameter Boolean show_V_flow = false "= true, if volume flow rate at inflowing port is computed"; parameter Boolean show_T = false "= true, if actual temperature at port is computed (may lead to events)"; Modelica.SIunits.VolumeFlowRate V_flow= m_flow/Medium.density(sta_a) if show_V_flow "Volume flow rate at inflowing port (positive when flow from port_a to port_b)"; Medium.MassFlowRate m_flow(start=0) "Mass flow rate from port_a to port_b (m_flow > 0 is design flow direction)"; Modelica.SIunits.Pressure dp(start=0, displayUnit="Pa") "Pressure difference between port_a and port_b"; Medium.ThermodynamicState sta_a= Medium.setState_phX(port_a.p, actualStream(port_a.h_outflow), actualStream(port_a.Xi_outflow)) if show_T or show_V_flow "Medium properties in port_a"; Medium.ThermodynamicState sta_b= Medium.setState_phX(port_b.p, actualStream(port_b.h_outflow), actualStream(port_b.Xi_outflow)) if show_T "Medium properties in port_b"; equation // Design direction of mass flow rate m_flow = port_a.m_flow; // Pressure difference between ports dp = port_a.p - port_b.p;end PartialStaticTwoPortInterface;
Type | Name | Default | Description |
---|---|---|---|
Nominal condition | |||
Pressure | dp_nominal | Pressure [Pa] | |
Flow resistance | |||
Boolean | computeFlowResistance | true | =true, compute flow resistance. Set to false to assume no friction |
Boolean | from_dp | false | = true, use m_flow = f(dp) else dp = f(m_flow) |
Boolean | linearizeFlowResistance | false | = true, use linear relation between m_flow and dp for any flow rate |
Real | deltaM | 0.1 | Fraction of nominal flow rate where flow transitions to laminar |
record TwoPortFlowResistanceParameters "Parameters for flow resistance for models with two ports" parameter Boolean computeFlowResistance = true "=true, compute flow resistance. Set to false to assume no friction"; parameter Boolean from_dp = false "= true, use m_flow = f(dp) else dp = f(m_flow)"; parameter Modelica.SIunits.Pressure dp_nominal(min=0, displayUnit="Pa") "Pressure"; parameter Boolean linearizeFlowResistance = false "= true, use linear relation between m_flow and dp for any flow rate"; parameter Real deltaM = 0.1 "Fraction of nominal flow rate where flow transitions to laminar";end TwoPortFlowResistanceParameters;
Interface and base class for an ideally mixed fluid volume with the ability to store mass and energy. An extending class must specify an equation for Qb_flow, e.g. convective or latent heat flow rate across the boundary.
The component volume fluidVolume is an input that needs to be set in the extending class to complete the model.Further source terms must be defined by an extending class for fluid flow across the segment boundary:
Hb_flow, enthalpy flow,
mb_flow, mass flow,
mbXi_flow, substance mass flow, and
mbC_flow, trace substance mass flow.
Note: This model is similar to Modelica.Fluid.Interfaces.PartialLumpedVolume, except for
final
keyword for
the declaration of the the substance and trace substance balance.
Type | Name | Default | Description |
---|---|---|---|
Assumptions | |||
Dynamics | |||
Dynamics | energyDynamics | system.energyDynamics | Formulation of energy balance |
Dynamics | massDynamics | system.massDynamics | Formulation of mass balance |
Dynamics | substanceDynamics | energyDynamics | Formulation of substance balance |
Dynamics | traceDynamics | energyDynamics | Formulation of trace substance balance |
Initialization | |||
AbsolutePressure | p_start | Medium.p_default | Start value of pressure [Pa] |
Boolean | use_T_start | true | = true, use T_start, otherwise h_start |
Temperature | T_start | if use_T_start then system.T... | Start value of temperature [K] |
SpecificEnthalpy | h_start | if use_T_start then Medium.s... | Start value of specific enthalpy [J/kg] |
MassFraction | X_start[Medium.nX] | Medium.X_default | Start value of mass fractions m_i/m [kg/kg] |
ExtraProperty | C_start[Medium.nC] | fill(0, Medium.nC) | Start value of trace substances |
partial model PartialLumpedVolume "Lumped volume with mass and energy balance" import Modelica.Fluid.Types; import Modelica.Fluid.Types.Dynamics; outer Modelica.Fluid.System system "System properties"; replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium in the component"; // Inputs provided to the volume model input Modelica.SIunits.Volume fluidVolume "Volume"; // Assumptions parameter Types.Dynamics energyDynamics=system.energyDynamics "Formulation of energy balance"; parameter Types.Dynamics massDynamics=system.massDynamics "Formulation of mass balance"; parameter Types.Dynamics substanceDynamics=energyDynamics "Formulation of substance balance"; parameter Types.Dynamics traceDynamics=energyDynamics "Formulation of trace substance balance"; // Initialization parameter Medium.AbsolutePressure p_start = Medium.p_default "Start value of pressure"; parameter Boolean use_T_start = true "= true, use T_start, otherwise h_start"; parameter Medium.Temperature T_start= if use_T_start then system.T_start else Medium.temperature_phX(p_start,h_start,X_start) "Start value of temperature"; parameter Medium.SpecificEnthalpy h_start= if use_T_start then Medium.specificEnthalpy_pTX(p_start, T_start, X_start) else Medium.h_default "Start value of specific enthalpy"; parameter Medium.MassFraction X_start[Medium.nX] = Medium.X_default "Start value of mass fractions m_i/m"; parameter Medium.ExtraProperty C_start[Medium.nC]( quantity=Medium.extraPropertiesNames)=fill(0, Medium.nC) "Start value of trace substances"; Medium.BaseProperties medium( preferredMediumStates=true, p(start=p_start), h(start=h_start), T(start=T_start), Xi(start=X_start[1:Medium.nXi])); // X(start=X_start[1:Medium.nX]), Modelica.SIunits.Energy U "Internal energy of fluid"; Modelica.SIunits.Mass m "Mass of fluid"; Modelica.SIunits.Mass[Medium.nXi] mXi "Masses of independent components in the fluid"; Modelica.SIunits.Mass[Medium.nC] mC "Masses of trace substances in the fluid"; // C need to be added here because unlike for Xi, which has medium.Xi, // there is no variable medium.C Medium.ExtraProperty C[Medium.nC] "Trace substance mixture content"; // variables that need to be defined by an extending class Modelica.SIunits.MassFlowRate mb_flow "Mass flows across boundaries"; Modelica.SIunits.MassFlowRate[Medium.nXi] mbXi_flow "Substance mass flows across boundaries"; Medium.ExtraPropertyFlowRate[Medium.nC] mbC_flow "Trace substance mass flows across boundaries"; Modelica.SIunits.EnthalpyFlowRate Hb_flow "Enthalpy flow across boundaries or energy source/sink"; Modelica.SIunits.HeatFlowRate Qb_flow "Heat flow across boundaries or energy source/sink"; protected parameter Boolean initialize_p = not Medium.singleState "= true to set up initial equations for pressure"; equation /* statement from original model assert(not (energyDynamics<>Dynamics.SteadyState and massDynamics==Dynamics.SteadyState) or Medium.singleState, "Bad combination of dynamics options and Medium not conserving mass if fluidVolume is fixed."); */ // Total quantities m = fluidVolume*medium.d; mXi = m*medium.Xi; U = m*medium.u; mC = m*C; // Energy and mass balances if energyDynamics == Dynamics.SteadyState then 0 = Hb_flow + Qb_flow; else der(U) = Hb_flow + Qb_flow; end if; if massDynamics == Dynamics.SteadyState then 0 = mb_flow; else der(m) = mb_flow; end if; if substanceDynamics == Dynamics.SteadyState then zeros(Medium.nXi) = mbXi_flow; else der(mXi) = mbXi_flow; end if; if traceDynamics == Dynamics.SteadyState then zeros(Medium.nC) = mbC_flow; else der(mC) = mbC_flow; end if; initial equation // initialization of balances if energyDynamics == Dynamics.FixedInitial then if use_T_start then medium.T = T_start; else medium.h = h_start; end if; elseif energyDynamics == Dynamics.SteadyStateInitial then if use_T_start then der(medium.T) = 0; else der(medium.h) = 0; end if; end if; if massDynamics == Dynamics.FixedInitial then if initialize_p then medium.p = p_start; end if; elseif massDynamics == Dynamics.SteadyStateInitial then if initialize_p then der(medium.p) = 0; end if; end if; if substanceDynamics == Dynamics.FixedInitial then medium.Xi = X_start[1:Medium.nXi]; elseif substanceDynamics == Dynamics.SteadyStateInitial then der(medium.Xi) = zeros(Medium.nXi); end if; if traceDynamics == Dynamics.FixedInitial then C = C_start[1:Medium.nC]; elseif traceDynamics == Dynamics.SteadyStateInitial then der(C) = zeros(Medium.nC); end if;end PartialLumpedVolume;