Package with base classes
Information
This package contains base classes that are used to construct the classes in
Buildings.Experimental.DHC.Loads.
Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).
Package Content
| Name | Description | 
|  ConstraintViolation | Block that outputs the fraction of time when a constraint is violated | 
|  PartialBuilding | Partial class for building model | 
|  PartialBuildingWithPartialETS | Partial model of a building with an energy transfer station | 
|  PartialTerminalUnit | Partial model for HVAC terminal unit | 
|  getPeakLoad | Function that reads the peak load from the load profile | 
|  Validation | Collection of validation models | 
Block that outputs the fraction of time when a constraint is violated
 
Information
Block that outputs the running fractional time during which any element
ui of the input signal
is not within umin ≤ ui ≤ umax.
Parameters
| Type | Name | Default | Description | 
|---|
| Real | uMin |  | Minimum value for input | 
| Real | uMax |  | Maximum value for input | 
Connectors
| Type | Name | Description | 
|---|
| input RealInput | u[nu] | Variables of interest | 
| output RealOutput | y | Fraction of time when the constraint is violated [1] | 
Modelica definition
block ConstraintViolation
  
  
parameter Real uMin ;
  
parameter Real uMax ;
  
parameter Integer nu(min=0) = 0
    ;
  
Buildings.Controls.OBC.CDL.Interfaces.RealInput u[nu]
    ;
  
Buildings.Controls.OBC.CDL.Interfaces.RealOutput y(
    
final unit="1",
    start=0,
    fixed=true)
    ;
  
Modelica.SIunits.Time t(
final start=0, 
final fixed=true)
    ;
protected 
  parameter Modelica.SIunits.Time t0(fixed=false)
    ;
  Boolean vioMin ;
  Boolean vioMax ;
initial equation 
  t0 = time - 1E-6;
equation 
  vioMin =
 Modelica.Math.BooleanVectors.anyTrue({u[i] < uMin 
for i
 in 1:nu});
  vioMax =
 Modelica.Math.BooleanVectors.anyTrue({u[i] > uMax 
for i
 in 1:nu});
  
if vioMin
 or vioMax
 then
    der(t) = 1;
  
else
    der(t) = 0;
  
end if;
  y = t / (time - t0);
end ConstraintViolation;
 
Partial class for building model
 
Information
Partial model to be used for modeling the thermal loads on an energy
transfer station or a dedicated plant.
Models extending this class are typically used in conjunction with
Buildings.Experimental.DHC.Loads.FlowDistribution
and models extending
Buildings.Experimental.DHC.Loads.BaseClasses.PartialTerminalUnit
as described in the schematics here under.
The fluid ports represent the connection between the production system and
the building distribution system.
Scaling
Scaling is implemented by means of a multiplier factor facMul.
Each extensive quantity (mass and heat flow rate, electric power)
flowing out through fluid ports, or connected to an
output connector is multiplied by facMul.
Each extensive quantity (mass and heat flow rate, electric power)
flowing in through fluid ports, or connected to an
input connector is multiplied by 1/facMul.
This allows modeling, with a single instance,
multiple identical buildings served by the same energy transfer station.
Examples
See various use cases in
Buildings.Experimental.DHC.Loads.Examples.
 
Parameters
| Type | Name | Default | Description | 
|---|
| replaceable package Medium | Buildings.Media.Water | Medium in the building distribution system | 
| Configuration | 
| Boolean | have_heaWat | false | Set to true if the building has heating water system | 
| Boolean | have_chiWat | false | Set to true if the building has chilled water system | 
| Boolean | have_eleHea | false | Set to true if the building has decentralized electric heating system | 
| Boolean | have_eleCoo | false | Set to true if the building has decentralized electric cooling system | 
| Boolean | have_fan | false | Set to true if fan power is computed | 
| Boolean | have_pum | false | Set to true if pump power is computed | 
| Boolean | have_weaBus | false | Set to true to use a weather bus | 
| Scaling | 
| Real | facMul | 1 | Multiplier factor | 
| Assumptions | 
| Boolean | allowFlowReversal | false | = true to allow flow reversal, false restricts to design direction (port_a -> port_b) | 
Connectors
| Type | Name | Description | 
|---|
| replaceable package Medium | Medium in the building distribution system | 
| Bus | weaBus | Weather data bus | 
| FluidPorts_a | ports_aHeaWat[nPorts_aHeaWat] | Heating water inlet ports | 
| FluidPorts_b | ports_bHeaWat[nPorts_bHeaWat] | Heating water outlet ports | 
| FluidPorts_a | ports_aChiWat[nPorts_aChiWat] | Chilled water inlet ports | 
| FluidPorts_b | ports_bChiWat[nPorts_bChiWat] | Chilled water outlet ports | 
| output RealOutput | QHea_flow | Total heating heat flow rate transferred to the loads (>=0) [W] | 
| output RealOutput | QCoo_flow | Total cooling heat flow rate transferred to the loads (<=0) [W] | 
| output RealOutput | PHea | Power drawn by decentralized heating system [W] | 
| output RealOutput | PCoo | Power drawn by decentralized cooling system [W] | 
| output RealOutput | PFan | Power drawn by fan motors [W] | 
| output RealOutput | PPum | Power drawn by pump motors [W] | 
Modelica definition
partial model PartialBuilding
  
  
replaceable package Medium=
Buildings.Media.Water
    constrainedby Modelica.Media.Interfaces.PartialMedium
    ;
  
parameter Integer nPorts_aHeaWat=0
    ;
  
parameter Integer nPorts_bHeaWat=0
    ;
  
parameter Integer nPorts_aChiWat=0
    ;
  
parameter Integer nPorts_bChiWat=0
    ;
  
parameter Boolean have_heaWat=false
    ;
  
parameter Boolean have_chiWat=false
    ;
  
parameter Boolean have_eleHea=false
    ;
  
parameter Boolean have_eleCoo=false
    ;
  
parameter Boolean have_fan=false
    ;
  
parameter Boolean have_pum=false
    ;
  
parameter Boolean have_weaBus=false
    ;
  
parameter Real facMul(min=Modelica.Constants.eps)=1
    ;
  
parameter Boolean allowFlowReversal=false
    ;
  
final parameter Boolean have_heaLoa=have_heaWat
 or have_eleHea
    ;
  
final parameter Boolean have_cooLoa=have_chiWat
 or have_eleCoo
    ;
  
  
Buildings.BoundaryConditions.WeatherData.Bus weaBus 
if have_weaBus
    ;
  
Modelica.Fluid.Interfaces.FluidPorts_a ports_aHeaWat[nPorts_aHeaWat](
    
redeclare each package Medium=
Medium,
    
each m_flow(
      min=
        
if allowFlowReversal
 then 
          -Modelica.Constants.inf
        else 
          0),
    
each h_outflow(
      start=Medium.h_default,
      nominal=Medium.h_default)) 
if have_heaWat
    ;
  
