GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 69.9% 95 / 0 / 136
Functions: 100.0% 1 / 0 / 1
Branches: 45.0% 227 / 0 / 504

src/energyplus/ForwardTranslator/ForwardTranslateElectricLoadCenterDistribution.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
8 #include "../../model/Model.hpp"
9 #include "../../model/ElectricLoadCenterDistribution.hpp"
10 #include "../../model/ElectricLoadCenterDistribution_Impl.hpp"
11 #include "../../model/Inverter.hpp"
12 #include "../../model/ElectricalStorage.hpp"
13 #include "../../model/ElectricLoadCenterStorageConverter.hpp"
14 #include "../../model/Generator.hpp"
15 #include "../../model/Schedule.hpp"
16 #include "../../model/ElectricLoadCenterTransformer.hpp"
17 #include "../../model/ElectricLoadCenterTransformer_Impl.hpp"
18
19 #include "../../utilities/core/Compare.hpp"
20 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
21 #include "../../utilities/idd/IddEnums.hpp"
22
23 #include <utilities/idd/ElectricLoadCenter_Distribution_FieldEnums.hxx>
24 #include <utilities/idd/ElectricLoadCenter_Generators_FieldEnums.hxx>
25 #include <utilities/idd/IddEnums.hxx>
26
27 using namespace openstudio::model;
28
29 using namespace std;
30
31 namespace openstudio {
32
33 namespace energyplus {
34
35 12 boost::optional<IdfObject> ForwardTranslator::translateElectricLoadCenterDistribution(model::ElectricLoadCenterDistribution& modelObject) {
36 12 boost::optional<double> optD;
37 12 std::string s;
38 12 boost::optional<std::string> optS;
39 12 boost::optional<Schedule> schedule;
40
41 // Remove Completely empty electric load center distribution objects (e.g. with no generators)
42
1/1
✓ Branch 1 taken 12 times.
12 std::vector<Generator> generators = modelObject.generators();
43
1/1
✓ Branch 1 taken 12 times.
12 boost::optional<Inverter> inverter = modelObject.inverter();
44
1/1
✓ Branch 1 taken 12 times.
12 boost::optional<ElectricLoadCenterTransformer> transformer = modelObject.transformer();
45
1/1
✓ Branch 1 taken 12 times.
12 boost::optional<ElectricalStorage> electricalStorage = modelObject.electricalStorage();
46
47 // This is the rough, high-level check
48
8/10
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 8 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1 time.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 12 times.
12 if ((generators.empty()) && (!inverter) && (!transformer) && !(electricalStorage)) {
49 ✗ LOG(Warn, "ElectricLoadCenterDistribution "
50 << modelObject.name().get()
51 << " is not referencing any Generator, Inverter, Transformer, or Electrical Storage, it will not be translated.");
52 }
53
54 // I'm going to try to register as few objects as possible starting now, but I can't avoid some of them due to calls to translateAndMap...
55 // It would require I change the translateAndMap functions for children to NOT register the objects, which would be
56 // 1) An unusual deviation regarding common patterns, and,
57 // 2) Subject to problems (some objects can stand on their own with an ELCD...like Transformer)
58
59
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 IdfObject idfObject(openstudio::IddObjectType::ElectricLoadCenter_Distribution);
60
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 idfObject.setName(modelObject.nameString());
61
62 12 boost::optional<IdfObject> m_generatorsIdf;
63
64 /// Generator Fields
65
2/2
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 4 times.
12 if (!generators.empty()) {
66 // Don't push it just yet...
67
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 IdfObject generatorsIdf(openstudio::IddObjectType::ElectricLoadCenter_Generators);
68
1/1
✓ Branch 1 taken 8 times.
8 m_generatorsIdf = generatorsIdf;
69
70
4/4
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
8 generatorsIdf.setName(idfObject.name().get() + " Generators");
71
72
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
8 idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorListName, generatorsIdf.name().get());
73
74
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorOperationSchemeType, modelObject.generatorOperationSchemeType());
75
76
3/3
✓ Branch 1 taken 8 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 7 times.
16 if ((optD = modelObject.demandLimitSchemePurchasedElectricDemandLimit())) {
77
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(ElectricLoadCenter_DistributionFields::GeneratorDemandLimitSchemePurchasedElectricDemandLimit, optD.get());
78 }
79
80
2/3
✓ Branch 1 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
16 if ((schedule = modelObject.trackScheduleSchemeSchedule())) {
81 ✗ idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorTrackScheduleNameSchemeScheduleName, schedule->name().get());
82 }
83
84
2/3
✓ Branch 1 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
16 if ((optS = modelObject.trackMeterSchemeMeterName())) {
85 ✗ idfObject.setString(ElectricLoadCenter_DistributionFields::GeneratorTrackMeterSchemeMeterName, (*optS));
86 }
87
88 /// ElectricLoadCenter:Generators
89
2/2
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 8 times.
16 for (auto& generator : generators) {
90
1/1
✓ Branch 1 taken 8 times.
8 boost::optional<IdfObject> generatorIdf = translateAndMapModelObject(generator);
91
92
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (generatorIdf) {
93
1/1
✓ Branch 1 taken 8 times.
8 IdfExtensibleGroup generatorGroup = generatorsIdf.pushExtensibleGroup();
94
95
4/4
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
8 generatorGroup.setString(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorName, generatorIdf->name().get());
96
97
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 generatorGroup.setString(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorObjectType, generator.generatorObjectType());
98
99
1/1
✓ Branch 1 taken 8 times.
8 optD = generator.ratedElectricPowerOutput();
100
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (optD) {
101
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 generatorGroup.setDouble(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorRatedElectricPowerOutput, *optD);
102 }
103
104
1/1
✓ Branch 1 taken 8 times.
8 schedule = generator.availabilitySchedule();
105
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 if (schedule) {
106
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 boost::optional<IdfObject> scheduleIdf = translateAndMapModelObject(*schedule);
107
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (scheduleIdf) {
108
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 generatorGroup.setString(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorAvailabilityScheduleName, scheduleIdf->name().get());
109 }
110 3 }
111
112
1/1
✓ Branch 1 taken 8 times.
8 optD = generator.ratedThermaltoElectricalPowerRatio();
113
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 7 times.
8 if (optD) {
114
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 generatorGroup.setDouble(ElectricLoadCenter_GeneratorsExtensibleFields::GeneratorRatedThermaltoElectricalPowerRatio, *optD);
115 }
116 8 } else {
117 // Let it pass...
118 ✗ LOG(Warn, "Could not translate generator '" << generator.name().get() << "' on ElectricLoadCenter:Distribution '" << idfObject.name().get()
119 << "'");
120 }
121 8 }
122 8 }
123
124 /// Transformer Object
125
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 11 times.
12 if (transformer) {
126
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 boost::optional<IdfObject> transformerIdf = translateAndMapModelObject(transformer.get());
127
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (transformerIdf) {
128
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 idfObject.setString(ElectricLoadCenter_DistributionFields::TransformerObjectName, transformerIdf->name().get());
129 }
130 1 }
131
132 // NEW: Note all of these checks should have been implemented in ElectricLoadCenter_Impl::validityCheck...
133
134 // Logic based on Electrical Buss Type to translate or not translate inverters, storage
135
1/1
✓ Branch 1 taken 12 times.
12 std::string bussType = modelObject.electricalBussType();
136
137 // Translate the buss Type already
138
1/1
✓ Branch 1 taken 12 times.
12 idfObject.setString(ElectricLoadCenter_DistributionFields::ElectricalBussType, bussType);
139
140 /// Inverter and Buss Type
141 bool bussWithInverter =
142
8/19
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 9 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 12 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 12 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
42 (openstudio::istringEqual("DirectCurrentWithInverter", bussType) || openstudio::istringEqual("DirectCurrentWithInverterDCStorage", bussType)
143
12/17
✓ Branch 1 taken 12 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 9 times.
✓ Branch 9 taken 9 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 3 times.
✓ Branch 16 taken 9 times.
✓ Branch 17 taken 3 times.
✓ Branch 18 taken 9 times.
✓ Branch 19 taken 3 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
42 || openstudio::istringEqual("DirectCurrentWithInverterACStorage", bussType));
144
145 // Case 3: if there is a buss that expects an inverter, but not inverter: this is bad, it'll throw a fatal in E+
146 // I'm treating this case first, to avoid translating the inverter altogether...
147
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
12 if (bussWithInverter && !inverter) {
148 ✗ LOG(Error, modelObject.briefDescription() << ": Your Electric Buss Type '" << bussType << "' Requires an inverter but you didn't specify one");
149 ✗ return boost::none;
150
151 // Case 1: There is an inverter and a Buss with inverter: all good
152
5/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 9 times.
12 } else if (inverter && bussWithInverter) {
153
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 boost::optional<IdfObject> inverterIdf = translateAndMapModelObject(*inverter);
154
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (inverterIdf) {
155
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 idfObject.setString(ElectricLoadCenter_DistributionFields::InverterName, inverterIdf->name().get());
156 }
157
158 // Case 2: if there's an inverter, but the buss is not compatible, we issue a Warning and don't translate the inverter
159
2/6
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
12 } else if (inverter && !bussWithInverter) {
160 ✗ LOG(Warn, modelObject.briefDescription() << ": Your Electric Buss Type '" << bussType
161 << "' is not compatible with inverter objects. The inverter object '" << inverter->name().get()
162 << " will not be translated'");
163 }
164
165 // Case 4: there's no inverter and a buss type without inverter: nothing needs to be done
166
167 /// Storage and Buss Type
168 bool bussWithStorage =
169
8/19
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 10 times.
✓ Branch 13 taken 2 times.
✓ Branch 14 taken 12 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 12 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
44 (openstudio::istringEqual("AlternatingCurrentWithStorage", bussType) || openstudio::istringEqual("DirectCurrentWithInverterDCStorage", bussType)
170
12/17
✓ Branch 1 taken 12 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 10 times.
✓ Branch 9 taken 10 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10 times.
✓ Branch 13 taken 10 times.
✓ Branch 14 taken 2 times.
✓ Branch 16 taken 10 times.
✓ Branch 17 taken 2 times.
✓ Branch 18 taken 10 times.
✓ Branch 19 taken 2 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
44 || openstudio::istringEqual("DirectCurrentWithInverterACStorage", bussType));
171
172 // Case 3: if there is a buss that expects Storage, but no Storage: this is bad, it'll throw a fatal in E+
173 // Treating it first to avoid translating more things if I can avoid it
174
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
12 if (bussWithStorage && !electricalStorage) {
175 ✗ LOG(Error, modelObject.briefDescription() << ": Your Electric Buss Type '" << bussType
176 << "' Requires an electrical Storage object but you didn't specify one");
177 ✗ return boost::none;
178
179 // Case 1: There is a Storage object and a Buss with Storage: all good
180
5/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 10 times.
12 } else if (electricalStorage && bussWithStorage) {
181
182 // Translate the storage object itself (I can't really avoid doing it until the end of the checks)
183
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 boost::optional<IdfObject> storageIdf = translateAndMapModelObject(*electricalStorage);
184
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (storageIdf) {
185
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 idfObject.setString(ElectricLoadCenter_DistributionFields::ElectricalStorageObjectName, storageIdf->name().get());
186 }
187
188 // Storage Operation Scheme, defaults to TrackFacilityElectricDemandStoreExcessOnSite
189
1/1
✓ Branch 1 taken 2 times.
2 std::string storageOperationScheme = modelObject.storageOperationScheme();
190
191
3/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
2 if (!modelObject.isStorageOperationSchemeDefaulted()) {
192
1/1
✓ Branch 1 taken 1 time.
1 idfObject.setString(ElectricLoadCenter_DistributionFields::StorageOperationScheme, storageOperationScheme);
193 }
194
195 // For all storageOperationScheme, we need to translate the Min/Max Storage SOC
196 // Maximum Storage State of Charge Fraction, defaults
197
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(ElectricLoadCenter_DistributionFields::MaximumStorageStateofChargeFraction,
198 modelObject.maximumStorageStateofChargeFraction());
199
200 // Minimum Storage State of Charge Fraction, defaults
201
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(ElectricLoadCenter_DistributionFields::MinimumStorageStateofChargeFraction,
202 modelObject.minimumStorageStateofChargeFraction());
203
204 // Translate any storage converter if there is one, store it into a bool so we can check if present when mandatory
205 2 bool has_storage_conv = false;
206 // Storage Converter Object Name - This is actually a mandatory field
207
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<ElectricLoadCenterStorageConverter> elcConv = modelObject.storageConverter();
208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (elcConv) {
209 // If the buss is compatible, we translate the invert
210 ✗ boost::optional<IdfObject> storageConverterIdf = translateAndMapModelObject(*elcConv);
211 ✗ if (storageConverterIdf) {
212 ✗ has_storage_conv = true;
213 ✗ idfObject.setString(ElectricLoadCenter_DistributionFields::StorageConverterObjectName, storageConverterIdf->name().get());
214 }
215 ✗ }
216
217 // Design Storage Control Charge Power
218
3/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
4 if ((optD = modelObject.designStorageControlChargePower())) {
219
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(ElectricLoadCenter_DistributionFields::DesignStorageControlChargePower, optD.get());
220 } else {
221
3/9
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
3 if (openstudio::istringEqual("FacilityDemandLeveling", storageOperationScheme)
222
8/17
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 time.
✓ Branch 9 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
✓ Branch 13 taken 1 time.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 time.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 time.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
4 || openstudio::istringEqual("TrackChargeDischargeSchedules", storageOperationScheme)) {
223 ✗ LOG(Error, modelObject.briefDescription() << ": You set the Storage Operation Scheme to " << storageOperationScheme
224 << " but you didn't specify the required 'Design Storage Control Charge Power'");
225 ✗ return boost::none;
226 }
227 }
228
229 // Design Storage Control Discharge Power
230
3/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
4 if ((optD = modelObject.designStorageControlDischargePower())) {
231
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(ElectricLoadCenter_DistributionFields::DesignStorageControlDischargePower, optD.get());
232 } else {
233
3/9
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
3 if (openstudio::istringEqual("FacilityDemandLeveling", storageOperationScheme)
234
8/17
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 time.
✓ Branch 9 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
✓ Branch 13 taken 1 time.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 time.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 time.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
4 || openstudio::istringEqual("TrackChargeDischargeSchedules", storageOperationScheme)) {
235 ✗ LOG(Error, modelObject.briefDescription() << ": You set the Storage Operation Scheme to " << storageOperationScheme
236 << " but you didn't specify the required 'Design Storage Control Discharge Power'");
237 ✗ return boost::none;
238 }
239 }
240
241 // Storage Charge Power Fraction Schedule Name
242
2/3
✓ Branch 1 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
4 if ((schedule = modelObject.storageChargePowerFractionSchedule())) {
243 ✗ idfObject.setString(ElectricLoadCenter_DistributionFields::StorageChargePowerFractionScheduleName, schedule->name().get());
244 } else {
245
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
4 if (openstudio::istringEqual("TrackChargeDischargeSchedules", storageOperationScheme)) {
246 ✗ LOG(Error, modelObject.briefDescription() << ": You set the Storage Operation Scheme to " << storageOperationScheme
247 << " but you didn't specify the required 'Storage Charge Power Fraction Schedule Name'");
248 ✗ return boost::none;
249 }
250 }
251
252 // Discharge Power Fraction Schedule Name
253
2/3
✓ Branch 1 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
4 if ((schedule = modelObject.storageDischargePowerFractionSchedule())) {
254 ✗ idfObject.setString(ElectricLoadCenter_DistributionFields::StorageDischargePowerFractionScheduleName, schedule->name().get());
255 } else {
256
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
4 if (openstudio::istringEqual("TrackChargeDischargeSchedules", storageOperationScheme)) {
257 ✗ LOG(Error, modelObject.briefDescription() << ": You set the Storage Operation Scheme to " << storageOperationScheme
258 << " but you didn't specify the required 'Storage Discharge Power Fraction Schedule Name'");
259 ✗ return boost::none;
260 }
261 }
262
263 /// Further testing based on storageOperationScheme
264
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
4 if (openstudio::istringEqual("TrackMeterDemandStoreExcessOnSite", storageOperationScheme)) {
265 // Storage Control Track Meter Name, required if operation = TrackMeterDemandStoreExcessOnSite or it'll produce a fatal
266 ✗ if ((optS = modelObject.storageControlTrackMeterName())) {
267 ✗ idfObject.setString(ElectricLoadCenter_DistributionFields::StorageControlTrackMeterName, (*optS));
268 } else {
269 ✗ LOG(Error, modelObject.briefDescription() << ": You set the Storage Operation Scheme to " << storageOperationScheme
270 << " but you didn't specify the required 'Storage Control Track Meter Name'");
271 ✗ return boost::none;
272 }
273
274
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
4 } else if (openstudio::istringEqual("TrackChargeDischargeSchedules", storageOperationScheme)) {
275 // Storage Converter Object Name - This is actually a mandatory field
276 ✗ if (!has_storage_conv) {
277 ✗ LOG(Error, modelObject.briefDescription() << ": You set the Storage Operation Scheme to " << storageOperationScheme
278 << " but you didn't specify the required 'Storage Converter Object Name'");
279 ✗ return boost::none;
280 }
281
282
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
4 } else if (openstudio::istringEqual("FacilityDemandLeveling", storageOperationScheme)) {
283 // Storage Converter Object Name - This is actually a mandatory field
284 ✗ if (!has_storage_conv) {
285 ✗ LOG(Error, modelObject.briefDescription() << ": You set the Storage Operation Scheme to " << storageOperationScheme
286 << " but you didn't specify the required 'Storage Converter Object Name'");
287 ✗ return boost::none;
288 }
289
290 // Storage Control Utility Demand Target
291 ✗ if ((optD = modelObject.storageControlUtilityDemandTarget())) {
292 ✗ idfObject.setDouble(ElectricLoadCenter_DistributionFields::StorageControlUtilityDemandTarget, optD.get());
293 } else {
294 ✗ LOG(Error, modelObject.briefDescription() << ": You set the Storage Operation Scheme to " << storageOperationScheme
295 << " but you didn't specify the required 'Storage Control Utility Demand Target'");
296 ✗ return boost::none;
297 }
298
299 // Storage Control Utility Demand Target Fraction Schedule Name
300 // This defaults to always 1.0 if omitted
301 ✗ idfObject.setString(ElectricLoadCenter_DistributionFields::StorageControlUtilityDemandTargetFractionScheduleName,
302 ✗ modelObject.storageControlUtilityDemandTargetFractionSchedule().name().get());
303
304 } // end if (storageOperationScheme)
305
306 // 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
307
5/12
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 10 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 10 times.
12 } else if (electricalStorage && !bussWithStorage) {
308 ✗ LOG(Warn, modelObject.briefDescription()
309 << ": Your Electric Buss Type '" << bussType
310 << "' is not compatible with storage objects. No storage objects will be translated including the Battery itself:'"
311 << electricalStorage->name().get() << "'");
312 }
313
314 // Case 4: there's no Storage object and the buss is not compatible: nothing needs to be done
315
316 // We reach this point, congratulations, you can now register the object
317
1/1
✓ Branch 1 taken 12 times.
12 m_idfObjects.push_back(idfObject);
318 // And the potential GeneratorList
319
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if (m_generatorsIdf) {
320
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 m_idfObjects.push_back(m_generatorsIdf.get());
321 }
322
323
1/1
✓ Branch 1 taken 12 times.
12 return idfObject;
324 12 }
325
326 } // namespace energyplus
327
328 } // namespace openstudio
329