GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 79.6% 437 / 0 / 549
Functions: 92.2% 141 / 0 / 153
Branches: 40.2% 266 / 0 / 662

src/model/ElectricLoadCenterDistribution.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 "ElectricLoadCenterDistribution.hpp"
7 #include "ElectricLoadCenterDistribution_Impl.hpp"
8
9 #include "Model.hpp"
10 #include "ModelObjectList.hpp"
11 #include "ModelObjectList_Impl.hpp"
12 #include "Schedule.hpp"
13 #include "Schedule_Impl.hpp"
14 #include "Generator.hpp"
15 #include "Generator_Impl.hpp"
16 #include "Inverter.hpp"
17 #include "Inverter_Impl.hpp"
18 #include "ElectricalStorage.hpp"
19 #include "ElectricalStorage_Impl.hpp"
20 #include "ScheduleTypeLimits.hpp"
21 #include "ScheduleTypeRegistry.hpp"
22 #include "ElectricLoadCenterStorageConverter.hpp"
23 #include "ElectricLoadCenterStorageConverter_Impl.hpp"
24 #include "ElectricLoadCenterTransformer.hpp"
25 #include "ElectricLoadCenterTransformer_Impl.hpp"
26 #include "ScheduleTypeLimits.hpp"
27 #include "ScheduleTypeRegistry.hpp"
28
29 #include <utilities/idd/IddFactory.hxx>
30 #include <utilities/idd/IddEnums.hxx>
31 #include <utilities/idd/OS_ElectricLoadCenter_Distribution_FieldEnums.hxx>
32
33 #include "../utilities/units/Unit.hpp"
34
35 #include "../utilities/core/Assert.hpp"
36
37 namespace openstudio {
38 namespace model {
39
40 namespace detail {
41
42 39 ElectricLoadCenterDistribution_Impl::ElectricLoadCenterDistribution_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
43 39 : ParentObject_Impl(idfObject, model, keepHandle) {
44
4/6
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
✓ Branch 7 taken 39 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 39 times.
✗ Branch 13 not taken.
39 OS_ASSERT(idfObject.iddObject().type() == ElectricLoadCenterDistribution::iddObjectType());
45 39 }
46
47 1 ElectricLoadCenterDistribution_Impl::ElectricLoadCenterDistribution_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
48 1 bool keepHandle)
49 1 : ParentObject_Impl(other, model, keepHandle) {
50
4/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
1 OS_ASSERT(other.iddObject().type() == ElectricLoadCenterDistribution::iddObjectType());
51 1 }
52
53 12 ElectricLoadCenterDistribution_Impl::ElectricLoadCenterDistribution_Impl(const ElectricLoadCenterDistribution_Impl& other, Model_Impl* model,
54 12 bool keepHandle)
55 12 : ParentObject_Impl(other, model, keepHandle) {}
56
57 ✗ const std::vector<std::string>& ElectricLoadCenterDistribution_Impl::outputVariableNames() const {
58 static const std::vector<std::string> result{"Electric Load Center Requested Electricity Rate",
59 "Electric Load Center Produced Electricity Rate",
60 "Electric Load Center Produced Electricity Energy", "Electric Load Center Produced Thermal Rate",
61 ✗ "Electric Load Center Produced Thermal Energy"};
62 ✗ return result;
63 ✗ }
64
65 ✗ IddObjectType ElectricLoadCenterDistribution_Impl::iddObjectType() const {
66 ✗ return ElectricLoadCenterDistribution::iddObjectType();
67 }
68
69 ✗ std::vector<ScheduleTypeKey> ElectricLoadCenterDistribution_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
70 // TODO: Check schedule display names.
71 ✗ std::vector<ScheduleTypeKey> result;
72 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
73 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
74 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
75 ✗ if (std::find(b, e, OS_ElectricLoadCenter_DistributionFields::TrackScheduleNameSchemeScheduleName) != e) {
76 ✗ result.push_back(ScheduleTypeKey("ElectricLoadCenterDistribution", "Track Scheme"));
77 }
78 ✗ if (std::find(b, e, OS_ElectricLoadCenter_DistributionFields::StorageChargePowerFractionScheduleName) != e) {
79 ✗ result.push_back(ScheduleTypeKey("ElectricLoadCenterDistribution", "Storage Charge Power Fraction"));
80 }
81 ✗ if (std::find(b, e, OS_ElectricLoadCenter_DistributionFields::StorageDischargePowerFractionScheduleName) != e) {
82 ✗ result.push_back(ScheduleTypeKey("ElectricLoadCenterDistribution", "Storage Discharge Power Fraction"));
83 }
84 ✗ if (std::find(b, e, OS_ElectricLoadCenter_DistributionFields::StorageControlUtilityDemandTargetFractionScheduleName) != e) {
85 ✗ result.push_back(ScheduleTypeKey("ElectricLoadCenterDistribution", "Storage Control Utility Demand Target Fraction"));
86 }
87 ✗ return result;
88 ✗ }
89
90 19 std::vector<ModelObject> ElectricLoadCenterDistribution_Impl::children() const {
91 19 std::vector<ModelObject> result;
92
2/2
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
19 result.push_back(generatorModelObjectList());
93
3/3
✓ Branch 1 taken 19 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 14 times.
38 if (boost::optional<Inverter> optInverter = inverter()) {
94
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 result.push_back(optInverter.get());
95 19 }
96
3/3
✓ Branch 1 taken 19 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 17 times.
38 if (boost::optional<ElectricalStorage> optElectricalStorage = electricalStorage()) {
97
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 result.push_back(optElectricalStorage.get());
98 19 }
99
3/3
✓ Branch 1 taken 19 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 17 times.
38 if (boost::optional<ElectricLoadCenterTransformer> optElectricLoadCenterTransformer = transformer()) {
100
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 result.push_back(optElectricLoadCenterTransformer.get());
101 19 }
102 19 return result;
103 ✗ }
104
105 7 std::vector<openstudio::IdfObject> ElectricLoadCenterDistribution_Impl::remove() {
106 7 return ParentObject_Impl::remove();
107 }
108
109 ✗ std::vector<IddObjectType> ElectricLoadCenterDistribution_Impl::allowableChildTypes() const {
110 ✗ return {};
111 }
112
113 ✗ ModelObject ElectricLoadCenterDistribution_Impl::clone(Model model) const {
114 // should this also clone the generators, inverters, and storage?
115 ✗ return ParentObject_Impl::clone(model);
116 }
117
118 59 std::vector<Generator> ElectricLoadCenterDistribution_Impl::generators() const {
119 59 std::vector<Generator> result;
120
4/4
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 12 taken 46 times.
✓ Branch 13 taken 59 times.
105 for (const auto& modelObject : generatorModelObjectList().modelObjects()) {
121
2/3
✓ Branch 1 taken 46 times.
✓ Branch 3 taken 46 times.
✗ Branch 4 not taken.
92 if (auto generator_ = modelObject.optionalCast<Generator>()) {
122
2/2
✓ Branch 1 taken 46 times.
✓ Branch 4 taken 46 times.
46 result.push_back(generator_.get());
123 46 }
124 59 }
125 59 return result;
126 ✗ }
127
128 12 std::string ElectricLoadCenterDistribution_Impl::generatorOperationSchemeType() const {
129
1/1
✓ Branch 1 taken 12 times.
12 boost::optional<std::string> value = getString(OS_ElectricLoadCenter_DistributionFields::GeneratorOperationSchemeType, true);
130
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 4 not taken.
12 OS_ASSERT(value);
131
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 return value.get();
132 12 }
133
134 5 bool ElectricLoadCenterDistribution_Impl::isGeneratorOperationSchemeTypeDefaulted() const {
135 5 return isEmpty(OS_ElectricLoadCenter_DistributionFields::GeneratorOperationSchemeType);
136 }
137
138 12 boost::optional<double> ElectricLoadCenterDistribution_Impl::demandLimitSchemePurchasedElectricDemandLimit() const {
139 12 return getDouble(OS_ElectricLoadCenter_DistributionFields::DemandLimitSchemePurchasedElectricDemandLimit, false);
140 }
141
142 12 boost::optional<Schedule> ElectricLoadCenterDistribution_Impl::trackScheduleSchemeSchedule() const {
143
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_ElectricLoadCenter_DistributionFields::TrackScheduleNameSchemeScheduleName);
144 }
145
146 12 boost::optional<std::string> ElectricLoadCenterDistribution_Impl::trackMeterSchemeMeterName() const {
147 12 return getString(OS_ElectricLoadCenter_DistributionFields::TrackMeterSchemeMeterName, true, true);
148 }
149
150 16 std::string ElectricLoadCenterDistribution_Impl::electricalBussType() const {
151
1/1
✓ Branch 1 taken 16 times.
16 boost::optional<std::string> value = getString(OS_ElectricLoadCenter_DistributionFields::ElectricalBussType, true);
152
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 4 not taken.
16 OS_ASSERT(value);
153
2/2
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
32 return value.get();
154 16 }
155
156 94 bool ElectricLoadCenterDistribution_Impl::isElectricalBussTypeDefaulted() const {
157 94 return isEmpty(OS_ElectricLoadCenter_DistributionFields::ElectricalBussType);
158 }
159
160 62 boost::optional<Inverter> ElectricLoadCenterDistribution_Impl::inverter() const {
161
2/2
✓ Branch 1 taken 62 times.
✓ Branch 4 taken 62 times.
62 return getObject<ModelObject>().getModelObjectTarget<Inverter>(OS_ElectricLoadCenter_DistributionFields::InverterName);
162 }
163
164 39 boost::optional<ElectricalStorage> ElectricLoadCenterDistribution_Impl::electricalStorage() const {
165
2/2
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
39 return getObject<ModelObject>().getModelObjectTarget<ElectricalStorage>(OS_ElectricLoadCenter_DistributionFields::ElectricalStorageObjectName);
166 }
167
168 35 boost::optional<ElectricLoadCenterTransformer> ElectricLoadCenterDistribution_Impl::transformer() const {
169
1/1
✓ Branch 1 taken 35 times.
70 return getObject<ModelObject>().getModelObjectTarget<ElectricLoadCenterTransformer>(
170
1/1
✓ Branch 1 taken 35 times.
70 OS_ElectricLoadCenter_DistributionFields::TransformerObjectName);
171 }
172
173 // Storage Operation Scheme, defaults to TrackFacilityElectricDemandStoreExcessOnSite
174 4 std::string ElectricLoadCenterDistribution_Impl::storageOperationScheme() const {
175
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<std::string> value = getString(OS_ElectricLoadCenter_DistributionFields::StorageOperationScheme, true);
176
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(value);
177
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 return value.get();
178 4 }
179
180 5 bool ElectricLoadCenterDistribution_Impl::isStorageOperationSchemeDefaulted() const {
181 5 return isEmpty(OS_ElectricLoadCenter_DistributionFields::StorageOperationScheme);
182 }
183 // Storage Control Track Meter Name, required if operation = TrackMeterDemandStoreExcessOnSite
184 4 boost::optional<std::string> ElectricLoadCenterDistribution_Impl::storageControlTrackMeterName() const {
185 4 return getString(OS_ElectricLoadCenter_DistributionFields::StorageControlTrackMeterName, true, true);
186 }
187
188 // Storage Converter Object Name
189 3 boost::optional<ElectricLoadCenterStorageConverter> ElectricLoadCenterDistribution_Impl::storageConverter() const {
190
1/1
✓ Branch 1 taken 3 times.
6 return getObject<ModelObject>().getModelObjectTarget<ElectricLoadCenterStorageConverter>(
191
1/1
✓ Branch 1 taken 3 times.
6 OS_ElectricLoadCenter_DistributionFields::StorageConverterObjectName);
192 }
193
194 // Maximum Storage State of Charge Fraction, required if storage, defaults
195 4 double ElectricLoadCenterDistribution_Impl::maximumStorageStateofChargeFraction() const {
196
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<double> value = getDouble(OS_ElectricLoadCenter_DistributionFields::MaximumStorageStateofChargeFraction, true);
197
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(value);
198
1/1
✓ Branch 1 taken 4 times.
8 return value.get();
199 }
200
201 3 bool ElectricLoadCenterDistribution_Impl::isMaximumStorageStateofChargeFractionDefaulted() const {
202 3 return isEmpty(OS_ElectricLoadCenter_DistributionFields::MaximumStorageStateofChargeFraction);
203 }
204
205 // Minimum Storage State of Charge Fraction, required if storage, defaults
206 4 double ElectricLoadCenterDistribution_Impl::minimumStorageStateofChargeFraction() const {
207
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<double> value = getDouble(OS_ElectricLoadCenter_DistributionFields::MinimumStorageStateofChargeFraction, true);
208
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(value);
209
1/1
✓ Branch 1 taken 4 times.
8 return value.get();
210 }
211 3 bool ElectricLoadCenterDistribution_Impl::isMinimumStorageStateofChargeFractionDefaulted() const {
212 3 return isEmpty(OS_ElectricLoadCenter_DistributionFields::MinimumStorageStateofChargeFraction);
213 }
214
215 // Design Storage Control Charge Power, required if FacilityDemandLeveling or TrackChargeDischargeSchedules
216 6 boost::optional<double> ElectricLoadCenterDistribution_Impl::designStorageControlChargePower() const {
217 6 return getDouble(OS_ElectricLoadCenter_DistributionFields::DesignStorageControlChargePower, true);
218 }
219
220 // Storage Charge Power Fraction Schedule Name, required if TrackChargeDischargeSchedules
221 // TODO: do I want to default that to daytime?
222 6 boost::optional<Schedule> ElectricLoadCenterDistribution_Impl::storageChargePowerFractionSchedule() const {
223
1/1
✓ Branch 1 taken 6 times.
12 return getObject<ModelObject>().getModelObjectTarget<Schedule>(
224
1/1
✓ Branch 1 taken 6 times.
12 OS_ElectricLoadCenter_DistributionFields::StorageChargePowerFractionScheduleName);
225 }
226
227 // Design Storage Control Discharge Power, required if FacilityDemandLeveling or TrackChargeDischargeSchedules
228 6 boost::optional<double> ElectricLoadCenterDistribution_Impl::designStorageControlDischargePower() const {
229 6 return getDouble(OS_ElectricLoadCenter_DistributionFields::DesignStorageControlDischargePower, true);
230 }
231
232 // Storage Charge Power Fraction Schedule Name, required if TrackChargeDischargeSchedules
233 // TODO: do I want to default that to daytime?
234 6 boost::optional<Schedule> ElectricLoadCenterDistribution_Impl::storageDischargePowerFractionSchedule() const {
235
1/1
✓ Branch 1 taken 6 times.
12 return getObject<ModelObject>().getModelObjectTarget<Schedule>(
236
1/1
✓ Branch 1 taken 6 times.
12 OS_ElectricLoadCenter_DistributionFields::StorageDischargePowerFractionScheduleName);
237 }
238
239 // Storage Control Utility Demand Target, required if FacilityDemandLeveling
240 4 boost::optional<double> ElectricLoadCenterDistribution_Impl::storageControlUtilityDemandTarget() const {
241 4 return getDouble(OS_ElectricLoadCenter_DistributionFields::StorageControlUtilityDemandTarget, true);
242 }
243
244 // Storage Control Utility Demand Target Fraction Schedule Name, will be used only if FacilityDemandLeveling, defaults to 1.0
245 2 Schedule ElectricLoadCenterDistribution_Impl::storageControlUtilityDemandTargetFractionSchedule() const {
246
1/1
✓ Branch 1 taken 2 times.
4 boost::optional<Schedule> sch = getObject<ModelObject>().getModelObjectTarget<Schedule>(
247
1/1
✓ Branch 1 taken 2 times.
2 OS_ElectricLoadCenter_DistributionFields::StorageControlUtilityDemandTargetFractionScheduleName);
248
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 if (sch) {
249
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return sch.get();
250 } else {
251
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return this->model().alwaysOnDiscreteSchedule();
252 }
253 2 }
254
255 3 bool ElectricLoadCenterDistribution_Impl::isStorageControlUtilityDemandTargetFractionScheduleDefaulted() const {
256 3 return isEmpty(OS_ElectricLoadCenter_DistributionFields::StorageControlUtilityDemandTargetFractionScheduleName);
257 }
258
259 /// Setters
260
261 39 bool ElectricLoadCenterDistribution_Impl::addGenerator(const Generator& generator) {
262
1/1
✓ Branch 1 taken 39 times.
39 if (!isElectricalBussTypeDefaulted()) {
263 // todo: check that generator is ok on this buss type
264 }
265
266
1/1
✓ Branch 1 taken 39 times.
39 ModelObjectList list = generatorModelObjectList();
267
3/3
✓ Branch 1 taken 39 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 37 times.
39 if (list.hasModelObject(generator)) {
268 2 return false;
269 }
270
271 // previous load center
272
1/1
✓ Branch 1 taken 37 times.
37 boost::optional<ElectricLoadCenterDistribution> previous = generator.electricLoadCenterDistribution();
273
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 31 times.
37 if (previous) {
274
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 previous->removeGenerator(generator);
275 }
276
277 // DLM: may have problems with signals here if inverter is temporarily on two load centers
278
2/2
✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
37 bool result = generatorModelObjectList().addModelObject(generator);
279
280
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (result) {
281
1/1
✓ Branch 1 taken 37 times.
37 if (isElectricalBussTypeDefaulted()) {
282 // TODO: update bus type
283 }
284 } else {
285 ✗ if (previous) {
286 ✗ bool test = previous->addGenerator(generator);
287 ✗ OS_ASSERT(test);
288 }
289 }
290
291 37 return result;
292 39 }
293
294 16 bool ElectricLoadCenterDistribution_Impl::removeGenerator(const Generator& generator) {
295
1/1
✓ Branch 1 taken 16 times.
16 ModelObjectList list = generatorModelObjectList();
296
3/3
✓ Branch 1 taken 16 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 14 times.
16 if (!list.hasModelObject(generator)) {
297 2 return false;
298 }
299
300
2/2
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
14 generatorModelObjectList().removeModelObject(generator);
301
302
3/3
✓ Branch 1 taken 14 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 3 times.
14 if (list.size() == 0) {
303
1/1
✓ Branch 1 taken 11 times.
11 resetElectricalBussType();
304 }
305
306 14 return true;
307 16 }
308
309 ✗ void ElectricLoadCenterDistribution_Impl::resetGenerators() {
310 ✗ generatorModelObjectList().removeAllModelObjects();
311 ✗ resetElectricalBussType();
312 ✗ }
313
314 3 bool ElectricLoadCenterDistribution_Impl::setGeneratorOperationSchemeType(const std::string& generatorOperationSchemeType) {
315 3 return setString(OS_ElectricLoadCenter_DistributionFields::GeneratorOperationSchemeType, generatorOperationSchemeType);
316 }
317
318 2 void ElectricLoadCenterDistribution_Impl::resetGeneratorOperationSchemeType() {
319
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 bool result = setString(OS_ElectricLoadCenter_DistributionFields::GeneratorOperationSchemeType, "");
320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
321 2 }
322
323 2 bool ElectricLoadCenterDistribution_Impl::setDemandLimitSchemePurchasedElectricDemandLimit(double demandLimitSchemePurchasedElectricDemandLimit) {
324 2 bool result = setDouble(OS_ElectricLoadCenter_DistributionFields::DemandLimitSchemePurchasedElectricDemandLimit,
325 demandLimitSchemePurchasedElectricDemandLimit);
326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
327 2 return result;
328 }
329
330 1 void ElectricLoadCenterDistribution_Impl::resetDemandLimitSchemePurchasedElectricDemandLimit() {
331
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::DemandLimitSchemePurchasedElectricDemandLimit, "");
332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
333 1 }
334
335 1 bool ElectricLoadCenterDistribution_Impl::setTrackScheduleSchemeSchedule(Schedule& schedule) {
336
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
4 bool result = setSchedule(OS_ElectricLoadCenter_DistributionFields::TrackScheduleNameSchemeScheduleName, "ElectricLoadCenterDistribution",
337 "Track Scheme", schedule);
338 1 return result;
339 }
340
341 1 void ElectricLoadCenterDistribution_Impl::resetTrackScheduleSchemeSchedule() {
342
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::TrackScheduleNameSchemeScheduleName, "");
343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
344 1 }
345
346 1 bool ElectricLoadCenterDistribution_Impl::setTrackMeterSchemeMeterName(const std::string& trackMeterSchemeMeterName) {
347 1 return setString(OS_ElectricLoadCenter_DistributionFields::TrackMeterSchemeMeterName, trackMeterSchemeMeterName);
348 }
349
350 1 void ElectricLoadCenterDistribution_Impl::resetTrackMeterSchemeMeterName() {
351
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::TrackMeterSchemeMeterName, "");
352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
353 1 }
354
355 13 bool ElectricLoadCenterDistribution_Impl::setElectricalBussType(const std::string& electricalBussType) {
356 13 bool result = setString(OS_ElectricLoadCenter_DistributionFields::ElectricalBussType, electricalBussType);
357 13 return result;
358 }
359
360 12 void ElectricLoadCenterDistribution_Impl::resetElectricalBussType() {
361
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 bool result = setString(OS_ElectricLoadCenter_DistributionFields::ElectricalBussType, "");
362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 OS_ASSERT(result);
363 12 }
364
365 13 bool ElectricLoadCenterDistribution_Impl::setInverter(const Inverter& inverter) {
366
367
1/1
✓ Branch 1 taken 13 times.
13 if (!isElectricalBussTypeDefaulted()) {
368 // todo: check that inverter is ok on this buss type
369 }
370
371 // previous load center
372
1/1
✓ Branch 1 taken 13 times.
13 boost::optional<ElectricLoadCenterDistribution> previous = inverter.electricLoadCenterDistribution();
373
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 12 times.
13 if (previous) {
374
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 previous->resetInverter();
375 }
376
377 // DLM: may have problems with signals here if inverter is temporarily on two load centers
378
2/2
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
13 bool result = setPointer(OS_ElectricLoadCenter_DistributionFields::InverterName, inverter.handle());
379
380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (result) {
381
382 // TODO: update bus type
383
384 } else {
385
386 ✗ if (previous) {
387 ✗ bool test = previous->setInverter(inverter);
388 ✗ OS_ASSERT(test);
389 }
390 }
391
392 13 return result;
393 13 }
394
395 4 void ElectricLoadCenterDistribution_Impl::resetInverter() {
396
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 bool result = setString(OS_ElectricLoadCenter_DistributionFields::InverterName, "");
397
398 // TODO: update bus type
399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 OS_ASSERT(result);
400 4 }
401
402 4 bool ElectricLoadCenterDistribution_Impl::setElectricalStorage(const ElectricalStorage& electricalStorage) {
403
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 return setPointer(OS_ElectricLoadCenter_DistributionFields::ElectricalStorageObjectName, electricalStorage.handle());
404 }
405
406 2 void ElectricLoadCenterDistribution_Impl::resetElectricalStorage() {
407
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 bool result = setString(OS_ElectricLoadCenter_DistributionFields::ElectricalStorageObjectName, "");
408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
409 2 }
410
411 3 bool ElectricLoadCenterDistribution_Impl::setTransformer(const ElectricLoadCenterTransformer& transformer) {
412
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 return setPointer(OS_ElectricLoadCenter_DistributionFields::TransformerObjectName, transformer.handle());
413 }
414
415 1 void ElectricLoadCenterDistribution_Impl::resetTransformer() {
416
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::TransformerObjectName, "");
417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
418 1 }
419
420 184 ModelObjectList ElectricLoadCenterDistribution_Impl::generatorModelObjectList() const {
421 boost::optional<ModelObjectList> result =
422
2/2
✓ Branch 1 taken 184 times.
✓ Branch 4 taken 184 times.
184 getObject<ModelObject>().getModelObjectTarget<ModelObjectList>(OS_ElectricLoadCenter_DistributionFields::GeneratorListName);
423
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 184 times.
✗ Branch 4 not taken.
184 OS_ASSERT(result);
424
2/2
✓ Branch 1 taken 184 times.
✓ Branch 4 taken 184 times.
368 return result.get();
425 184 }
426
427 // Storage Operation Scheme
428 2 bool ElectricLoadCenterDistribution_Impl::setStorageOperationScheme(const std::string& operationScheme) {
429 2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::StorageOperationScheme, operationScheme);
430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
431 2 return result;
432 }
433
434 1 void ElectricLoadCenterDistribution_Impl::resetStorageOperationScheme() {
435
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::StorageOperationScheme, "");
436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
437 1 }
438
439 // Storage Control Track Meter Name, required if operation = TrackMeterDemandStoreExcessOnSite
440 1 bool ElectricLoadCenterDistribution_Impl::setStorageControlTrackMeterName(const std::string& meterName) {
441 1 return setString(OS_ElectricLoadCenter_DistributionFields::StorageControlTrackMeterName, meterName);
442 }
443
444 1 void ElectricLoadCenterDistribution_Impl::resetStorageControlTrackMeterName() {
445
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::StorageControlTrackMeterName, "");
446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
447 1 }
448
449 // Storage Converter Object Name
450 2 bool ElectricLoadCenterDistribution_Impl::setStorageConverter(const ElectricLoadCenterStorageConverter& converter) {
451
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return setPointer(OS_ElectricLoadCenter_DistributionFields::StorageConverterObjectName, converter.handle());
452 }
453
454 1 void ElectricLoadCenterDistribution_Impl::resetStorageConverter() {
455
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::StorageConverterObjectName, "");
456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
457 1 }
458
459 // Maximum Storage State of Charge Fraction, required if storage, defaults
460 1 bool ElectricLoadCenterDistribution_Impl::setMaximumStorageStateofChargeFraction(const double maxStateofCharge) {
461 1 bool result = setDouble(OS_ElectricLoadCenter_DistributionFields::MaximumStorageStateofChargeFraction, maxStateofCharge);
462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
463 1 return result;
464 }
465 1 void ElectricLoadCenterDistribution_Impl::resetMaximumStorageStateofChargeFraction() {
466
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::MaximumStorageStateofChargeFraction, "");
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
468 1 }
469
470 // Minimum Storage State of Charge Fraction, required if storage, defaults
471 1 bool ElectricLoadCenterDistribution_Impl::setMinimumStorageStateofChargeFraction(const double minStateofCharge) {
472 1 bool result = setDouble(OS_ElectricLoadCenter_DistributionFields::MinimumStorageStateofChargeFraction, minStateofCharge);
473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
474 1 return result;
475 }
476 1 void ElectricLoadCenterDistribution_Impl::resetMinimumStorageStateofChargeFraction() {
477
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::MinimumStorageStateofChargeFraction, "");
478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
479 1 }
480
481 // Design Storage Control Charge Power, required if FacilityDemandLeveling or TrackChargeDischargeSchedules
482 2 bool ElectricLoadCenterDistribution_Impl::setDesignStorageControlChargePower(const double designStorageControlChargePower) {
483 2 bool result = setDouble(OS_ElectricLoadCenter_DistributionFields::DesignStorageControlChargePower, designStorageControlChargePower);
484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
485 2 return result;
486 }
487 1 void ElectricLoadCenterDistribution_Impl::resetDesignStorageControlChargePower() {
488
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::DesignStorageControlChargePower, "");
489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
490 1 }
491
492 // Storage Charge Power Fraction Schedule Name, required if TrackChargeDischargeSchedules
493 // TODO: do I want to default that to daytime?
494 1 bool ElectricLoadCenterDistribution_Impl::setStorageChargePowerFractionSchedule(Schedule& schedule) {
495
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
4 bool result = setSchedule(OS_ElectricLoadCenter_DistributionFields::StorageChargePowerFractionScheduleName, "ElectricLoadCenterDistribution",
496 "Storage Charge Power Fraction", schedule);
497 1 return result;
498 }
499
500 1 void ElectricLoadCenterDistribution_Impl::resetStorageChargePowerFractionSchedule() {
501
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::StorageChargePowerFractionScheduleName, "");
502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
503 1 }
504
505 // Design Storage Control Discharge Power, required if FacilityDemandLeveling or TrackChargeDischargeSchedules
506 2 bool ElectricLoadCenterDistribution_Impl::setDesignStorageControlDischargePower(const double designStorageControlDischargePower) {
507 2 bool result = setDouble(OS_ElectricLoadCenter_DistributionFields::DesignStorageControlDischargePower, designStorageControlDischargePower);
508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
509 2 return result;
510 }
511 1 void ElectricLoadCenterDistribution_Impl::resetDesignStorageControlDischargePower() {
512
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::DesignStorageControlDischargePower, "");
513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
514 1 }
515
516 // Storage Charge Power Fraction Schedule Name, required if TrackChargeDischargeSchedules
517 // TODO: do I want to default that to daytime?
518 1 bool ElectricLoadCenterDistribution_Impl::setStorageDischargePowerFractionSchedule(Schedule& schedule) {
519
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
4 bool result = setSchedule(OS_ElectricLoadCenter_DistributionFields::StorageDischargePowerFractionScheduleName, "ElectricLoadCenterDistribution",
520 "Storage Discharge Power Fraction", schedule);
521 1 return result;
522 }
523
524 1 void ElectricLoadCenterDistribution_Impl::resetStorageDischargePowerFractionSchedule() {
525
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::StorageDischargePowerFractionScheduleName, "");
526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
527 1 }
528
529 // Storage Control Utility Demand Target, required if FacilityDemandLeveling
530 1 bool ElectricLoadCenterDistribution_Impl::setStorageControlUtilityDemandTarget(const double storageControlUtilityDemandTarget) {
531 1 bool result = setDouble(OS_ElectricLoadCenter_DistributionFields::StorageControlUtilityDemandTarget, storageControlUtilityDemandTarget);
532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
533 1 return result;
534 }
535 1 void ElectricLoadCenterDistribution_Impl::resetStorageControlUtilityDemandTarget() {
536
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::StorageControlUtilityDemandTarget, "");
537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
538 1 }
539
540 // Storage Control Utility Demand Target Fraction Schedule Name, will be used only if FacilityDemandLeveling, defaults to 1.0
541 1 bool ElectricLoadCenterDistribution_Impl::setStorageControlUtilityDemandTargetFractionSchedule(Schedule& schedule) {
542
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
4 bool result = setSchedule(OS_ElectricLoadCenter_DistributionFields::StorageControlUtilityDemandTargetFractionScheduleName,
543 "ElectricLoadCenterDistribution", "Storage Control Utility Demand Target Fraction", schedule);
544 1 return result;
545 }
546
547 1 void ElectricLoadCenterDistribution_Impl::resetStorageControlUtilityDemandTargetFractionSchedule() {
548
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_ElectricLoadCenter_DistributionFields::StorageControlUtilityDemandTargetFractionScheduleName, "");
549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
550 1 }
551
552 // Validity Checking
553 ✗ bool ElectricLoadCenterDistribution_Impl::validityCheck() const {
554
555 // Logic based on Electrical Buss Type to translate or not translate inverters, storage
556 ✗ bool result = true;
557
558 ✗ std::string bussType = electricalBussType();
559
560 /// Inverter and Buss Type
561 ✗ boost::optional<Inverter> inv = inverter();
562 ✗ bool bussWithInverter = (bussType == "DirectCurrentWithInverter" || bussType == "DirectCurrentWithInverterDCStorage"
563 ✗ || bussType == "DirectCurrentWithInverterACStorage");
564
565 // Case 1: There is an inverter and a Buss with inverter: all good
566 ✗ if (inv && bussWithInverter) {
567 ✗ LOG(Info, briefDescription() << ": Your Electric Buss Type '" << bussType
568 << "' is compatible with inverter objects and you do have an inverter '" << inv->name().get() << "'");
569 // Case 2: if there's an inverter, but the buss is not compatible, we issue a Warning and don't translate the inverter
570 ✗ } else if (inv && !bussWithInverter) {
571 ✗ LOG(Warn, briefDescription() << ": Your Electric Buss Type '" << bussType
572 << "' is not compatible with inverter objects. The inverter object '" << inv->name().get()
573 << " will not be translated'");
574
575 // Case 3: if there is a buss that expects an inverter, but not inverter: this is bad, it'll throw a fatal in E+
576 ✗ } else if (bussWithInverter && !inv) {
577 ✗ result = false;
578 ✗ LOG(Error, briefDescription() << ": Your Electric Buss Type '" << bussType << "' Requires an inverter but you didn't specify one");
579 }
580 // Case 4: there's no inverter and a buss type without inverter: nothing needs to be done
581
582 /// Storage & Buss Type
583 ✗ boost::optional<ElectricalStorage> elcSto = electricalStorage();
584 ✗ bool bussWithStorage = (bussType == "AlternatingCurrentWithStorage" || bussType == "DirectCurrentWithInverterDCStorage"
585 ✗ || bussType == "DirectCurrentWithInverterACStorage");
586
587 // Case 1: There is a Storage object and a Buss with Storage: all good
588 ✗ if (elcSto && bussWithStorage) {
589
590 ✗ LOG(Info, briefDescription() << ": Your Electric Buss Type '" << bussType
591 << "' is compatible with storage objects and you do have an ELC:Storage:Simple '" << elcSto->name().get()
592 << "'");
593
594 // Storage Operation Scheme, defaults to TrackFacilityElectricDemandStoreExcessOnSite
595 ✗ std::string stoOpScheme = storageOperationScheme();
596
597 ✗ if (!isStorageOperationSchemeDefaulted()) {
598 ✗ LOG(Info, "Your Storage Operation Scheme is defaulted to '" << stoOpScheme << "'");
599 }
600
601 // For all storageOperationScheme, we need to translate the Min/Max Storage SOC
602 // Maximum Storage State of Charge Fraction, defaults
603 // Nothing to do
604
605 // Minimum Storage State of Charge Fraction, defaults
606 // Nothing to do
607
608 /// Further testing based on storageOperationScheme
609 ✗ if (stoOpScheme == "TrackMeterDemandStoreExcessOnSite") {
610 // Storage Control Track Meter Name, required if operation = TrackMeterDemandStoreExcessOnSite or it'll produce a fatal
611 ✗ if (!storageControlTrackMeterName()) {
612 ✗ result = false;
613 ✗ LOG(Error, briefDescription() << ": You set the Storage Operation Scheme to " << stoOpScheme
614 << " but you didn't specify the required 'Storage Control Track Meter Name'");
615 }
616
617 ✗ } else if (stoOpScheme == "TrackChargeDischargeSchedules") {
618 // Storage Converter Object Name
619 ✗ boost::optional<ElectricLoadCenterStorageConverter> stoConverter = storageConverter();
620 ✗ if (!stoConverter) {
621 ✗ result = false;
622 ✗ LOG(Error, briefDescription() << ": You set the Storage Operation Scheme to " << stoOpScheme
623 << " but you didn't specify the required 'Storage Converter Object Name'");
624 }
625
626 // Design Storage Control Charge Power
627 ✗ if (!designStorageControlChargePower()) {
628 ✗ result = false;
629 ✗ LOG(Error, briefDescription() << ": You set the Storage Operation Scheme to " << stoOpScheme
630 << " but you didn't specify the required 'Design Storage Control Charge Power'");
631 }
632
633 // Design Storage Control Discharge Power
634 ✗ if (!designStorageControlDischargePower()) {
635 ✗ result = false;
636 ✗ LOG(Error, briefDescription() << ": You set the Storage Operation Scheme to " << stoOpScheme
637 << " but you didn't specify the required 'Design Storage Control Discharge Power'");
638 }
639
640 // Storage Charge Power Fraction Schedule Name
641 ✗ if (!storageChargePowerFractionSchedule()) {
642 ✗ result = false;
643 ✗ LOG(Error, briefDescription() << ": You set the Storage Operation Scheme to " << stoOpScheme
644 << " but you didn't specify the required 'Storage Charge Power Fraction Schedule Name'");
645 }
646
647 // Discharge Power Fraction Schedule Name
648 ✗ if (!storageDischargePowerFractionSchedule()) {
649 ✗ result = false;
650 ✗ LOG(Error, briefDescription() << ": You set the Storage Operation Scheme to " << stoOpScheme
651 << " but you didn't specify the required 'Storage Discharge Power Fraction Schedule Name'");
652 }
653
654 ✗ } else if (stoOpScheme == "FacilityDemandLeveling") {
655 // Storage Converter Object Name
656 ✗ boost::optional<ElectricLoadCenterStorageConverter> stoConverter = storageConverter();
657 ✗ if (!stoConverter) {
658 ✗ result = false;
659 ✗ LOG(Error, briefDescription() << ": You set the Storage Operation Scheme to " << stoOpScheme
660 << " but you didn't specify the required 'Storage Converter Object Name'");
661 }
662
663 // Design Storage Control Charge Power
664 ✗ if (!designStorageControlChargePower()) {
665 ✗ result = false;
666 ✗ LOG(Error, briefDescription() << ": You set the Storage Operation Scheme to " << stoOpScheme
667 << " but you didn't specify the required 'Design Storage Control Charge Power'");
668 }
669
670 // Design Storage Control Discharge Power
671 ✗ if (!designStorageControlDischargePower()) {
672 ✗ result = false;
673 ✗ LOG(Error, briefDescription() << ": You set the Storage Operation Scheme to " << stoOpScheme
674 << " but you didn't specify the required 'Design Storage Control Discharge Power'");
675 }
676
677 // Storage Control Utility Demand Target
678 ✗ if (!storageControlUtilityDemandTarget()) {
679 ✗ result = false;
680 ✗ LOG(Error, briefDescription() << ": You set the Storage Operation Scheme to " << stoOpScheme
681 << " but you didn't specify the required 'Storage Control Utility Demand Target'");
682 }
683
684 ✗ } // end if (storageOperationScheme)
685 // Case 2: if there's a Storage object, but the buss is not compatible, we issue a Warning and don't translate Any of the storage objects
686 ✗ } else if (elcSto && !bussWithStorage) {
687 ✗ LOG(Warn,
688 briefDescription() << ": Your Electric Buss Type '" << bussType
689 << "' is not compatible with storage objects. No storage objects will be translated including the Battery itself:'"
690 << elcSto->name().get() << "'");
691
692 // Case 3: if there is a buss that expects Storage, but no Storage: this is bad, it'll throw a fatal in E+
693 ✗ } else if (bussWithStorage && !elcSto) {
694 ✗ LOG(Error,
695 briefDescription() << ": Your Electric Buss Type '" << bussType << "' Requires an electrical Storage object but you didn't specify one");
696 }
697 // Case 4: there's no inverter and a buss type without inverter: nothing needs to be done
698
699 ✗ return result;
700 ✗ }
701
702 } // namespace detail
703
704 38 ElectricLoadCenterDistribution::ElectricLoadCenterDistribution(const Model& model)
705 38 : ParentObject(ElectricLoadCenterDistribution::iddObjectType(), model) {
706
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✗ Branch 5 not taken.
38 OS_ASSERT(getImpl<detail::ElectricLoadCenterDistribution_Impl>());
707
708
1/1
✓ Branch 1 taken 38 times.
38 ModelObjectList generatorList(model);
709
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 bool ok = setPointer(OS_ElectricLoadCenter_DistributionFields::GeneratorListName, generatorList.handle());
710
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 3 not taken.
38 OS_ASSERT(ok);
711 38 }
712
713 7886 IddObjectType ElectricLoadCenterDistribution::iddObjectType() {
714
1/1
✓ Branch 1 taken 7886 times.
7886 return {IddObjectType::OS_ElectricLoadCenter_Distribution};
715 }
716
717 ✗ std::vector<std::string> ElectricLoadCenterDistribution::generatorOperationSchemeTypeValues() {
718 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(),
719 ✗ OS_ElectricLoadCenter_DistributionFields::GeneratorOperationSchemeType);
720 }
721
722 ✗ std::vector<std::string> ElectricLoadCenterDistribution::electricalBussTypeValues() {
723 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_ElectricLoadCenter_DistributionFields::ElectricalBussType);
724 }
725
726 ✗ std::vector<std::string> ElectricLoadCenterDistribution::storageOperationSchemeValues() {
727 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_ElectricLoadCenter_DistributionFields::StorageOperationScheme);
728 }
729
730 59 std::vector<Generator> ElectricLoadCenterDistribution::generators() const {
731
1/1
✓ Branch 3 taken 59 times.
59 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->generators();
732 }
733
734 12 std::string ElectricLoadCenterDistribution::generatorOperationSchemeType() const {
735
1/1
✓ Branch 3 taken 12 times.
12 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->generatorOperationSchemeType();
736 }
737
738 5 bool ElectricLoadCenterDistribution::isGeneratorOperationSchemeTypeDefaulted() const {
739
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->isGeneratorOperationSchemeTypeDefaulted();
740 }
741
742 12 boost::optional<double> ElectricLoadCenterDistribution::demandLimitSchemePurchasedElectricDemandLimit() const {
743
1/1
✓ Branch 3 taken 12 times.
12 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->demandLimitSchemePurchasedElectricDemandLimit();
744 }
745
746 12 boost::optional<Schedule> ElectricLoadCenterDistribution::trackScheduleSchemeSchedule() const {
747
1/1
✓ Branch 3 taken 12 times.
12 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->trackScheduleSchemeSchedule();
748 }
749
750 12 boost::optional<std::string> ElectricLoadCenterDistribution::trackMeterSchemeMeterName() const {
751
1/1
✓ Branch 3 taken 12 times.
12 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->trackMeterSchemeMeterName();
752 }
753
754 16 std::string ElectricLoadCenterDistribution::electricalBussType() const {
755
1/1
✓ Branch 3 taken 16 times.
16 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->electricalBussType();
756 }
757
758 5 bool ElectricLoadCenterDistribution::isElectricalBussTypeDefaulted() const {
759
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->isElectricalBussTypeDefaulted();
760 }
761
762 43 boost::optional<Inverter> ElectricLoadCenterDistribution::inverter() const {
763
1/1
✓ Branch 3 taken 43 times.
43 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->inverter();
764 }
765
766 20 boost::optional<ElectricalStorage> ElectricLoadCenterDistribution::electricalStorage() const {
767
1/1
✓ Branch 3 taken 20 times.
20 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->electricalStorage();
768 }
769
770 16 boost::optional<ElectricLoadCenterTransformer> ElectricLoadCenterDistribution::transformer() const {
771
1/1
✓ Branch 3 taken 16 times.
16 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->transformer();
772 }
773
774 // New
775
776 // Storage Operation Scheme, defaults to TrackFacilityElectricDemandStoreExcessOnSite
777 4 std::string ElectricLoadCenterDistribution::storageOperationScheme() const {
778
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->storageOperationScheme();
779 }
780 5 bool ElectricLoadCenterDistribution::isStorageOperationSchemeDefaulted() const {
781
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->isStorageOperationSchemeDefaulted();
782 }
783
784 // Storage Control Track Meter Name, required if operation = TrackMeterDemandStoreExcessOnSite
785 4 boost::optional<std::string> ElectricLoadCenterDistribution::storageControlTrackMeterName() const {
786
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->storageControlTrackMeterName();
787 }
788
789 // Storage Converter Object Name
790 3 boost::optional<ElectricLoadCenterStorageConverter> ElectricLoadCenterDistribution::storageConverter() const {
791
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->storageConverter();
792 }
793
794 // Maximum Storage State of Charge Fraction, required if storage, defaults
795 4 double ElectricLoadCenterDistribution::maximumStorageStateofChargeFraction() const {
796
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->maximumStorageStateofChargeFraction();
797 }
798 3 bool ElectricLoadCenterDistribution::isMaximumStorageStateofChargeFractionDefaulted() const {
799
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->isMaximumStorageStateofChargeFractionDefaulted();
800 }
801
802 // Minimum Storage State of Charge Fraction, required if storage, defaults
803 4 double ElectricLoadCenterDistribution::minimumStorageStateofChargeFraction() const {
804
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->minimumStorageStateofChargeFraction();
805 }
806 3 bool ElectricLoadCenterDistribution::isMinimumStorageStateofChargeFractionDefaulted() const {
807
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->isMinimumStorageStateofChargeFractionDefaulted();
808 }
809
810 // Design Storage Control Charge Power, required if FacilityDemandLeveling or TrackChargeDischargeSchedules
811 6 boost::optional<double> ElectricLoadCenterDistribution::designStorageControlChargePower() const {
812
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->designStorageControlChargePower();
813 }
814
815 // Storage Charge Power Fraction Schedule Name, required if TrackChargeDischargeSchedules
816 // TODO: do I want to default that to daytime?
817 6 boost::optional<Schedule> ElectricLoadCenterDistribution::storageChargePowerFractionSchedule() const {
818
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->storageChargePowerFractionSchedule();
819 }
820
821 // Design Storage Control Discharge Power, required if FacilityDemandLeveling or TrackChargeDischargeSchedules
822 6 boost::optional<double> ElectricLoadCenterDistribution::designStorageControlDischargePower() const {
823
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->designStorageControlDischargePower();
824 }
825
826 // Storage Charge Power Fraction Schedule Name, required if TrackChargeDischargeSchedules
827 // TODO: do I want to default that to daytime?
828 6 boost::optional<Schedule> ElectricLoadCenterDistribution::storageDischargePowerFractionSchedule() const {
829
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->storageDischargePowerFractionSchedule();
830 }
831
832 // Storage Control Utility Demand Target, required if FacilityDemandLeveling
833 4 boost::optional<double> ElectricLoadCenterDistribution::storageControlUtilityDemandTarget() const {
834
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->storageControlUtilityDemandTarget();
835 }
836
837 // Storage Control Utility Demand Target Fraction Schedule Name, will be used only if FacilityDemandLeveling, defaults to 1.0
838 2 Schedule ElectricLoadCenterDistribution::storageControlUtilityDemandTargetFractionSchedule() const {
839
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->storageControlUtilityDemandTargetFractionSchedule();
840 }
841 3 bool ElectricLoadCenterDistribution::isStorageControlUtilityDemandTargetFractionScheduleDefaulted() const {
842
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->isStorageControlUtilityDemandTargetFractionScheduleDefaulted();
843 }
844
845 39 bool ElectricLoadCenterDistribution::addGenerator(const Generator& generator) {
846
1/1
✓ Branch 3 taken 39 times.
39 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->addGenerator(generator);
847 }
848
849 16 bool ElectricLoadCenterDistribution::removeGenerator(const Generator& generator) {
850
1/1
✓ Branch 3 taken 16 times.
16 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->removeGenerator(generator);
851 }
852
853 ✗ void ElectricLoadCenterDistribution::resetGenerators() {
854 ✗ getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetGenerators();
855 ✗ }
856
857 3 bool ElectricLoadCenterDistribution::setGeneratorOperationSchemeType(const std::string& generatorOperationSchemeType) {
858
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setGeneratorOperationSchemeType(generatorOperationSchemeType);
859 }
860
861 2 void ElectricLoadCenterDistribution::resetGeneratorOperationSchemeType() {
862
1/1
✓ Branch 3 taken 2 times.
2 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetGeneratorOperationSchemeType();
863 2 }
864
865 2 bool ElectricLoadCenterDistribution::setDemandLimitSchemePurchasedElectricDemandLimit(double demandLimitSchemePurchasedElectricDemandLimit) {
866
1/1
✓ Branch 3 taken 2 times.
4 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setDemandLimitSchemePurchasedElectricDemandLimit(
867 4 demandLimitSchemePurchasedElectricDemandLimit);
868 }
869
870 1 void ElectricLoadCenterDistribution::resetDemandLimitSchemePurchasedElectricDemandLimit() {
871
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetDemandLimitSchemePurchasedElectricDemandLimit();
872 1 }
873
874 1 bool ElectricLoadCenterDistribution::setTrackScheduleSchemeSchedule(Schedule& schedule) {
875
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setTrackScheduleSchemeSchedule(schedule);
876 }
877
878 1 void ElectricLoadCenterDistribution::resetTrackScheduleSchemeSchedule() {
879
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetTrackScheduleSchemeSchedule();
880 1 }
881
882 1 bool ElectricLoadCenterDistribution::setTrackMeterSchemeMeterName(const std::string& trackMeterSchemeMeterName) {
883
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setTrackMeterSchemeMeterName(trackMeterSchemeMeterName);
884 }
885
886 1 void ElectricLoadCenterDistribution::resetTrackMeterSchemeMeterName() {
887
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetTrackMeterSchemeMeterName();
888 1 }
889
890 13 bool ElectricLoadCenterDistribution::setElectricalBussType(const std::string& electricalBussType) {
891
1/1
✓ Branch 3 taken 13 times.
13 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setElectricalBussType(electricalBussType);
892 }
893
894 1 void ElectricLoadCenterDistribution::resetElectricalBussType() {
895
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetElectricalBussType();
896 1 }
897
898 13 bool ElectricLoadCenterDistribution::setInverter(const Inverter& inverter) {
899
1/1
✓ Branch 3 taken 13 times.
13 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setInverter(inverter);
900 }
901
902 4 void ElectricLoadCenterDistribution::resetInverter() {
903
1/1
✓ Branch 3 taken 4 times.
4 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetInverter();
904 4 }
905
906 4 bool ElectricLoadCenterDistribution::setElectricalStorage(const ElectricalStorage& electricalStorage) {
907
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setElectricalStorage(electricalStorage);
908 }
909
910 2 void ElectricLoadCenterDistribution::resetElectricalStorage() {
911
1/1
✓ Branch 3 taken 2 times.
2 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetElectricalStorage();
912 2 }
913
914 3 bool ElectricLoadCenterDistribution::setTransformer(const ElectricLoadCenterTransformer& transformer) {
915
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setTransformer(transformer);
916 }
917
918 1 void ElectricLoadCenterDistribution::resetTransformer() {
919
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetTransformer();
920 1 }
921
922 // Storage Operation Scheme
923 2 bool ElectricLoadCenterDistribution::setStorageOperationScheme(const std::string& operationScheme) {
924
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setStorageOperationScheme(operationScheme);
925 }
926 1 void ElectricLoadCenterDistribution::resetStorageOperationScheme() {
927
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetStorageOperationScheme();
928 1 }
929
930 // Storage Control Track Meter Name, required if operation = TrackMeterDemandStoreExcessOnSite
931 1 bool ElectricLoadCenterDistribution::setStorageControlTrackMeterName(const std::string& meterName) {
932
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setStorageControlTrackMeterName(meterName);
933 }
934 1 void ElectricLoadCenterDistribution::resetStorageControlTrackMeterName() {
935
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetStorageControlTrackMeterName();
936 1 }
937
938 // Storage Converter Object Name
939 2 bool ElectricLoadCenterDistribution::setStorageConverter(const ElectricLoadCenterStorageConverter& converter) {
940
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setStorageConverter(converter);
941 }
942 1 void ElectricLoadCenterDistribution::resetStorageConverter() {
943
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetStorageConverter();
944 1 }
945
946 // Maximum Storage State of Charge Fraction, required if storage, defaults
947 1 bool ElectricLoadCenterDistribution::setMaximumStorageStateofChargeFraction(const double maxStateofCharge) {
948
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setMaximumStorageStateofChargeFraction(maxStateofCharge);
949 }
950 1 void ElectricLoadCenterDistribution::resetMaximumStorageStateofChargeFraction() {
951
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetMaximumStorageStateofChargeFraction();
952 1 }
953
954 // Minimum Storage State of Charge Fraction, required if storage, defaults
955 1 bool ElectricLoadCenterDistribution::setMinimumStorageStateofChargeFraction(const double minStateofCharge) {
956
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setMinimumStorageStateofChargeFraction(minStateofCharge);
957 }
958 1 void ElectricLoadCenterDistribution::resetMinimumStorageStateofChargeFraction() {
959
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetMinimumStorageStateofChargeFraction();
960 1 }
961
962 // Design Storage Control Charge Power, required if FacilityDemandLeveling or TrackChargeDischargeSchedules
963 2 bool ElectricLoadCenterDistribution::setDesignStorageControlChargePower(const double designStorageControlChargePower) {
964
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setDesignStorageControlChargePower(designStorageControlChargePower);
965 }
966 1 void ElectricLoadCenterDistribution::resetDesignStorageControlChargePower() {
967
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetDesignStorageControlChargePower();
968 1 }
969
970 // Storage Charge Power Fraction Schedule Name, required if TrackChargeDischargeSchedules
971 // TODO: do I want to default that to daytime?
972 1 bool ElectricLoadCenterDistribution::setStorageChargePowerFractionSchedule(Schedule& schedule) {
973
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setStorageChargePowerFractionSchedule(schedule);
974 }
975 1 void ElectricLoadCenterDistribution::resetStorageChargePowerFractionSchedule() {
976
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetStorageChargePowerFractionSchedule();
977 1 }
978
979 // Design Storage Control Discharge Power, required if FacilityDemandLeveling or TrackChargeDischargeSchedules
980 2 bool ElectricLoadCenterDistribution::setDesignStorageControlDischargePower(const double designStorageControlDischargePower) {
981
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setDesignStorageControlDischargePower(designStorageControlDischargePower);
982 }
983 1 void ElectricLoadCenterDistribution::resetDesignStorageControlDischargePower() {
984
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetDesignStorageControlDischargePower();
985 1 }
986
987 // Storage Charge Power Fraction Schedule Name, required if TrackChargeDischargeSchedules
988 // TODO: do I want to default that to daytime?
989 1 bool ElectricLoadCenterDistribution::setStorageDischargePowerFractionSchedule(Schedule& schedule) {
990
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setStorageDischargePowerFractionSchedule(schedule);
991 }
992 1 void ElectricLoadCenterDistribution::resetStorageDischargePowerFractionSchedule() {
993
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetStorageDischargePowerFractionSchedule();
994 1 }
995
996 // Storage Control Utility Demand Target, required if FacilityDemandLeveling
997 1 bool ElectricLoadCenterDistribution::setStorageControlUtilityDemandTarget(const double storageControlUtilityDemandTarget) {
998
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setStorageControlUtilityDemandTarget(storageControlUtilityDemandTarget);
999 }
1000 1 void ElectricLoadCenterDistribution::resetStorageControlUtilityDemandTarget() {
1001
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetStorageControlUtilityDemandTarget();
1002 1 }
1003
1004 // Storage Control Utility Demand Target Fraction Schedule Name, will be used only if FacilityDemandLeveling, defaults to 1.0
1005 1 bool ElectricLoadCenterDistribution::setStorageControlUtilityDemandTargetFractionSchedule(Schedule& schedule) {
1006
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->setStorageControlUtilityDemandTargetFractionSchedule(schedule);
1007 }
1008 1 void ElectricLoadCenterDistribution::resetStorageControlUtilityDemandTargetFractionSchedule() {
1009
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ElectricLoadCenterDistribution_Impl>()->resetStorageControlUtilityDemandTargetFractionSchedule();
1010 1 }
1011
1012 ✗ bool ElectricLoadCenterDistribution::validityCheck() const {
1013 ✗ return getImpl<detail::ElectricLoadCenterDistribution_Impl>()->validityCheck();
1014 }
1015
1016 /// @cond
1017 63 ElectricLoadCenterDistribution::ElectricLoadCenterDistribution(std::shared_ptr<detail::ElectricLoadCenterDistribution_Impl> impl)
1018
1/1
✓ Branch 3 taken 63 times.
63 : ParentObject(std::move(impl)) {}
1019 /// @endcond
1020
1021 } // namespace model
1022 } // namespace openstudio
1023