Modelica.Fluid.Interfaces.FluidPorts_b ports_bHeaWat[nPorts_bHeaWat](
    
redeclare each package Medium=
Medium,
    
each m_flow(
      max=
        
if allowFlowReversal
 then 
          +Modelica.Constants.inf
        else 
          0),
    
each h_outflow(
      start=Medium.h_default,
      nominal=Medium.h_default)) 
if have_heaWat
    ;
  
Modelica.Fluid.Interfaces.FluidPorts_a ports_aChiWat[nPorts_aChiWat](
    
redeclare each package Medium=
Medium,
    
each m_flow(
      min=
        
if allowFlowReversal
 then 
          -Modelica.Constants.inf
        else 
          0),
    
each h_outflow(
      start=Medium.h_default,
      nominal=Medium.h_default)) 
if have_chiWat
    ;
  
Modelica.Fluid.Interfaces.FluidPorts_b ports_bChiWat[nPorts_bChiWat](
    
redeclare each package Medium=
Medium,
    
each m_flow(
      max=
        
if allowFlowReversal
 then 
          +Modelica.Constants.inf
        else 
          0),
    
each h_outflow(
      start=Medium.h_default,
      nominal=Medium.h_default)) 
if have_chiWat
    ;
  
Modelica.Blocks.Interfaces.RealOutput QHea_flow(
    
final unit="W") 
if have_heaLoa
    ;
  
Modelica.Blocks.Interfaces.RealOutput QCoo_flow(
    
final unit="W") 
if have_cooLoa
    ;
  
Modelica.Blocks.Interfaces.RealOutput PHea(
    
final unit="W") 
if have_eleHea
    ;
  
Modelica.Blocks.Interfaces.RealOutput PCoo(
    
final unit="W") 
if have_eleCoo
    ;
  
Modelica.Blocks.Interfaces.RealOutput PFan(
    
final quantity="Power",
    
final unit="W") 
if have_fan
    ;
  
Modelica.Blocks.Interfaces.RealOutput PPum(
    
final quantity="Power",
    
final unit="W") 
if have_pum
    ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulHeaWatInl[nPorts_aHeaWat](
    
redeclare each final package Medium = 
Medium,
    
each final k=1/facMul,
    
each final allowFlowReversal=allowFlowReversal) 
if have_heaWat
    ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulChiWatInl[nPorts_aChiWat](
    
redeclare each final package Medium = 
Medium,
    
each final k=1/facMul,
    
each final allowFlowReversal=allowFlowReversal) 
if have_chiWat
    ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulHeaWatOut[nPorts_bHeaWat](
    
redeclare each final package Medium = 
Medium,
    
each final k=facMul,
    
each final allowFlowReversal=allowFlowReversal) 
if have_heaWat
    ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulChiWatOut[nPorts_bChiWat](
    
redeclare each final package Medium = 
Medium,
    
each final k=facMul,
    
each final allowFlowReversal=allowFlowReversal) 
if have_chiWat
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulQHea_flow(
    u(
final unit="W"),
    
final k=facMul) 
if have_heaLoa ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulQCoo_flow(
    u(
final unit="W"),
    
final k=facMul) 
if have_cooLoa ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPHea(
    u(
final unit="W"),
    
final k=facMul) 
if have_eleHea ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPCoo(
    u(
final unit="W"),
    
final k=facMul) 
if have_eleCoo ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPFan(
    u(
final unit="W"),
    
final k=facMul) 
if have_fan ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPPum(
    u(
final unit="W"),
    
final k=facMul) 
if have_pum ;
protected 
  final parameter Modelica.SIunits.SpecificHeatCapacity cp_default=
    
Medium.specificHeatCapacityCp(
Medium.setState_pTX(
      p = Medium.p_default,
      T = Medium.T_default,
      X = Medium.X_default))
    ;
initial equation 
  assert(
    nPorts_aHeaWat == nPorts_bHeaWat,
    "In "+
getInstanceName()+": The numbers of heating water inlet ports ("+
String(
      nPorts_aHeaWat)+") and outlet ports ("+
String(
      nPorts_bHeaWat)+") must be equal.");
  
assert(
    nPorts_aChiWat == nPorts_bChiWat,
    "In "+
getInstanceName()+": The numbers of chilled water inlet ports ("+
String(
      nPorts_aChiWat)+") and outlet ports ("+
String(
      nPorts_bChiWat)+") must be equal.");
equation 
  connect(mulQHea_flow.y, QHea_flow);
  
connect(mulQCoo_flow.y, QCoo_flow);
  
connect(mulPHea.y, PHea);
  
connect(mulPCoo.y, PCoo);
  
connect(mulPFan.y, PFan);
  
connect(mulPPum.y, PPum);
  
connect(ports_aChiWat,mulChiWatInl. port_a);
  
connect(ports_aHeaWat,mulHeaWatInl. port_a);
  
connect(mulHeaWatOut.port_b, ports_bHeaWat);
  
connect(mulChiWatOut.port_b, ports_bChiWat);
end PartialBuilding;
 
Partial model of a building with an energy transfer station
 
Information
Partial model to be used for modeling
See the schematics below for a description of the physical boundaries
of the composing systems.
The parameters defining the set of outside connectors of this class
are propagated up from the ETS and building components.
The connect clauses between the ETS and the building connectors
are automatically generated based on the previous parameters and the
additional parameters nPorts_heaWat and nPorts_chiWat
that need to be specified.
In case of a heating service line, the model allows for using two
different media at the inlet port_aSerHea and at the oulet
port_bSerHea to represent a steam supply and condensate
return.
Scaling
Scaling is implemented by means of a multiplier factor facMul.
Each extensive quantity (mass and heat flow rate, electric power)
flowing out through fluid ports, or connected to an
output connector is multiplied by facMul.
Each extensive quantity (mass and heat flow rate, electric power)
flowing in through fluid ports, or connected to an
input connector is multiplied by 1/facMul.
This allows modeling, with a single instance,
multiple identical buildings with identical energy transfer stations,
served by the same service line.
 
