Skip to content

Commit

Permalink
Merged IBPSA, branch IBPSASync_issue1341_homotopyInitialization [ci s…
Browse files Browse the repository at this point in the history
…kip]
  • Loading branch information
mwetter committed Apr 14, 2020
1 parent d0598e1 commit a39ccf7
Show file tree
Hide file tree
Showing 21 changed files with 276 additions and 66 deletions.
16 changes: 13 additions & 3 deletions Buildings/Airflow/Multizone/BaseClasses/PowerLawResistance.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ partial model PowerLawResistance "Flow resistance that uses the power law"
final m_flow_nominal=rho_default*k*dp_turbulent);
extends Buildings.Airflow.Multizone.BaseClasses.ErrorControl;

constant Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(HideResult=true);

parameter Real m(min=0.5, max=1)
"Flow exponent, m=0.5 for turbulent, m=1 for laminar";
parameter Boolean useDefaultProperties=true
Expand All @@ -14,9 +17,6 @@ partial model PowerLawResistance "Flow resistance that uses the power law"
"Pressure difference where laminar and turbulent flow relation coincide. Recommended = 0.1"
annotation(Dialog(tab="Advanced"));

parameter Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(Evaluate=true, Dialog(tab="Advanced"));

Modelica.SIunits.VolumeFlowRate V_flow
"Volume flow rate through the component";
Modelica.SIunits.Velocity v(nominal=1) "Average velocity";
Expand Down Expand Up @@ -54,6 +54,10 @@ protected
"Air mass exchanged (for purpose of error control only)";
initial equation
mExc=0;
assert(homotopyInitialization, "In " + getInstanceName() +
": The constant homotopyInitialization is set to false. This constant will be removed in future releases.",
level = AssertionLevel.warning);

equation
if forceErrorControlOnFlow then
der(mExc) = port_a.m_flow;
Expand Down Expand Up @@ -128,6 +132,12 @@ The model is used as a base for the interzonal air flow models.
revisions="<html>
<ul>
<li>
April 14, 2020, by Michael Wetter:<br/>
Changed <code>homotopyInitialization</code> to a constant.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1341\">Buildings, #1341</a>.
</li>
<li>
June 24, 2018, by Michael Wetter:<br/>
Removed parameter <code>A</code> because
<a href=\"modelica://Buildings.Airflow.Multizone.EffectiveAirLeakageArea\">
Expand Down
17 changes: 14 additions & 3 deletions Buildings/Fluid/Actuators/BaseClasses/PartialThreeWayValve.mo
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ partial model PartialThreeWayValve "Partial three way valve"
extends Buildings.Fluid.Actuators.BaseClasses.ValveParameters(
rhoStd=Medium.density_pTX(101325, 273.15+4, Medium.X_default));

constant Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(HideResult=true);

parameter Modelica.SIunits.PressureDifference dpFixed_nominal[2](each displayUnit="Pa",
each min=0) = {0, 0}
"Nominal pressure drop of pipes and other equipment in flow legs at port_1 and port_3"
Expand All @@ -52,15 +55,17 @@ partial model PartialThreeWayValve "Partial three way valve"
"= true, use linear relation between m_flow and dp for any flow rate"
annotation(Dialog(tab="Advanced"));

parameter Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(Evaluate=true, Dialog(tab="Advanced"));

protected
Modelica.Blocks.Math.Feedback inv "Inversion of control signal"
annotation (Placement(transformation(extent={{-74,40},{-62,52}})));
Modelica.Blocks.Sources.Constant uni(final k=1)
"Outputs one for bypass valve"
annotation (Placement(transformation(extent={{-92,40},{-80,52}})));
initial equation
assert(homotopyInitialization, "In " + getInstanceName() +
": The constant homotopyInitialization is set to false. This constant will be removed in future releases.",
level = AssertionLevel.warning);

equation
connect(uni.y, inv.u1)
annotation (Line(points={{-79.4,46},{-72.8,46}},
Expand Down Expand Up @@ -145,6 +150,12 @@ for details regarding the valve implementation.
</html>", revisions="<html>
<ul>
<li>
April 14, 2020, by Michael Wetter:<br/>
Changed <code>homotopyInitialization</code> to a constant.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1341\">Buildings, #1341</a>.
</li>
<li>
November 5, 2019, by Michael Wetter:<br/>
Moved assignment of leakage from <a href=\"modelica://Buildings.Fluid.Actuators.BaseClasses.PartialThreeWayValve\">
Buildings.Fluid.Actuators.BaseClasses.PartialThreeWayValve</a>
Expand Down
17 changes: 15 additions & 2 deletions Buildings/Fluid/BaseClasses/PartialResistance.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ partial model PartialResistance "Partial model for a hydraulic resistance"
then m_flow_nominal_pos else 1),
final m_flow_small = 1E-4*abs(m_flow_nominal));

