GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 70.6% 72 / 0 / 102
Functions: 71.9% 23 / 0 / 32
Branches: 55.2% 48 / 0 / 87

src/model/DistrictCooling.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 "DistrictCooling.hpp"
7 #include "DistrictCooling_Impl.hpp"
8 #include "Model.hpp"
9 #include "Node.hpp"
10 #include "Node_Impl.hpp"
11 #include "Schedule.hpp"
12 #include "Schedule_Impl.hpp"
13
14 #include "../utilities/core/Assert.hpp"
15 #include "../utilities/data/DataEnums.hpp"
16
17 #include <utilities/idd/OS_DistrictCooling_FieldEnums.hxx>
18 #include <utilities/idd/IddEnums.hxx>
19
20 namespace openstudio {
21 namespace model {
22
23 namespace detail {
24
25 9 DistrictCooling_Impl::DistrictCooling_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
26 9 : StraightComponent_Impl(idfObject, model, keepHandle) {
27
4/6
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 9 times.
✗ Branch 13 not taken.
9 OS_ASSERT(idfObject.iddObject().type() == DistrictCooling::iddObjectType());
28 9 }
29
30 2 DistrictCooling_Impl::DistrictCooling_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
31 2 : StraightComponent_Impl(other, model, keepHandle) {
32
4/6
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 13 not taken.
2 OS_ASSERT(other.iddObject().type() == DistrictCooling::iddObjectType());
33 2 }
34
35 6 DistrictCooling_Impl::DistrictCooling_Impl(const DistrictCooling_Impl& other, Model_Impl* model, bool keepHandle)
36 6 : StraightComponent_Impl(other, model, keepHandle) {}
37
38 ✗ const std::vector<std::string>& DistrictCooling_Impl::outputVariableNames() const {
39 static const std::vector<std::string> result{
40 "District Cooling Water Rate",
41 "District Cooling Water Energy",
42 "District Cooling Water Inlet Temperature",
43 "District Cooling Water Outlet Temperature",
44 "District Cooling Water Mass Flow Rate",
45 ✗ };
46 ✗ return result;
47 ✗ }
48
49 ✗ IddObjectType DistrictCooling_Impl::iddObjectType() const {
50 ✗ return DistrictCooling::iddObjectType();
51 }
52
53 ✗ std::vector<ScheduleTypeKey> DistrictCooling_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
54 ✗ std::vector<ScheduleTypeKey> result;
55 ✗ const UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
56 ✗ if (std::find(fieldIndices.cbegin(), fieldIndices.cend(), OS_DistrictCoolingFields::CapacityFractionSchedule) != fieldIndices.cend()) {
57 ✗ result.emplace_back("DistrictCooling", "Capacity Fraction Schedule");
58 }
59 ✗ return result;
60 ✗ }
61
62 11 unsigned DistrictCooling_Impl::inletPort() const {
63 11 return OS_DistrictCoolingFields::ChilledWaterInletNodeName;
64 }
65
66 23 unsigned DistrictCooling_Impl::outletPort() const {
67 23 return OS_DistrictCoolingFields::ChilledWaterOutletNodeName;
68 }
69
70 9 bool DistrictCooling_Impl::addToNode(Node& node) {
71
3/3
✓ Branch 1 taken 9 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 3 times.
18 if (boost::optional<PlantLoop> plant = node.plantLoop()) {
72
5/5
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 1 time.
12 if (plant->supplyComponent(node.handle())) {
73
1/1
✓ Branch 1 taken 5 times.
5 return StraightComponent_Impl::addToNode(node);
74 }
75 9 }
76
77 4 return false;
78 }
79
80 6 boost::optional<double> DistrictCooling_Impl::nominalCapacity() const {
81 6 return getDouble(OS_DistrictCoolingFields::NominalCapacity, true);
82 }
83
84 3 bool DistrictCooling_Impl::isNominalCapacityAutosized() const {
85 3 bool result = false;
86
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> value = getString(OS_DistrictCoolingFields::NominalCapacity, true);
87
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (value) {
88
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 result = openstudio::istringEqual(value.get(), "autosize");
89 }
90 3 return result;
91 3 }
92
93 2 bool DistrictCooling_Impl::setNominalCapacity(double nominalCapacity) {
94 2 return setDouble(OS_DistrictCoolingFields::NominalCapacity, nominalCapacity);
95 }
96
97 8 void DistrictCooling_Impl::autosizeNominalCapacity() {
98
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
16 const bool result = setString(OS_DistrictCoolingFields::NominalCapacity, "autosize");
99
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
100 8 }
101
102 2 Schedule DistrictCooling_Impl::capacityFractionSchedule() const {
103
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 auto sch_ = getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_DistrictCoolingFields::CapacityFractionSchedule);
104
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(sch_);
105
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 return *sch_;
106 2 }
107
108 8 bool DistrictCooling_Impl::setCapacityFractionSchedule(Schedule& schedule) {
109
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
32 const bool result = setSchedule(OS_DistrictCoolingFields::CapacityFractionSchedule, "DistrictCooling", "Capacity Fraction", schedule);
110 8 return result;
111 }
112
113 ✗ boost::optional<double> DistrictCooling_Impl::autosizedNominalCapacity() const {
114 ✗ return getAutosizedValue("Design Size Nominal Capacity", "W");
115 }
116
117 ✗ void DistrictCooling_Impl::autosize() {
118 ✗ autosizeNominalCapacity();
119 ✗ }
120
121 ✗ void DistrictCooling_Impl::applySizingValues() {
122 ✗ boost::optional<double> val;
123 ✗ val = autosizedNominalCapacity();
124 ✗ if (val) {
125 ✗ setNominalCapacity(val.get());
126 }
127 ✗ }
128
129 1 ComponentType DistrictCooling_Impl::componentType() const {
130
1/1
✓ Branch 1 taken 1 time.
1 return ComponentType::Cooling;
131 }
132
133 2 std::vector<FuelType> DistrictCooling_Impl::coolingFuelTypes() const {
134
1/1
✓ Branch 1 taken 2 times.
6 return {FuelType::DistrictCooling};
135 }
136
137 ✗ std::vector<FuelType> DistrictCooling_Impl::heatingFuelTypes() const {
138 ✗ return {};
139 }
140
141 ✗ std::vector<AppGFuelType> DistrictCooling_Impl::appGHeatingFuelTypes() const {
142 ✗ return {};
143 }
144
145 } // namespace detail
146
147 7 DistrictCooling::DistrictCooling(const Model& model) : StraightComponent(DistrictCooling::iddObjectType(), model) {
148
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 5 not taken.
7 OS_ASSERT(getImpl<detail::DistrictCooling_Impl>());
149
1/1
✓ Branch 1 taken 7 times.
7 autosizeNominalCapacity();
150
151 {
152
1/1
✓ Branch 1 taken 7 times.
7 auto schedule = model.alwaysOnContinuousSchedule();
153
1/1
✓ Branch 1 taken 7 times.
7 const bool ok = setCapacityFractionSchedule(schedule);
154
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 3 not taken.
7 OS_ASSERT(ok);
155 7 }
156 7 }
157
158 7746 IddObjectType DistrictCooling::iddObjectType() {
159
1/1
✓ Branch 1 taken 7746 times.
7746 IddObjectType result(IddObjectType::OS_DistrictCooling);
160 7746 return result;
161 }
162
163 6 boost::optional<double> DistrictCooling::nominalCapacity() const {
164
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::DistrictCooling_Impl>()->nominalCapacity();
165 }
166
167 3 bool DistrictCooling::isNominalCapacityAutosized() const {
168
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::DistrictCooling_Impl>()->isNominalCapacityAutosized();
169 }
170
171 2 Schedule DistrictCooling::capacityFractionSchedule() const {
172
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::DistrictCooling_Impl>()->capacityFractionSchedule();
173 }
174
175 2 bool DistrictCooling::setNominalCapacity(double nominalCapacity) {
176
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::DistrictCooling_Impl>()->setNominalCapacity(nominalCapacity);
177 }
178
179 8 void DistrictCooling::autosizeNominalCapacity() {
180
1/1
✓ Branch 3 taken 8 times.
8 getImpl<detail::DistrictCooling_Impl>()->autosizeNominalCapacity();
181 8 }
182
183 8 bool DistrictCooling::setCapacityFractionSchedule(Schedule& schedule) {
184
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::DistrictCooling_Impl>()->setCapacityFractionSchedule(schedule);
185 }
186
187 /// @cond
188
189
1/1
✓ Branch 3 taken 3 times.
3 DistrictCooling::DistrictCooling(std::shared_ptr<detail::DistrictCooling_Impl> impl) : StraightComponent(std::move(impl)) {}
190 /// @endcond
191
192 ✗ boost::optional<double> DistrictCooling::autosizedNominalCapacity() const {
193 ✗ return getImpl<detail::DistrictCooling_Impl>()->autosizedNominalCapacity();
194 }
195
196 } // namespace model
197
198 } // namespace openstudio
199