within AixLib.Airflow.Multizone.Validation;
model ThreeRoomsContam
  "Model with three rooms for the validation of the multizone air exchange models"
  extends Modelica.Icons.Example;

  package Medium = AixLib.Media.Air(extraPropertiesNames={"CO2"});

  AixLib.Fluid.MixingVolumes.MixingVolume volEas(
    redeclare package Medium = Medium,
    T_start=273.15 + 20,
    V=2.5*5*5*1,
    nPorts=5,
    m_flow_nominal=0.001,
    energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial)
    "Air volume east room"

  AixLib.Airflow.Multizone.Orifice oriOutBot(
    redeclare package Medium = Medium,
    A=0.01,
    m=0.5) "Orifice at bottom of facade"
  AixLib.Airflow.Multizone.MediumColumn colOutTop(
    redeclare package Medium = Medium,
    h=1.5,
    densitySelection=AixLib.Airflow.Multizone.Types.densitySelection.fromBottom)
    "Medium column for bottom floor outside air"
  AixLib.Airflow.Multizone.Orifice oriOutTop(
    redeclare package Medium = Medium,
    A=0.01,
    m=0.5) "Orifice at top of facade"
  AixLib.Airflow.Multizone.MediumColumn colEasInTop(
    redeclare package Medium = Medium,
    h=1.5,
    densitySelection=AixLib.Airflow.Multizone.Types.densitySelection.fromBottom)
    "Medium column for bottom floor"
  AixLib.Fluid.Sources.Boundary_pT volOut(
    redeclare package Medium = Medium,
    nPorts=2,
    p(displayUnit="Pa") = 101325,
    T=283.15) "Outside air boundary condition"

  AixLib.Airflow.Multizone.MediumColumn colEasInBot(
    redeclare package Medium = Medium,
    h=1.5,
    densitySelection=AixLib.Airflow.Multizone.Types.densitySelection.fromTop)
    "Medium column for bottom floor"
  AixLib.Airflow.Multizone.MediumColumn colOutBot(
    redeclare package Medium = Medium,
    h=1.5,
    densitySelection=AixLib.Airflow.Multizone.Types.densitySelection.fromTop)
    "Medium column for bottom floor outside air"
  AixLib.Airflow.Multizone.MediumColumn colWesBot(
    redeclare package Medium = Medium,
    h=1.5,
    densitySelection=AixLib.Airflow.Multizone.Types.densitySelection.fromBottom)
    "Medium column for bottom floor"
  AixLib.Airflow.Multizone.Orifice oriWesTop(
    redeclare package Medium = Medium,
    m=0.5,
    A=0.01) "Orifice between top and bottom west floor"

  AixLib.Airflow.Multizone.MediumColumn colWesTop(
    redeclare package Medium = Medium,
    h=1.5,
    densitySelection=AixLib.Airflow.Multizone.Types.densitySelection.fromTop)
    "Medium column for top floor"

  replaceable DoorOpen dooOpeClo(
    redeclare package Medium = Medium,
    wOpe=1,
    hOpe=2.2,
    dp_turbulent(displayUnit="Pa") = 0.01,
    CD=0.78,
    m=0.5)  constrainedby Fluid.Interfaces.PartialFourPortInterface
    "Door"
  AixLib.Fluid.MixingVolumes.MixingVolume volWes(
    redeclare package Medium = Medium,
    T_start=273.15 + 25,
    nPorts=3,
    V=2.5*5*5,
    m_flow_nominal=0.001,
    energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial)
    "Air volume west floor"
  AixLib.Airflow.Multizone.MediumColumn col1EasBot(
    redeclare package Medium = Medium,
    h=1.5,
    densitySelection=AixLib.Airflow.Multizone.Types.densitySelection.fromBottom)
    "Medium column for bottom floor"
  AixLib.Airflow.Multizone.Orifice oriEasTop(
    redeclare package Medium = Medium,
    m=0.5,
    A=0.01) "Orifice between top and bottom east floor"
  AixLib.Airflow.Multizone.MediumColumn colEasTop(
    redeclare package Medium = Medium,
    h=1.5,
    densitySelection=AixLib.Airflow.Multizone.Types.densitySelection.fromTop)
    "Medium column for top floor"
  AixLib.Fluid.MixingVolumes.MixingVolume volTop(
    redeclare package Medium = Medium,
    T_start=273.15 + 20,
    V=2.5*5*10*1,
    nPorts=2,
    m_flow_nominal=0.001,
    energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial)
    "Air volume top floor"

  Modelica.Thermal.HeatTransfer.Sources.FixedTemperature TTop(T=293.15)
    "Fixed temperature"
  Modelica.Thermal.HeatTransfer.Sources.FixedTemperature TWes(T=298.15)
    "Fixed temperature"
  Modelica.Thermal.HeatTransfer.Sources.FixedTemperature TEas(T=293.15)
    "Fixed temperature"
  Modelica.Thermal.HeatTransfer.Components.ThermalConductor conTop(G=1E9)
    "Thermal conductor"
  Modelica.Thermal.HeatTransfer.Components.ThermalConductor conWes(G=1E9)
    "Thermal conductor"
  Modelica.Thermal.HeatTransfer.Components.ThermalConductor conEas(G=1E9)
    "Thermal conductor"
equation
  connect(volWes.ports[1], dooOpeClo.port_b2)
  connect(volWes.ports[2], dooOpeClo.port_a1)
  connect(volWes.ports[3], colWesBot.port_b)
  connect(colWesBot.port_a, oriWesTop.port_b)
  connect(oriWesTop.port_a, colWesTop.port_b)
  connect(colWesTop.port_a, volTop.ports[1])
  connect(volTop.ports[2], colEasTop.port_a)
  connect(colEasTop.port_b, oriEasTop.port_b)
  connect(oriEasTop.port_a, col1EasBot.port_a)
  connect(dooOpeClo.port_b1, volEas.ports[1])
  connect(volEas.ports[2], dooOpeClo.port_a2)
  connect(colEasInBot.port_a, volEas.ports[3])
  connect(volEas.ports[4], colEasInTop.port_b)
  connect(volEas.ports[5], col1EasBot.port_b)
  connect(colEasInTop.port_a, oriOutTop.port_a)
  connect(oriOutTop.port_b, colOutTop.port_a)
  connect(colOutTop.port_b, volOut.ports[1])
  connect(colOutBot.port_a, volOut.ports[2])
  connect(colOutBot.port_b, oriOutBot.port_b)
  connect(oriOutBot.port_a, colEasInBot.port_b)

  connect(TTop.port, conTop.port_a)
  connect(conTop.port_b, volTop.heatPort)
  connect(TWes.port, conWes.port_a)
  connect(conWes.port_b, volWes.heatPort)
  connect(TEas.port, conEas.port_a)
  connect(conEas.port_b, volEas.heatPort)
end ThreeRoomsContam;


within AixLib.Airflow.Multizone.Validation;
model ThreeRoomsContamDiscretizedDoor
  "Model with three rooms for the validation of the multizone air exchange models"
  extends AixLib.Airflow.Multizone.Validation.ThreeRoomsContam(
    redeclare AixLib.Airflow.Multizone.DoorDiscretizedOperable dooOpeClo(
    redeclare package Medium = Medium,
    LClo=20*1E-4,
    wOpe=1,
    hOpe=2.2,
    CDOpe=0.78,
    CDClo=0.78,
    nCom=10,
    hA=3/2,
    hB=3/2,
    dp_turbulent(displayUnit="Pa") = 0.01));
  Modelica.Blocks.Sources.Constant open1(k=1)
    "Constant signal for door opening"
equation
  connect(open1.y, dooOpeClo.y)
end ThreeRoomsContamDiscretizedDoor;


within AixLib.Airflow;
package WindowVentilation "Package of different window ventilation models"
end WindowVentilation;


Partial model for empirical expressions of ventilation flow rate. This partial model provides a base class of models that estimate ventilation volume flow.

within AixLib.Airflow.WindowVentilation.BaseClasses;
partial model PartialEmpiricalFlow
  "Partial model for empirical expressions of ventilation flow rate"
  parameter Modelica.Units.SI.Length winClrWidth(min=0)
    "Width of the window clear opening";
  parameter Modelica.Units.SI.Height winClrHeight(min=0)
    "Height of the window clear opening";
  final parameter Boolean use_opnWidth_in=openingArea.use_opnWidth_in
    "Use input port for window sash opening";
  Modelica.Blocks.Interfaces.RealInput opnWidth_in(
    final quantity="Length", final unit="m", min=0) if use_opnWidth_in
    "Conditional input port for window sash opening width"
  Modelica.Blocks.Interfaces.RealOutput V_flow(
    final quantity="VolumeFlowRate", final unit="m3/s", min=0)
    "Ventilation flow rate"
  replaceable model OpeningArea =
    AixLib.Airflow.WindowVentilation.BaseClasses.PartialOpeningArea
    constrainedby
    AixLib.Airflow.WindowVentilation.BaseClasses.PartialOpeningArea(
      final winClrWidth=winClrWidth,
      final winClrHeight=winClrHeight)
    "Model for window opening area calculation"
  OpeningArea openingArea "Model instance for window opening area calculation"
  //Variables and parameters for assertion check
  Real intRes
    "Interim result used to check the if assertion is raised in root calculation";
  Integer errCouIntRes(start=0) "Warning counter for interim result warnings";
  parameter String varNameIntRes "Variable name of interim result";
initial equation
  errCouIntRes = 0;
equation
  // Assertion check
  when intRes < Modelica.Constants.eps then
    errCouIntRes = pre(errCouIntRes) + 1;
  end when;
  assert(intRes > Modelica.Constants.eps or errCouIntRes > 1,
    "In " + getInstanceName() + ": The polynomial under the square root to
    calculate '" + varNameIntRes + "' is equal or less than 0, '" +
    varNameIntRes + "' will be set to 0",
    AssertionLevel.warning);
  // Connection(s)
  connect(opnWidth_in, openingArea.opnWidth_in)
end PartialEmpiricalFlow;


Partial model for empirical expressions with stack effect considered. This partial model provides a base class of models that estimate ventilation volume flow. The model has indoor and ambient temperature input ports to account for the thermal stack effect.

within AixLib.Airflow.WindowVentilation.BaseClasses;
partial model PartialEmpiricalFlowStack
  "Partial model for empirical expressions with stack effect considered"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlow;
  Modelica.Blocks.Interfaces.RealInput TRoom(
    final unit="K", min=273, max=313)
    "Room temperature, ranging from 0 to 40 °C"
  Modelica.Blocks.Interfaces.RealInput TAmb(
    final unit="K", min=243, max=323)
    "Ambient temperature, ranging from -30 to 50 °C"
protected
  Modelica.Units.SI.TemperatureDifference dTRoomAmb = TRoom - TAmb
    "Temperature difference between room and ambient";
  Modelica.Units.SI.Temperature TAvg = (TRoom + TAmb)/2
    "Average temperature of room and ambient";
end PartialEmpiricalFlowStack;