constant Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(HideResult=true);

parameter Boolean from_dp = false
"= true, use m_flow = f(dp) else dp = f(m_flow)"
annotation (Evaluate=true, Dialog(tab="Advanced"));

parameter Modelica.SIunits.PressureDifference dp_nominal(displayUnit="Pa")
"Pressure drop at nominal mass flow rate"
annotation(Dialog(group = "Nominal condition"));
parameter Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(Evaluate=true, Dialog(tab="Advanced"));

parameter Boolean linearized = false
"= true, use linear relation between m_flow and dp for any flow rate"
annotation(Evaluate=true, Dialog(tab="Advanced"));
Expand All @@ -35,6 +37,11 @@ protected
"Absolute value of nominal flow rate";
final parameter Modelica.SIunits.PressureDifference dp_nominal_pos(displayUnit="Pa") = abs(dp_nominal)
"Absolute value of nominal pressure difference";
initial equation
assert(homotopyInitialization, "In " + getInstanceName() +
": The constant homotopyInitialization is set to false. This constant will be removed in future releases.",
level = AssertionLevel.warning);

equation
// Isenthalpic state transformation (no storage and no loss of energy)
port_a.h_outflow = if allowFlowReversal then inStream(port_b.h_outflow) else Medium.h_default;
Expand Down Expand Up @@ -98,6 +105,12 @@ this base class.
</html>", revisions="<html>
<ul>
<li>
April 14, 2020, by Michael Wetter:<br/>
Changed <code>homotopyInitialization</code> to a constant.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1341\">Buildings, #1341</a>.
</li>
<li>
February 26, 2020, by Michael Wetter:<br/>
Changed icon to display its operating state.<br/>
This is for
Expand Down
15 changes: 12 additions & 3 deletions Buildings/Fluid/Chillers/BaseClasses/Carnot.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ partial model Carnot
m1_flow_nominal = QCon_flow_nominal/cp1_default/dTCon_nominal,
m2_flow_nominal = QEva_flow_nominal/cp2_default/dTEva_nominal);

constant Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(HideResult=true);

parameter Modelica.SIunits.HeatFlowRate QEva_flow_nominal(max=0)
"Nominal cooling heat flow rate (QEva_flow_nominal < 0)"
annotation (Dialog(group="Nominal condition"));
Expand Down Expand Up @@ -58,9 +61,6 @@ partial model Carnot
"Temperature difference between refrigerant and working fluid outlet in evaporator"
annotation (Dialog(group="Efficiency"));

parameter Boolean homotopyInitialization=true "= true, use homotopy method"
annotation (Dialog(tab="Advanced"));

parameter Boolean from_dp1=false
"= true, use m_flow = f(dp) else dp = f(m_flow)"
annotation (Dialog(tab="Flow resistance", group="Condenser"));
Expand Down Expand Up @@ -229,6 +229,9 @@ initial equation
a=a, x=1)-1) < 0.01, "Efficiency curve is wrong. Need etaPL(y=1)=1.");
assert(etaCarnot_nominal_internal < 1, "Parameters lead to etaCarnot_nominal > 1. Check parameters.");

assert(homotopyInitialization, "In " + getInstanceName() +
": The constant homotopyInitialization is set to false. This constant will be removed in future releases.",
level = AssertionLevel.warning);

equation
connect(port_a2, eva.port_a)
Expand Down Expand Up @@ -382,6 +385,12 @@ and the part load ratio are set up.
</html>", revisions="<html>
<ul>
<li>
April 14, 2020, by Michael Wetter:<br/>
Changed <code>homotopyInitialization</code> to a constant.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1341\">Buildings, #1341</a>.
</li>
<li>
September 12, 2019, by Michael Wetter:<br/>
Corrected value of <code>evaluate_etaPL</code> and how it is used.
This correction only affects protected variables and does not affect the results.<br/>
Expand Down
26 changes: 19 additions & 7 deletions Buildings/Fluid/FixedResistances/BaseClasses/PlugFlowCore.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ model PlugFlowCore
"Pipe model using spatialDistribution for temperature delay with modified delay tracker"
extends Buildings.Fluid.Interfaces.PartialTwoPort;