Parameters
| Type | Name | Default | Description | 
|---|
| replaceable package MediumSer | Buildings.Media.Water | Service side medium | 
| replaceable package MediumSerHea_a | Buildings.Media.Water | Service side medium at heating inlet | 
| replaceable package MediumBui | Buildings.Media.Water | Building side medium | 
| PartialBuilding | bui | bui(redeclare final package ... | Building model | 
| PartialETS | ets | ets(redeclare final package ... | Energy transfer station model | 
| Configuration | 
| Integer | nPorts_heaWat | 0 | Number of heating water fluid ports | 
| Integer | nPorts_chiWat | 0 | Number of chilled water fluid ports | 
| Scaling | 
| Real | facMul | 1 | Multiplier factor | 
| Assumptions | 
| Boolean | allowFlowReversalSer | false | Set to true to allow flow reversal on service side | 
| Boolean | allowFlowReversalBui | false | Set to true to allow flow reversal on building side | 
Connectors
| Type | Name | Description | 
|---|
| replaceable package MediumSer | Service side medium | 
| replaceable package MediumSerHea_a | Service side medium at heating inlet | 
| replaceable package MediumBui | Building side medium | 
| FluidPort_a | port_aSerAmb | Fluid connector for ambient water service supply line | 
| FluidPort_b | port_bSerAmb | Fluid connector for ambient water service return line | 
| FluidPort_a | port_aSerHea | Fluid connector for heating service supply line | 
| FluidPort_b | port_bSerHea | Fluid connector for heating service return line | 
| FluidPort_a | port_aSerCoo | Fluid connector for cooling service supply line | 
| FluidPort_b | port_bSerCoo | Fluid connector for cooling service return line | 
| Bus | weaBus | Weather data bus | 
| output RealOutput | QHea_flow | Total heating heat flow rate transferred to the loads (>=0) [W] | 
| output RealOutput | QCoo_flow | Total cooling heat flow rate transferred to the loads (<=0) [W] | 
| output RealOutput | PHea | Power drawn by heating system [W] | 
| output RealOutput | PCoo | Power drawn by cooling system [W] | 
| output RealOutput | PFan | Power drawn by fan motors [W] | 
| output RealOutput | PPum | Power drawn by pump motors [W] | 
| output RealOutput | QFue_flow[nFue] | Fuel energy input rate [W] | 
Modelica definition
partial model PartialBuildingWithPartialETS
  
  
import TypDisSys=
Buildings.Experimental.DHC.Types.DistrictSystemType
    ;
  
replaceable package MediumSer=
Buildings.Media.Water
    constrainedby Modelica.Media.Interfaces.PartialMedium
    ;
  
replaceable package MediumSerHea_a=
Buildings.Media.Water
    constrainedby Modelica.Media.Interfaces.PartialMedium
    ;
  
replaceable package MediumBui=
Buildings.Media.Water
    constrainedby Modelica.Media.Interfaces.PartialMedium
    ;
  
parameter Integer nPorts_heaWat=0
    ;
  
parameter Integer nPorts_chiWat=0
    ;
  
parameter Real facMul = 1
    ;
  
parameter Boolean allowFlowReversalSer=false
    ;
  
parameter Boolean allowFlowReversalBui=false
    ;
  
  
final parameter TypDisSys typ=ets.typ
    ;
  
final parameter Boolean have_heaWat=ets.have_heaWat
    ;
  
final parameter Boolean have_hotWat=ets.have_hotWat
    ;
  
final parameter Boolean have_chiWat=ets.have_chiWat
    ;
  
final parameter Boolean have_eleHea=bui.have_eleHea
 or ets.have_eleHea
    ;
  
final parameter Integer nFue=ets.nFue
    ;
  
final parameter Boolean have_eleCoo=bui.have_eleCoo
 or ets.have_eleCoo
    ;
  
final parameter Boolean have_fan=bui.have_fan
 or ets.have_fan
    ;
  
final parameter Boolean have_pum=bui.have_pum
 or ets.have_pum
    ;
  
final parameter Boolean have_weaBus=bui.have_weaBus
 or ets.have_weaBus
    ;
  
final parameter Modelica.SIunits.HeatFlowRate QHeaWat_flow_nominal(min=0)=
    ets.QHeaWat_flow_nominal
    ;
  
final parameter Modelica.SIunits.HeatFlowRate QHotWat_flow_nominal(min=0)=
    ets.QHotWat_flow_nominal
    ;
  
final parameter Modelica.SIunits.HeatFlowRate QChiWat_flow_nominal(max=0)=
    ets.QChiWat_flow_nominal
    ;
  
  
final parameter Integer idxPHeaETS=
max(
    
Modelica.Math.BooleanVectors.countTrue(
      {bui.have_eleHea,ets.have_eleHea}),
    1)
    ;
  
final parameter Integer idxPCooETS=
max(
    
Modelica.Math.BooleanVectors.countTrue(
      {bui.have_eleCoo,ets.have_eleCoo}),
    1)
    ;
  
final parameter Integer idxPFanETS=
max(
    
Modelica.Math.BooleanVectors.countTrue(
      {bui.have_fan,ets.have_fan}),
    1)
    ;
  
final parameter Integer idxPPumETS=
max(
    
Modelica.Math.BooleanVectors.countTrue(
      {bui.have_pum,ets.have_pum}),
    1)
    ;
  
  
Modelica.Fluid.Interfaces.FluidPort_a port_aSerAmb(
    
redeclare package Medium = 
MediumSer,
    m_flow(min=
if allowFlowReversalSer
 then -Modelica.Constants.inf
 else 0),
    h_outflow(start=MediumSer.h_default, nominal=MediumSer.h_default))
 
if typ == TypDisSys.CombinedGeneration5
    ;
  
Modelica.Fluid.Interfaces.FluidPort_b port_bSerAmb(
    
redeclare package Medium = 
MediumSer,
    m_flow(max=
if allowFlowReversalSer
 then +Modelica.Constants.inf
 else 0),
    h_outflow(start=MediumSer.h_default, nominal=MediumSer.h_default))
 
if typ == TypDisSys.CombinedGeneration5
    ;
  
Modelica.Fluid.Interfaces.FluidPort_a port_aSerHea(
    
redeclare package Medium = 
MediumSerHea_a,
    m_flow(min=
if allowFlowReversalSer
 then -Modelica.Constants.inf
 else 0),
    h_outflow(start=MediumSerHea_a.h_default, nominal=MediumSerHea_a.h_default))
 
if typ <> TypDisSys.Cooling
 and 
    typ <> TypDisSys.CombinedGeneration5
    ;
  
Modelica.Fluid.Interfaces.FluidPort_b port_bSerHea(
    
redeclare package Medium = 
MediumSer,
    m_flow(max=
if allowFlowReversalSer
 then +Modelica.Constants.inf
 else 0),
    h_outflow(start=MediumSer.h_default, nominal=MediumSer.h_default))
 
if typ <> TypDisSys.Cooling
 and 
    typ <> TypDisSys.CombinedGeneration5
    ;
  
Modelica.Fluid.Interfaces.FluidPort_a port_aSerCoo(
    
redeclare package Medium = 
MediumSer,
    m_flow(min=
if allowFlowReversalSer
 then -Modelica.Constants.inf
 else 0),
    h_outflow(start=MediumSer.h_default, nominal=MediumSer.h_default))
 
if typ == TypDisSys.CombinedGeneration1
 or 
    typ == TypDisSys.CombinedGeneration2to4
 or 
    typ == TypDisSys.Cooling
    ;
  
Modelica.Fluid.Interfaces.FluidPort_b port_bSerCoo(
    
redeclare package Medium = 
MediumSer,
    m_flow(max=
if allowFlowReversalSer
 then +Modelica.Constants.inf
 else 0),
    h_outflow(start=MediumSer.h_default, nominal=MediumSer.h_default))
 
if typ == TypDisSys.CombinedGeneration1
 or 
    typ == TypDisSys.CombinedGeneration2to4
 or 
    typ == TypDisSys.Cooling
    ;
  
BoundaryConditions.WeatherData.Bus weaBus 
if have_weaBus
    ;
  
Buildings.Controls.OBC.CDL.Interfaces.RealOutput QHea_flow(
    
final unit="W") 
if bui.have_heaLoa
    ;
  
Buildings.Controls.OBC.CDL.Interfaces.RealOutput QCoo_flow(
    
final unit="W") 
if bui.have_cooLoa
    ;
  
Buildings.Controls.OBC.CDL.Interfaces.RealOutput PHea(
    
final unit="W") 
if have_eleHea
    ;
  
Buildings.Controls.OBC.CDL.Interfaces.RealOutput PCoo(
    
final unit="W") 
if have_eleCoo
    ;
  
Buildings.Controls.OBC.CDL.Interfaces.RealOutput PFan(
    
final unit="W") 
if have_fan
    ;
  
Buildings.Controls.OBC.CDL.Interfaces.RealOutput PPum(
    
final unit="W") 
if have_pum
    ;
  
Buildings.Controls.OBC.CDL.Interfaces.RealOutput QFue_flow[nFue](
    
each final unit="W") 
if nFue>0
    ;
  
  
replaceable DHC.Loads.BaseClasses.PartialBuilding bui(
    
redeclare final package Medium=
MediumBui,
    
final nPorts_aHeaWat=nPorts_heaWat,
    
final nPorts_bHeaWat=nPorts_heaWat,
    
final nPorts_aChiWat=nPorts_chiWat,
    
final nPorts_bChiWat=nPorts_chiWat,
    
final allowFlowReversal=allowFlowReversalBui)
    ;
  
replaceable DHC.EnergyTransferStations.BaseClasses.PartialETS ets(
    
redeclare final package MediumBui=
MediumBui,
    
redeclare final package MediumSer=
MediumSer,
    
redeclare final package MediumSerHea_a=
MediumSerHea_a,
    
final nPorts_aHeaWat=nPorts_heaWat,
    
final nPorts_bHeaWat=nPorts_heaWat,
    
final nPorts_aChiWat=nPorts_chiWat,
    
final nPorts_bChiWat=nPorts_chiWat,
    
final allowFlowReversalSer=allowFlowReversalSer,
    
final allowFlowReversalBui=allowFlowReversalBui)
    ;
  
Buildings.Controls.OBC.CDL.Continuous.MultiSum totPHea(
    
final nin=
Modelica.Math.BooleanVectors.countTrue(
      {bui.have_eleHea,ets.have_eleHea}))
    ;
  
Buildings.Controls.OBC.CDL.Continuous.MultiSum totPCoo(
    
final nin=
Modelica.Math.BooleanVectors.countTrue(
      {bui.have_eleCoo,ets.have_eleCoo}))
    ;
  
Buildings.Controls.OBC.CDL.Continuous.MultiSum totPFan(
    
final nin=
Modelica.Math.BooleanVectors.countTrue(
      {bui.have_fan,ets.have_fan}))
    ;
  
Buildings.Controls.OBC.CDL.Continuous.MultiSum totPPum(
    
final nin=
Modelica.Math.BooleanVectors.countTrue(
      {bui.have_pum,ets.have_pum}))
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulQHea_flow(
    u(
final unit="W"),
    
final k=facMul) 
if bui.have_heaLoa ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulQCoo_flow(
    u(
final unit="W"),
    
final k=facMul) 
if bui.have_cooLoa
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPHea(
    u(
final unit="W"),
    
final k=facMul) 
if have_eleHea ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPCoo(
    u(
final unit="W"),
    
final k=facMul) 
if have_eleCoo ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPFan(
    u(
final unit="W"),
    
final k=facMul) 
if have_fan ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPPum(
    u(
final unit="W"),
    
final k=facMul) 
if have_pum ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulSerAmbInl(
    
redeclare final package Medium = 
MediumSer,
    
final k=1/facMul,
    
final allowFlowReversal=allowFlowReversalSer)
 
if typ == TypDisSys.CombinedGeneration5 ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulSerAmbOut(
    
redeclare final package Medium = 
MediumSer,
    
final k=facMul,
    
final allowFlowReversal=allowFlowReversalSer)
 
if typ == TypDisSys.CombinedGeneration5 ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulSerHeaInl(
    
redeclare final package Medium = 
MediumSerHea_a,
    
final k=1/facMul,
    
final allowFlowReversal=allowFlowReversalSer)
 
if typ <> TypDisSys.Cooling
 and 
    typ <> TypDisSys.CombinedGeneration5 ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulSerHeaOut(
    
redeclare final package Medium = 
MediumSer,
    
final k=facMul,
    
final allowFlowReversal=allowFlowReversalSer)
 
if typ <> TypDisSys.Cooling
 and 
    typ <> TypDisSys.CombinedGeneration5 ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulSerCooInl(
    
redeclare final package Medium = 
MediumSer,
    
final k=1/facMul,
    
final allowFlowReversal=allowFlowReversalSer)
 
if typ == TypDisSys.CombinedGeneration1
 or 
    typ == TypDisSys.CombinedGeneration2to4
 or 
    typ == TypDisSys.Cooling ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulSerCooOut(
    
redeclare final package Medium = 
MediumSer,
    
final k=facMul,
    
final allowFlowReversal=allowFlowReversalSer)
 
if typ == TypDisSys.CombinedGeneration1
 or 
    typ == TypDisSys.CombinedGeneration2to4
 or 
    typ == TypDisSys.Cooling ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulQFue_flow[nFue](
    u(
each final unit="W"),
    
each final k=facMul) 
if nFue>0
    ;
initial equation 
  assert(ets.have_heaWat == bui.have_heaWat,
    "In "+
getInstanceName()+": The ETS component is configured with have_heaWat="+
    
String(ets.have_heaWat)+" whereas the building is configured with have_heaWat="+
    
String(bui.have_heaWat));
  
assert(ets.have_chiWat == bui.have_chiWat,
    "In "+
getInstanceName()+": The ETS component is configured with have_chiWat="+
    
String(ets.have_chiWat)+" whereas the building is configured with have_chiWat="+
    
String(bui.have_chiWat));
  
if have_heaWat
 then
    assert(nPorts_heaWat > 0,
    "In "+
getInstanceName()+": The ETS component is configured with have_heaWat="+
    
String(ets.have_heaWat)+" but the number of fluid ports for chilled water
    (nPorts_heaWat) is zero.");
  
end if;
  
if have_chiWat
 then
    assert(nPorts_chiWat > 0,
    "In "+
getInstanceName()+": The ETS component is configured with have_chiWat="+
    
String(ets.have_chiWat)+" but the number of fluid ports for chilled water
    (nPorts_chiWat) is zero.");
  
end if;
equation 
  connect(bui.ports_bHeaWat,ets.ports_aHeaWat);
  
connect(ets.ports_bHeaWat,bui.ports_aHeaWat);
  
connect(bui.ports_bChiWat,ets.ports_aChiWat);
  
connect(ets.ports_bChiWat,bui.ports_aChiWat);
  
connect(weaBus,bui.weaBus);
  
connect(weaBus,ets.weaBus);
  
connect(bui.PHea,totPHea.u[1]);
  
connect(ets.PHea,totPHea.u[idxPHeaETS]);
  
connect(bui.PCoo,totPCoo.u[1]);
  
connect(ets.PCoo,totPCoo.u[idxPCooETS]);
  
connect(bui.PFan,totPFan.u[1]);
  
connect(ets.PFan,totPFan.u[idxPFanETS]);
  
connect(bui.PPum,totPPum.u[1]);
  
connect(ets.PPum,totPPum.u[idxPPumETS]);
  
connect(bui.QHea_flow, mulQHea_flow.u);
  
connect(mulQHea_flow.y, QHea_flow);
  
connect(bui.QCoo_flow, mulQCoo_flow.u);
  
connect(mulQCoo_flow.y, QCoo_flow);
  
connect(totPHea.y, mulPHea.u);
  
connect(mulPHea.y, PHea);
  
connect(totPCoo.y, mulPCoo.u);
  
connect(mulPCoo.y, PCoo);
  
connect(totPFan.y, mulPFan.u);
  
connect(mulPFan.y, PFan);
  
connect(totPPum.y, mulPPum.u);
  
connect(mulPPum.y, PPum);
  
connect(port_aSerCoo,mulSerCooInl. port_a);
  
connect(mulSerCooInl.port_b, ets.port_aSerCoo);
  
connect(mulSerCooOut.port_b, port_bSerCoo);
  
connect(ets.port_bSerCoo,mulSerCooOut. port_a);
  
connect(port_aSerHea,mulSerHeaInl. port_a);
  
connect(mulSerHeaInl.port_b, ets.port_aSerHea);
  
connect(port_aSerAmb,mulSerAmbInl. port_a);
  
connect(mulSerAmbInl.port_b, ets.port_aSerAmb);
  
connect(ets.port_bSerHea,mulSerHeaOut. port_a);
  
connect(mulSerHeaOut.port_b, port_bSerHea);
  
connect(ets.port_bSerAmb,mulSerAmbOut. port_a);
  
connect(mulSerAmbOut.port_b, port_bSerAmb);
  
connect(mulQFue_flow.y, QFue_flow);
  
connect(ets.QFue_flow, mulQFue_flow.u);
end PartialBuildingWithPartialETS;
 
Partial model for HVAC terminal unit
 
Information
Partial model to be used for modeling an HVAC terminal unit.
The models inheriting from this class are typically used in conjunction with
Buildings.Experimental.DHC.Loads.FlowDistribution. They must
compute a so-called required mass flow rate defined as the heating or chilled
water mass flow rate needed to meet the load.
It can be approximated using a control loop to avoid inverting a heat
exchanger model as illustrated in
Buildings.Experimental.DHC.Loads.Examples.
The model connectivity can be modified to address various use cases:
- 
On the source side (typically connected to
Buildings.Experimental.DHC.Loads.FlowDistribution):
- 
Fluid ports for chilled water and heating water can be conditionally
instantiated by respectively setting have_chiWatandhave_heaWatto true.
 
- 
On the load side (typically connected to a room model):
- 
Fluid ports can be conditionally instantiated by setting
have_fluPorto true.
- 
Alternatively heat ports (for convective and radiative heat transfer)
can be conditionally instantiated by setting have_heaPorto true.
- 
Real input connectors can be conditionally instantiated by setting
have_QReq_flowto true. Those connectors can be used to provide
heating and cooling loads as time series, see
Buildings.Experimental.DHC.Loads.Examples.CouplingTimeSeries
for an illustration of that use case.
The impact on the room air temperature of an unmet load can be assessed with
Buildings.Experimental.DHC.Loads.SimpleRoomODE.
 
The heating or cooling nominal capacity is provided for the water based heat
exchangers only. Electric heating or cooling systems are supposed to have
an infinite capacity.
Connection with the flow distribution model
When connecting the model to
Buildings.Experimental.DHC.Loads.FlowDistribution:
- 
The nominal pressure drop on the source side (heating or chilled water) is
irrelevant as the computation of the pump head relies on a specific algorithm
described in
Buildings.Experimental.DHC.Loads.FlowDistribution.
- 
The parameter allowFlowReversalmust be set tofalse(default)
in consistency with
Buildings.Experimental.DHC.Loads.FlowDistribution.
This requirement only applies to the source side.
On the load side one is free to use whatever option suitable for the modeling needs.
Note that typically for an air flow network connected to the outdoor
(either at the room level for modeling infiltration or at the system level
for the fresh air source), the unidirectional air flow condition cannot be guaranted.
The reason is the varying pressure of the outdoor air that can lead to a negative
pressure difference at the terminal unit boundaries when the fan is off.
Scaling
Scaling is implemented by means of two multiplier factors.
- 
The parameter facMulserves as a terminal unit multiplier.
Each extensive quantity (mass and heat flow rate, electric power)
flowing out through fluid or heat ports, or connected to an
output connector is multiplied byfacMul.
Each extensive quantity (mass and heat flow rate, electric power)
flowing in through fluid or heat ports, or connected to an
input connector is multiplied by1/facMul.
This parameter allows modeling, with a single instance,
multiple identical units served by the same distribution system,
and serving an aggregated load (e.g., a thermal zone representing several rooms).
- 
The parameter facMulZonserves as a thermal zone multiplier.
Except for the variables connected to the load side, which are not affected byfacMulZon, the logic is otherwise identical to the one described
forfacMul.
This parameter allows modeling, with a single instance (of both the terminal
unit model and the load model),
multiple identical units served by the same distribution system,
and serving multiple identical loads (e.g., a thermal zone representing a single room).
Both multiplier factors are of type real (as opposed to integer) to allow
for instance modeling a set of terminal units based on manufacturer data,
while still being able to size the full set based on a peak load.
See
Buildings.Experimental.DHC.Loads.Validation.TerminalUnitScaling
for an illustration of the use case when heating and cooling loads are
provided as time series.
Change-over mode
When modeling a change-over system:
- 
The parameters have_chiWatandhave_chaOvemust both be set totrueandhave_heaWatmust be set tofalse.
- 
The heat exchanger is sized by providing the nominal parameters for the cooling
configuration (suffix ChiWat). The nominal mass flow rate on the
source and the load side must also be provided for the heating configuration
(suffixHeaWat) as it can differ from the cooling configuration.
- 
The computed heat flow rate must be split into its positive part that gets
connected to QActHea_flowand its negative part that gets connected
toQActCoo_flow.
- 
The computed required mass flow rate must be connected to
mReqChiWat_flow.
Base class parameters
All the parameters of this base class that pertain to the nominal conditions
shall not be exposed in the derived class, as this would lead to an
overdetermined model.
For instance, the nominal mass flow rate may not be exposed but rather
computed from the nominal heat flow rate, entering and leaving fluid temperature.
However, those parameters are included in the base class because other components
are likely to reference them. For instance the distribution system model
may use the nominal mass flow rate of each terminal unit to compute
the nominal mass flow rate of the circulation pump.
Parameters
| Type | Name | Default | Description | 
|---|
| replaceable package Medium1 | Buildings.Media.Water | Medium in the building distribution system | 
| replaceable package Medium2 | Buildings.Media.Air | Load side medium | 
| Scaling | 
| Real | facMul | 1 | Multiplier factor | 
| Real | facMulZon | 1 | Zone multiplier factor | 
| Configuration | 
| Boolean | have_heaWat | false | Set to true if the system uses heating water | 
| Boolean | have_chiWat | false | Set to true if the system uses chilled water | 
| Boolean | have_chaOve | false | Set to true if the chilled water based heat exchanger operates in change-over | 
| Boolean | have_eleHea | false | Set to true if the system has electric heating system | 
| Boolean | have_eleCoo | false | Set to true if the system has electric cooling system | 
| Boolean | have_heaPor | false | Set to true for heat ports on the load side | 
| Boolean | have_fluPor | false | Set to true for fluid ports on the load side | 
| Boolean | have_TSen | false | Set to true for measured temperature as an input | 
| Boolean | have_QReq_flow | false | Set to true for required heat flow rate as an input | 
| Boolean | have_weaBus | false | Set to true to use a weather bus | 
| Boolean | have_fan | false | Set to true if fan power is computed | 
| Boolean | have_pum | false | Set to true if pump power is computed | 
| Nominal condition | 
| HeatFlowRate | QHea_flow_nominal | 0 | Nominal heating capacity (>=0) [W] | 
| HeatFlowRate | QCoo_flow_nominal | 0 | Nominal cooling capacity (<=0) [W] | 
| MassFlowRate | mHeaWat_flow_nominal | 0 | Heating water mass flow rate at nominal conditions [kg/s] | 
| MassFlowRate | mChiWat_flow_nominal | 0 | Chilled water mass flow rate at nominal conditions [kg/s] | 
| MassFlowRate | mLoaHea_flow_nominal | 0 | Load side mass flow rate at nominal conditions in heating mode [kg/s] | 
| MassFlowRate | mLoaCoo_flow_nominal | 0 | Load side mass flow rate at nominal conditions in cooling mode [kg/s] | 
| Temperature | T_aHeaWat_nominal | 273.15 + 60 | Heating water inlet temperature at nominal conditions [K] | 
| Temperature | T_bHeaWat_nominal | T_aHeaWat_nominal - 22.2 | Heating water outlet temperature at nominal conditions [K] | 
| Temperature | T_aChiWat_nominal | 273.15 + 7.2 | Chilled water inlet temperature at nominal conditions  [K] | 
| Temperature | T_bChiWat_nominal | T_aChiWat_nominal + 5.6 | Chilled water outlet temperature at nominal conditions [K] | 
| Temperature | T_aLoaHea_nominal | 273.15 + 21.1 | Load side inlet temperature at nominal conditions in heating mode [K] | 
| Temperature | T_aLoaCoo_nominal | 273.15 + 26.7 | Load side inlet temperature at nominal conditions in cooling mode [K] | 
| Assumptions | 
| Boolean | allowFlowReversal | false | Set to true to allow flow reversal in building distribution system | 
| Boolean | allowFlowReversalLoa | true | Set to true to allow flow reversal on the load side | 
Connectors
| Type | Name | Description | 
|---|
| replaceable package Medium1 | Medium in the building distribution system | 
| replaceable package Medium2 | Load side medium | 
| input RealInput | TSen | Temperature (measured) [K] | 
| input RealInput | TSetHea | Heating set point [K] | 
| input RealInput | TSetCoo | Cooling set point [K] | 
| input RealInput | QReqHea_flow | Required heat flow rate to meet heating set point (>=0) [W] | 
| input RealInput | QReqCoo_flow | Required heat flow rate to meet cooling set point (<=0) [W] | 
| output RealOutput | QActHea_flow | Heating heat flow rate transferred to the load (>=0) [W] | 
| output RealOutput | QActCoo_flow | Cooling heat flow rate transferred to the load (<=0) [W] | 
| output RealOutput | PHea | Power drawn by heating system [W] | 
| output RealOutput | PCoo | Power drawn by cooling system [W] | 
| output RealOutput | PFan | Power drawn by fans motors [W] | 
| output RealOutput | PPum | Power drawn by pumps motors [W] | 
| output RealOutput | mReqHeaWat_flow | Required heating water flow rate to meet heating set point [kg/s] | 
| output RealOutput | mReqChiWat_flow | Required chilled water flow rate to meet cooling set point [kg/s] | 
| FluidPort_a | port_aLoa | Fluid stream inlet port on the load side | 
| FluidPort_b | port_bLoa | Fluid stream outlet port on the load side | 
| HeatPort_b | heaPorCon | Heat port transferring convective heat to the load | 
| HeatPort_b | heaPorRad | Heat port transferring radiative heat to the load | 
| Bus | weaBus | Weather data bus | 
| FluidPort_a | port_aHeaWat | Heating water inlet port | 
| FluidPort_a | port_aChiWat | Chilled water inlet port | 
| FluidPort_b | port_bHeaWat | Heating water outlet port | 
| FluidPort_b | port_bChiWat | Chilled water outlet port | 
Modelica definition
partial model PartialTerminalUnit
  
  
replaceable package Medium1=
Buildings.Media.Water
    constrainedby Modelica.Media.Interfaces.PartialMedium
    ;
  
replaceable package Medium2=
Buildings.Media.Air
    constrainedby Modelica.Media.Interfaces.PartialMedium
    ;
  
parameter Boolean allowFlowReversal=false
    ;
  
parameter Boolean allowFlowReversalLoa=true
    ;
  
parameter Real facMul(min=Modelica.Constants.eps)=1
    ;
   
parameter Real facMulZon(min=Modelica.Constants.eps)=1
    ;
  
parameter Boolean have_heaWat=false
    ;
  
parameter Boolean have_chiWat=false
    ;
  
parameter Boolean have_chaOve=false
    ;
  
parameter Boolean have_eleHea=false
    ;
  
parameter Boolean have_eleCoo=false
    ;
  
parameter Boolean have_heaPor=false
    ;
  
parameter Boolean have_fluPor=false
    ;
  
parameter Boolean have_TSen=false
    ;
  
parameter Boolean have_QReq_flow=false
    ;
  
parameter Boolean have_weaBus=false
    ;
  
parameter Boolean have_fan=false
    ;
  
parameter Boolean have_pum=false
    ;
  
parameter Modelica.SIunits.HeatFlowRate QHea_flow_nominal(
    min=0)=0
    ;
  
parameter Modelica.SIunits.HeatFlowRate QCoo_flow_nominal(
    max=0)=0
    ;
  
parameter Modelica.SIunits.MassFlowRate mHeaWat_flow_nominal(
    min=0)=0
    ;
  
parameter Modelica.SIunits.MassFlowRate mChiWat_flow_nominal(
    min=0)=0
    ;
  
parameter Modelica.SIunits.MassFlowRate mLoaHea_flow_nominal(
    min=0)=0
    ;
  
parameter Modelica.SIunits.MassFlowRate mLoaCoo_flow_nominal(
    min=0)=0
    ;
  
  
parameter Modelica.SIunits.Temperature T_aHeaWat_nominal=273.15 + 60
    ;
  
parameter Modelica.SIunits.Temperature T_bHeaWat_nominal(
    min=273.15,
    displayUnit="degC")=T_aHeaWat_nominal-22.2
    ;
  
  
parameter Modelica.SIunits.Temperature T_aChiWat_nominal=273.15 + 7.2
    ;
  
parameter Modelica.SIunits.Temperature T_bChiWat_nominal(
    min=273.15,
    displayUnit="degC")=T_aChiWat_nominal+5.6
    ;
  
parameter Modelica.SIunits.Temperature T_aLoaHea_nominal=273.15 + 21.1
    ;
  
parameter Modelica.SIunits.Temperature T_aLoaCoo_nominal=273.15 + 26.7
    ;
  
  
Modelica.Blocks.Interfaces.RealInput TSen(
    
final quantity="ThermodynamicTemperature",
    
final unit="K",
    displayUnit="degC") 
if have_TSen
    ;
  
Modelica.Blocks.Interfaces.RealInput TSetHea(
    quantity="ThermodynamicTemperature",
    
final unit="K",
    displayUnit="degC") 
if have_heaWat
 or have_chaOve
 or have_eleHea
    ;
  
Modelica.Blocks.Interfaces.RealInput TSetCoo(
    
final quantity="ThermodynamicTemperature",
    
final unit="K",
    displayUnit="degC") 
if have_chiWat
 or have_eleCoo
    ;
  
Modelica.Blocks.Interfaces.RealInput QReqHea_flow(
    
final quantity="HeatFlowRate",
    
final unit="W") 
if have_QReq_flow
 and (have_heaWat
 or have_chaOve
 or have_eleHea)
    ;
  
Modelica.Blocks.Interfaces.RealInput QReqCoo_flow(
    
final quantity="HeatFlowRate",
    
final unit="W") 
if have_QReq_flow
 and (have_chiWat
 or have_eleCoo)
    ;
  
Modelica.Blocks.Interfaces.RealOutput QActHea_flow(
    
final quantity="HeatFlowRate",
    
final unit="W") 
if have_heaWat
 or have_chaOve
 or have_eleHea
    ;
  
Modelica.Blocks.Interfaces.RealOutput QActCoo_flow(
    
final quantity="HeatFlowRate",
    
final unit="W") 
if have_chiWat
 or have_eleCoo
    ;
  
Modelica.Blocks.Interfaces.RealOutput PHea(
    
final quantity="Power",
    
final unit="W") 
if have_eleHea
    ;
  
Modelica.Blocks.Interfaces.RealOutput PCoo(
    
final quantity="Power",
    
final unit="W") 
if have_eleCoo
    ;
  
Modelica.Blocks.Interfaces.RealOutput PFan(
    
final quantity="Power",
    
final unit="W") 
if have_fan
    ;
  
Modelica.Blocks.Interfaces.RealOutput PPum(
    
final quantity="Power",
    
final unit="W") 
if have_pum
    ;
  
Modelica.Blocks.Interfaces.RealOutput mReqHeaWat_flow(
    
final quantity="MassFlowRate",
    
final unit="kg/s") 
if have_heaWat
    ;
  
Modelica.Blocks.Interfaces.RealOutput mReqChiWat_flow(
    
final quantity="MassFlowRate",
    
final unit="kg/s") 
if have_chiWat
    ;
  
Modelica.Fluid.Interfaces.FluidPort_a port_aLoa(
    
redeclare final package Medium=
Medium2,
    p(start=Medium2.p_default),
    m_flow(
      min=
        
if allowFlowReversalLoa
 then 
          -Modelica.Constants.inf
        else 
          0),
    h_outflow(
      start=Medium2.h_default,
      nominal=Medium2.h_default)) 
if have_fluPor
    ;
  
Modelica.Fluid.Interfaces.FluidPort_b port_bLoa(
    
redeclare final package Medium=
Medium2,
    p(start=Medium2.p_default),
    m_flow(
      max=
        
if allowFlowReversalLoa
 then 
          +Modelica.Constants.inf
        else 
          0),
    h_outflow(
      start=Medium2.h_default,
      nominal=Medium2.h_default)) 
if have_fluPor
    ;
  
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b heaPorCon 
if have_heaPor
    ;
  
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b heaPorRad 
if have_heaPor
    ;
  
BoundaryConditions.WeatherData.Bus weaBus 
if have_weaBus
    ;
  
Modelica.Fluid.Interfaces.FluidPort_a port_aHeaWat(
    p(start=Medium1.p_default),
    
redeclare final package Medium=
Medium1,
    m_flow(
      min=
        
if allowFlowReversal
 then 
          -Modelica.Constants.inf
        else 
          0),
    h_outflow(
      start=Medium1.h_default,
      nominal=Medium1.h_default)) 
if have_heaWat
    ;
  
Modelica.Fluid.Interfaces.FluidPort_a port_aChiWat(
    p(start=Medium1.p_default),
    
redeclare final package Medium=
Medium1,
    m_flow(
      min=
        
if allowFlowReversal
 then 
          -Modelica.Constants.inf
        else 
          0),
    h_outflow(
      start=Medium1.h_default,
      nominal=Medium1.h_default)) 
if have_chiWat
    ;
  
Modelica.Fluid.Interfaces.FluidPort_b port_bHeaWat(
    p(start=Medium1.p_default),
    
redeclare final package Medium=
Medium1,
    m_flow(
      max=
        
if allowFlowReversal
 then 
          +Modelica.Constants.inf
        else 
          0),
    h_outflow(
      start=Medium1.h_default,
      nominal=Medium1.h_default)) 
if have_heaWat
    ;
  
Modelica.Fluid.Interfaces.FluidPort_b port_bChiWat(
    p(start=Medium1.p_default),
    
redeclare final package Medium=
Medium1,
    m_flow(
      max=
        
if allowFlowReversal
 then 
          +Modelica.Constants.inf
        else 
          0),
    h_outflow(
      start=Medium1.h_default,
      nominal=Medium1.h_default)) 
if have_chiWat
    ;
  
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulQReqHea_flow(
    u(
final unit="W"),
    
final k=1/facMul) 
if have_QReq_flow
 and (have_heaWat
 or have_chaOve
 or have_eleHea)
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulQReqCoo_flow(
    u(
final unit="W"),
    
final k=1/facMul) 
if have_QReq_flow
 and (have_chiWat
 or have_eleCoo)
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulQActHea_flow(
    u(
final unit="W"),
    
final k=facMul*facMulZon) 
if have_heaWat
 or have_chaOve
 or have_eleHea
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulQActCoo_flow(
    u(
final unit="W"),
    
final k=facMul*facMulZon) 
if have_chiWat
 or have_eleCoo
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPHea(
    u(
final unit="W"),
    
final k=facMul*facMulZon) 
if have_eleHea
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPCoo(
    u(
final unit="W"),
    
final k=facMul*facMulZon) 
if have_eleCoo
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPFan(
    u(
final unit="W"),
    
final k=facMul*facMulZon) 
if have_fan
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulPPum(
    u(
final unit="W"),
    
final k=facMul*facMulZon) 
if have_pum
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulMasFloReqHeaWat(
    u(
final unit="kg/s"),
    
final k=facMul*facMulZon) 
if have_heaWat
    ;
  
Buildings.Controls.OBC.CDL.Continuous.Gain mulMasFloReqChiWat(
    u(
final unit="kg/s"),
    
final k=facMul*facMulZon) 
if have_chiWat
    ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulHeaWatFloInl(
    
redeclare final package Medium=
Medium1,
    
final k=1/facMul/facMulZon,
    
final allowFlowReversal=allowFlowReversal) 
if have_heaWat
    ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulHeaWatFloOut(
    
redeclare final package Medium=
Medium1,
    
final k=facMul*facMulZon,
    
final allowFlowReversal=allowFlowReversal) 
if have_heaWat
    ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulChiWatFloInl(
    
redeclare final package Medium=
Medium1,
    
final k=1/facMul/facMulZon,
    
final allowFlowReversal=allowFlowReversal) 
if have_chiWat
    ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulChiWatFloOut(
    
redeclare final package Medium=
Medium1,
    
final k=facMul*facMulZon,
    
final allowFlowReversal=allowFlowReversal) 
if have_chiWat
    ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulLoaMasFloOut(
    
redeclare final package Medium=
Medium2,
    
final k=facMul,
    
final allowFlowReversal=allowFlowReversalLoa) 
if have_fluPor
    ;
  
Fluid.BaseClasses.MassFlowRateMultiplier mulLoaMasFloInl(
    
redeclare final package Medium=
Medium2,
    
final k=1/facMul,
    
final allowFlowReversal=allowFlowReversalLoa) 
if have_fluPor
    ;
  
Fluid.HeatExchangers.RadiantSlabs.BaseClasses.HeatFlowRateMultiplier mulHeaFloCon(
final k=
        facMul)     
if have_heaPor ;
  
Fluid.HeatExchangers.RadiantSlabs.BaseClasses.HeatFlowRateMultiplier mulHeaFloRad(
final k=
        facMul)     
if have_heaPor ;
protected 
  parameter Modelica.SIunits.SpecificHeatCapacity cpHeaWat_nominal=
    
Medium1.specificHeatCapacityCp(
      
Medium1.setState_pTX(
        Medium1.p_default,
        T_aHeaWat_nominal))
    ;
  
parameter Modelica.SIunits.SpecificHeatCapacity cpChiWat_nominal=
    
Medium1.specificHeatCapacityCp(
      
Medium1.setState_pTX(
        Medium1.p_default,
        T_aChiWat_nominal))
    ;
  
parameter Modelica.SIunits.SpecificHeatCapacity cpLoaHea_nominal=
    
Medium2.specificHeatCapacityCp(
      
Medium2.setState_pTX(
        Medium2.p_default,
        T_aLoaHea_nominal))
    ;
  
parameter Modelica.SIunits.SpecificHeatCapacity cpLoaCoo_nominal=
    
Medium2.specificHeatCapacityCp(
      
Medium2.setState_pTX(
        Medium2.p_default,
        T_aLoaCoo_nominal))
    ;
equation 
  connect(QReqHea_flow,mulQReqHea_flow.u);
  
connect(QReqCoo_flow,mulQReqCoo_flow.u);
  
connect(mulQActHea_flow.y,QActHea_flow);
  
connect(mulQActCoo_flow.y,QActCoo_flow);
  
connect(mulPHea.y,PHea);
  
connect(mulPCoo.y,PCoo);
  
connect(mulPFan.y,PFan);
  
connect(mulPPum.y,PPum);
  
connect(mulMasFloReqHeaWat.y,mReqHeaWat_flow);
  
connect(mulMasFloReqChiWat.y,mReqChiWat_flow);
  
connect(port_aHeaWat,mulHeaWatFloInl.port_a);
  
connect(mulHeaWatFloOut.port_b,port_bHeaWat);
  
connect(port_aChiWat,mulChiWatFloInl.port_a);
  
connect(mulChiWatFloOut.port_b,port_bChiWat);
  
connect(mulLoaMasFloOut.port_b,port_bLoa);
  
connect(port_aLoa,mulLoaMasFloInl.port_a);
  
connect(mulHeaFloCon.port_b,heaPorCon);
  
connect(mulHeaFloRad.port_b,heaPorRad);
end PartialTerminalUnit;
 
Function that reads the peak load from the load profile
Information
Function that reads a double value from a text file.
This function scans a file that has a format such as
#1
#Some other text
#Peak space cooling load = -383165.6989 Watts
#Peak space heating load = 893931.4335 Watts
double tab1(8760,4)
0,0,5972.314925,16
3600,0,4925.839944,1750.915684
...
The parameter string is a string that the function
searches for, starting at the first line.
If it finds the string, it expects an equality sign, and
returns the double value after this equality sign.
If the function encounters the end of the file, it
terminates the simulation with an assertion.
See
Buildings.Experimental.DHC.Loads.BaseClasses.Validation.GetPeakLoad
for how to invoke this function.
Inputs
Outputs
| Type | Name | Description | 
|---|
| Real | number | Number that is read from the file | 
Modelica definition
function getPeakLoad
  
  input String string
    ;
  input String filNam
    ;
  output Real number
    ;
protected 
  String lin
    ;
  Integer iLin
    ;
  Integer index=0
    ;
  Integer staInd
    ;
  Integer nexInd
    ;
  Boolean found
    ;
  Boolean EOF
    ;
  String del
    ;
algorithm 
  
  iLin := 0;
  EOF := false;
  while 
       (not EOF) and 
                    (index == 0) loop
    iLin := iLin+1;
    (lin,EOF) := Modelica.Utilities.Streams.readLine(
      fileName=filNam,
      lineNumber=iLin);
    index := Modelica.Utilities.Strings.find(
      string=lin,
      searchString=string,
      startIndex=1,
      caseSensitive=true);
  end while;
  assert(
    not EOF,
    "Error: Did not find '"+string+"' when scanning '"+filNam+"'."+"\n   Check for correct file syntax.");
  
  (del,nexInd) := Modelica.Utilities.Strings.scanDelimiter(
    string=lin,
    startIndex=Modelica.Utilities.Strings.length(string)+1,
    requiredDelimiters={"="},
    message="Failed to find '=' when reading peak load in '"+filNam+"'.");
  
  number := Modelica.Utilities.Strings.scanReal(
    string=lin,
    startIndex=nexInd,
    message="Failed to read double value when reading peak load in '"+filNam+"'.");
end getPeakLoad;