Partial model for empirical expressions with stack effect and wind incidence angle considered. This partial model provides a base class of models that estimate ventilation volume flow. The model has a wind direction input port to account for the wind incidence.

within AixLib.Airflow.WindowVentilation.BaseClasses;
partial model PartialEmpiricalFlowStackWindIncidence
  "Partial model for empirical expressions with stack effect and wind incidence angle considered"
  extends PartialEmpiricalFlowStack;
  parameter Modelica.Units.SI.Angle aziRef(displayUnit="deg")=0
    "Azimuth angle of the referece surface impacted by wind";
  Modelica.Units.SI.Angle incAng(displayUnit="deg")
    "Incidence angle of wind on reference surface";
  Modelica.Blocks.Interfaces.RealInput winDir(
    final unit="rad", displayUnit="deg", min=0, max=2*Modelica.Constants.pi)
    "Local wind direction"
protected
  Modelica.Units.NonSI.Angle_deg incAngDeg "Incidence angle in degree";
equation
  incAngDeg = Modelica.Units.Conversions.to_deg(incAng);
end PartialEmpiricalFlowStackWindIncidence;


Calculation of window opening area, unspecified type. This partial model provides a base class of window opening area.

within AixLib.Airflow.WindowVentilation.BaseClasses;
partial model PartialOpeningArea
  "Calculation of window opening area, unspecified type"
  extends Modelica.Blocks.Icons.Block;
  parameter Modelica.Units.SI.Length winClrWidth(min=0)
    "Width of the window clear opening";
  parameter Modelica.Units.SI.Height winClrHeight(min=0)
    "Height of the window clear opening";
  parameter Boolean use_opnWidth_in=true
    "Use input port for window sash opening width"
  parameter Modelica.Units.SI.Length prescribedOpnWidth(min=0)=0
    "Fixed value of prescribed opening width"
  final parameter Modelica.Units.SI.Area AClrOpn = winClrWidth*winClrHeight
    "Window clear opening area";
  Modelica.Blocks.Interfaces.RealInput opnWidth_in(
    final quantity="Length", final unit="m", min=0) if use_opnWidth_in
    "Conditional input port for window sash opening width"
  Modelica.Blocks.Interfaces.RealOutput A(
    final quantity="Area", final unit="m2", min=0)
    "Output port for window opening area, must be defined by extended model"
  Modelica.Blocks.Interfaces.RealOutput opnWidth_internal(final unit="m", min=0)
    "Internal port to connect to opnWidth_in or prescribedOpnWidth";
equation
  connect(opnWidth_in, opnWidth_internal);
  if not use_opnWidth_in then
    opnWidth_internal = prescribedOpnWidth;
  end if;
end PartialOpeningArea;


Window opening area, sash opening. This partial model provides a base class of window sash opening area.

within AixLib.Airflow.WindowVentilation.BaseClasses;
partial model PartialOpeningAreaSash
  "Window opening area, sash opening"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialOpeningArea;
  parameter AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes
    opnTyp = AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward
    "Window opening type";
  /*Variables to describe the opening*/
  Modelica.Units.SI.Angle opnAng(
    min=0, max=Modelica.Constants.pi/2, displayUnit="deg")=
    if (opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungInward
      or opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungOutward)
    then
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.WidthToAngle(
        winClrHeight, winClrWidth, opnWidth_internal)
    else if (opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.TopHungOutward
       or opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward)
    then
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.WidthToAngle(
        winClrWidth, winClrHeight, opnWidth_internal)
    else if (opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotVertical)
    then
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.WidthToAngle(
        winClrHeight, winClrWidth/2, opnWidth_internal)
    else if (opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal)
    then
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.WidthToAngle(
        winClrWidth, winClrHeight/2, opnWidth_internal)
    else 0 "Window sash opening angle";
end PartialOpeningAreaSash;


Coefficient for hinged opening area according to DIN CEN/TR 16798-8 (DIN SPEC 32739-8). This function calculates the coefficient for hinged opening area according to DIN CEN/TR 16798-8 (DIN SPEC 32739-8).

within AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged;
function CoeffOpeningAreaDIN16798
  "Coefficient for hinged opening area according to DIN CEN/TR 16798-8 (DIN SPEC 32739-8)"
  extends Modelica.Icons.Function;
  input Modelica.Units.SI.Angle ang(min=0, max=Modelica.Constants.pi/2)
    "Window sash opening angle";
  output Real cof "Coefficient";
protected
  Modelica.Units.NonSI.Angle_deg angDeg "Window sash opening angle in deg";
algorithm
  angDeg := Modelica.Units.Conversions.to_deg(ang);
  assert(angDeg <= 90,
    "The model only applies to a maximum tilt angle of 90°",
    AssertionLevel.error);
  cof := 2.6e-7*(angDeg^3) - 1.19e-4*(angDeg^2) + 1.86e-2*angDeg;
end CoeffOpeningAreaDIN16798;


within AixLib.Airflow.WindowVentilation.BaseClasses.Functions;
package OpeningAreaHinged "Calculation of different hinged-opening areas by rectangular windows"
extends Modelica.Icons.FunctionsPackage;
end OpeningAreaHinged;


Empirical expression according to ASHRAE handbook (2009). This model contains the empirical expression according to ASHRAE handbook.

within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
model ASHRAE "Empirical expression according to ASHRAE handbook (2009)"
  extends
    AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStackWindIncidence(
      redeclare replaceable model OpeningArea =
        AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
      final varNameIntRes = "V_flow");
  Modelica.Blocks.Interfaces.RealInput winSpeLoc(unit="m/s", min=0)
    "Local wind speed by window or facade"
protected
  Real cofDcg = 0.4 + 0.0045*abs(dTRoomAmb) "Discharge coefficient";
  Real cofWin = 0.55 - abs(incAngDeg)/180*0.25 "Coefficient of wind speed";
  Modelica.Units.SI.Height dHeightNPL = openingArea.winClrHeight/2
    "Height from midpoint of lower opening to the neutral pressure level: Value
    of 'dHeightNPL' is difficult to estimate, if one window or door represents a
    large fraction (approximately 90%) of the total opening area in the envelope,
    then the NPL is at the mid-height of that aperture, and dHeightNPL equals
    one-half the height of the aperture.";
  Modelica.Units.SI.VolumeFlowRate V_flow_th "Thermal induced volume flow";
  Modelica.Units.SI.VolumeFlowRate V_flow_win "Wind induced volume flow";
equation
  V_flow_win = cofWin*openingArea.A*winSpeLoc;
  incAng = AixLib.Airflow.WindowVentilation.BaseClasses.Functions.SmallestAngleDifference(
    AixLib.Airflow.WindowVentilation.BaseClasses.Types.SmallestAngleDifferenceTypes.Range180,
    aziRef, winDir);
  V_flow_th = cofDcg*openingArea.A*sqrt(intRes);
  intRes = 2*Modelica.Constants.g_n*dHeightNPL*abs(dTRoomAmb)/TRoom;
  V_flow = sqrt(V_flow_th^2 + V_flow_win^2);
end ASHRAE;


Empirical expression developed by Caciolo et al. (2013). This model contains the empirical expression developed by Caciolo et al..

within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
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,
      final varNameIntRes = "V_flow_th");
    Integer errCouWinSpeLoc(start=0)
      "Warning counter for assertion check of 'winSpeLoc'";
  Modelica.Blocks.Interfaces.RealInput winSpeLoc(unit="m/s", min=0)
    "Local wind speed by window or facade"
protected
  Real cofDcg = 0.60 "Discharge coefficient";
  Real cofWin "Coefficient of wind";
  Modelica.Units.SI.Velocity winSpeLim = 1.23
    "Lower bound of wind speed in windward conditions";
  Modelica.Units.SI.VolumeFlowRate V_flow_th "Thermal induced volume flow";
  Modelica.Units.SI.VolumeFlowRate V_flow_win "Wind induced volume flow";
initial equation
  errCouWinSpeLoc = 0;
equation
  incAng = AixLib.Airflow.WindowVentilation.BaseClasses.Functions.SmallestAngleDifference(
    AixLib.Airflow.WindowVentilation.BaseClasses.Types.SmallestAngleDifferenceTypes.Range180,
    winDir, aziRef);
  // Assertion of wind speed
  when (winSpeLoc < winSpeLim) and abs(incAngDeg) <= 90 then
    errCouWinSpeLoc = pre(errCouWinSpeLoc) + 1;
  end when;
  assert(winSpeLoc > winSpeLim or errCouWinSpeLoc > 1,
    "In " + getInstanceName() + ": The wind speed in the windward condition
    is equal or less than the limitation (" + String(winSpeLim) + " m/s), the
    'V_flow_win' will be set to 0",
    AssertionLevel.warning);
  // Calculate V_flow_win
  if abs(incAngDeg) <= 90 then
    /*Windward*/
    cofWin = 1.234 - 0.490*winSpeLoc + 0.048*(winSpeLoc^2);
    V_flow_win =if noEvent(winSpeLoc > winSpeLim) then
      0.0357*openingArea.A*(winSpeLoc - winSpeLim) else 0;
  else
    /*Leeward*/
    cofWin = 1.355 - 0.179*winSpeLoc;
    V_flow_win = 0;
  end if;
  intRes = Modelica.Constants.g_n*winClrHeight*dTRoomAmb*cofWin/TAvg;
  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;
end Caciolo;


Empirical expression according to DIN EN 16798-7 (2017). This model contains the empirical expression according to DIN CEN/TR 16798-8 (DIN SPEC 32739-8):2018-03.

within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
model DIN16798 "Empirical expression according to DIN EN 16798-7 (2017)"
  extends
    AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStack(
      redeclare replaceable model OpeningArea =
        AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashDIN16798,
      final varNameIntRes = "V_flow");
  parameter Modelica.Units.SI.Height heightASL=0 "Height above sea level";
  Modelica.Blocks.Interfaces.RealInput winSpe10(unit="m/s", min=0)
    "Local wind speed at a height of 10 m"
protected
  Real cofExt = min(1, max(0, (1 - 0.1*winSpe10)*((TAmb - T0)/25 + 0.2)))
    "Coefficient depending on external conditions";
  Real cofTh = 0.0035 "Coefficient of thermal buoyancy";
  Real cofWin = 0.001 "Coefficient of wind speed";
  Modelica.Units.SI.Temperature T0 = 273.15 "Temperature at 0 °C";
  Modelica.Units.SI.Temperature TRef = 293 "Reference temperature";
  Modelica.Units.SI.Density rhoRefASL0 = 1.204
    "Reference dry air density, 293 K, 0 m above see level";
  Modelica.Units.SI.Density rhoRefASL=
    rhoRefASL0*(1 - 0.00651*heightASL/293)^4.255
    "Air density, 293 K, by height above sea level";
  Modelica.Units.SI.Density rhoAmbASL = TRef/TAmb*rhoRefASL
    "Air density, by ambient temperature, by height above sea level";
