GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 83
Functions: 0.0% 0 / 0 / 1
Branches: 0.0% 0 / 0 / 201

src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEnergyRecoveryVentilator.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "../ForwardTranslator.hpp"
7 #include "../../model/Model.hpp"
8 #include "../../model/Schedule.hpp"
9 #include "../../model/Schedule_Impl.hpp"
10 #include "../../model/HeatExchangerAirToAirSensibleAndLatent.hpp"
11 #include "../../model/HeatExchangerAirToAirSensibleAndLatent_Impl.hpp"
12 #include "../../model/Node.hpp"
13 #include "../../model/Node_Impl.hpp"
14 #include "../../model/ZoneHVACEnergyRecoveryVentilator.hpp"
15 #include "../../model/ZoneHVACEnergyRecoveryVentilator_Impl.hpp"
16 #include "../../model/ZoneHVACEnergyRecoveryVentilatorController.hpp"
17 #include "../../model/ZoneHVACEnergyRecoveryVentilatorController_Impl.hpp"
18 #include "../../model/ThermalZone.hpp"
19 #include "../../model/ThermalZone_Impl.hpp"
20 #include <utilities/idd/Fan_OnOff_FieldEnums.hxx>
21 #include <utilities/idd/Fan_SystemModel_FieldEnums.hxx>
22 #include <utilities/idd/HeatExchanger_AirToAir_SensibleAndLatent_FieldEnums.hxx>
23 #include <utilities/idd/ZoneHVAC_EnergyRecoveryVentilator_FieldEnums.hxx>
24 #include <utilities/idd/ZoneHVAC_EnergyRecoveryVentilator_Controller_FieldEnums.hxx>
25 #include "../../utilities/idd/IddEnums.hpp"
26 #include <utilities/idd/IddEnums.hxx>
27 #include <utilities/idd/IddFactory.hxx>
28
29 using namespace openstudio::model;
30
31 namespace openstudio {
32
33 namespace energyplus {
34
35 ✗ boost::optional<IdfObject> ForwardTranslator::translateZoneHVACEnergyRecoveryVentilator(ZoneHVACEnergyRecoveryVentilator& modelObject) {
36 ✗ boost::optional<std::string> s;
37 ✗ boost::optional<double> value;
38 ✗ boost::optional<ModelObject> temp;
39
40 // Model Name
41 ✗ std::string const baseName = modelObject.name().get();
42 // Node Names
43 ✗ std::string const oaNodeName = baseName + " OA Node";
44 ✗ std::string const supplyFanInletNodeName = baseName + " Supply Fan Inlet Node";
45 ✗ std::string const exhaustFanInletNodeName = baseName + " Exhaust Fan Inlet Node";
46 ✗ std::string const exhaustFanOutletNodeName = baseName + " Exhaust Fan Outlet Node";
47
48 ✗ auto const zoneExhaustNode = modelObject.inletNode();
49 ✗ auto const zoneInletNode = modelObject.outletNode();
50
51 // Name
52 ✗ IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ZoneHVAC_EnergyRecoveryVentilator, modelObject);
53
54 // AvailabilityScheduleName
55 {
56 ✗ auto schedule = modelObject.availabilitySchedule();
57 ✗ if (auto _schedule = translateAndMapModelObject(schedule)) {
58 ✗ idfObject.setString(ZoneHVAC_EnergyRecoveryVentilatorFields::AvailabilityScheduleName, _schedule->name().get());
59 ✗ }
60 ✗ }
61
62 // Heat Exchanger
63 {
64 ✗ auto heatExchanger = modelObject.heatExchanger().cast<HeatExchangerAirToAirSensibleAndLatent>();
65
66 ✗ if (heatExchanger.supplyAirOutletTemperatureControl()) {
67 ✗ LOG(Warn, "Overriding supplyAirOutletTemperatureControl to \"No\" for "
68 << heatExchanger.briefDescription() << " because the HX needs to control itself, not through Setpoint Manager.");
69 ✗ heatExchanger.setSupplyAirOutletTemperatureControl(false);
70 }
71
72 ✗ if (auto _heatExchanger = translateAndMapModelObject(heatExchanger)) {
73 // HeatExchangerName
74 ✗ idfObject.setString(ZoneHVAC_EnergyRecoveryVentilatorFields::HeatExchangerName, _heatExchanger->name().get());
75 // Heat Exchanger Nodes
76 ✗ if (_heatExchanger->iddObject().type() == IddObjectType::HeatExchanger_AirToAir_SensibleAndLatent) {
77 ✗ _heatExchanger->setString(HeatExchanger_AirToAir_SensibleAndLatentFields::SupplyAirInletNodeName, oaNodeName);
78 ✗ _heatExchanger->setString(HeatExchanger_AirToAir_SensibleAndLatentFields::SupplyAirOutletNodeName, supplyFanInletNodeName);
79 ✗ _heatExchanger->setString(HeatExchanger_AirToAir_SensibleAndLatentFields::ExhaustAirInletNodeName, zoneExhaustNode->name().get());
80 ✗ _heatExchanger->setString(HeatExchanger_AirToAir_SensibleAndLatentFields::ExhaustAirOutletNodeName, exhaustFanInletNodeName);
81
82 ✗ IdfObject _oaNodeList(openstudio::IddObjectType::OutdoorAir_NodeList);
83 ✗ _oaNodeList.setString(0, oaNodeName);
84 ✗ m_idfObjects.push_back(_oaNodeList);
85 ✗ }
86 ✗ }
87 ✗ }
88
89 // SupplyAirFlowRate
90 ✗ if (modelObject.isSupplyAirFlowRateAutosized()) {
91 ✗ idfObject.setString(ZoneHVAC_EnergyRecoveryVentilatorFields::SupplyAirFlowRate, "AutoSize");
92 ✗ } else if ((value = modelObject.supplyAirFlowRate())) {
93 ✗ idfObject.setDouble(ZoneHVAC_EnergyRecoveryVentilatorFields::SupplyAirFlowRate, value.get());
94 }
95
96 // ExhaustAirFlowRate
97 ✗ if (modelObject.isExhaustAirFlowRateAutosized()) {
98 ✗ idfObject.setString(ZoneHVAC_EnergyRecoveryVentilatorFields::ExhaustAirFlowRate, "AutoSize");
99 ✗ } else if ((value = modelObject.exhaustAirFlowRate())) {
100 ✗ idfObject.setDouble(ZoneHVAC_EnergyRecoveryVentilatorFields::ExhaustAirFlowRate, value.get());
101 }
102
103 // Supply Air Fan
104 {
105 ✗ auto supplyAirFan = modelObject.supplyAirFan();
106 ✗ if (auto _supplyAirFan = translateAndMapModelObject(supplyAirFan)) {
107 // SupplyAirFanName
108 ✗ idfObject.setString(ZoneHVAC_EnergyRecoveryVentilatorFields::SupplyAirFanName, _supplyAirFan->name().get());
109 // Supply Air Fan Inlet and Outlet Nodes
110 ✗ if (_supplyAirFan->iddObject().type() == IddObjectType::Fan_OnOff) {
111 ✗ _supplyAirFan->setString(Fan_OnOffFields::AirInletNodeName, supplyFanInletNodeName);
112 ✗ _supplyAirFan->setString(Fan_OnOffFields::AirOutletNodeName, zoneInletNode->name().get());
113 ✗ } else if (_supplyAirFan->iddObject().type() == IddObjectType::Fan_SystemModel) {
114 ✗ _supplyAirFan->setString(Fan_SystemModelFields::AirInletNodeName, supplyFanInletNodeName);
115 ✗ _supplyAirFan->setString(Fan_SystemModelFields::AirOutletNodeName, zoneInletNode->name().get());
116 } else {
117 ✗ LOG(Error, modelObject.briefDescription() << " is attached to an unsupported type of fan: " << supplyAirFan.briefDescription());
118 }
119 ✗ }
120 ✗ }
121
122 // Exhaust Air Fan
123 {
124 ✗ auto exhaustAirFan = modelObject.exhaustAirFan();
125 ✗ if (auto _exhaustAirFan = translateAndMapModelObject(exhaustAirFan)) {
126 // ExhaustAirFanName
127 ✗ idfObject.setString(ZoneHVAC_EnergyRecoveryVentilatorFields::ExhaustAirFanName, _exhaustAirFan->name().get());
128 // Exhaust Air Fan Inlet and Outlet Nodes
129 ✗ if (_exhaustAirFan->iddObject().type() == IddObjectType::Fan_OnOff) {
130 ✗ _exhaustAirFan->setString(Fan_OnOffFields::AirInletNodeName, exhaustFanInletNodeName);
131 ✗ _exhaustAirFan->setString(Fan_OnOffFields::AirOutletNodeName, exhaustFanOutletNodeName);
132 ✗ } else if (_exhaustAirFan->iddObject().type() == IddObjectType::Fan_SystemModel) {
133 ✗ _exhaustAirFan->setString(Fan_SystemModelFields::AirInletNodeName, exhaustFanInletNodeName);
134 ✗ _exhaustAirFan->setString(Fan_SystemModelFields::AirOutletNodeName, exhaustFanOutletNodeName);
135 } else {
136 ✗ LOG(Error, modelObject.briefDescription() << " is attached to an unsupported type of fan: " << exhaustAirFan.briefDescription());
137 }
138 ✗ }
139 ✗ }
140
141 // ControllerName
142 ✗ if (auto controller = modelObject.controller()) {
143 ✗ if (auto _controller = translateAndMapModelObject(controller.get())) {
144 ✗ idfObject.setString(ZoneHVAC_EnergyRecoveryVentilatorFields::ControllerName, _controller->name().get());
145
146 // Need to set Humidistat Control Thermal Zone in Controller
147 ✗ if (controller->highHumidityControlFlag()) {
148 ✗ if (auto thermalZone = modelObject.thermalZone()) {
149 ✗ if (auto _thermalZone = translateAndMapModelObject(thermalZone.get())) {
150 ✗ _controller->setString(ZoneHVAC_EnergyRecoveryVentilator_ControllerFields::HumidistatControlZoneName, _thermalZone->name().get());
151 ✗ }
152 ✗ }
153 }
154 ✗ }
155 ✗ }
156
157 // VentilationRateperUnitFloorArea
158 ✗ if ((value = modelObject.ventilationRateperUnitFloorArea())) {
159 ✗ idfObject.setDouble(ZoneHVAC_EnergyRecoveryVentilatorFields::VentilationRateperUnitFloorArea, value.get());
160 }
161
162 // VentilationRateperOccupant
163 ✗ if ((value = modelObject.ventilationRateperOccupant())) {
164 ✗ idfObject.setDouble(ZoneHVAC_EnergyRecoveryVentilatorFields::VentilationRateperOccupant, value.get());
165 }
166
167 // AvailabilityManagerListName
168
169 ✗ return idfObject;
170 ✗ }
171
172 } // namespace energyplus
173
174 } // namespace openstudio
175