Skip to content

Commit

Permalink
Make use of extends except for jiang
Browse files Browse the repository at this point in the history
  • Loading branch information
FWuellhorst committed Jul 15, 2024
1 parent 3cfd09e commit 16b75dd
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ protected
"Temperature difference between room and ambient";
Modelica.Units.SI.Temperature TAvg = (TRoom + TAmb)/2
"Average temperature of room and ambient";
Real intRes "Interim result used to check if assertion is raised";
Integer errCou(start=0) "Error counter";
parameter String varName "Variable name of root calculation";

equation
assert(intRes > Modelica.Constants.eps and errCou < 2,
"In " + getInstanceName() + ": The polynomial under the square root to
calculate" + varName + "is less than 0, " + varName + " will be set to 0",
AssertionLevel.warning);
when intRes > Modelica.Constants.eps then
errCou = pre(errCou) + 1;
end when;
annotation (Documentation(revisions="<html>
<ul>
<li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ model ASHRAE "Empirical expression according to ASHRAE handbook (2009)"
extends
AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStackWindIncidence(
redeclare replaceable model OpeningArea =
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple);
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
varName="V_flow");
Modelica.Blocks.Interfaces.RealInput winSpeLoc(unit="m/s", min=0)
"Local wind speed by window or facade"
annotation (Placement(transformation(extent={{-140,-40},{-100,0}})));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ model Caciolo "Empirical expression developed by Caciolo et al. (2013)"
extends
AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStackWindIncidence(
redeclare replaceable model OpeningArea =
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple);
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
varName="V_flow_th");
Modelica.Blocks.Interfaces.RealInput winSpeLoc(unit="m/s", min=0)
"Local wind speed by window or facade"
annotation (Placement(transformation(extent={{-140,-40},{-100,0}})));
Expand Down Expand Up @@ -33,9 +34,6 @@ equation
V_flow_win = 0;
end if;
intRes = Modelica.Constants.g_n*winClrHeight*dTRoomAmb*cofWin/TAvg;
assert(intRes > Modelica.Constants.eps,
"The polynomial under the square root to calculate V_flow_th is less than 0, the V_flow_th will be set to 0",
AssertionLevel.warning);
V_flow_th = if noEvent(intRes > Modelica.Constants.eps) then
1/3*openingArea.A*cofDcg*sqrt(intRes) else 0;
V_flow = V_flow_th + V_flow_win;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected
Modelica.Units.SI.Density rhoAmbASL = TRef/TAmb*rhoRefASL
"Air density, by ambient temperature, by height above sea level";
equation
intRes = 1;
V_flow = rhoRefASL0/rhoAmbASL*cofExt*openingArea.A/2*sqrt(
max(cofWin*(winSpe10^2), cofTh*winClrHeight*abs(dTRoomAmb)));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ model DIN4108 "Empirical expression according to DIN/TS 4108-8 (2022)"
extends
AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStack(
redeclare replaceable model OpeningArea =
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashDIN4108);
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashDIN4108,
varName="V_flow_th");
Modelica.Blocks.Interfaces.RealInput winSpeLoc(unit="m/s", min=0)
"Local wind speed by window or facade"
annotation (Placement(transformation(extent={{-140,-40},{-100,0}})));
Expand All @@ -15,9 +16,6 @@ protected
Modelica.Units.SI.VolumeFlowRate V_flow_win "Wind induced volume flow";
equation
intRes = Modelica.Constants.g_n*winClrHeight*dTRoomAmb/TAmb;
assert(intRes > Modelica.Constants.eps,
"The polynomial under the square root to calculate V_flow_th is less than 0, the V_flow_th will be set to 0",
AssertionLevel.warning);
V_flow_th = if noEvent(intRes > Modelica.Constants.eps) then
1/3*cofDcg*openingArea.A*sqrt(intRes) else 0;
V_flow_win = cofWin*openingArea.A*winSpeLoc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ model GidsPhaff "Empirical expression developed by de Gids and Phaff (1982)"
extends
AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStack(
redeclare replaceable model OpeningArea =
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple);
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
varName="V_flow");
Modelica.Blocks.Interfaces.RealInput winSpe10(unit="m/s", min=0)
"Local wind speed at a height of 10 m"
annotation (Placement(transformation(extent={{-140,-40},{-100,0}})));
Expand All @@ -14,9 +15,6 @@ protected
Real intRes "Interim result";
equation
intRes = cof1*(winSpe10^2) + cof2*winClrHeight*abs(dTRoomAmb) + cof3;
assert(intRes > Modelica.Constants.eps,
"The polynomial under the square root to calculate V_flow is less than 0, the V_flow will be set to 0",
AssertionLevel.warning);
V_flow = if noEvent(intRes > Modelica.Constants.eps) then
1/2*openingArea.A*sqrt(intRes) else 0;
annotation (Documentation(revisions="<html>
Expand Down
6 changes: 2 additions & 4 deletions AixLib/Airflow/WindowVentilation/EmpiricalExpressions/Hall.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ model Hall "Empirical expression developed by Hall (2004)"
AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStack(
redeclare model OpeningArea =
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashHall (
final sWinSas=sWinSas, final widthWinGap=widthWinGap));
final sWinSas=sWinSas, final widthWinGap=widthWinGap),
varName="V_flow");
parameter Modelica.Units.SI.Thickness sWinSas(min=0) = 0
"Window sash thickness (depth)";
parameter Modelica.Units.SI.Length widthWinGap(min=0) = 0.01
Expand All @@ -16,9 +17,6 @@ protected
equation
intRes = 2*Modelica.Constants.g_n*winClrHeight*openingArea.corNPL*dTRoomAmb/
TRoom;
assert(intRes > Modelica.Constants.eps,
"The polynomial under the square root to calculate V_flow is less than 0, the V_flow will be set to 0",
AssertionLevel.warning);
V_flow = if noEvent(intRes > Modelica.Constants.eps) then
cofDcg*openingArea.A*sqrt(intRes) else 0;
annotation (Documentation(revisions="<html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ model LarsenHeiselberg "Empirical expression developed by Larsen and Heiselberg
extends
AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStackWindIncidence(
redeclare replaceable model OpeningArea =
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple);
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
varName="V_flow");
parameter Modelica.Units.SI.Velocity winSpeLim(min=0.25)=1
"Limitation of wind speed: Due to the wind speed in the denominator, this
expression is not applicable to low wind speeds, output with 0 if the wind
Expand Down Expand Up @@ -47,9 +48,6 @@ equation
then cof1*(cofWinInc^2)*(winSpe10^2) + cof2*dTRoomAmb*winClrHeight
+ cof3*dCofWinInc*dTRoomAmb/(winSpe10^2)
else cof1*(cofWinInc^2)*(winSpe10^2) + cof2*dTRoomAmb*winClrHeight + 0;
assert(intRes > Modelica.Constants.eps,
"The polynomial under the square root to calculate V_flow is less than 0, the V_flow will be set to 0",
AssertionLevel.warning);
V_flow = if noEvent(intRes > Modelica.Constants.eps) then
openingArea.A*sqrt(intRes) else 0;
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
Expand Down
6 changes: 2 additions & 4 deletions AixLib/Airflow/WindowVentilation/EmpiricalExpressions/Maas.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ model Maas "Empirical expression developed by Maas (1995)"
redeclare model OpeningArea =
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon (
final opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
final opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Effective));
final opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Effective),
varName="V_flow");
Modelica.Blocks.Interfaces.RealInput winSpe13(unit="m/s", min=0)
"Local wind speed at a height of 13 m"
annotation (Placement(transformation(extent={{-140,-40},{-100,0}})));
Expand All @@ -15,9 +16,6 @@ protected
Real intRes "Interim result";
equation
intRes = cof1*(winSpe13^2) + cof2*winClrHeight*dTRoomAmb + cof3;
assert(intRes > Modelica.Constants.eps,
"The polynomial under the square root to calculate V_flow is less than 0, the V_flow will be set to 0",
AssertionLevel.warning);
V_flow = if noEvent(intRes > Modelica.Constants.eps) then
1/2*openingArea.A*sqrt(intRes) else 0;
annotation (Documentation(revisions="<html>
Expand Down
6 changes: 2 additions & 4 deletions AixLib/Airflow/WindowVentilation/EmpiricalExpressions/Tang.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
model Tang "Empirical expression developed by Tang et al. (2016)"
extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStack(
redeclare replaceable model OpeningArea =
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple);
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
varName="V_flow");
parameter Modelica.Units.SI.TemperatureDifference dTLim(min=0.02)=0.05
"Limitation of temperature difference: Due to the temperature difference in
the denominator, this expression is not applicable to low temperature
Expand All @@ -20,9 +21,6 @@ equation
then Modelica.Constants.g_n*winClrHeight*abs(dTRoomAmb)/TRoom + cof_dT/
abs(dTRoomAmb)
else Modelica.Constants.g_n*winClrHeight*abs(dTRoomAmb)/TRoom + 0;
assert(intRes > Modelica.Constants.eps,
"The polynomial under the square root to calculate V_flow is less than 0, the V_flow will be set to 0",
AssertionLevel.warning);
V_flow = if noEvent(intRes > Modelica.Constants.eps) then
1/3*cofDcg*openingArea.A*sqrt(intRes) else 0;
annotation (Documentation(revisions="<html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
model VDI2078 "Empirical expression according to VDI 2078 (2015)"
extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStack(
redeclare replaceable model OpeningArea =
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashVDI2078);
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashVDI2078,
varName="V_flow");
parameter Boolean use_cofSunSha_in=false
"Use input port for sunshading coefficient"
annotation(choices(checkBox=true));
Expand All @@ -29,9 +30,6 @@ equation
sunShaTyp);
end if;
intRes = Modelica.Constants.g_n*openingArea.effHeight*dTRoomAmb/(2*TAmb);
assert(intRes > Modelica.Constants.eps,
"The polynomial under the square root to calculate V_flow is less than 0, the V_flow will be set to 0",
AssertionLevel.warning);
V_flow =if noEvent(intRes > Modelica.Constants.eps) then cofSunSha_internal*
openingArea.A*sqrt(intRes) else 0;
annotation (Documentation(revisions="<html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
model WarrenParkins "Empirical expression developed by Warren and Parkins (1984)"
extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStack(
redeclare replaceable model OpeningArea =
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple);
AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
varName="V_flow_th");
Modelica.Blocks.Interfaces.RealInput winSpe10(unit="m/s", min=0)
"Local wind speed at a height of 10 m"
annotation (Placement(transformation(extent={{-140,-40},{-100,0}})));
Expand All @@ -13,9 +14,6 @@ protected
Modelica.Units.SI.VolumeFlowRate V_flow_win "Wind induced volume flow";
equation
intRes = Modelica.Constants.g_n*winClrHeight*dTRoomAmb/TAvg;
assert(intRes > Modelica.Constants.eps,
"The polynomial under the square root to calculate V_flow_th is less than 0, the V_flow_th will be set to 0",
AssertionLevel.warning);
V_flow_th = if noEvent(intRes > Modelica.Constants.eps) then
1/3*cofDcg*openingArea.A*sqrt(intRes) else 0;
V_flow_win = 0.025*openingArea.A*winSpe10;
Expand Down

0 comments on commit 16b75dd

Please sign in to comment.