equation
  intRes = max(cofWin*(winSpe10^2), cofTh*winClrHeight*abs(dTRoomAmb));
  V_flow = rhoRefASL0/rhoAmbASL*cofExt*openingArea.A/2*sqrt(intRes);
end DIN16798;


Empirical expression according to DIN/TS 4108-8 (2022). This model contains the empirical expression according to DIN/TS 4108-8:2022-09.

within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
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,
      final varNameIntRes = "V_flow_th");
  Modelica.Blocks.Interfaces.RealInput winSpeLoc(unit="m/s", min=0)
    "Local wind speed by window or facade"
protected
  Real cofDcg = 0.61 "Discharge coefficient";
  Real cofWin = 0.05 "Coefficient of wind speed";
  Modelica.Units.SI.VolumeFlowRate V_flow_th "Thermal induced volume flow";
  Modelica.Units.SI.VolumeFlowRate V_flow_win "Wind induced volume flow";
equation
  intRes = Modelica.Constants.g_n*winClrHeight*dTRoomAmb/TAmb;
  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;
  V_flow = sqrt(V_flow_th^2 + V_flow_win^2);
end DIN4108;


Empirical expression developed by de Gids and Phaff (1982). This model contains the empirical expression developed by de Gids and Phaff.

within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
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,
      final varNameIntRes = "V_flow");
  Modelica.Blocks.Interfaces.RealInput winSpe10(unit="m/s", min=0)
    "Local wind speed at a height of 10 m"
protected
  Real cof1 = 0.001 "Coefficient 1";
  Real cof2 = 0.0035 "Coefficient 2";
  Real cof3 = 0.01 "Coefficient 3";
equation
  intRes = cof1*(winSpe10^2) + cof2*winClrHeight*abs(dTRoomAmb) + cof3;
  V_flow = if noEvent(intRes > Modelica.Constants.eps) then
    1/2*openingArea.A*sqrt(intRes) else 0;
end GidsPhaff;


Empirical expression developed by Hall (2004). This model contains the empirical expression developed by Hall.

within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
model Hall "Empirical expression developed by Hall (2004)"
  extends
    AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStack(
      redeclare model OpeningArea =
        AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashHall (
        final sWinSas=sWinSas, final widthWinGap=widthWinGap),
      final varNameIntRes = "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
    "Gap width in the overlap area between the frame and the sash";
protected
  Real cofDcg = 0.930*(openingArea.opnWidth_internal^0.2)
    "Discharge coefficient, case: without window reveal, without radiator";
equation
  intRes = 2*Modelica.Constants.g_n*winClrHeight*openingArea.corNPL*dTRoomAmb/
    TRoom;
  V_flow = if noEvent(intRes > Modelica.Constants.eps) then
    cofDcg*openingArea.A*sqrt(intRes) else 0;
end Hall;


Empirical expression developed by Jiang et al. (2022). This model contains the empirical expression developed by Jiang et al..

within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
model Jiang "Empirical expression developed by Jiang et al. (2022)"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlow(
    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 varNameIntRes = "V_flow");
  Modelica.Blocks.Interfaces.RealInput dp(unit="Pa")
    "Pressure difference between the outside and inside of the facade "
protected
  Real cof1 = 0.15 "Coefficient 1";
  Real cof2 = 0.33 "Coefficient 2";
equation
  intRes = cof1*dp + cof2;
  V_flow = if noEvent(intRes > Modelica.Constants.eps) then
    1/2*openingArea.A*sqrt(intRes) else 0;
end Jiang;


Empirical expression developed by Larsen and Heiselberg (2008). This model contains the empirical expression developed by Larsen and Heiselberg.

within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
model LarsenHeiselberg "Empirical expression developed by Larsen and Heiselberg (2008)"
  extends
    AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStackWindIncidence(
      redeclare replaceable model OpeningArea =
        AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
      final varNameIntRes = "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
    speed is less than this limit.";
  Integer errCouWinSpe10(start=0)
    "Warning counter for assertion check of 'winSpe10'";
  Modelica.Blocks.Interfaces.RealInput winSpe10(unit="m/s", min=0)
    "Local wind speed at a height of 10 m"
protected
  Real cofWinInc
    "Coefficient of wind incidence, equivalent to C_beta*sqrt(abs(C_p)) in the equation";
  Real dCofWinInc
    "Correlation of coefficient of wind incidence, equivalent to deltaC_p";
  Real cof1, cof2, cof3 "Other coefficients";
initial equation
  errCouWinSpe10 = 0;
equation
  incAng = AixLib.Airflow.WindowVentilation.BaseClasses.Functions.SmallestAngleDifference(
    AixLib.Airflow.WindowVentilation.BaseClasses.Types.SmallestAngleDifferenceTypes.Range360,
    winDir, aziRef);
  (cofWinInc,)  = Modelica.Math.Vectors.interpolate(
    {0, 45, 90, 135, 180, 225, 270, 315, 360},
    {0.2, 0.53, 0.56, 0.28, 0.09, 0.28, 0.56, 0.53, 0.2},
    incAngDeg);
  dCofWinInc = 9.1894e-9*(incAngDeg^3) - 2.626e-6*(incAngDeg^2) - 2.354e-4*incAngDeg + 0.113;
  if incAngDeg>=285 or incAngDeg<=75 then
    cof1 = 0.0015;
    cof2 = 0.0009;
    cof3 = -0.0005;
  elseif incAngDeg>=105 and incAngDeg<=255 then
    cof1 = 0.0050;
    cof2 = 0.0009;
    cof3 = 0.0160;
  else
    cof1 = 0.0010;
    cof2 = 0.0005;
    cof3 = 0.0111;
  end if;
  // Assertion of wind speed check
  when winSpe10 < winSpeLim then
    errCouWinSpe10 = pre(errCouWinSpe10) + 1;
  end when;
  assert(winSpe10 > winSpeLim or errCouWinSpe10 > 1,
    "In " + getInstanceName() + ": The wind speed is equal or less than the
    limited value (" + String(winSpeLim) + " m/s), the term of wind correlation
    will be set to 0",
    AssertionLevel.warning);
  // Calculate intRes
  intRes =if noEvent(winSpe10 > winSpeLim)
    then cof1*(cofWinInc^2)*(winSpe10^2) + cof2*dTRoomAmb*winClrHeight
      + cof3*dCofWinInc*dTRoomAmb/(winSpe10^2)
    else cof1*(cofWinInc^2)*(winSpe10^2) + cof2*dTRoomAmb*winClrHeight + 0;
  // Calculate volume flow
  V_flow = if noEvent(intRes > Modelica.Constants.eps) then
    openingArea.A*sqrt(intRes) else 0;
end LarsenHeiselberg;


Empirical expression developed by Maas (1995). This model contains the empirical expression developed by Maas.

within AixLib.Airflow.WindowVentilation.EmpiricalExpressions;
model Maas "Empirical expression developed by Maas (1995)"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialEmpiricalFlowStack(
    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 varNameIntRes = "V_flow");
  Modelica.Blocks.Interfaces.RealInput winSpe13(unit="m/s", min=0)
    "Local wind speed at a height of 13 m"
protected
  Real cof1 = 0.0056 "Coefficient 1";
  Real cof2 = 0.0037 "Coefficient 2";
  Real cof3 = 0.012 "Coefficient 3";
equation
  intRes = cof1*(winSpe13^2) + cof2*winClrHeight*dTRoomAmb + cof3;
  V_flow = if noEvent(intRes > Modelica.Constants.eps) then
    1/2*openingArea.A*sqrt(intRes) else 0;
end Maas;


within AixLib.Airflow.WindowVentilation;
package EmpiricalExpressions "Empirical expressions for calculation of the airflow"
  extends Modelica.Icons.VariantsPackage;
end EmpiricalExpressions;


Empirical expression developed by Tang et al. (2016). This model contains the empirical expression developed by Tang et al..

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,
    final varNameIntRes = "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
    difference, output with 0 if the absolute temperature difference is less
    than this limit.";
  Integer errCou_dT(start=0)
    "Warning counter for assertion check of 'dT'";
protected
  Real cofDcg = 0.6 "Discharge coefficient";
  Real cof_dT = 0.02 "Coefficient of temperature difference";
initial equation
  errCou_dT = 0;
equation
  // Assertion of temperature difference check
  when abs(dTRoomAmb) < dTLim then
    errCou_dT = pre(errCou_dT) + 1;
  end when;
  assert(abs(dTRoomAmb) > dTLim or errCou_dT > 1,
    "In " + getInstanceName() + ": The temperature difference between indoor
    and ambient is equal or less than the limited value (" + String(dTLim) + "
    K), the term of temperature difference correlation will be set to 0",
    AssertionLevel.warning);
  // Calculate intRes
  intRes = if noEvent(abs(dTRoomAmb) > dTLim)
    then Modelica.Constants.g_n*winClrHeight*abs(dTRoomAmb)/TRoom + cof_dT/
      abs(dTRoomAmb)
    else Modelica.Constants.g_n*winClrHeight*abs(dTRoomAmb)/TRoom + 0;
  // Calculate volume flow
  V_flow = if noEvent(intRes > Modelica.Constants.eps) then
    1/3*cofDcg*openingArea.A*sqrt(intRes) else 0;
end Tang;


Empirical expression according to VDI 2078 (2015). This model contains the empirical expression according to VDI 2078:2015-06.

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,
    final varNameIntRes = "V_flow");
  parameter Boolean use_cofSunSha_in=false
    "Use input port for sunshading coefficient"
  parameter
    AixLib.Airflow.WindowVentilation.BaseClasses.Types.SunshadingInstallationTypesVDI2078
    sunShaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.SunshadingInstallationTypesVDI2078.NoSunshading
    "Sunshading type"
  Modelica.Blocks.Interfaces.RealInput cofSunSha_in(min=0, max=1) if use_cofSunSha_in
    "Conditional input port for sunshading coefficient"
  Modelica.Blocks.Interfaces.RealOutput cofSunSha_internal(min=0, max=1)
    "Internal port to connect to cofSunSha_in or prescribed coefficient defined by type";
equation
  connect(cofSunSha_in, cofSunSha_internal);
  if not use_cofSunSha_in then
    cofSunSha_internal =
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.CoeffsSunshadingInstallationVDI2078(
      sunShaTyp);
  end if;
  intRes = Modelica.Constants.g_n*openingArea.effHeight*dTRoomAmb/(2*TAmb);
  V_flow =if noEvent(intRes > Modelica.Constants.eps) then cofSunSha_internal*
    openingArea.A*sqrt(intRes) else 0;
end VDI2078;


Empirical expression developed by Warren and Parkins (1984). This model contains the empirical expression developed by Warren and Parkins.

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,
    final varNameIntRes = "V_flow_th");
  Modelica.Blocks.Interfaces.RealInput winSpe10(unit="m/s", min=0)
    "Local wind speed at a height of 10 m"
protected
  Real cofDcg = 0.61 "Discharge coefficient";
  Modelica.Units.SI.VolumeFlowRate V_flow_th "Thermal induced volume flow";
  Modelica.Units.SI.VolumeFlowRate V_flow_win "Wind induced volume flow";
