Collection of validation models
Information
This package contains validation models for the classes in
Buildings.Fluid.MixingVolumes.
Note that most validation models contain simple input data
which may not be realistic, but for which the correct
output can be obtained through an analytic solution.
The examples plot various outputs, which have been verified against these
solutions. These model outputs are stored as reference data and
used for continuous validation whenever models in the library change.
Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).
Package Content
Name |
Description |
MixingVolume
|
Test model for mixing volumes |
MixingVolumeHeatReverseFlow
|
Validation model for mixing volume with heat input and flow reversal |
MixingVolumeHeatReverseFlowPrescribedHeatFlowRate
|
Validation model for mixing volume with heat input and flow reversal and prescribed heat flow rate |
MixingVolumeInitialization
|
Test model for mixing volume initialization |
MixingVolumeMFactor
|
A check for verifying the implementation of the parameter mSenFac |
MixingVolumeMassFlow
|
Test model for mass flow into and out of volume |
MixingVolumeMoistureReverseFlow
|
Validation model for mixing volume with moisture input and flow reversal |
MixingVolumeMoistureReverseFlowPrescribedHeatFlowRate
|
Validation model for mixing volume with moisture input and flow reversal and prescribed heat flow rate |
MixingVolumeSteadyStateMass
|
Test model for steady state mass dynamics |
MixingVolumeTraceSubstance
|
Test model for mixing volume with trace substance input |
MixingVolumeTraceSubstanceReverseFlow
|
Validation model for mixing volume with trace substance input and flow reversal |
MixingVolumeTraceSubstanceReverseFlowPrescribedHeatFlowRate
|
Validation model for mixing volume with trace substance input and flow reversal, and prescribed heat flow rate |
MixingVolumeZeroFlow
|
Mixing volume verification around zero flow with heat exchange |
MoistureMixingConservationDynamicBalance
|
This test checks if mass and energy is conserved when mixing fluid streams using dynamic balances |
MoistureMixingConservationSteadyState
|
This test checks if mass and energy is conserved when mixing fluid streams using steady state balances |
TraceSubstanceConservationDynamicBalance
|
This test checks if trace substance mass flow rates are conserved when a dynamic balance is used |
TraceSubstanceConservationSteadyState
|
This test checks if trace substance mass flow rates are conserved when steady state |
BaseClasses
|
Baseclasses package |
Test model for mixing volumes
Information
This model tests the implementation of the mixing volumes.
It compares the results from the mixing volume of the Modelica
Standard Library with the implementation in the Buildings
library. If the changes are bigger than a prescribed limit,
the simulation stops with an error.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
model MixingVolume
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Air;
Modelica.Blocks.Sources.Ramp P(
duration=0.5,
startTime=0.5,
height=-10,
offset=101330);
Buildings.Fluid.Sources.Boundary_pT sou(
redeclare package Medium
= Medium, T=293.15,
use_p_in=true,
nPorts=3);
Buildings.Fluid.Sources.Boundary_pT sin(
redeclare package Medium
= Medium,
nPorts=3,
use_p_in=false,
p=101325,
T=283.15);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res1(
redeclare each package Medium = Medium,
from_dp=true,
m_flow_nominal=2,
dp_nominal=2.5);
MixingVolumes.MixingVolume vol1(
redeclare package Medium = Medium,
V=0.1,
nPorts=2,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
massDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
m_flow_nominal=2);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res2(
redeclare each package Medium = Medium,
from_dp=true,
m_flow_nominal=2,
dp_nominal=2.5);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res11(
redeclare each package Medium = Medium,
from_dp=true,
m_flow_nominal=2,
dp_nominal=2.5);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res12(
redeclare each package Medium = Medium,
from_dp=true,
m_flow_nominal=2,
dp_nominal=2.5);
Modelica.Fluid.Vessels.ClosedVolume vol(
redeclare package Medium = Medium,
V=0.1,
nPorts=2,
h_start=45300.945,
use_portsData=false,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
massDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial);
Buildings.Utilities.Diagnostics.AssertEquality assertEquality;
Buildings.Fluid.Sensors.EnthalpyFlowRate entFloRat(
redeclare package Medium
= Medium, m_flow_nominal=2) ;
Buildings.Fluid.Sensors.EnthalpyFlowRate entFloRat1(
redeclare package Medium
= Medium, m_flow_nominal=2) ;
Buildings.Fluid.MixingVolumes.MixingVolumeMoistAir vol2(
redeclare package Medium = Medium,
V=0.1,
nPorts=2,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
massDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
m_flow_nominal=2);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res21(
redeclare each package Medium = Medium,
from_dp=true,
m_flow_nominal=2,
dp_nominal=2.5);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res22(
redeclare each package Medium = Medium,
from_dp=true,
m_flow_nominal=2,
dp_nominal=2.5);
Buildings.Utilities.Diagnostics.AssertEquality assertEquality1;
Buildings.Fluid.Sensors.EnthalpyFlowRate entFloRat2(
redeclare package Medium
= Medium, m_flow_nominal=2) ;
Modelica.Blocks.Sources.Constant zero(k=0);
Modelica.Blocks.Sources.Constant TLiq(k=283.15);
inner Modelica.Fluid.System system;
equation
connect(P.y, sou.p_in);
connect(res2.port_a, entFloRat.port_b);
connect(entFloRat2.H_flow, assertEquality1.u2);
connect(zero.y, vol2.mWat_flow);
connect(TLiq.y, vol2.TWat);
connect(sou.ports[1], res1.port_a);
connect(sou.ports[2], res11.port_a);
connect(sou.ports[3], res21.port_a);
connect(sin.ports[1], res2.port_b);
connect(sin.ports[2], res12.port_b);
connect(res22.port_b, sin.ports[3]);
connect(res1.port_b, vol.ports[1]);
connect(vol.ports[2], entFloRat.port_a);
connect(res11.port_b, vol1.ports[1]);
connect(vol1.ports[2], entFloRat1.port_a);
connect(res21.port_b, vol2.ports[1]);
connect(vol2.ports[2], entFloRat2.port_a);
connect(entFloRat2.port_b, res22.port_a);
connect(entFloRat1.port_b, res12.port_a);
connect(entFloRat.H_flow, assertEquality.u1);
connect(entFloRat.H_flow, assertEquality1.u1);
connect(entFloRat1.H_flow, assertEquality.u2);
end MixingVolume;
Validation model for mixing volume with heat input and flow reversal
Information
This model validates the use of the mixing volume with air flowing into and out of the volume
and sensible heat added to the volume.
The model volDyn
uses a dynamic balance,
whereas the model volSte
uses a steady-state balance.
The mass flow rate starts positive and reverses its direction at t=5 seconds.
Extends from Buildings.Fluid.MixingVolumes.Validation.BaseClasses.MixingVolumeReverseFlow (Test model for mixing volume with flow reversal).
Parameters
Type | Name | Default | Description |
Pressure | dp_nominal | 10 | Nominal pressure drop [Pa] |
MassFlowRate | m_flow_nominal | 2.0 | Nominal mass flow rate [kg/s] |
MixingVolume | volDyn | redeclare Buildings.Fluid.Mi... | Volume with dynamic balance |
MixingVolume | volSte | redeclare Buildings.Fluid.Mi... | Volume with steady-state balance |
Modelica definition
Validation model for mixing volume with heat input and flow reversal and prescribed heat flow rate
Information
This model is identical to
Buildings.Fluid.MixingVolumes.Validation.MixingVolumeHeatReverseFlow,
except that the steady state volume volSte
is configured to have a prescribed heat flow rate,
which is in this case zero as the heat port is not connected.
This configures volSte
to use the two port
steady state heat and mass balance model
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation.
Extends from MixingVolumeHeatReverseFlow (Validation model for mixing volume with heat input and flow reversal).
Parameters
Type | Name | Default | Description |
Pressure | dp_nominal | 10 | Nominal pressure drop [Pa] |
MassFlowRate | m_flow_nominal | 2.0 | Nominal mass flow rate [kg/s] |
MixingVolume | volDyn | redeclare Buildings.Fluid.Mi... | Volume with dynamic balance |
MixingVolume | volSte | redeclare Buildings.Fluid.Mi... | Volume with steady-state balance |
Modelica definition
model MixingVolumeHeatReverseFlowPrescribedHeatFlowRate
extends MixingVolumeHeatReverseFlow(
prescribedHeatFlowRate=true);
end MixingVolumeHeatReverseFlowPrescribedHeatFlowRate;
Test model for mixing volume initialization
Information
This model tests the initialization of the mixing volume.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
model MixingVolumeInitialization
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Air;
Buildings.Fluid.Sources.Boundary_pT sou1(
redeclare package Medium =
Medium,
p=101330,
nPorts=1,
T=293.15);
Buildings.Fluid.Sources.Boundary_pT sin1(
redeclare package Medium =
Medium,
p=101320,
nPorts=1,
T=293.15);
Modelica.Fluid.Pipes.StaticPipe pipe1(
redeclare package Medium = Medium,
length=1,
diameter=0.25,
flowModel(m_flow_nominal=2));
Modelica.Fluid.Pipes.StaticPipe pipe2(
redeclare package Medium = Medium,
length=1,
diameter=0.25,
flowModel(m_flow_nominal=2));
MixingVolumes.MixingVolume vol1(
redeclare package Medium = Medium,
V=0.1,
nPorts=2,
m_flow_nominal=2,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial);
inner Modelica.Fluid.System system;
equation
connect(sou1.ports[1], pipe1.port_a);
connect(pipe1.port_b, vol1.ports[1]);
connect(vol1.ports[2], pipe2.port_a);
connect(pipe2.port_b, sin1.ports[1]);
end MixingVolumeInitialization;
A check for verifying the implementation of the parameter mSenFac
Information
This model contains two verifications for the implementation of mSenFac
:
-
The mixingVolume temperature
vol.T
should be constant.
This is to check the correct implementation of the parameter mSenFac
for moist air media.
-
The temperature response of
volMFactor.T
and vol1.T
should be nearly identical.
Furthermore the response of the species concentration Xi
demonstrates the
difference between using an mSenFac = 10
and multiplying volume by 10.
See
Buildings.Fluid.MixingVolumes.Validation.MixingVolumeMassFlow
for the rational of the selected initial conditions for the volumes.
Extends from Buildings.Fluid.MixingVolumes.Validation.MixingVolumeMassFlow (Test model for mass flow into and out of volume).
Parameters
Modelica definition
model MixingVolumeMFactor
extends Buildings.Fluid.MixingVolumes.Validation.MixingVolumeMassFlow(
sou(X={0.02,0.98},
T=Medium.T_default),
vol(mSenFac=10),
bou(nPorts=3));
Buildings.Fluid.MixingVolumes.MixingVolume volMFactor(
redeclare package Medium = Medium,
mSenFac=10,
V=1,
nPorts=2,
m_flow_nominal=m_flow_nominal,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
massDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial) ;
Buildings.Fluid.MixingVolumes.MixingVolume vol1(
redeclare package Medium = Medium,
V=10,
nPorts=2,
m_flow_nominal=m_flow_nominal,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
massDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial) ;
Buildings.Fluid.Sources.MassFlowSource_T boundaryMFactor(
redeclare package Medium = Medium,
T=300,
nPorts=1,
m_flow=1,
X={0.02,0.98}) ;
Buildings.Fluid.Sources.MassFlowSource_T boundary(
redeclare package Medium = Medium,
T=300,
nPorts=1,
m_flow=1,
X={0.02,0.98}) ;
equation
connect(boundaryMFactor.ports[1],volMFactor. ports[1]);
connect(boundary.ports[1], vol1.ports[1]);
connect(bou.ports[2], volMFactor.ports[2]);
connect(bou.ports[3], vol1.ports[2]);
end MixingVolumeMFactor;
Test model for mass flow into and out of volume
Information
This model demonstrates the use of the mixing volume with air flowing into and out of the volume.
The initial conditions for the volume is declared as fixed initial
values for the energy dynamics, but free initial conditions
for the mass dynamics. The reason for leaving the initial conditions
unspecified for the mass dynamics is that the sink bou
declares the pressure of the fluid. As there is no flow resistance
between that boundary condition and the volume,
the volume has the same pressure. Therefore, specifying an
initial condition for the mass dynamics would yield to an overspecified
initial value problem for the pressure of the medium.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Modelica definition
model MixingVolumeMassFlow
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Air ;
parameter Modelica.SIunits.PressureDifference dp_nominal = 10 ;
parameter Modelica.SIunits.MassFlowRate m_flow_nominal = 0.5 ;
Modelica.Fluid.Sources.MassFlowSource_T sou(
redeclare package Medium = Medium,
nPorts=1,
use_m_flow_in=false,
m_flow=m_flow_nominal,
T=313.15) ;
Sources.Boundary_pT bou(
redeclare package Medium = Medium,
T=303.15,
nPorts=1) ;
Buildings.Fluid.MixingVolumes.MixingVolume vol(
V=1,
redeclare package Medium = Medium,
nPorts=2,
allowFlowReversal=false,
m_flow_nominal=m_flow_nominal,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
massDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial);
equation
connect(sou.ports[1], vol.ports[1]);
connect(bou.ports[1], vol.ports[2]);
end MixingVolumeMassFlow;
Validation model for mixing volume with moisture input and flow reversal
Information
This model validates the use of the mixing volume with air flowing into and out of the volume
and moisture added to the volume.
The model volDyn
uses a dynamic balance,
whereas the model volSte
uses a steady-state balance.
The mass flow rate starts positive and reverses its direction at t=5 seconds.
Extends from Buildings.Fluid.MixingVolumes.Validation.BaseClasses.MixingVolumeReverseFlow (Test model for mixing volume with flow reversal).
Parameters
Type | Name | Default | Description |
Pressure | dp_nominal | 10 | Nominal pressure drop [Pa] |
MassFlowRate | m_flow_nominal | 2.0 | Nominal mass flow rate [kg/s] |
Modelica definition
Validation model for mixing volume with moisture input and flow reversal and prescribed heat flow rate
Information
This model is identical to
Buildings.Fluid.MixingVolumes.Validation.MixingVolumeMoistureReverseFlow,
except that the steady state volume volSte
is configured to have a prescribed heat flow rate,
which is in this case zero as the heat port is not connected.
This configures volSte
to use the two port
steady state heat and mass balance model
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation.
Extends from MixingVolumeMoistureReverseFlow (Validation model for mixing volume with moisture input and flow reversal).
Parameters
Type | Name | Default | Description |
Pressure | dp_nominal | 10 | Nominal pressure drop [Pa] |
MassFlowRate | m_flow_nominal | 2.0 | Nominal mass flow rate [kg/s] |
Modelica definition
model MixingVolumeMoistureReverseFlowPrescribedHeatFlowRate
extends MixingVolumeMoistureReverseFlow(
prescribedHeatFlowRate=true);
end MixingVolumeMoistureReverseFlowPrescribedHeatFlowRate;
Test model for steady state mass dynamics
Information
This model shows that steady state mass dynamics are correctly simulated.
A change in pressure does not lead to an exchange and/or creation of mass.
The mixing volume temperature is also unaffected by a pressure change.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
model MixingVolumeSteadyStateMass
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Air;
Sources.MassFlowSource_T sou(
redeclare package Medium = Medium,
use_m_flow_in=true,
nPorts=1) ;
Sources.Boundary_pT bou(
redeclare package Medium = Medium,
nPorts=1) ;
Buildings.Fluid.MixingVolumes.MixingVolume vol(
V=1,
redeclare package Medium = Medium,
m_flow_nominal=0.01,
massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
allowFlowReversal=true,
nPorts=2,
mSenFac=2,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) ;
Modelica.Blocks.Sources.Ramp ramp(
duration=1,
offset=1,
height=-2) ;
Modelica.Blocks.Math.Gain gain(k=0.01) ;
FixedResistances.FixedResistanceDpM res(
redeclare package Medium = Medium,
m_flow_nominal=0.01,
dp_nominal=1000) ;
equation
connect(ramp.y, gain.u);
connect(gain.y, sou.m_flow_in);
connect(sou.ports[1], vol.ports[1]);
connect(vol.ports[2], res.port_a);
connect(res.port_b, bou.ports[1]);
end MixingVolumeSteadyStateMass;
Test model for mixing volume with trace substance input
Information
This model demonstrates the use of the mixing volume with air flowing into and out of the volume
and trace substances added to the volume.
The model volDyn
uses a dynamic balance,
whereas the model volSte
uses a steady-state balance.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
Pressure | dp_nominal | 10 | Nominal pressure drop [Pa] |
MassFlowRate | m_flow_nominal | 0.5 | Nominal mass flow rate [kg/s] |
Modelica definition
model MixingVolumeTraceSubstance
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Air(extraPropertiesNames={"CO2"}) ;
parameter Modelica.SIunits.Pressure dp_nominal = 10 ;
parameter Modelica.SIunits.MassFlowRate m_flow_nominal = 0.5 ;
Modelica.Fluid.Sources.MassFlowSource_T sou(
redeclare package Medium = Medium,
nPorts=1,
use_m_flow_in=false,
m_flow=m_flow_nominal,
T=313.15) ;
Sources.Boundary_pT bou(
redeclare package Medium = Medium,
T=303.15,
nPorts=2) ;
Buildings.Fluid.MixingVolumes.MixingVolume volDyn(
redeclare package Medium = Medium,
V=1,
nPorts=2,
allowFlowReversal=false,
m_flow_nominal=m_flow_nominal,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
use_C_flow=true) ;
Modelica.Blocks.Sources.Constant C_flow(k=m_flow_nominal/1000) ;
Modelica.Fluid.Sources.MassFlowSource_T sou1(
redeclare package Medium = Medium,
nPorts=1,
use_m_flow_in=false,
m_flow=m_flow_nominal,
T=313.15) ;
Buildings.Fluid.MixingVolumes.MixingVolume volSte(
redeclare package Medium = Medium,
V=1,
nPorts=2,
m_flow_nominal=m_flow_nominal,
use_C_flow=true,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
allowFlowReversal=false) ;
equation
connect(sou.ports[1], volDyn.ports[1]);
connect(C_flow.y, volDyn.C_flow[1]);
connect(sou1.ports[1], volSte.ports[1]);
connect(C_flow.y, volSte.C_flow[1]);
connect(volSte.ports[2], bou.ports[1]);
connect(volDyn.ports[2], bou.ports[2]);
end MixingVolumeTraceSubstance;
Validation model for mixing volume with trace substance input and flow reversal
Information
This model validates the use of the mixing volume with air flowing into and out of the volume
and trace substances added to the volume.
The model volDyn
uses a dynamic balance,
whereas the model volSte
uses a steady-state balance.
The mass flow rate starts positive and reverses its direction at t=5 seconds.
Extends from Buildings.Fluid.MixingVolumes.Validation.BaseClasses.MixingVolumeReverseFlow (Test model for mixing volume with flow reversal).
Parameters
Type | Name | Default | Description |
Pressure | dp_nominal | 10 | Nominal pressure drop [Pa] |
MassFlowRate | m_flow_nominal | 2.0 | Nominal mass flow rate [kg/s] |
Modelica definition
Validation model for mixing volume with trace substance input and flow reversal, and prescribed heat flow rate
Information
This model is identical to
Buildings.Fluid.MixingVolumes.Validation.MixingVolumeTraceSubstanceReverseFlow,
except that the steady state volume volSte
is configured to have a prescribed heat flow rate,
which is in this case zero as the heat port is not connected.
This configures volSte
to use the two port
steady state heat and mass balance model
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation.
Extends from MixingVolumeTraceSubstanceReverseFlow (Validation model for mixing volume with trace substance input and flow reversal).
Parameters
Type | Name | Default | Description |
Pressure | dp_nominal | 10 | Nominal pressure drop [Pa] |
MassFlowRate | m_flow_nominal | 2.0 | Nominal mass flow rate [kg/s] |
MixingVolume | volDyn | volDyn(use_C_flow=true) | Volume with dynamic balance |
MixingVolume | volSte | volSte(use_C_flow=true) | Volume with steady-state balance |
Modelica definition
model MixingVolumeTraceSubstanceReverseFlowPrescribedHeatFlowRate
extends MixingVolumeTraceSubstanceReverseFlow(
prescribedHeatFlowRate=true);
end MixingVolumeTraceSubstanceReverseFlowPrescribedHeatFlowRate;
Mixing volume verification around zero flow with heat exchange
Information
This model verifies whether the equations in
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation
are consisent for all foreseeable cases.
All MixingVolume
instances contain the correct
setting for prescribedHeatFlowRate
.
Switching the value will result in an error in each case.
This error either is a non-physical solution to the (non-)linear system
or a division by zero, which halts the simulation.
If you use Dymola, set Advanced.Define.AimForHighAccuracy = false
to
increase the chance of the error being produced for this simple example.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
model MixingVolumeZeroFlow
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Water;
Buildings.Fluid.MixingVolumes.MixingVolume volNonLinSys(
nPorts=2,
redeclare package Medium = Medium,
m_flow_nominal=1,
V=1,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
allowFlowReversal=false) ;
Buildings.Fluid.Sources.MassFlowSource_T sou2(
nPorts=1,
redeclare package Medium = Medium,
use_m_flow_in=true,
use_T_in=true) ;
Buildings.Fluid.Sources.Boundary_pT sin(nPorts=4,
redeclare package Medium =
Medium) ;
Modelica.Blocks.Sources.Ramp ramp_m_flow(
height=-1,
duration=1,
offset=1) ;
Buildings.HeatTransfer.Sources.PrescribedHeatFlow preHea2 ;
Modelica.Blocks.Sources.RealExpression reaExp(y=(290 - volNonLinSys.heatPort.T)
/100*volNonLinSys.heatPort.T^(3/5)*time) ;
Buildings.HeatTransfer.Sources.PrescribedTemperature preTem ;
Modelica.Blocks.Sources.Cosine cos1(
freqHz=1,
offset=283.15,
amplitude=0.001) ;
Buildings.Fluid.MixingVolumes.MixingVolume volT(
nPorts=2,
redeclare package Medium = Medium,
m_flow_nominal=1,
V=1,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
allowFlowReversal=false) ;
Buildings.Fluid.Sources.MassFlowSource_T sou3(
nPorts=1,
redeclare package Medium = Medium,
use_m_flow_in=true,
use_T_in=true) ;
Buildings.Fluid.MixingVolumes.MixingVolume volLinSys(
nPorts=2,
redeclare package Medium = Medium,
m_flow_nominal=1,
V=1,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
allowFlowReversal=false,
prescribedHeatFlowRate=false) ;
Buildings.Fluid.Sources.MassFlowSource_T sou4(
nPorts=1,
redeclare package Medium = Medium,
use_m_flow_in=true,
use_T_in=true) ;
Modelica.Thermal.HeatTransfer.Components.ThermalResistor theRes(R=0.001) ;
Modelica.Blocks.Sources.Ramp ramp_T(
duration=2,
offset=283.15,
height=0) ;
Buildings.HeatTransfer.Sources.PrescribedHeatFlow preHea1 ;
Modelica.Blocks.Sources.Constant const(k=1) ;
Buildings.Fluid.MixingVolumes.MixingVolume volQflow(
nPorts=2,
redeclare package Medium = Medium,
m_flow_nominal=1,
V=1,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
allowFlowReversal=false,
prescribedHeatFlowRate=true) ;
Buildings.Fluid.Sources.MassFlowSource_T sou1(
nPorts=1,
redeclare package Medium = Medium,
use_m_flow_in=true,
use_T_in=true) ;
equation
assert(
abs(volNonLinSys.heatPort.Q_flow)<Modelica.Constants.small
or time<1,
"Heat flow leakage around zero flow.");
assert(
abs(volLinSys.heatPort.Q_flow)<Modelica.Constants.small
or time<1,
"Heat flow leakage around zero flow.");
connect(sou2.ports[1], volNonLinSys.ports[1]);
connect(volNonLinSys.ports[2], sin.ports[1]);
connect(reaExp.y, preHea2.Q_flow);
connect(preTem.T, cos1.y);
connect(volT.ports[1],sou3. ports[1]);
connect(volT.ports[2], sin.ports[2]);
connect(volT.heatPort, preTem.port);
connect(sou4.ports[1], volLinSys.ports[1]);
connect(volLinSys.ports[2], sin.ports[3]);
connect(theRes.port_a, volLinSys.heatPort);
connect(theRes.port_b, preTem.port);
connect(volNonLinSys.heatPort, preHea2.port);
connect(const.y, preHea1.Q_flow);
connect(volQflow.heatPort, preHea1.port);
connect(sou1.ports[1], volQflow.ports[1]);
connect(volQflow.ports[2], sin.ports[4]);
connect(ramp_m_flow.y, sou1.m_flow_in);
connect(ramp_m_flow.y, sou2.m_flow_in);
connect(ramp_m_flow.y, sou3.m_flow_in);
connect(ramp_m_flow.y, sou4.m_flow_in);
connect(ramp_T.y, sou1.T_in);
connect(ramp_T.y, sou2.T_in);
connect(ramp_T.y, sou3.T_in);
connect(ramp_T.y, sou4.T_in);
end MixingVolumeZeroFlow;
This test checks if mass and energy is conserved when mixing fluid streams using dynamic balances
Information
This model verifies if mass and energy are conserved,
using a dynamic balance.
Two air streams with different mass flow rate are humidified
by a mixing volume with two different vapor mass flow rates.
These flows are then mixed.
Boundary integrals are used to verify if air mass,
vapour mass and internal energy are conserved.
Note, however, that there is some approximation error because
in its default configuration, the conservation balance
models simplify the treatment of the water that is added
to the fluid.
See
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation
and
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation
for a discussion.
Extends from Buildings.Fluid.MixingVolumes.Validation.BaseClasses.MoistureMixingConservation (Partial for checking conservation of mass for independent mass fraction).
Parameters
Type | Name | Default | Description |
Mass | m_start[3] | | Initial mass of the mixing volumes [kg] |
InternalEnergy | U_start[3] | | Initial energy of the mixing volumes [J] |
Modelica definition
model MoistureMixingConservationDynamicBalance
extends Buildings.Fluid.MixingVolumes.Validation.BaseClasses.MoistureMixingConservation
(
mWatFloSol(k={vol.X_start[1],vol1.X_start[1],vol2.X_start[1]}*m_start),
vol(energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, massDynamics=
Modelica.Fluid.Types.Dynamics.FixedInitial),
vol1(energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
massDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial),
vol2(energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
massDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial),
mFloSol(k=
sum(m_start)),
hSol(k=
sum(U_start)),
mWatFlo3(k=0));
parameter Modelica.SIunits.Mass[3] m_start(
each fixed=false) ;
parameter Modelica.SIunits.InternalEnergy[3] U_start(
each fixed=false) ;
Modelica.Blocks.Continuous.Integrator intMasFloVapIn(
k=1,
initType=Modelica.Blocks.Types.Init.InitialState,
y_start=0) ;
Modelica.Blocks.Math.Add3 add ;
Modelica.Blocks.Sources.RealExpression masVapVol(y=vol.mXi[1] + vol1.mXi[1] +
vol2.mXi[1]) ;
Modelica.Blocks.Math.Add3 add3Vap(k3=-1) ;
Modelica.Blocks.Sources.RealExpression masVol(y=vol1.m + vol.m + vol2.m) ;
Modelica.Blocks.Continuous.Integrator intMasFloOut(
k=1,
initType=Modelica.Blocks.Types.Init.InitialState,
y_start=0) ;
Modelica.Blocks.Math.Add3 add3Mass(k3=-1) ;
Modelica.Blocks.Continuous.Integrator intMasFloIn(
k=1,
initType=Modelica.Blocks.Types.Init.InitialState,
y_start=0) ;
Modelica.Blocks.Sources.Constant masFloIn(k=sou1.m_flow + sou2.m_flow) ;
Modelica.Blocks.Continuous.Integrator intEntOut(
k=1,
initType=Modelica.Blocks.Types.Init.InitialState,
y_start=0) ;
Modelica.Blocks.Continuous.Integrator intEntIn(
k=1,
initType=Modelica.Blocks.Types.Init.InitialState,
y_start=0) ;
Modelica.Blocks.Sources.RealExpression entVol(y=vol1.U + vol.U + vol2.U) ;
Modelica.Blocks.Math.Add3 add3Ent(k3=-1) ;
Modelica.Blocks.Sources.Constant entIn(k=sou1.m_flow*sou1.h + sou2.m_flow*
sou2.h +
Medium.enthalpyOfLiquid(TWat.k)*(mWatFlo1.k + mWatFlo2.k)) ;
Modelica.Blocks.Math.Product pro ;
Modelica.Blocks.Continuous.Integrator intMasVapOut(
k=1,
initType=Modelica.Blocks.Types.Init.InitialState,
y_start=0) ;
initial equation
m_start = {vol.m, vol1.m,vol2.m};
U_start = {vol.U, vol1.U,vol2.U};
equation
connect(add.u1, mWatFlo2.y);
connect(add.u2, mWatFlo1.y);
connect(add3Vap.y, assMasFra.u2);
connect(masVapVol.y,add3Vap. u2);
connect(intMasFloVapIn.u, add.y);
connect(intMasFloVapIn.y,add3Vap. u3);
connect(senMasFlo.m_flow, intMasFloOut.u);
connect(add3Mass.y, assMasFlo.u2);
connect(masVol.y, add3Mass.u2);
connect(intMasFloIn.y, add3Mass.u3);
connect(intMasFloIn.u, masFloIn.y);
connect(add3Ent.y, assSpeEnt.u2);
connect(entVol.y, add3Ent.u2);
connect(intEntIn.y, add3Ent.u3);
connect(entIn.y, intEntIn.u);
connect(add3Ent.u1, intEntOut.y);
connect(intEntOut.u, senSpeEnt.H_flow);
connect(add.u3, mWatFlo3.y);
connect(pro.u1, senMasFra.X);
connect(pro.u2, senMasFlo.m_flow);
connect(intMasVapOut.y, add3Vap.u1);
connect(intMasVapOut.u, pro.y);
connect(add3Mass.u1, intMasFloOut.y);
end MoistureMixingConservationDynamicBalance;
This test checks if mass and energy is conserved when mixing fluid streams using steady state balances
Information
This test checks if water vapour mass is conserved.
Two air streams with different mass flow rate are humidified
by a mixing volume with two different vapor mass flow rates.
These flows are then mixed.
Afterwards the added water is removed again.
The final water concentration, mass flow rate and enthalpy
flow rate should then be equal to the initial values.
Note, however, that there is some approximation error because
in its default configuration, the conservation balance
models simplify the treatment of the water that is added
to the fluid.
See
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation
and
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation
for a discussion.
Extends from Buildings.Fluid.MixingVolumes.Validation.BaseClasses.MoistureMixingConservation (Partial for checking conservation of mass for independent mass fraction).
Modelica definition
model MoistureMixingConservationSteadyState
extends Buildings.Fluid.MixingVolumes.Validation.BaseClasses.MoistureMixingConservation
(
mWatFloSol(k=0),
mFloSol(k=sou1.m_flow + sou2.m_flow),
hSol(k=Medium.h_default*(sou1.m_flow + sou2.m_flow)));
equation
connect(assMasFra.u2, senMasFra.X);
connect(assMasFlo.u2, senMasFlo.m_flow);
connect(assSpeEnt.u2, senSpeEnt.H_flow);
end MoistureMixingConservationSteadyState;
This test checks if trace substance mass flow rates are conserved when a dynamic balance is used
Information
This test checks if the trace substance flow rate is
conserved when adding moisture to a mixing volume that is configured to steady state.
The trace substance flow rate at the inlet and outlet should be equal
since the trace substance concentration should not
be affected by the independent mass fraction concentration.
Note, however, that there is some approximation error because
in its default configuration, the conservation balance
models simplify the treatment of the water that is added
to the fluid.
See
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation
and
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation
for a discussion.
Extends from Buildings.Fluid.MixingVolumes.Validation.BaseClasses.TraceSubstanceConservation (This test checks if trace substance mass flow rates are conserved).
Modelica definition
model TraceSubstanceConservationDynamicBalance
extends Buildings.Fluid.MixingVolumes.Validation.BaseClasses.TraceSubstanceConservation
(vol(massDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
C_nominal=
zeros(Medium.nC)));
Modelica.Blocks.Continuous.Integrator intTraSubIn(
k=1,
initType=Modelica.Blocks.Types.Init.InitialState,
y_start=0) ;
Modelica.Blocks.Continuous.Integrator intTraSubOut(
k=1,
initType=Modelica.Blocks.Types.Init.InitialState,
y_start=0) ;
Modelica.Blocks.Sources.RealExpression reaExp(y=vol.m*vol.C[1]) ;
Buildings.Utilities.Diagnostics.AssertEquality assZer(threShold=1E-10) ;
Modelica.Blocks.Math.Add3 add3(
k1=-1,
k2=+1,
k3=-1) ;
Modelica.Blocks.Sources.Constant zero(k=0) ;
equation
connect(reaExp.y, add3.u3);
connect(intTraSubIn.y, add3.u2);
connect(intTraSubOut.y, add3.u1);
connect(add3.y, assZer.u1);
connect(zero.y, assZer.u2);
connect(intTraSubIn.u, CfloIn.y);
connect(CfloOut.y, intTraSubOut.u);
end TraceSubstanceConservationDynamicBalance;
This test checks if trace substance mass flow rates are conserved when steady state
Information
This test checks if the trace substance flow rate is conserved
when adding moisture to a mixing volume that is configured to steady state.
The trace substance flow rate at the inlet and outlet should be equal
since the trace substance concentration should not
be affected by the independent mass fraction concentration.
Note, however, that there is some approximation error because
in its default configuration, the conservation balance
models simplify the treatment of the water that is added
to the fluid.
See
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation
and
Buildings.Fluid.Interfaces.StaticTwoPortConservationEquation
for a discussion.
Extends from Buildings.Fluid.MixingVolumes.Validation.BaseClasses.TraceSubstanceConservation (This test checks if trace substance mass flow rates are conserved).
Modelica definition
http://simulationresearch.lbl.gov/modelica