Collection of models that illustrate model use and test models
Information
This package contains examples for the use of models that can be found in
Buildings.Fluid.FixedResistances.
Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).
Package Content
Test model for the fixed resistance model
Information
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
model FixedResistance
"Test model for the fixed resistance model"
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Water;
Modelica.Blocks.Sources.Constant PAtm(k=101325);
Modelica.Blocks.Sources.Ramp P(
duration=1,
height=20,
offset=101315);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res1(
redeclare package Medium = Medium,
from_dp=true,
m_flow_nominal=5,
dp_nominal=10);
Buildings.Fluid.Sources.Boundary_pT sou1(
redeclare package Medium
= Medium,
use_p_in=true,
T=293.15,
nPorts=3);
Buildings.Fluid.Sources.Boundary_pT sin1(
redeclare package Medium
= Medium, T=283.15,
use_p_in=true,
nPorts=3);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res2(
redeclare package Medium = Medium,
from_dp=true,
m_flow_nominal=5,
dp_nominal=10,
use_dh=true);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res3(
redeclare package Medium = Medium,
from_dp=true,
m_flow_nominal=5,
dp_nominal=10,
use_dh=true);
FixedResistances.LosslessPipe pipCon(
redeclare package Medium = Medium,
m_flow_nominal=5)
"Lossless pipe connection";
Buildings.Fluid.Sensors.MassFlowRate masFlo2(
redeclare package Medium = Medium)
"Mass flow rate sensor";
Buildings.Fluid.Sensors.MassFlowRate masFlo3(
redeclare package Medium = Medium)
"Mass flow rate sensor";
Buildings.Utilities.Diagnostics.AssertEquality assEqu(threShold=1E-4, message=
"Inputs differ, check that lossless pipe is correctly implemented.")
"Assert equality of the two mass flow rates";
equation
connect(res2.port_b, masFlo2.port_a);
connect(res3.port_b, masFlo3.port_a);
connect(masFlo3.port_b, pipCon.port_a);
connect(P.y, sou1.p_in);
connect(sou1.ports[1], res1.port_a);
connect(sin1.ports[1], res1.port_b);
connect(masFlo3.m_flow, assEqu.u1);
connect(masFlo2.m_flow, assEqu.u2);
connect(PAtm.y, sin1.p_in);
connect(sou1.ports[2], res2.port_a);
connect(sou1.ports[3], res3.port_a);
connect(sin1.ports[2], masFlo2.port_b);
connect(sin1.ports[3], pipCon.port_b);
end FixedResistance;
Test of multiple resistances in series
Information
This model tests whether inverse functions are being used by the code
translator. In Dymola 7.2, there should only be one non-linear equation system
in one variable after the symbolic manipulations.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
model FixedResistancesExplicit
"Test of multiple resistances in series"
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Air;
Buildings.Fluid.Sources.Boundary_ph sou(
redeclare package Medium = Medium,
nPorts=1,
p(displayUnit="Pa") = 101335,
use_p_in=true);
Buildings.Fluid.Sources.Boundary_ph sin(
redeclare package Medium = Medium,
nPorts=1,
use_p_in=false,
p=101325);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res11(
redeclare package Medium = Medium,
from_dp=false,
m_flow_nominal=2,
dp_nominal=5);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res12(
redeclare package Medium = Medium,
from_dp=false,
m_flow_nominal=2,
dp_nominal=5);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res22(
redeclare package Medium = Medium,
m_flow_nominal=2,
dp_nominal=5,
from_dp=true);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res21(
redeclare package Medium = Medium,
m_flow_nominal=2,
dp_nominal=5,
from_dp=true);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res31(
redeclare package Medium = Medium,
from_dp=false,
m_flow_nominal=2,
dp_nominal=5);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res32(
redeclare package Medium = Medium,
from_dp=false,
m_flow_nominal=2,
dp_nominal=5);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res42(
redeclare package Medium = Medium,
m_flow_nominal=2,
dp_nominal=5,
from_dp=true);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res41(
redeclare package Medium = Medium,
m_flow_nominal=2,
dp_nominal=5,
from_dp=true);
Buildings.Fluid.Sources.MassFlowSource_h bou(
redeclare package Medium = Medium,
m_flow=1,
nPorts=1);
Buildings.Fluid.Sources.MassFlowSource_h bou1(
redeclare package Medium = Medium,
m_flow=1,
nPorts=1);
Buildings.Fluid.Sources.Boundary_pT sin1(
redeclare package Medium
= Medium, T=273.15 + 10,
nPorts=2,
use_p_in=false,
p=101325);
Buildings.Fluid.Sources.Boundary_ph sin2(
redeclare package Medium
= Medium,
nPorts=1,
use_p_in=false,
p=101325);
Buildings.Fluid.Sources.Boundary_ph sou1(
redeclare package Medium
= Medium,
nPorts=1,
p(displayUnit="Pa") = 101335,
use_p_in=true);
Modelica.Blocks.Sources.Ramp P(
duration=1,
height=20,
offset=101315);
Buildings.Fluid.Sensors.MassFlowRate senMasFlo1(
redeclare package Medium =
Medium)
"Mass flow rate sensor";
Buildings.Fluid.Sensors.MassFlowRate senMasFlo2(
redeclare package Medium =
Medium)
"Mass flow rate sensor";
Buildings.Fluid.Sensors.MassFlowRate senMasFlo3(
redeclare package Medium =
Medium)
"Mass flow rate sensor";
Buildings.Fluid.Sensors.MassFlowRate senMasFlo4(
redeclare package Medium =
Medium)
"Mass flow rate sensor";
Buildings.Utilities.Diagnostics.AssertEquality assertEquality(threShold=1E-1);
Buildings.Utilities.Diagnostics.AssertEquality assertEquality1(threShold=1E-1);
equation
connect(res11.port_b, res12.port_a);
connect(res21.port_b, res22.port_a);
connect(res31.port_b, res32.port_a);
connect(res41.port_b, res42.port_a);
connect(sou.ports[1], res11.port_a);
connect(bou.ports[1], res31.port_a);
connect(bou1.ports[1], res41.port_a);
connect(sou1.ports[1], res21.port_a);
connect(P.y, sou.p_in);
connect(P.y, sou1.p_in);
connect(res12.port_b, senMasFlo1.port_a);
connect(res22.port_b, senMasFlo2.port_a);
connect(res32.port_b, senMasFlo3.port_a);
connect(res42.port_b, senMasFlo4.port_a);
connect(senMasFlo3.port_b, sin1.ports[1]);
connect(senMasFlo4.port_b, sin1.ports[2]);
connect(senMasFlo1.port_b, sin.ports[1]);
connect(senMasFlo2.port_b, sin2.ports[1]);
connect(senMasFlo3.m_flow, assertEquality1.u1);
connect(senMasFlo4.m_flow, assertEquality1.u2);
connect(senMasFlo1.m_flow, assertEquality.u1);
connect(senMasFlo2.m_flow, assertEquality.u2);
end FixedResistancesExplicit;
Information
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
model FixedResistancesParallel
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Water;
Modelica.Blocks.Sources.Constant PAtm(k=101325);
Modelica.Blocks.Sources.Ramp P(
duration=1,
height=20,
offset=101315);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res1(
redeclare package Medium = Medium,
m_flow_nominal=5,
dp_nominal=10,
deltaM=0.3,
linearized=false,
from_dp=false);
Buildings.Fluid.Sources.Boundary_pT sou1(
redeclare package Medium
= Medium,
T=293.15,
nPorts=2,
use_p_in=true);
Buildings.Fluid.Sources.Boundary_pT sin1(
redeclare package Medium
= Medium,
T=283.15,
nPorts=2,
use_p_in=true);
Buildings.Fluid.FixedResistances.FixedResistanceDpM res2(
redeclare package Medium = Medium,
m_flow_nominal=5,
dp_nominal=10,
deltaM=0.3,
linearized=false,
from_dp=false);
Buildings.Fluid.Sensors.MassFlowRate masFlo2(
redeclare package Medium = Medium)
"Mass flow rate sensor";
Buildings.Utilities.Diagnostics.AssertEquality assEqu(threShold=1E-4, message=
"Inputs differ, check that lossless pipe is correctly implemented.")
"Assert equality of the two mass flow rates";
Buildings.Fluid.Sensors.MassFlowRate masFlo1(
redeclare package Medium = Medium)
"Mass flow rate sensor";
equation
connect(PAtm.y, sin1.p_in);
connect(P.y, sou1.p_in);
connect(res2.port_b, masFlo2.port_a);
connect(res1.port_b, masFlo1.port_a);
connect(sou1.ports[1], res1.port_a);
connect(sou1.ports[2], res2.port_a);
connect(sin1.ports[1], masFlo1.port_b);
connect(sin1.ports[2], masFlo2.port_b);
connect(masFlo2.m_flow, assEqu.u1);
connect(masFlo1.m_flow, assEqu.u2);
end FixedResistancesParallel;
Test of multiple resistances in series
Information
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
Pressure | dp_nominal | 5 | Nominal pressure drop for each resistance [Pa] |
Integer | nRes | 10 | Number of resistances |
Modelica definition
model FixedResistancesSeries
"Test of multiple resistances in series"
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Air;
Modelica.Blocks.Sources.Constant PAtm(k=101325);
parameter Modelica.SIunits.Pressure dp_nominal = 5
"Nominal pressure drop for each resistance";
Modelica.Blocks.Sources.Ramp P(
duration=1,
height=2*dp_nominal*nRes,
offset=101325 - dp_nominal*nRes);
Buildings.Fluid.Sources.Boundary_pT sou(
redeclare package Medium
= Medium, T=273.15 + 20,
use_p_in=true,
nPorts=1);
Buildings.Fluid.Sources.Boundary_pT sin(
redeclare package Medium
= Medium, T=273.15 + 10,
use_p_in=true,
nPorts=1);
parameter Integer nRes( min=2) = 10
"Number of resistances";
Buildings.Fluid.FixedResistances.FixedResistanceDpM[
nRes] res(
redeclare each package Medium = Medium,
each dp_nominal=dp_nominal,
each from_dp = false,
each m_flow_nominal=2);
equation
for i
in 1:nRes-1
loop
connect(res[i].port_b, res[i+1].port_a);
end for;
connect(PAtm.y, sin.p_in);
connect(P.y, sou.p_in);
connect(sin.ports[1], res[nRes].port_b);
connect(sou.ports[1], res[1].port_a);
end FixedResistancesSeries;
Test of a pipe with multiple segments
Information
This model demonstrates the use of a pipe model.
Both pipe models have the same mass flow rates and temperatures.
Otherwise, the assert
block would terminate the simulation.
The model on the top is connected to the ambient with one heat port,
whereas the model at the bottom uses a vector of heat ports.
Since they are all connected to the same temperature, they
result in the same energy balance for the medium that flows
through the pipe.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
replaceable package Medium | Buildings.Media.Water | |
Connectors
Type | Name | Description |
replaceable package Medium | |
Modelica definition
model Pipe
"Test of a pipe with multiple segments"
extends Modelica.Icons.Example;
replaceable package Medium =
Buildings.Media.Water;
Modelica.Blocks.Sources.Ramp P(
duration=1,
height=2*pip.dp_nominal,
offset=101325 - pip.dp_nominal);
Buildings.Fluid.Sources.Boundary_pT sou(
redeclare package Medium =
Medium,
use_p_in=true,
T=273.15 + 50,
nPorts=2);
Buildings.Fluid.Sources.Boundary_pT sin(
redeclare package Medium =
Medium,
T=273.15 + 10,
nPorts=2,
use_p_in=false,
p(displayUnit="Pa") = 101325);
HeatTransfer.Sources.FixedTemperature TEnv(T=263.15);
Buildings.Fluid.FixedResistances.Pipe pip(
thicknessIns=0.01,
lambdaIns=0.01,
m_flow_nominal=10,
redeclare package Medium =
Medium,
length=10,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial);
HeatTransfer.Sources.FixedTemperature TEnv1[10](
each T=263.15);
Buildings.Fluid.FixedResistances.Pipe pip1(
thicknessIns=0.01,
lambdaIns=0.01,
m_flow_nominal=10,
redeclare package Medium =
Medium,
length=10,
useMultipleHeatPorts=true,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial);
Buildings.Fluid.Sensors.TemperatureTwoPort senTem(
redeclare package Medium =
Medium, m_flow_nominal=pip.m_flow_nominal)
"Temperature sensor";
Buildings.Fluid.Sensors.TemperatureTwoPort senTem1(
redeclare package Medium
=
Medium, m_flow_nominal=pip.m_flow_nominal)
"Temperature sensor";
Buildings.Utilities.Diagnostics.AssertEquality assEqu;
equation
connect(P.y, sou.p_in);
connect(sou.ports[1], pip.port_a);
connect(TEnv.port, pip.heatPort);
connect(sou.ports[2], pip1.port_a);
connect(TEnv1.port, pip1.heatPorts);
connect(pip.port_b, senTem.port_a);
connect(senTem.port_b, sin.ports[1]);
connect(pip1.port_b, senTem1.port_a);
connect(senTem1.port_b, sin.ports[2]);
connect(assEqu.u1, senTem.T);
connect(senTem1.T, assEqu.u2);
end Pipe;
Test model for the three way splitter/mixer model
Information
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
model SplitterFixedResistanceDpM
"Test model for the three way splitter/mixer model"
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Air;
Buildings.Fluid.FixedResistances.SplitterFixedResistanceDpM spl(
m_flow_nominal={1,2,3},
dh={1,2,3},
redeclare package Medium = Medium,
dp_nominal(
each displayUnit="Pa") = {5,10,15},
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial)
"Splitter";
Buildings.Fluid.Sources.Boundary_pT bou1(
redeclare package Medium = Medium,
T=273.15 + 10,
use_p_in=true,
nPorts=1);
Buildings.Fluid.Sources.Boundary_pT bou2(
redeclare package Medium = Medium,
T=273.15 + 20,
use_p_in=true,
nPorts=1);
Buildings.Fluid.Sources.Boundary_pT bou3(
redeclare package Medium = Medium,
T=273.15 + 30,
use_p_in=true,
nPorts=1);
Modelica.Blocks.Sources.Constant P2(k=101325);
Modelica.Blocks.Sources.Ramp P1(
offset=101320,
height=10,
duration=0.5);
Modelica.Blocks.Sources.Ramp P3(
offset=101320,
height=10,
duration=0.5,
startTime=0.5);
equation
connect(P1.y, bou1.p_in);
connect(P2.y, bou2.p_in);
connect(bou3.p_in, P3.y);
connect(bou1.ports[1], spl.port_1);
connect(bou3.ports[1], spl.port_3);
connect(spl.port_2, bou2.ports[1]);
end SplitterFixedResistanceDpM;
Automatically generated Mon May 4 10:20:36 2015.