GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 57.1% 105 / 0 / 184
Functions: 62.3% 33 / 0 / 53
Branches: 25.6% 55 / 0 / 215

src/model/GeneratorFuelCellElectricalStorage.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 "Model.hpp"
7 #include "Model_Impl.hpp"
8
9 #include "GeneratorFuelCellElectricalStorage.hpp"
10 #include "GeneratorFuelCellElectricalStorage_Impl.hpp"
11 #include "GeneratorFuelCell.hpp"
12 #include "GeneratorFuelCell_Impl.hpp"
13
14 #include <utilities/idd/IddFactory.hxx>
15 #include <utilities/idd/IddEnums.hxx>
16 #include <utilities/idd/OS_Generator_FuelCell_ElectricalStorage_FieldEnums.hxx>
17
18 #include "../utilities/units/Unit.hpp"
19
20 #include "../utilities/core/Assert.hpp"
21
22 namespace openstudio {
23 namespace model {
24
25 namespace detail {
26
27 8 GeneratorFuelCellElectricalStorage_Impl::GeneratorFuelCellElectricalStorage_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
28 8 : ModelObject_Impl(idfObject, model, keepHandle) {
29
4/6
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 8 times.
✗ Branch 13 not taken.
8 OS_ASSERT(idfObject.iddObject().type() == GeneratorFuelCellElectricalStorage::iddObjectType());
30 8 }
31
32 ✗ GeneratorFuelCellElectricalStorage_Impl::GeneratorFuelCellElectricalStorage_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
33 ✗ Model_Impl* model, bool keepHandle)
34 ✗ : ModelObject_Impl(other, model, keepHandle) {
35 ✗ OS_ASSERT(other.iddObject().type() == GeneratorFuelCellElectricalStorage::iddObjectType());
36 ✗ }
37
38 6 GeneratorFuelCellElectricalStorage_Impl::GeneratorFuelCellElectricalStorage_Impl(const GeneratorFuelCellElectricalStorage_Impl& other,
39 6 Model_Impl* model, bool keepHandle)
40 6 : ModelObject_Impl(other, model, keepHandle) {}
41
42 ✗ const std::vector<std::string>& GeneratorFuelCellElectricalStorage_Impl::outputVariableNames() const {
43 ✗ static const std::vector<std::string> result;
44 ✗ return result;
45 }
46
47 ✗ IddObjectType GeneratorFuelCellElectricalStorage_Impl::iddObjectType() const {
48 ✗ return GeneratorFuelCellElectricalStorage::iddObjectType();
49 }
50
51 // Get the parent GeneratorFuelCell
52 ✗ boost::optional<GeneratorFuelCell> GeneratorFuelCellElectricalStorage_Impl::fuelCell() const {
53
54 ✗ boost::optional<GeneratorFuelCell> fc;
55 // We use getModelObjectSources to check if more than one
56 ✗ std::vector<GeneratorFuelCell> fcs = getObject<ModelObject>().getModelObjectSources<GeneratorFuelCell>(GeneratorFuelCell::iddObjectType());
57
58 ✗ if (!fcs.empty()) {
59 ✗ if (fcs.size() > 1u) {
60 ✗ LOG(Error, briefDescription() << " is referenced by more than one GeneratorFuelCell, returning the first");
61 }
62 ✗ fc = fcs[0];
63 }
64 ✗ return fc;
65 ✗ }
66
67 4 std::string GeneratorFuelCellElectricalStorage_Impl::choiceofModel() const {
68
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<std::string> value = getString(OS_Generator_FuelCell_ElectricalStorageFields::ChoiceofModel, true);
69
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (!value) {
70 ✗ LOG_AND_THROW(" does not have choiceofModel");
71 }
72
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 return value.get();
73 4 }
74
75 4 double GeneratorFuelCellElectricalStorage_Impl::nominalChargingEnergeticEfficiency() const {
76
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<double> value = getDouble(OS_Generator_FuelCell_ElectricalStorageFields::NominalChargingEnergeticEfficiency, true);
77
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (!value) {
78 ✗ LOG_AND_THROW(" does not have nominalChargingEnergeticEfficiency");
79 }
80
1/1
✓ Branch 1 taken 4 times.
8 return value.get();
81 }
82
83 4 double GeneratorFuelCellElectricalStorage_Impl::nominalDischargingEnergeticEfficiency() const {
84
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<double> value = getDouble(OS_Generator_FuelCell_ElectricalStorageFields::NominalDischargingEnergeticEfficiency, true);
85
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (!value) {
86 ✗ LOG_AND_THROW(" does not have nominalDischargingEnergeticEfficiency");
87 }
88
1/1
✓ Branch 1 taken 4 times.
8 return value.get();
89 }
90
91 4 double GeneratorFuelCellElectricalStorage_Impl::simpleMaximumCapacity() const {
92
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<double> value = getDouble(OS_Generator_FuelCell_ElectricalStorageFields::SimpleMaximumCapacity, true);
93
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (!value) {
94 ✗ LOG_AND_THROW(" does not have simpleMaximumCapacity");
95 }
96
1/1
✓ Branch 1 taken 4 times.
8 return value.get();
97 }
98
99 4 double GeneratorFuelCellElectricalStorage_Impl::simpleMaximumPowerDraw() const {
100
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<double> value = getDouble(OS_Generator_FuelCell_ElectricalStorageFields::SimpleMaximumPowerDraw, true);
101
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (!value) {
102 ✗ LOG_AND_THROW(" does not have simpleMaximumPowerDraw");
103 }
104
1/1
✓ Branch 1 taken 4 times.
8 return value.get();
105 }
106
107 4 double GeneratorFuelCellElectricalStorage_Impl::simpleMaximumPowerStore() const {
108
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<double> value = getDouble(OS_Generator_FuelCell_ElectricalStorageFields::SimpleMaximumPowerStore, true);
109
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (!value) {
110 ✗ LOG_AND_THROW(" does not have simpleMaximumPowerStore.");
111 }
112
1/1
✓ Branch 1 taken 4 times.
8 return value.get();
113 }
114
115 4 double GeneratorFuelCellElectricalStorage_Impl::initialChargeState() const {
116
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<double> value = getDouble(OS_Generator_FuelCell_ElectricalStorageFields::InitialChargeState, true);
117
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (!value) {
118 ✗ LOG_AND_THROW(" does not have initialChargeState.");
119 }
120
1/1
✓ Branch 1 taken 4 times.
8 return value.get();
121 }
122
123 8 bool GeneratorFuelCellElectricalStorage_Impl::setChoiceofModel(const std::string& choiceofModel) {
124 8 bool result = setString(OS_Generator_FuelCell_ElectricalStorageFields::ChoiceofModel, choiceofModel);
125 8 return result;
126 }
127
128 ✗ void GeneratorFuelCellElectricalStorage_Impl::resetChoiceofModel() {
129 ✗ bool result = setString(OS_Generator_FuelCell_ElectricalStorageFields::ChoiceofModel, "SimpleEfficiencyWithConstraints");
130 ✗ OS_ASSERT(result);
131 ✗ }
132
133 8 bool GeneratorFuelCellElectricalStorage_Impl::setNominalChargingEnergeticEfficiency(double nominalChargingEnergeticEfficiency) {
134 8 bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::NominalChargingEnergeticEfficiency, nominalChargingEnergeticEfficiency);
135 8 return result;
136 }
137
138 ✗ void GeneratorFuelCellElectricalStorage_Impl::resetNominalChargingEnergeticEfficiency() {
139 ✗ bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::NominalChargingEnergeticEfficiency, 1.0);
140 ✗ OS_ASSERT(result);
141 ✗ }
142
143 8 bool GeneratorFuelCellElectricalStorage_Impl::setNominalDischargingEnergeticEfficiency(double nominalDischargingEnergeticEfficiency) {
144 bool result =
145 8 setDouble(OS_Generator_FuelCell_ElectricalStorageFields::NominalDischargingEnergeticEfficiency, nominalDischargingEnergeticEfficiency);
146 8 return result;
147 }
148
149 ✗ void GeneratorFuelCellElectricalStorage_Impl::resetNominalDischargingEnergeticEfficiency() {
150 ✗ bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::NominalDischargingEnergeticEfficiency, 1.0);
151 ✗ OS_ASSERT(result);
152 ✗ }
153
154 8 bool GeneratorFuelCellElectricalStorage_Impl::setSimpleMaximumCapacity(double simpleMaximumCapacity) {
155 8 bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::SimpleMaximumCapacity, simpleMaximumCapacity);
156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
157 8 return result;
158 }
159
160 ✗ void GeneratorFuelCellElectricalStorage_Impl::resetSimpleMaximumCapacity() {
161 ✗ bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::SimpleMaximumCapacity, 0);
162 ✗ OS_ASSERT(result);
163 ✗ }
164
165 8 bool GeneratorFuelCellElectricalStorage_Impl::setSimpleMaximumPowerDraw(double simpleMaximumPowerDraw) {
166 8 bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::SimpleMaximumPowerDraw, simpleMaximumPowerDraw);
167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
168 8 return result;
169 }
170
171 ✗ void GeneratorFuelCellElectricalStorage_Impl::resetSimpleMaximumPowerDraw() {
172 ✗ bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::SimpleMaximumPowerDraw, 0);
173 ✗ OS_ASSERT(result);
174 ✗ }
175
176 8 bool GeneratorFuelCellElectricalStorage_Impl::setSimpleMaximumPowerStore(double simpleMaximumPowerStore) {
177 8 bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::SimpleMaximumPowerStore, simpleMaximumPowerStore);
178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
179 8 return result;
180 }
181
182 ✗ void GeneratorFuelCellElectricalStorage_Impl::resetSimpleMaximumPowerStore() {
183 ✗ bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::SimpleMaximumPowerStore, 0);
184 ✗ OS_ASSERT(result);
185 ✗ }
186
187 8 bool GeneratorFuelCellElectricalStorage_Impl::setInitialChargeState(double initialChargeState) {
188 8 bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::InitialChargeState, initialChargeState);
189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
190 8 return result;
191 }
192
193 ✗ void GeneratorFuelCellElectricalStorage_Impl::resetInitialChargeState() {
194 ✗ bool result = setDouble(OS_Generator_FuelCell_ElectricalStorageFields::InitialChargeState, 0);
195 ✗ OS_ASSERT(result);
196 ✗ }
197
198 } // namespace detail
199
200 8 GeneratorFuelCellElectricalStorage::GeneratorFuelCellElectricalStorage(const Model& model)
201 8 : ModelObject(GeneratorFuelCellElectricalStorage::iddObjectType(), model) {
202
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 5 not taken.
8 OS_ASSERT(getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>());
203
204
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 setChoiceofModel("SimpleEfficiencyWithConstraints");
205
1/1
✓ Branch 1 taken 8 times.
8 setNominalChargingEnergeticEfficiency(1.0);
206
1/1
✓ Branch 1 taken 8 times.
8 setNominalDischargingEnergeticEfficiency(1.0);
207
1/1
✓ Branch 1 taken 8 times.
8 setSimpleMaximumCapacity(0);
208
1/1
✓ Branch 1 taken 8 times.
8 setSimpleMaximumPowerDraw(0);
209
1/1
✓ Branch 1 taken 8 times.
8 setSimpleMaximumPowerStore(0);
210
1/1
✓ Branch 1 taken 8 times.
8 setInitialChargeState(0);
211 8 }
212
213 7744 IddObjectType GeneratorFuelCellElectricalStorage::iddObjectType() {
214
1/1
✓ Branch 1 taken 7744 times.
7744 return {IddObjectType::OS_Generator_FuelCell_ElectricalStorage};
215 }
216
217 ✗ std::vector<std::string> GeneratorFuelCellElectricalStorage::choiceofModelValues() {
218 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Generator_FuelCell_ElectricalStorageFields::ChoiceofModel);
219 }
220
221 ✗ boost::optional<GeneratorFuelCell> GeneratorFuelCellElectricalStorage::fuelCell() const {
222 ✗ return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->fuelCell();
223 }
224
225 4 std::string GeneratorFuelCellElectricalStorage::choiceofModel() const {
226
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->choiceofModel();
227 }
228
229 4 double GeneratorFuelCellElectricalStorage::nominalChargingEnergeticEfficiency() const {
230
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->nominalChargingEnergeticEfficiency();
231 }
232
233 4 double GeneratorFuelCellElectricalStorage::nominalDischargingEnergeticEfficiency() const {
234
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->nominalDischargingEnergeticEfficiency();
235 }
236
237 4 double GeneratorFuelCellElectricalStorage::simpleMaximumCapacity() const {
238
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->simpleMaximumCapacity();
239 }
240
241 4 double GeneratorFuelCellElectricalStorage::simpleMaximumPowerDraw() const {
242
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->simpleMaximumPowerDraw();
243 }
244
245 4 double GeneratorFuelCellElectricalStorage::simpleMaximumPowerStore() const {
246
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->simpleMaximumPowerStore();
247 }
248
249 4 double GeneratorFuelCellElectricalStorage::initialChargeState() const {
250
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->initialChargeState();
251 }
252
253 8 bool GeneratorFuelCellElectricalStorage::setChoiceofModel(const std::string& choiceofModel) {
254
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->setChoiceofModel(choiceofModel);
255 }
256
257 ✗ void GeneratorFuelCellElectricalStorage::resetChoiceofModel() {
258 ✗ getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->resetChoiceofModel();
259 ✗ }
260
261 8 bool GeneratorFuelCellElectricalStorage::setNominalChargingEnergeticEfficiency(double nominalChargingEnergeticEfficiency) {
262
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->setNominalChargingEnergeticEfficiency(nominalChargingEnergeticEfficiency);
263 }
264
265 ✗ void GeneratorFuelCellElectricalStorage::resetNominalChargingEnergeticEfficiency() {
266 ✗ getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->resetNominalChargingEnergeticEfficiency();
267 ✗ }
268
269 8 bool GeneratorFuelCellElectricalStorage::setNominalDischargingEnergeticEfficiency(double nominalDischargingEnergeticEfficiency) {
270
1/1
✓ Branch 3 taken 8 times.
16 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->setNominalDischargingEnergeticEfficiency(
271 16 nominalDischargingEnergeticEfficiency);
272 }
273
274 ✗ void GeneratorFuelCellElectricalStorage::resetNominalDischargingEnergeticEfficiency() {
275 ✗ getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->resetNominalDischargingEnergeticEfficiency();
276 ✗ }
277
278 8 bool GeneratorFuelCellElectricalStorage::setSimpleMaximumCapacity(double simpleMaximumCapacity) {
279
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->setSimpleMaximumCapacity(simpleMaximumCapacity);
280 }
281
282 ✗ void GeneratorFuelCellElectricalStorage::resetSimpleMaximumCapacity() {
283 ✗ getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->resetSimpleMaximumCapacity();
284 ✗ }
285
286 8 bool GeneratorFuelCellElectricalStorage::setSimpleMaximumPowerDraw(double simpleMaximumPowerDraw) {
287
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->setSimpleMaximumPowerDraw(simpleMaximumPowerDraw);
288 }
289
290 ✗ void GeneratorFuelCellElectricalStorage::resetSimpleMaximumPowerDraw() {
291 ✗ getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->resetSimpleMaximumPowerDraw();
292 ✗ }
293
294 8 bool GeneratorFuelCellElectricalStorage::setSimpleMaximumPowerStore(double simpleMaximumPowerStore) {
295
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->setSimpleMaximumPowerStore(simpleMaximumPowerStore);
296 }
297
298 ✗ void GeneratorFuelCellElectricalStorage::resetSimpleMaximumPowerStore() {
299 ✗ getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->resetSimpleMaximumPowerStore();
300 ✗ }
301
302 8 bool GeneratorFuelCellElectricalStorage::setInitialChargeState(double initialChargeState) {
303
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->setInitialChargeState(initialChargeState);
304 }
305
306 ✗ void GeneratorFuelCellElectricalStorage::resetInitialChargeState() {
307 ✗ getImpl<detail::GeneratorFuelCellElectricalStorage_Impl>()->resetInitialChargeState();
308 ✗ }
309
310 /// @cond
311 16 GeneratorFuelCellElectricalStorage::GeneratorFuelCellElectricalStorage(std::shared_ptr<detail::GeneratorFuelCellElectricalStorage_Impl> impl)
312
1/1
✓ Branch 3 taken 16 times.
16 : ModelObject(std::move(impl)) {}
313 /// @endcond
314
315 } // namespace model
316 } // namespace openstudio
317