GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 88.4% 38 / 0 / 43
Functions: 100.0% 1 / 0 / 1
Branches: 70.7% 53 / 0 / 75

src/energyplus/ForwardTranslator/ForwardTranslateControllerMechanicalVentilation.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/Space.hpp"
11 #include "../../model/Space_Impl.hpp"
12 #include "../../model/ThermalZone.hpp"
13 #include "../../model/ThermalZone_Impl.hpp"
14 #include "../../model/AirLoopHVACOutdoorAirSystem.hpp"
15 #include "../../model/AirLoopHVACOutdoorAirSystem_Impl.hpp"
16 #include "../../model/ControllerMechanicalVentilation.hpp"
17 #include "../../model/ControllerMechanicalVentilation_Impl.hpp"
18 #include "../../model/DesignSpecificationOutdoorAir.hpp"
19 #include "../../model/DesignSpecificationOutdoorAir_Impl.hpp"
20 #include "../../model/ControllerOutdoorAir.hpp"
21 #include "../../model/ControllerOutdoorAir_Impl.hpp"
22 #include "../../model/AirLoopHVAC.hpp"
23 #include "../../model/AirLoopHVAC_Impl.hpp"
24 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
25 #include "../../utilities/idf/Workspace.hpp"
26 #include "../../utilities/idf/WorkspaceObjectOrder.hpp"
27 #include "../../utilities/core/Logger.hpp"
28 #include <utilities/idd/Controller_MechanicalVentilation_FieldEnums.hxx>
29 #include <utilities/idd/IddEnums.hxx>
30
31 using namespace openstudio::model;
32
33 namespace openstudio {
34
35 namespace energyplus {
36
37 53 boost::optional<IdfObject> ForwardTranslator::translateControllerMechanicalVentilation(ControllerMechanicalVentilation& modelObject) {
38
39 // NOTE: don't translate it if it has no DSOA
40
3/3
✓ Branch 1 taken 53 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 18 times.
53 if (!modelObject.hasZonesWithDesignSpecificationOutdoorAir()) {
41 35 return boost::none;
42 }
43
44 18 OptionalString s;
45 18 OptionalDouble d;
46 18 OptionalModelObject temp;
47
48
2/2
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
18 IdfObject idfObject(IddObjectType::Controller_MechanicalVentilation);
49
50 // Name
51
1/1
✓ Branch 1 taken 18 times.
18 s = modelObject.name();
52
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (s) {
53
2/2
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
18 idfObject.setName(*s);
54 }
55
56 // Availability Schedule
57 // If there is a ControllerOutdoorAir::minimumOutdoorAirSchedule
58 // then use that for the ControllerMechanicalVentilation::availabilitySchedule
59 // Note that this scheme will not support fractions (schedule values above 0) because anything greater than 0 will
60 // make the mechanical ventilation controller avaiable and thus taking precedence.
61 18 bool useAvailabiltySchedule = true;
62
1/1
✓ Branch 1 taken 18 times.
18 auto availabilitySchedule = modelObject.availabilitySchedule();
63
64 // alwaysOnDiscreteSchedule is the default availability schedule for the mechanical ventilation controller
65 // if the default is still in place BUT the user has defined a minimumOutdoorAirSchedule for the oa controller,
66 // then use the minimumOutdoorAirSchedule for the mechanical ventilation controller availability schedule
67 // The minimumOutdoorAirSchedule will not do its job while the controller mechanical ventilation object is available.
68
5/5
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 10 times.
18 if (availabilitySchedule == modelObject.model().alwaysOnDiscreteSchedule()) {
69
3/4
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 8 times.
16 if (auto minOASchedule = modelObject.controllerOutdoorAir().minimumOutdoorAirSchedule()) {
70 ✗ auto _schedule = translateAndMapModelObject(minOASchedule.get());
71 ✗ OS_ASSERT(_schedule);
72 ✗ idfObject.setString(Controller_MechanicalVentilationFields::AvailabilityScheduleName, _schedule->name().get());
73 ✗ useAvailabiltySchedule = false;
74 8 }
75 }
76
77
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (useAvailabiltySchedule) {
78
1/1
✓ Branch 1 taken 18 times.
18 boost::optional<IdfObject> availabilityScheduleIdf = translateAndMapModelObject(availabilitySchedule);
79
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
18 OS_ASSERT(availabilityScheduleIdf);
80
4/4
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
✓ Branch 10 taken 18 times.
18 idfObject.setString(openstudio::Controller_MechanicalVentilationFields::AvailabilityScheduleName, availabilityScheduleIdf->name().get());
81 18 }
82
83 // Demand Controlled Ventilation
84
2/3
✓ Branch 1 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
18 if (modelObject.demandControlledVentilation()) {
85 ✗ idfObject.setString(openstudio::Controller_MechanicalVentilationFields::DemandControlledVentilation, "Yes");
86 } else {
87
2/2
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
36 idfObject.setString(openstudio::Controller_MechanicalVentilationFields::DemandControlledVentilation, "No");
88 }
89
90 // System Outdoor Air Method
91
2/2
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
18 s = modelObject.systemOutdoorAirMethod();
92
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (s) {
93
2/2
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
18 idfObject.setString(openstudio::Controller_MechanicalVentilationFields::SystemOutdoorAirMethod, s.get());
94 }
95
96 // Extensible Groups for DSOAs are no longer pushed in translateSizingZone to retain order of the file, because:
97 // 1) Thermal Zones are translated before AirLoopHVACs, so we guarantee proper order (unless we mess something up, like adding a new always
98 // translated object early on that will call it)
99 // 2) Doing it in translateSizingZone means that it will NOT be written if the Sizing:Zone isn't, for eg when you have no design days
100 // but that is a valid use case
101
1/1
✓ Branch 1 taken 18 times.
18 auto oa_controller = modelObject.controllerOutdoorAir();
102
2/3
✓ Branch 1 taken 18 times.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
36 if (auto oa_sys_ = oa_controller.airLoopHVACOutdoorAirSystem()) {
103
3/4
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
36 if (auto a_ = oa_sys_->airLoopHVAC()) {
104
4/4
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 11 taken 20 times.
✓ Branch 12 taken 18 times.
38 for (const auto& z : a_->thermalZones()) {
105
3/3
✓ Branch 1 taken 20 times.
✓ Branch 3 taken 19 times.
✓ Branch 4 taken 1 time.
40 if (auto dsoaOrList_ = getOrCreateThermalZoneDSOA(z)) {
106
4/6
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 57 times.
✓ Branch 8 taken 19 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
95 IdfExtensibleGroup eg = idfObject.pushExtensibleGroup({z.nameString(), dsoaOrList_->nameString(), zoneDSZADName(z).value_or("")});
107 39 }
108 18 }
109 18 }
110 18 }
111
112
1/1
✓ Branch 1 taken 18 times.
18 m_idfObjects.push_back(idfObject);
113
1/1
✓ Branch 1 taken 18 times.
18 return boost::optional<IdfObject>(idfObject);
114 37 }
115
116 } // namespace energyplus
117
118 } // namespace openstudio
119