equation
  intRes = Modelica.Constants.g_n*winClrHeight*dTRoomAmb/TAvg;
  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;
  V_flow = max(V_flow_th, V_flow_win);
end WarrenParkins;


Calculation of different opening areas. This example simulates and checks the models in package OpeningAreas, calculating the window opening area with variable opening width or angle.

within AixLib.Airflow.WindowVentilation.Examples;
model OpeningArea "Calculation of different opening areas"
  extends Modelica.Icons.Example;
  parameter Modelica.Units.SI.Length winClrWidth = 1.0 "Window clear width";
  parameter Modelica.Units.SI.Height winClrHeight = 1.5 "Window clear height";
  parameter Modelica.Units.SI.Thickness sWinSas = 0.08 "Window sash thickness";
  Modelica.Blocks.Sources.Ramp opnWidthSet(
    height=0.5,
    duration=50,
    startTime=5) "Window opening width set value"
  Modelica.Blocks.Sources.Ramp opnAngSet(
    height=30,
    duration=50,
    startTime=5) "Window opening angle set value"
  Modelica.Blocks.Math.UnitConversions.From_deg from_deg
    "Convert from deg to rad"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple opnSimp(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight) "Simple opening without sash"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimpleVDI2078 opnSimpVDI2078(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight) "Simple opening without sash, VDI 2078"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasSdHunInGeo(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungInward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric)
    "Side-hung, inward, geometric opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasSdHunInPrj(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungInward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Projective)
    "Side-hung, inward, projective opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasSdHunInEqv(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungInward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Equivalent)
    "Side-hung, inward, equivalent opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasSdHunInEff(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungInward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Effective)
    "Side-hung, inward, effective opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasSdHunOutGeo(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungOutward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric)
    "Side-hung, outward, geometric opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasBtmHunInGeo(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric)
    "Bottom-hung, inward, geometric opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasBtmHunInPrj(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Projective)
    "Bottom-hung, inward, projective opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasBtmHunInEqv(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Equivalent)
    "Bottom-hung, inward, equivalent opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasBtmHunInEff(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Effective)
    "Bottom-hung, inward, effective opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasTopHunOutPrj(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.TopHungOutward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Projective)
    "Top-hung, outward, projective opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasPivVerGeo(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotVertical,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric)
    "Pivot, vertical, geometric opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasPivVerPrj(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotVertical,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Projective)
    "Pivot, vertical, projective opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasPivVerEqv(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotVertical,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Equivalent)
    "Pivot, vertical, equivalent opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasPivVerEff(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotVertical,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Effective)
    "Pivot, vertical, effective opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasPivHorGeo(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric)
    "Pivot, horizontal, geometric opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasPivHorPrj(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Projective)
    "Pivot, horizontal, projective opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasPivHorEqv(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Equivalent)
    "Pivot, horizontal, equivalent opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasPivHorEff(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Effective)
    "Pivot, horizontal, effective opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasPivHorEffPre(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    use_opnWidth_in=false,
    prescribedOpnWidth=0.5,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Effective)
    "Pivot, horizontal, effective opening, prescribed input"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasSldVerGeo(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SlidingVertical,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric)
    "Sliding, vertical, geometric opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasSldHorGeo(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SlidingHorizontal,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric)
    "Sliding, horizontal, geometric opening"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashDIN16798 opnSasBtmHunInDIN16798(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward)
    "Bottom-hung, inward, DIN 16798"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashDIN4108 opnSasSdHunInDIN4108(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungInward)
    "Side-hung, inward, DIN 4108"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashDIN4108 opnSasBtmHunInDIN4108(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward)
    "Bottom-hung, inward, DIN 4108"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashDIN4108 opnSasPivHorDIN4108(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal,
    sWinSas=sWinSas) "Pivot, horizontal, DIN 4108"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashHall opnSasBtmHunInHall(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    sWinSas=sWinSas) "Bottom-hung, inward, Hall"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashVDI2078 opnSasBtmHunInVDI2078(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    sWinSas=sWinSas) "Bottom-hung, inward, VDI2078"
  AixLib.Airflow.WindowVentilation.Utilities.AngleToWidth angToWidth(lenAxs=opnSasAngBtmHunInGeo.lenAxs,
      lenAxsToFrm=opnSasAngBtmHunInGeo.lenAxsToFrm)
    "Convert opening angle to opening width"
  AixLib.Airflow.WindowVentilation.Utilities.WidthToAngle widthToAng(lenAxs=opnSasAngBtmHunInGeo.lenAxs,
      lenAxsToFrm=opnSasAngBtmHunInGeo.lenAxsToFrm)
    "Convert opening width to opening angle"
  AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon opnSasAngBtmHunInGeo(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
    opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric)
    "Input of angle, bottom-hung, inward, geometric opening"

equation
  connect(opnWidthSet.y, opnSasSdHunInGeo.opnWidth_in)
  connect(opnWidthSet.y, opnSasSdHunInPrj.opnWidth_in)
  connect(opnWidthSet.y, opnSasSdHunInEqv.opnWidth_in)
  connect(opnWidthSet.y, opnSasSdHunInEff.opnWidth_in)
  connect(opnWidthSet.y, opnSasSdHunOutGeo.opnWidth_in)
  connect(opnWidthSet.y, opnSasBtmHunInGeo.opnWidth_in)
  connect(opnWidthSet.y, opnSasBtmHunInPrj.opnWidth_in)
  connect(opnWidthSet.y, opnSasBtmHunInEqv.opnWidth_in)
  connect(opnWidthSet.y, opnSasBtmHunInEff.opnWidth_in)
  connect(opnWidthSet.y, opnSasTopHunOutPrj.opnWidth_in)
  connect(opnWidthSet.y, opnSasPivVerGeo.opnWidth_in)
  connect(opnWidthSet.y, opnSasPivVerPrj.opnWidth_in)
  connect(opnWidthSet.y, opnSasPivVerEqv.opnWidth_in)
  connect(opnWidthSet.y, opnSasPivVerEff.opnWidth_in)
  connect(opnWidthSet.y, opnSasPivHorGeo.opnWidth_in)
  connect(opnWidthSet.y, opnSasPivHorPrj.opnWidth_in)
  connect(opnWidthSet.y, opnSasPivHorEqv.opnWidth_in)
  connect(opnWidthSet.y, opnSasPivHorEff.opnWidth_in)
  connect(opnWidthSet.y, opnSasSldVerGeo.opnWidth_in)
  connect(opnWidthSet.y, opnSasSldHorGeo.opnWidth_in)
  connect(opnAngSet.y, from_deg.u)
  connect(opnWidthSet.y, opnSasBtmHunInDIN16798.opnWidth_in)
  connect(opnWidthSet.y, opnSasSdHunInDIN4108.opnWidth_in)
  connect(opnWidthSet.y, opnSasBtmHunInDIN4108.opnWidth_in)
  connect(opnWidthSet.y, opnSasPivHorDIN4108.opnWidth_in)
  connect(opnWidthSet.y, opnSasBtmHunInHall.opnWidth_in)
  connect(opnWidthSet.y, opnSasBtmHunInVDI2078.opnWidth_in)
  connect(from_deg.y, angToWidth.u)
  connect(angToWidth.y, opnSasAngBtmHunInGeo.opnWidth_in)
  connect(angToWidth.y, widthToAng.u)
end OpeningArea;


Use different empirical expressions to determine the window ventilation flow rate by sash opening. This example checks the models that simulate the window ventilation flow rate with the sash opening. For the sash opening type, all models are set to the bottom-hung opening.

within AixLib.Airflow.WindowVentilation.Examples;
model VentilationFlowRateSashOpening
  "Use different empirical expressions to determine the window ventilation flow rate by sash opening"
  extends Modelica.Icons.Example;
  /*Parameters for boundary conditions*/
  parameter Modelica.Units.SI.Length winClrWidth(min=0)=1.0
    "Width of the window clear opening";
  parameter Modelica.Units.SI.Height winClrHeight(min=0)=1.8
    "Height of the window clear opening";
  parameter Modelica.Units.SI.Angle aziRef(displayUnit="deg")=0
    "Azimuth angle of the referece surface impacted by wind";
  parameter Modelica.Units.SI.Height locHeight(min=0)=4
    "Middle local height of the ventilation zone";
  Modelica.Blocks.Sources.Ramp TRoomSet(
    height=15,
    duration=120,
    offset=15,
    startTime=50) "Set room temperature in °C"
  Modelica.Blocks.Math.UnitConversions.From_degC from_degC "Convert degC to K"
  Modelica.Blocks.Sources.Ramp TAmbSet(
    height=-40,
    duration=160,
    offset=40,
    startTime=10) "Set ambient temperature in °C"
  Modelica.Blocks.Math.UnitConversions.From_degC from_degC1 "Convert degC to K"
  Modelica.Blocks.Sources.TimeTable winSpe10Set(table=[0,0; 20,0; 30,5; 40,0; 50,
        10; 60,0; 70,20; 80,0; 100,0; 110,20; 120,0; 130,10; 140,0; 150,5; 160,0;
        180,0]) "Set wind speed at the height of 10 m"
  Modelica.Blocks.Sources.Sine winDirSet(amplitude=2*Modelica.Constants.pi, f=0.05)
    "Set wind direction"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.WarrenParkins warrenParkins(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon (
        opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
        opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric))
        "Model Warren Parkins"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.GidsPhaff gidsPhaff(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon (
        opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
        opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric))
      "Model de Gids Phaff"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.LarsenHeiselberg larsenHeiselberg(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon (
        opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
        opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric),
    aziRef=aziRef) "Model Larsen Heiselberg"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.Caciolo caciolo(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon (
        opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
        opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric),
    aziRef=aziRef) "Model Caciolo"
  AixLib.Airflow.WindowVentilation.Utilities.WindProfilePowerLaw winSpeProLoc(
    height=locHeight, heightRef=10)
    "Calculate wind speed profile local"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.Tang tang(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon (
        opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
        opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric))
    "Model Tang"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.VDI2078 vdi2078_1(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashVDI2078,
    sunShaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.SunshadingInstallationTypesVDI2078.NoSunshading)
    "Model VDI 2078, without sun shading"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.VDI2078 vdi2078_2(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashVDI2078 (
        use_opnWidth_in=false, prescribedOpnWidth=0.1),
    sunShaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.SunshadingInstallationTypesVDI2078.ExternalBlindsOn)
    "Model VDI 2078, with sun shading"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.VDI2078 vdi2078_3(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashVDI2078 (
        use_opnWidth_in=false, prescribedOpnWidth=0.1),
    use_cofSunSha_in=true) "Model VDI 2078, with sun shading input"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.DIN16798 din16798_1(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashDIN16798 (
        opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward),
    heightASL=200) "Model DIN 16798"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.DIN4108 din4108_1(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashDIN4108 (
        opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward))
    "Model DIN 4108"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.ASHRAE ashrae(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSashCommon (
        opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
        opnAreaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric),
    aziRef=aziRef) "Model ASHRAE"
  Modelica.Blocks.Sources.Pulse cofSunShaSet(
    amplitude=0.5,
    period=10,
    offset=0.5) "Set sunshading coefficient"
  Modelica.Blocks.Sources.SawTooth winOpnWidthSet(amplitude=0.3, period=10)
    "Set window opening width"
  Modelica.Blocks.Sources.Ramp dpSet(
    height=20,
    duration=160,
    offset=-10,
    startTime=10) "Set pressure difference"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.Maas maas(
    winClrWidth=winClrWidth, winClrHeight=winClrHeight)
    "Model Maas"
  AixLib.Airflow.WindowVentilation.Utilities.WindProfilePowerLaw winSpePro13(
    height=13, heightRef=10)
    "Calculate wind speed profile at height of 13 m"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.Hall hall(
    winClrWidth=winClrWidth, winClrHeight=winClrHeight)
    "Model Hall"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.Jiang jiang(
    winClrWidth=winClrWidth, winClrHeight=winClrHeight)
    "Model Jiang"