constant Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(HideResult=true);

parameter Modelica.SIunits.Length dh
"Hydraulic diameter (assuming a round cross section area)";

Expand Down Expand Up @@ -53,8 +56,6 @@ model PlugFlowCore
parameter Real ReC=4000
"Reynolds number where transition to turbulent starts";

parameter Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(Evaluate=true, Dialog(tab="Advanced"));
parameter Boolean linearized = false
"= true, use linear relation between m_flow and dp for any flow rate"
annotation(Evaluate=true, Dialog(tab="Advanced"));
Expand Down Expand Up @@ -134,6 +135,11 @@ protected
"Default density (e.g., rho_liquidWater = 995, rho_air = 1.2)"
annotation (Dialog(group="Advanced"));

initial equation
assert(homotopyInitialization, "In " + getInstanceName() +
": The constant homotopyInitialization is set to false. This constant will be removed in future releases.",
level = AssertionLevel.warning);

equation
connect(senMasFlo.m_flow, timDel.m_flow) annotation (Line(
points={{-40,-11},{-40,-40},{-12,-40}},
Expand Down Expand Up @@ -201,6 +207,12 @@ equation
Documentation(revisions="<html>
<ul>
<li>
April 14, 2020, by Michael Wetter:<br/>
Changed <code>homotopyInitialization</code> to a constant.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1341\">Buildings, #1341</a>.
</li>
<li>
October 20, 2017, by Michael Wetter:<br/>
Replaced model that lumps flow resistance and transport delays
with two separate models, as these are physically distinct processes.
Expand Down Expand Up @@ -230,16 +242,16 @@ for the transport delay of the fluid.
<p>
The
<code>spatialDistribution</code> operator is used for the temperature wave propagation
through the length of the pipe. This operator is contained in
through the length of the pipe. This operator is contained in
<a href=\"modelica://Buildings.Fluid.FixedResistances.BaseClasses.PlugFlow\">BaseClasses.PlugFlow</a>.
</p>
<p>
This model does not include thermal inertia of the pipe wall.
The wall inertia is implemented in
<a href=\"modelica://Buildings.Fluid.FixedResistances.PlugFlowPipe\">PlugFlowPipe</a>, which uses this model.
<br/>
The removal of the thermal inertia with a mixing volume can be desirable in the
case where mixing volumes are added manually at the pipe junctions.
The removal of the thermal inertia with a mixing volume can be desirable in the
case where mixing volumes are added manually at the pipe junctions.
</p>
<p>
The model
Expand All @@ -254,10 +266,10 @@ Full details on the model implementation and experimental validation can be foun
in:
</p>
<p>
van der Heijde, B., Fuchs, M., Ribas Tugores, C., Schweiger, G., Sartor, K., Basciotti, D., M&uuml;ller,
van der Heijde, B., Fuchs, M., Ribas Tugores, C., Schweiger, G., Sartor, K., Basciotti, D., M&uuml;ller,
D., Nytsch-Geusen, C., Wetter, M. and Helsen, L. (2017).<br/>
Dynamic equation-based thermo-hydraulic pipe model for district heating and cooling systems.<br/>
<i>Energy Conversion and Management</i>, vol. 151, p. 158-169.
<i>Energy Conversion and Management</i>, vol. 151, p. 158-169.
<a href=\"https://doi.org/10.1016/j.enconman.2017.08.072\">doi: 10.1016/j.enconman.2017.08.072</a>.</p>
</html>"));
end PlugFlowCore;
15 changes: 13 additions & 2 deletions Buildings/Fluid/FixedResistances/Junction.mo
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ model Junction
homotopyInitialization=homotopyInitialization,
deltaM=deltaM));

constant Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(HideResult=true);

parameter Modelica.SIunits.MassFlowRate[3] m_flow_nominal
"Mass flow rate. Set negative at outflowing ports."
annotation(Dialog(group = "Nominal condition"));
Expand All @@ -43,8 +46,10 @@ model Junction
"= true, use linear relation between m_flow and dp for any flow rate"
annotation(Dialog(tab="Advanced"));

parameter Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(Evaluate=true, Dialog(tab="Advanced"));
initial equation
assert(homotopyInitialization, "In " + getInstanceName() +
": The constant homotopyInitialization is set to false. This constant will be removed in future releases.",
level = AssertionLevel.warning);

annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
-100},{100,100}}), graphics={
Expand Down Expand Up @@ -153,6 +158,12 @@ system of equations.
</html>", revisions="<html>
<ul>
<li>
April 14, 2020, by Michael Wetter:<br/>
Changed <code>homotopyInitialization</code> to a constant.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1341\">Buildings, #1341</a>.
</li>
<li>
February 26, 2020, by Michael Wetter:<br/>
Changed icon to display its operating state.<br/>
This is for
Expand Down
19 changes: 15 additions & 4 deletions Buildings/Fluid/FixedResistances/PlugFlowPipe.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ model PlugFlowPipe
"Pipe model using spatialDistribution for temperature delay"
extends Buildings.Fluid.Interfaces.PartialTwoPortVector;

constant Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(HideResult=true);

parameter Boolean from_dp=false
"= true, use m_flow = f(dp) else dp = f(m_flow)"
annotation (Dialog(tab="Advanced"));
Expand Down Expand Up @@ -72,9 +75,6 @@ model PlugFlowPipe
parameter Real fac=1
"Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal";

parameter Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(Evaluate=true, Dialog(tab="Advanced"));

parameter Boolean linearized = false
"= true, use linear relation between m_flow and dp for any flow rate"
annotation(Evaluate=true, Dialog(tab="Advanced"));
Expand Down Expand Up @@ -151,6 +151,11 @@ protected
"Default density (e.g., rho_liquidWater = 995, rho_air = 1.2)"
annotation (Dialog(group="Advanced"));

initial equation
assert(homotopyInitialization, "In " + getInstanceName() +
": The constant homotopyInitialization is set to false. This constant will be removed in future releases.",
level = AssertionLevel.warning);

equation
for i in 1:nPorts loop
connect(vol.ports[i + 1], ports_b[i])
Expand Down Expand Up @@ -210,8 +215,14 @@ d = %dh")}),
Documentation(revisions="<html>
<ul>
<li>
April 14, 2020, by Michael Wetter:<br/>
Changed <code>homotopyInitialization</code> to a constant.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1341\">Buildings, #1341</a>.
</li>
<li>
March 6, 2020, by Jelger Jansen:<br/>
Revised calculation of thermal resistance <code>R</code>
Revised calculation of thermal resistance <code>R</code>
by using correct radiuses.
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1310\">#1310</a>.
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ model Convector "Heat exchanger for the water stream"
final computeFlowResistance=true,
final dp_nominal = per.dpWat_nominal "Don't multiply with nBeams, as the beams are in parallel");

constant Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(HideResult=true);

parameter Data.Generic per "Performance data"
annotation (choicesAllMatching = true,
Placement(transformation(extent={{60,-80},{80,-60}})));
Expand All @@ -16,10 +19,6 @@ model Convector "Heat exchanger for the water stream"
"Time constant at nominal flow (if energyDynamics <> SteadyState)"
annotation (Dialog(tab = "Dynamics", group="Nominal condition"));

// Advanced
parameter Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(Evaluate=true, Dialog(tab="Advanced"));

// Dynamics
parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial
"Type of energy balance: dynamic (3 initialization options) or steady state"
Expand Down Expand Up @@ -94,6 +93,12 @@ protected
Sensors.MassFlowRate senFloWatCoo(
redeclare final package Medium = Medium) "Mass flow rate sensor"
annotation (Placement(transformation(extent={{-80,-10},{-60,10}})));

initial equation
assert(homotopyInitialization, "In " + getInstanceName() +
": The constant homotopyInitialization is set to false. This constant will be removed in future releases.",
level = AssertionLevel.warning);

equation
connect(hex.Q_flow, Q_flow) annotation (Line(points={{61,6},{70,6},{70,70},{
110,70}},
Expand Down Expand Up @@ -149,6 +154,12 @@ In heating mode, the heat is removed from the water stream.
</html>", revisions="<html>
<ul>
<li>
April 14, 2020, by Michael Wetter:<br/>
Changed <code>homotopyInitialization</code> to a constant.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1341\">Buildings, #1341</a>.
</li>
<li>
November 2, 2016, by Michael Wetter:<br/>
Made assignment of <code>senTem.y</code> final.
</li>
Expand Down
Loading

0 comments on commit a39ccf7

Please sign in to comment.