equation
  connect(TRoomSet.y, from_degC.u)
  connect(TAmbSet.y, from_degC1.u)
  connect(winSpe10Set.y, winSpeProLoc.winSpeRef)
  connect(winSpe10Set.y, winSpePro13.winSpeRef)
  connect(cofSunShaSet.y, vdi2078_3.cofSunSha_in)
  connect(from_degC.y, warrenParkins.TRoom)
  connect(from_degC1.y, warrenParkins.TAmb)
  connect(winSpe10Set.y, warrenParkins.winSpe10)
  connect(from_degC.y, gidsPhaff.TRoom)
  connect(from_degC1.y, gidsPhaff.TAmb)
  connect(winSpe10Set.y, gidsPhaff.winSpe10)
  connect(from_degC.y, larsenHeiselberg.TRoom)
  connect(from_degC1.y, larsenHeiselberg.TAmb)
  connect(winSpe10Set.y, larsenHeiselberg.winSpe10)
  connect(winDirSet.y, larsenHeiselberg.winDir)
  connect(from_degC.y, caciolo.TRoom)
  connect(from_degC1.y, caciolo.TAmb)
  connect(winSpeProLoc.winSpe, caciolo.winSpeLoc)
  connect(winDirSet.y, caciolo.winDir)
  connect(from_degC.y, tang.TRoom)
  connect(from_degC1.y, tang.TAmb)
  connect(from_degC.y, maas.TRoom)
  connect(from_degC1.y, maas.TAmb)
  connect(winSpePro13.winSpe, maas.winSpe13)
  connect(from_degC.y, vdi2078_1.TRoom)
  connect(from_degC1.y, vdi2078_1.TAmb)
  connect(from_degC.y, vdi2078_2.TRoom)
  connect(from_degC1.y, vdi2078_2.TAmb)
  connect(from_degC.y, vdi2078_3.TRoom)
  connect(from_degC1.y, vdi2078_3.TAmb)
  connect(from_degC.y, din16798_1.TRoom)
  connect(from_degC1.y, din16798_1.TAmb)
  connect(winSpe10Set.y, din16798_1.winSpe10)
  connect(from_degC.y, din4108_1.TRoom)
  connect(from_degC1.y, din4108_1.TAmb)
  connect(winSpeProLoc.winSpe, din4108_1.winSpeLoc)
  connect(from_degC.y, ashrae.TRoom)
  connect(from_degC1.y, ashrae.TAmb)
  connect(winSpeProLoc.winSpe, ashrae.winSpeLoc)
  connect(winDirSet.y, ashrae.winDir)
  connect(from_degC.y, hall.TRoom)
  connect(from_degC1.y, hall.TAmb)
  connect(dpSet.y, jiang.dp)
  connect(winOpnWidthSet.y, warrenParkins.opnWidth_in)
  connect(winOpnWidthSet.y, gidsPhaff.opnWidth_in)
  connect(winOpnWidthSet.y, larsenHeiselberg.opnWidth_in)
  connect(winOpnWidthSet.y, caciolo.opnWidth_in)
  connect(winOpnWidthSet.y, tang.opnWidth_in)
  connect(winOpnWidthSet.y, maas.opnWidth_in)
  connect(winOpnWidthSet.y, vdi2078_1.opnWidth_in)
  connect(winOpnWidthSet.y, din16798_1.opnWidth_in)
  connect(winOpnWidthSet.y, din4108_1.opnWidth_in)
  connect(winOpnWidthSet.y, ashrae.opnWidth_in)
  connect(winOpnWidthSet.y, hall.opnWidth_in)
  connect(winOpnWidthSet.y, jiang.opnWidth_in)
end VentilationFlowRateSashOpening;


Use different empirical expressions to determine the window ventilation flow rate by simple opening. This example checks the models that simulate the window ventilation flow rate with the simple opening.

within AixLib.Airflow.WindowVentilation.Examples;
model VentilationFlowRateSimpleOpening
  "Use different empirical expressions to determine the window ventilation flow rate by simple opening"
  extends Modelica.Icons.Example;
  /*Parameters for boundary conditions*/
  parameter Modelica.Units.SI.Length winClrWidth(min=0)=1.0
    "Width of the window clear opening";
  parameter Modelica.Units.SI.Height winClrHeight(min=0)=1.8
    "Height of the window clear opening";
  parameter Modelica.Units.SI.Angle aziRef(displayUnit="deg")=0
    "Azimuth angle of the referece surface impacted by wind";
  parameter Modelica.Units.SI.Height locHeight(min=0)=4
    "Middle local height of the ventilation zone";
  Modelica.Blocks.Sources.Ramp TRoomSet(
    height=15,
    duration=120,
    offset=15,
    startTime=50) "Set room temperature in °C"
  Modelica.Blocks.Math.UnitConversions.From_degC from_degC "Convert degC to K"
  Modelica.Blocks.Sources.Ramp TAmbSet(
    height=-40,
    duration=160,
    offset=40,
    startTime=10) "Set ambient temperature in °C"
  Modelica.Blocks.Math.UnitConversions.From_degC from_degC1 "Convert degC to K"
  Modelica.Blocks.Sources.TimeTable winSpe10Set(table=[0,0; 20,0; 30,5; 40,0; 50,
        10; 60,0; 70,20; 80,0; 100,0; 110,20; 120,0; 130,10; 140,0; 150,5; 160,0;
        180,0]) "Set wind speed at the height of 10 m"
  Modelica.Blocks.Sources.Sine winDirSet(amplitude=2*Modelica.Constants.pi, f=0.05)
    "Set wind direction"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.WarrenParkins warrenParkins(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple)
        "Model Warren Parkins"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.GidsPhaff gidsPhaff(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple)
      "Model de Gids Phaff"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.LarsenHeiselberg larsenHeiselberg(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
    aziRef=aziRef) "Model Larsen Heiselberg"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.Caciolo caciolo(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
    aziRef=aziRef) "Model Caciolo"
  AixLib.Airflow.WindowVentilation.Utilities.WindProfilePowerLaw winSpeProLoc(
    height=locHeight, heightRef=10)
    "Calculate wind speed profile local"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.Tang tang(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple)
    "Model Tang"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.VDI2078 vdi2078_1(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimpleVDI2078,
    sunShaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.SunshadingInstallationTypesVDI2078.NoSunshading)
    "Model VDI 2078, without sun shading"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.VDI2078 vdi2078_2(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimpleVDI2078,
    sunShaTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.SunshadingInstallationTypesVDI2078.ExternalBlindsOn)
    "Model VDI 2078, with sun shading"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.VDI2078 vdi2078_3(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimpleVDI2078,
    use_cofSunSha_in=true) "Model VDI 2078, with sun shading input"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.DIN16798 din16798_1(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
    heightASL=200) "Model DIN 16798"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.DIN4108 din4108_1(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple)
    "Model DIN 4108"
  AixLib.Airflow.WindowVentilation.EmpiricalExpressions.ASHRAE ashrae(
    winClrWidth=winClrWidth,
    winClrHeight=winClrHeight,
    redeclare model OpeningArea =
      AixLib.Airflow.WindowVentilation.OpeningAreas.OpeningAreaSimple,
    aziRef=aziRef) "Model ASHRAE"
  Modelica.Blocks.Sources.Pulse cofSunShaSet(
    amplitude=0.5,
    period=10,
    offset=0.5) "Set sunshading coefficient"
equation
  connect(TRoomSet.y, from_degC.u)
  connect(TAmbSet.y, from_degC1.u)
  connect(winSpe10Set.y, winSpeProLoc.winSpeRef)
  connect(cofSunShaSet.y, vdi2078_3.cofSunSha_in)
  connect(from_degC.y, warrenParkins.TRoom)
  connect(from_degC1.y, warrenParkins.TAmb)
  connect(winSpe10Set.y, warrenParkins.winSpe10)
  connect(from_degC.y, gidsPhaff.TRoom)
  connect(from_degC1.y, gidsPhaff.TAmb)
  connect(winSpe10Set.y, gidsPhaff.winSpe10)
  connect(from_degC.y, larsenHeiselberg.TRoom)
  connect(from_degC1.y, larsenHeiselberg.TAmb)
  connect(winSpe10Set.y, larsenHeiselberg.winSpe10)
  connect(winDirSet.y, larsenHeiselberg.winDir)
  connect(from_degC.y, caciolo.TRoom)
  connect(from_degC1.y, caciolo.TAmb)
  connect(winSpeProLoc.winSpe, caciolo.winSpeLoc)
  connect(winDirSet.y, caciolo.winDir)
  connect(from_degC.y, tang.TRoom)
  connect(from_degC1.y, tang.TAmb)
  connect(from_degC.y, vdi2078_1.TRoom)
  connect(from_degC1.y, vdi2078_1.TAmb)
  connect(from_degC.y, vdi2078_2.TRoom)
  connect(from_degC1.y, vdi2078_2.TAmb)
  connect(from_degC.y, vdi2078_3.TRoom)
  connect(from_degC1.y, vdi2078_3.TAmb)
  connect(from_degC.y, din16798_1.TRoom)
  connect(from_degC1.y, din16798_1.TAmb)
  connect(winSpe10Set.y, din16798_1.winSpe10)
  connect(from_degC.y, din4108_1.TRoom)
  connect(from_degC1.y, din4108_1.TAmb)
  connect(winSpeProLoc.winSpe, din4108_1.winSpeLoc)
  connect(from_degC.y, ashrae.TRoom)
  connect(from_degC1.y, ashrae.TAmb)
  connect(winSpeProLoc.winSpe, ashrae.winSpeLoc)
  connect(winDirSet.y, ashrae.winDir)
end VentilationFlowRateSimpleOpening;


Calculate geometric, projective, equivalent, and effective window opening
  areas, by different types of sash opening. This partial model provides a base class of common window sash opening area, incl. geometric, projective, equivalent, and effective opening area.

within AixLib.Airflow.WindowVentilation.OpeningAreas;
model OpeningAreaSashCommon
  "Calculate geometric, projective, equivalent, and effective window opening
  areas, by different types of sash opening"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialOpeningAreaSash;
  parameter AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes
    opnAreaTyp = AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric
    "Window opening area types to calculate";

  /*Characterize lengths*/
  final parameter Modelica.Units.SI.Length lenAxs(min=0)=
    if (opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungInward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungOutward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotVertical) then
    winClrHeight else if (opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.TopHungOutward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal) then
    winClrWidth else 0
    "Length to characterize the hung and pivot window opening:
    length of the hinged axis";
  final parameter Modelica.Units.SI.Length lenAxsToFrm(min=0)=
    if (opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungInward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungOutward) then
    winClrWidth else if (opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.TopHungOutward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward) then
    winClrHeight else if (opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotVertical) then
    winClrWidth/2 else if (opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal) then
    winClrHeight/2 else 0
    "Length to characterize the hung and pivot window opening:
    distance from the hinged axis to the frame across the opening area";

  /*Variables to describe the opening*/
  Modelica.Units.SI.Area AGeoOpn(min=0) "Geometric opening area";
  Modelica.Units.SI.Area APrjOpn(min=0) "Projective opening area";
  Modelica.Units.SI.Area AEqvOpn(min=0) "Equivalent opening area";
  Modelica.Units.SI.Area AEffOpn(min=0) "Effective opening area";
protected
  Modelica.Units.SI.Length opnWidth90(min=0)
    "Sash opening width by 90° opening / full sliding opening";
  Modelica.Units.SI.Area AGeoOpn90(min=0)
    "Geometric opening area by 90° opening";
  Modelica.Units.SI.Area AEqvOpn90(min=0)
    "Equivalent opening area by 90° opening";
initial equation
  if opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SlidingVertical or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SlidingHorizontal then
    assert(
      opnAreaTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric,
      "By opening type 'Sliding', only 'geometric' opening area is valid.",
      AssertionLevel.error);
  end if;
equation
  /*Hinged opening*/
  if opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungInward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungOutward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.TopHungOutward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward then
    /*Calculate area values*/
    AGeoOpn =
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.GeometricOpeningArea(
      lenAxs, lenAxsToFrm, opnWidth_internal);
    APrjOpn =
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.ProjectiveOpeningArea(
      lenAxs, lenAxsToFrm, opnWidth_internal);
    opnWidth90 =
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.AngleToWidth(
      lenAxs, lenAxsToFrm, Modelica.Constants.pi/2);
    AGeoOpn90 = AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.GeometricOpeningArea(
      lenAxs, lenAxsToFrm, opnWidth90);

  /*Pivot opening*/
  elseif opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotVertical or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal then
    /*Calculate area values*/
    AGeoOpn =
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.GeometricOpeningArea(
      lenAxs, lenAxsToFrm, opnWidth_internal)*2;
    APrjOpn =
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.ProjectiveOpeningArea(
      lenAxs, lenAxsToFrm, opnWidth_internal)*2;
    opnWidth90 =
      AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.AngleToWidth(
      lenAxs, lenAxsToFrm, Modelica.Constants.pi/2);
    AGeoOpn90 = AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.GeometricOpeningArea(
      lenAxs, lenAxsToFrm, opnWidth90)*2;

  /*Sliding opening*/
  elseif opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SlidingVertical or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SlidingHorizontal then
    /*Calculate area values*/
    if opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SlidingVertical then
      /*Vertical*/
      AGeoOpn = winClrWidth*opnWidth_internal;
      opnWidth90 = winClrHeight;
      AGeoOpn90 = winClrWidth*opnWidth90;
    else
      /*Horizontal*/
      AGeoOpn = winClrHeight*opnWidth_internal;
      opnWidth90 = winClrWidth;
      AGeoOpn90 = winClrHeight*opnWidth90;
    end if;
    APrjOpn = AGeoOpn;

  /*Exceptions*/
  else
    AGeoOpn = 0;
    APrjOpn = 0;
    opnWidth90 = 0;
    AGeoOpn90 = 0;
  end if;

  /*Calculate the rest area types*/
  AEqvOpn = AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.EquivalentOpeningArea(
    AClrOpn, AGeoOpn);
  AEqvOpn90 = AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.EquivalentOpeningArea(
    AClrOpn, AGeoOpn90);
  AEffOpn = AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.EffectiveOpeningArea(
    AClrOpn, AEqvOpn, AEqvOpn90);

  /*Export area to port based on choice*/
  A = if opnAreaTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Geometric then
    AGeoOpn else if opnAreaTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Projective then
    APrjOpn else if opnAreaTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Equivalent then
    AEqvOpn else if opnAreaTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.OpeningAreaTypes.Effective then
    AEffOpn else 0;
end OpeningAreaSashCommon;


Specified DIN CEN/TR 16798-8: Only valid for bottom- or top-hung opening. This model determines the window opening area according to DIN CEN/TR 16798-8 (DIN SPEC 32739-8):2018-03.

within AixLib.Airflow.WindowVentilation.OpeningAreas;
model OpeningAreaSashDIN16798
  "Specified DIN CEN/TR 16798-8: Only valid for bottom- or top-hung opening"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialOpeningAreaSash;
  Real cof "Coefficient depending on the kind of window";
initial equation
  assert(
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.TopHungOutward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward,
    "The model is only valid for top- or bottom-hung opening.",
    AssertionLevel.error);
  assert((winClrHeight/winClrWidth >= 1) and (winClrHeight/winClrWidth <= 2),
    "For hinged windows, the model applies for height and width geometries of approx. 1:1 to 2:1",
    AssertionLevel.warning);
equation
  cof = AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.CoeffOpeningAreaDIN16798(
    opnAng);
  A = cof*AClrOpn;
end OpeningAreaSashDIN16798;


Specified DIN/TS 4108-8: Valid for different opening types. This model determines the window opening area according to DIN/TS 4108-8:2022-09.

within AixLib.Airflow.WindowVentilation.OpeningAreas;
model OpeningAreaSashDIN4108
  "Specified DIN/TS 4108-8: Valid for different opening types"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialOpeningAreaSash;
  parameter Modelica.Units.SI.Thickness sWinSas(min=0) = 0
    "Window sash thickness (depth)"
initial equation
  if opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.TopHungOutward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward then
    assert((winClrHeight/winClrWidth >= 1) and (winClrHeight/winClrWidth <= 2),
      "For hinged windows, the model applies for height and width geometries of approx. 1:1 to 2:1",
      AssertionLevel.warning);
  end if;
equation
  if opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungInward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SideHungOutward then
    A = if opnWidth_internal < Modelica.Constants.eps then 0 else sqrt(1/(
      (winClrWidth*winClrHeight)^(-2) + (2*winClrWidth*winClrHeight*sin(opnAng/2)
      + winClrWidth^2*sin(opnAng))^(-2)));

  elseif opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.TopHungOutward or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward then
    assert(opnAng <= Modelica.Units.Conversions.from_deg(30),
      "The model only applies to a maximum tilt angle of 30°",
      AssertionLevel.warning);
    A = AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.CoeffOpeningAreaDIN16798(
      opnAng)*winClrWidth*winClrHeight;

  elseif opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotVertical or
    opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.PivotHorizontal then
    A = if opnWidth_internal < Modelica.Constants.eps then 0 else min(2*(
      opnWidth_internal*(winClrWidth - 2*sWinSas) + opnWidth_internal*sqrt((
      winClrHeight/2*opnWidth_internal/(opnWidth_internal + sWinSas))^2 - 0.25*
      opnWidth_internal^2)), (winClrHeight - sWinSas)*winClrWidth);

  elseif opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SlidingVertical then
    A = opnWidth_internal*winClrWidth;

  elseif opnTyp == AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.SlidingHorizontal then
    A = opnWidth_internal*winClrHeight;

  else
    A = 0;
  end if;
end OpeningAreaSashDIN4108;


Specified Hall: Only valid for bottom-hung inwards opening. This model determines the window opening area according to the empirical expression developed by Hall.

within AixLib.Airflow.WindowVentilation.OpeningAreas;
model OpeningAreaSashHall
  "Specified Hall: Only valid for bottom-hung inwards opening"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialOpeningAreaSash(
    final opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward);
  parameter Modelica.Units.SI.Thickness sWinSas(min=0) = 0
    "Window sash thickness (depth)";
  parameter Modelica.Units.SI.Length widthWinGap(min=0) = 0.01
    "Gap width in the overlap area between the frame and the sash";
  Real corNPL "Correction factor of the neutral pressure level";
initial equation
  assert(winClrHeight >= winClrWidth,
    "The model only applies to windows whose height is not less than the width",
    AssertionLevel.warning);
equation
  corNPL = sqrt((winClrWidth - opnWidth_internal)/winClrHeight);
  A = if noEvent(opnWidth_internal > Modelica.Constants.eps) then corNPL*
    opnWidth_internal*(winClrHeight*opnWidth_internal/(opnWidth_internal +
    sWinSas) - winClrHeight*(1 - corNPL)) + 2*winClrHeight*sWinSas/(
    opnWidth_internal + sWinSas)*widthWinGap else 0;
end OpeningAreaSashHall;


Specified VDI 2078: Only valid for bottom-hung inwards opening. This model determines the window opening area according to VDI 2078:2015-06.

within AixLib.Airflow.WindowVentilation.OpeningAreas;
model OpeningAreaSashVDI2078
  "Specified VDI 2078: Only valid for bottom-hung inwards opening"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialOpeningAreaSash(
    final opnTyp=AixLib.Airflow.WindowVentilation.BaseClasses.Types.WindowOpeningTypes.BottomHungInward);
  parameter Modelica.Units.SI.Height heightRevToFrm = 0.1
    "Vertical distance (height) between the reveal above the window and window top frame";
  parameter Modelica.Units.SI.Thickness sWinSas(min=0) = 0
    "Window sash thickness (depth)";
  Modelica.Units.SI.Height effHeight(min=0)
    "Effective height for the thermal updraft";
  Modelica.Units.SI.Height ovlHeight(min=0)
    "Height of the overlap between window frame and casement";
  Real corRev "Correction factor of the window reveal";
equation
  assert(opnAng <= Modelica.Units.Conversions.from_deg(15),
    "The model only applies to a maximum tilt angle of 15°",
    AssertionLevel.warning);
  effHeight = 2/3*(winClrHeight - ovlHeight);
  ovlHeight = if sWinSas > Modelica.Constants.eps then
    sWinSas/(opnWidth_internal + sWinSas)*winClrHeight else 0;
  corRev = if opnWidth_internal <= heightRevToFrm then 1 else
    1 - 0.6*(1 - heightRevToFrm/opnWidth_internal);
  A = if noEvent(opnWidth_internal > Modelica.Constants.eps) then
    ((winClrWidth + winClrHeight - ovlHeight)*opnWidth_internal/3)*corRev else 0;
end OpeningAreaSashVDI2078;


Common simple opening (no sash). This model determines the window opening area by a simple opening without window sash.

within AixLib.Airflow.WindowVentilation.OpeningAreas;
model OpeningAreaSimple "Common simple opening (no sash)"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialOpeningArea(
    final use_opnWidth_in=false,
    final prescribedOpnWidth=0);
equation
  A = AClrOpn;
end OpeningAreaSimple;


Specified VDI 2078: Simple opening (no sash). This model determines the window opening area by a simple opening without window sash according to VDI 2078:2015-06.

within AixLib.Airflow.WindowVentilation.OpeningAreas;
model OpeningAreaSimpleVDI2078
  "Specified VDI 2078: Simple opening (no sash)"
  extends AixLib.Airflow.WindowVentilation.BaseClasses.PartialOpeningArea(
    final use_opnWidth_in=false,
    final prescribedOpnWidth=0);
  final parameter Modelica.Units.SI.Height effHeight(min=0) = 2/3*winClrHeight
    "Effective height for the thermal updraft";
equation
  A = 1/3*AClrOpn;
end OpeningAreaSimpleVDI2078;


within AixLib.Airflow.WindowVentilation;
package OpeningAreas "Calculation of different opening areas based on different window types"
  extends Modelica.Icons.VariantsPackage;
end OpeningAreas;


Convert from window opening angle to opening width. Convert from window opening angle to opening width.

within AixLib.Airflow.WindowVentilation.Utilities;
model AngleToWidth
  "Convert from window opening angle to opening width"
  extends Modelica.Blocks.Interfaces.PartialConversionBlock(
    u(unit="rad"), y(unit="m"));
  parameter Modelica.Units.SI.Length lenAxs(min=0)
    "Length of the hinged axis, the axis should be parallel to a window frame";
  parameter Modelica.Units.SI.Length lenAxsToFrm(min=0)
    "Distance from the hinged axis to the frame across the opening area";
equation
  y =
    AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.AngleToWidth(
    lenAxs, lenAxsToFrm, u);
end AngleToWidth;


Convert from window opening width to opening angle. Convert from window opening width to opening angle.

within AixLib.Airflow.WindowVentilation.Utilities;
model WidthToAngle
  "Convert from window opening width to opening angle"
  extends Modelica.Blocks.Interfaces.PartialConversionBlock(
    u(unit="m"), y(unit="rad"));
  parameter Modelica.Units.SI.Length lenAxs(min=0)
    "Length of the hinged axis, the axis should be parallel to a window frame";
  parameter Modelica.Units.SI.Length lenAxsToFrm(min=0)
    "Distance from the hinged axis to the frame across the opening area";
equation
  y =
    AixLib.Airflow.WindowVentilation.BaseClasses.Functions.OpeningAreaHinged.WidthToAngle(
    lenAxs, lenAxsToFrm, u);
end WidthToAngle;


Wind profile power law relationship of Hellmann. This model contains the wind profile power law relationship of
  Hellmann.

within AixLib.Airflow.WindowVentilation.Utilities;
model WindProfilePowerLaw
  "Wind profile power law relationship of Hellmann"
  parameter Modelica.Units.SI.Height height(min=0)
    "Height of the wind speed to calculate";
  parameter Modelica.Units.SI.Height heightRef(min=0)=10
    "Reference height of the known wind speed";
  parameter Modelica.Units.SI.Length lenRuf(min=0)=0.6 "Roughness length";
  final parameter Real cof = 1/log(height/lenRuf)
    "Hellmann exponent (coefficient)";
  Modelica.Blocks.Interfaces.RealInput winSpeRef(unit="m/s", min=0)
    "Wind speed at the reference height"
  Modelica.Blocks.Interfaces.RealOutput winSpe(unit="m/s", min=0)
    "Wind speed at height"
initial equation
  assert(
    height > lenRuf,
    "Power law not applicable by height less than the roughness length",
    AssertionLevel.error);
equation
  winSpe = winSpeRef*(height/heightRef)^cof;
end WindProfilePowerLaw;


within AixLib;
package BoundaryConditions "Package with models for boundary conditions"
  extends Modelica.Icons.Package;
end BoundaryConditions;


Package with type definitions

within AixLib.BoundaryConditions;
package Types "Package with type definitions"
 extends Modelica.Icons.TypesPackage;
  type DataSource = enumeration(
      File "Use data from file",
      Parameter "Use parameter",
      Input "Use input connector") "Enumeration to define data source"

  type RadiationDataSource = enumeration(
      File "Use data from file",
      Input_HGloHor_HDifHor
        "Global horizontal and diffuse horizontal radiation from connector",
      Input_HDirNor_HDifHor
        "Direct normal and diffuse horizontal radiation from connector",
      Input_HDirNor_HGloHor
        "Direct normal and global horizontal radiation from connector")
    "Enumeration to define solar radiation data source"
  type SkyTemperatureCalculation = enumeration(
      HorizontalRadiation
        "Use horizontal irradiation",
      TemperaturesAndSkyCover
        "Use dry-bulb and dew-point temperatures and sky cover")
    "Enumeration for computation of sky temperature"
end Types;


User's Guide

within AixLib.BoundaryConditions;
package UsersGuide "User's Guide"
  extends Modelica.Icons.Information;
end UsersGuide;


Model for undisturbed ground temperature.

within AixLib.BoundaryConditions.GroundTemperature;
model GroundTemperatureKusuda "Model for undisturbed ground temperature"

  parameter Modelica.Units.SI.Temperature T_mean
    "Average air temperature over the year";
  parameter Modelica.Units.SI.TemperatureDifference T_amp
    "Amplitude of surface temperature [(maximum air temperature - minimum air temperature)/2]";
  parameter Modelica.Units.SI.Distance D "Depth of ground temperature";
  parameter Modelica.Units.SI.ThermalDiffusivity alpha=0.04
    "Thermal diffusivity of the ground. Declare in m2/day!";
  parameter Modelica.Units.SI.Time t_shift
    "Time of the year with minimum air temperature. Declare in days!";

  Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature
    prescribedTemperature "Transfers computed ground temperature to heat port"
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b port
    "Heat port for ground"

equation

  prescribedTemperature.T =  (T_mean)-(T_amp)*(exp(-D*sqrt(Modelica.Constants.pi/(365*alpha)))*cos(2*Modelica.Constants.pi/365*(time/(3600*24)-t_shift-D/2*sqrt(Modelica.Constants.pi/(365*alpha)))));

  connect(prescribedTemperature.port, port)
end GroundTemperatureKusuda;


within AixLib.BoundaryConditions;
package GroundTemperature "Package with models to compute the ground temperature"
  extends Modelica.Icons.VariantsPackage;
end GroundTemperature;


Ground temperature at the site of EBC. This example shows the ground temperature at the site of the
  Institute for Energy Efficient Buildings and Indoor Climate at RWTH
  Aachen University's E.ON Energy Research Center (Mathieustr. 10,
  52074 Aachen).

within AixLib.BoundaryConditions.GroundTemperature.Examples;
model ExampleAachen "Ground temperature at the site of EBC"
  extends Modelica.Icons.Example;
  GroundTemperatureKusuda groundTemperatureAachen(
    alpha=0.039,
    D=1,
    T_amp=19.25,
    t_shift=3,
    T_mean=283.6)
    "Undisturbed ground temperature model with values for EBC main building"
  Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor temperatureSensor
    "Sensor to show ground temperature"
  Modelica.Blocks.Interfaces.RealOutput T_ground
    "Output to show ground temperature"
equation
  connect(groundTemperatureAachen.port, temperatureSensor.port)
  connect(temperatureSensor.T, T_ground)
end ExampleAachen;


Keeps track of the maximum air temperature. Example to test and tune Kusuda ground temperature model with the
  weather model from the Modelica Buildings Library.

within AixLib.BoundaryConditions.GroundTemperature.Examples;
model ExampleSanFran
  extends Modelica.Icons.Example;
  Real T_max(start=0) "Keeps track of the maximum air temperature";
  Real T_min(start=300) "Keeps track of the minimum air temperature";

  AixLib.BoundaryConditions.WeatherData.Bus    weaBus "Component to supply air
  temperature"
  Modelica.Blocks.Interfaces.RealOutput T_air "Output to show air temperature"
  Modelica.Blocks.Continuous.Integrator integrator "Integrates air temperature
  to compute average air temperature"
  Modelica.Blocks.Math.Division division "Division for average air temperature"
  Modelica.Blocks.Sources.RealExpression timeSource(y=time) "Denominator for
  average air temperature"
  Modelica.Blocks.Interfaces.RealOutput T_mean "Output of average air
  temperature since beginning of simulation"
  Modelica.Blocks.Math.Max denominatorTmean
    "Max-function to prevent division by 0 at time=0"
  Modelica.Blocks.Sources.RealExpression denominatorAtTimeZero(y=1) "Real source
  to prevent division by 0 at time=0"
  AixLib.BoundaryConditions.WeatherData.ReaderTMY3    weaDat(
      computeWetBulbTemperature=false, filNam=Modelica.Utilities.Files.loadResource("modelica://AixLib/Resources/weatherdata/USA_CA_San.Francisco.Intl.AP.724940_TMY3.mos"))
                                       "File reader that reads weather data"
  GroundTemperatureKusuda groundTemperatureKusuda(
    t_shift=23,
    alpha=0.039,
    D=1,
    T_amp=15.49,
    T_mean=286.95) "Undisturbed ground temperature model"
  Modelica.Blocks.Interfaces.RealOutput T_ground "Output to show ground
  temperature"
  Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor temperatureSensor
    "Sensor to show ground temperature"
  Modelica.Blocks.Interfaces.RealOutput T_amp
    "Keeps track of the amplitude of the air temperature"
equation

 T_max=max(T_max, T_air);
 T_min=min(T_min, T_air);
 T_amp = (T_max-T_min)/2;
  connect(T_air, weaBus.TDryBul)
  connect(integrator.u, T_air)
  connect(integrator.y, division.u1)
  connect(division.y, T_mean)
  connect(division.u2, denominatorTmean.y)
  connect(denominatorTmean.u2, timeSource.y)
  connect(denominatorAtTimeZero.y, denominatorTmean.u1)
  connect(weaDat.weaBus, weaBus)
  connect(groundTemperatureKusuda.port, temperatureSensor.port)
  connect(temperatureSensor.T, T_ground)
  connect(T_mean, T_mean)
end ExampleSanFran;


within AixLib.BoundaryConditions;
package InternalGains "Models for humans, maschines, light and other heat sources"
  extends Modelica.Icons.Package;
end InternalGains;


low

within AixLib.BoundaryConditions.InternalGains;
package Types
  type MachineActivity = enumeration(
      low "low",
      middle "middle",
      high "high") "Enumeration to define the machine activity";
end Types;


Partial model to build a heat source with convective and radiative component. Overview

within AixLib.BoundaryConditions.InternalGains.BaseClasses;
partial model PartialInternalGain
  "Partial model to build a heat source with convective and radiative component"
  parameter Real ratioConv(final min=0, final max=1) = 0.6
    "Ratio convective to total heat release"
  parameter Modelica.Units.SI.Emissivity emissivity(
    min=0,
    max=1) = 0.95 "Emissivity of radiative heat source surface";
  Modelica.Blocks.Interfaces.RealInput uRel(min=0, max=1) "Relative input related to max. value (might be a ratio related to number of people [-] or room area and specific heat flow [W/m2] or maximal heat flow [W]"
  Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow convectiveHeat(final T_ref=293.15, final alpha=0)
  Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow radiativeHeat(final T_ref=293.15, final alpha=0)
  AixLib.Utilities.HeatTransfer.HeatToRad radConvertor(final eps=emissivity, final use_A_in=true)
    "Adaptor for approximative longwave radiation exchange with surface area"
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a convHeat
    "Convective heat flow connector"
  AixLib.Utilities.Interfaces.RadPort radHeat
    "Radiative heat flow connector"
  Modelica.Blocks.Math.Gain gain
  Modelica.Blocks.Math.Gain gainSurfaces
  Modelica.Blocks.Nonlinear.Limiter limiter(final uMax=Modelica.Constants.inf, final uMin=Modelica.Constants.eps)
protected
  Modelica.Blocks.Math.MultiProduct productHeatOutput(nu=1, y(final quantity="Power", final unit="W"))
  Modelica.Blocks.Math.Gain gainConv(final k=ratioConv)
  Modelica.Blocks.Math.Gain gainRad(final k=1 - ratioConv)
equation
  connect(convectiveHeat.port,convHeat)
  connect(gainConv.y, convectiveHeat.Q_flow)
  connect(gainRad.y, radiativeHeat.Q_flow)
  connect(productHeatOutput.y, gainConv.u)
  connect(productHeatOutput.y, gainRad.u)
  connect(radiativeHeat.port, radConvertor.convPort)
  connect(radConvertor.radPort, radHeat)
  connect(uRel, gain.u)
  connect(gain.y, productHeatOutput.u[1])
  connect(gainSurfaces.y,limiter. u)
  connect(limiter.y, radConvertor.A_in)
  connect(uRel, gainSurfaces.u)
end PartialInternalGain;


Calculation of CO2 concentration within a thermal zone. This model assumes co2 as an ideal gas to calculate the density of
  co2:

within AixLib.BoundaryConditions.InternalGains.CO2;
model CO2Balance "Calculation of CO2 concentration within a thermal zone"
  parameter Modelica.Units.SI.Area areaZon "Zone area";
  parameter Real actDeg = 1.8 "Activity degree (Met units)";
  parameter Modelica.Units.SI.Volume VZon "Zone volume";
  parameter Modelica.Units.SI.MassFraction XCO2_amb=6.12157E-4
    "Massfraction of CO2 in atmosphere (equals 403ppm)";
  parameter Modelica.Units.SI.Area areaBod=1.8
    "Body surface area source SIA 2024:2015";
  parameter Modelica.Units.SI.DensityOfHeatFlowRate metOnePerSit=58
    "Metabolic rate of a relaxed seated person in Met (1 Met = 58 W/m^2)";
  parameter Real spePeo(unit="1/(m.m)") = 0.05
    "Specific persons per square metre room area";

  Modelica.Blocks.Interfaces.RealInput XCO2(final quantity="MassFraction",
      final unit="kg/kg") "Massfraction of CO2 in room in kgCO2/kgTotalAir"
  Modelica.Blocks.Interfaces.RealInput airExc(final quantity="VolumeFlowRate",
      final unit="1/h") "Total ventilation and infiltration rate in 1/h"
  Modelica.Blocks.Interfaces.RealOutput mCO2_flow(final quantity="MassFlowRate",
      final unit="kg/s") "Incoming and outgoing CO2 massflow in kg/s"
  Modelica.Blocks.Interfaces.RealInput TAir(
    final quantity="ThermodynamicTemperature",
    final unit="K",
    displayUnit="degC") "Air temperature of thermal zone"
  Modelica.Blocks.Interfaces.RealInput uRel
    "relative number of people related to max. value"
  Modelica.Blocks.Interfaces.RealOutput CO2Con(min=0, max=1000000)
    "CO2 concentration in the thermal zone in ppm"

protected
  constant Modelica.Units.SI.MolarMass MolCO2=0.04401;
  constant Modelica.Units.SI.MolarMass MolAir=0.028949;
  constant Real CalEqu=5.617*3600*1000
    "caloric equivalent in J/m^3";
  constant Real ResQuo=0.83 "respiratory quotient in m^3_CO2/ m^3_O2";
  constant Modelica.Units.SI.Pressure pAir=101325;
  constant Modelica.Units.SI.Density rhoAir=1.2041;
  Real numPeo "Number of people in the thermal zone";
  Modelica.Units.SI.VolumeFlowRate VCO2OnePer_flow
    "Pure CO2 emission of an adult person";
  Modelica.Units.SI.DensityOfHeatFlowRate metOnePerAct
    "Metabolic heat production rate considering activity degree in W/m^2";
  Modelica.Units.SI.MassFlowRate mCO2Peo_flow;
  Modelica.Units.SI.MassFlowRate mAirExc_flow
    "Massflowrate of ventilation and infiltration in kg/s";
  Modelica.Units.SI.Density rhoCO2 "CO2 density";
  Modelica.Units.SI.MassFlowRate mCO2OnePer_flow
    "Emission CO2 of one Person in kg/s";

equation

  // ideal gas equation
  rhoCO2 = MolCO2*pAir/(Modelica.Constants.R*TAir);

  // CO2 emissions of people in the zone
  metOnePerAct = metOnePerSit*actDeg;
  VCO2OnePer_flow = ResQuo*metOnePerAct*areaBod/CalEqu*TAir/273.15;
  mCO2OnePer_flow = VCO2OnePer_flow*rhoCO2;
  numPeo = spePeo*areaZon*uRel;
  mCO2Peo_flow = mCO2OnePer_flow*numPeo;

  // CO2 balance
  mAirExc_flow = airExc/3600*rhoAir*VZon;
  mCO2_flow = mAirExc_flow*(XCO2_amb - XCO2) + mCO2Peo_flow;

  // calculation of concentration in the thermal zone in ppm
  CO2Con = XCO2*(MolAir/MolCO2)*1E6;
end CO2Balance;


Package for examples of internal gains

within AixLib.BoundaryConditions.InternalGains;
package Examples "Package for examples of internal gains"
  extends Modelica.Icons.ExamplesPackage;
end Examples;


Simulation to check the human models.

within AixLib.BoundaryConditions.InternalGains.Examples.InternalGains;
model HumansSenTDep "Simulation to check the human models"
  extends Modelica.Icons.Example;
  extends AixLib.BoundaryConditions.InternalGains.Examples.InternalGains.BaseClasses.PartialHumansExample(redeclare Humans.HumanSensibleHeatTemperatureDependent humanIntGains);
equation
end HumansSenTDep;


Simulation to check the human models.

within AixLib.BoundaryConditions.InternalGains.Examples.InternalGains;
model HumansSenTIndep "Simulation to check the human models"
  extends Modelica.Icons.Example;
  extends AixLib.BoundaryConditions.InternalGains.Examples.InternalGains.BaseClasses.PartialHumansExample(redeclare Humans.HumanSensibleHeatTemperatureIndependent humanIntGains);
equation
end HumansSenTIndep;


Simulation to check the human models.

within AixLib.BoundaryConditions.InternalGains.Examples.InternalGains;
model HumansTotTDep "Simulation to check the human models"
  extends Modelica.Icons.Example;
  extends AixLib.BoundaryConditions.InternalGains.Examples.InternalGains.BaseClasses.PartialHumansExample(redeclare Humans.HumanTotalHeatTemperatureDependent humanIntGains, sumQ_flows(nu=3));
equation

  connect(humanIntGains.QLat_flow, sumQ_flows.u[3])
end HumansTotTDep;


Simulation to check the light models.

within AixLib.BoundaryConditions.InternalGains.Examples.InternalGains;
model Lights "Simulation to check the light models"
  extends Modelica.Icons.Example;
  AixLib.BoundaryConditions.InternalGains.Lights.LightsAreaSpecific lightsAreaSpecific(roomArea=20)
  AixLib.BoundaryConditions.InternalGains.Lights.LightsRelToMaxValue lightsFromMaxValue(maxHeatFlowAbsolute=100)
  Modelica.Blocks.Sources.CombiTimeTable combiTimeTable(table=[0,0; 28740,0;
        28800,1; 64800,1; 64860,0; 86400,0])
  Modelica.Thermal.HeatTransfer.Sources.FixedTemperature fixedTemp(T=293.15)
equation
  connect(combiTimeTable.y[1], lightsAreaSpecific.uRel)
  connect(combiTimeTable.y[1], lightsFromMaxValue.uRel)
  connect(lightsAreaSpecific.convHeat, fixedTemp.port)
  connect(lightsFromMaxValue.convHeat, fixedTemp.port)
  connect(lightsFromMaxValue.radHeat, fixedTemp.port)
  connect(lightsAreaSpecific.radHeat, fixedTemp.port)
end Lights;


Simulation to check the machine models.

within AixLib.BoundaryConditions.InternalGains.Examples.InternalGains;
model Machines "Simulation to check the machine models"
  extends Modelica.Icons.Example;
  AixLib.BoundaryConditions.InternalGains.Machines.MachinesDIN18599 machinesSensibleHeatDIN18599(areaSurfaceMachinesTotal=10)
  AixLib.BoundaryConditions.InternalGains.Machines.MachinesRelToMaxValue machinesSensibleHeatFromMaxValue(areaSurfaceMachinesTotal=10, maxHeatFlowAbsolute=200)
  Modelica.Blocks.Sources.CombiTimeTable combiTimeTable(table=[0,0; 28740,0;
        28800,1; 64800,1; 64860,0; 86400,0])
  Modelica.Thermal.HeatTransfer.Sources.FixedTemperature fixedTemp(T=293.15)
  AixLib.BoundaryConditions.InternalGains.Machines.MachinesAreaSpecific machinesAreaSpecific(areaSurfaceMachinesTotal=10, roomArea=20)
equation
  connect(combiTimeTable.y[1], machinesSensibleHeatDIN18599.uRel)
  connect(combiTimeTable.y[1], machinesSensibleHeatFromMaxValue.uRel)
  connect(machinesSensibleHeatDIN18599.convHeat, fixedTemp.port)
  connect(machinesSensibleHeatDIN18599.radHeat, fixedTemp.port)
  connect(machinesSensibleHeatFromMaxValue.convHeat, fixedTemp.port)
  connect(machinesSensibleHeatFromMaxValue.radHeat, fixedTemp.port)
  connect(combiTimeTable.y[1], machinesAreaSpecific.uRel)
  connect(machinesAreaSpecific.convHeat, fixedTemp.port)
  connect(machinesAreaSpecific.radHeat, fixedTemp.port)
end Machines;