GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 67.7% 63 / 0 / 93
Functions: 100.0% 1 / 0 / 1
Branches: 42.7% 64 / 0 / 150

src/energyplus/ReverseTranslator/ReverseTranslateGeneratorWindTurbine.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 "../ReverseTranslator.hpp"
7
8 #include "../../model/GeneratorWindTurbine.hpp"
9 #include "../../model/GeneratorWindTurbine_Impl.hpp"
10
11 #include "../../model/Schedule.hpp"
12 #include "../../model/Schedule_Impl.hpp"
13
14 #include <utilities/idd/Generator_WindTurbine_FieldEnums.hxx>
15 #include "../../utilities/idd/IddEnums.hpp"
16 #include <utilities/idd/IddEnums.hxx>
17
18 using namespace openstudio::model;
19
20 namespace openstudio {
21
22 namespace energyplus {
23
24 2 OptionalModelObject ReverseTranslator::translateGeneratorWindTurbine(const WorkspaceObject& workspaceObject) {
25
4/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
2 if (workspaceObject.iddObject().type() != IddObjectType::Generator_WindTurbine) {
26 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: GeneratorWindTurbine");
27 ✗ return boost::none;
28 }
29
30 2 OptionalDouble d;
31 2 OptionalString s;
32 2 OptionalInt i;
33 2 OptionalWorkspaceObject target;
34
35
1/1
✓ Branch 1 taken 2 times.
2 openstudio::model::GeneratorWindTurbine wind(m_model);
36
37 // Name
38
1/1
✓ Branch 1 taken 2 times.
2 s = workspaceObject.name();
39
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (s) {
40
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 wind.setName(*s);
41 }
42
43 // Availability Schedule Name
44
2/3
✓ Branch 1 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
4 if ((target = workspaceObject.getTarget(Generator_WindTurbineFields::AvailabilityScheduleName))) {
45 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
46 ✗ if (modelObject) {
47 ✗ if (auto optSch = modelObject->optionalCast<Schedule>()) {
48 ✗ wind.setAvailabilitySchedule(optSch.get());
49 ✗ }
50 }
51 ✗ }
52
53 // Rotor Type
54
1/1
✓ Branch 1 taken 2 times.
2 s = workspaceObject.getString(Generator_WindTurbineFields::RotorType);
55
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (s) {
56
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 wind.setRotorType(*s);
57 }
58
59 // Power Control
60
1/1
✓ Branch 1 taken 2 times.
2 s = workspaceObject.getString(Generator_WindTurbineFields::PowerControl);
61
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (s) {
62
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 wind.setPowerControl(*s);
63 }
64
65 // Rated Rotor Speed
66
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::RatedRotorSpeed);
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
68 ✗ wind.setRatedRotorSpeed(*d);
69 }
70
71 // Rotor Diameter
72
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::RotorDiameter);
73
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
74 ✗ wind.setRotorDiameter(*d);
75 }
76
77 // Overall Height
78
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::OverallHeight);
79
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
80 ✗ wind.setOverallHeight(*d);
81 }
82
83 // Number of Blades
84
1/1
✓ Branch 1 taken 2 times.
2 i = workspaceObject.getInt(Generator_WindTurbineFields::NumberofBlades);
85
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (i) {
86 ✗ wind.setNumberofBlades(*i);
87 }
88
89 // Rated Power
90
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::RatedPower);
91
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
92 ✗ wind.setRatedPower(*d);
93 }
94
95 // Rated Wind Speed
96
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::RatedWindSpeed);
97
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
98 ✗ wind.setRatedWindSpeed(*d);
99 }
100
101 // Cut In Wind Speed
102
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::CutInWindSpeed);
103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
104 ✗ wind.setCutInWindSpeed(*d);
105 }
106
107 // Cut Out Wind Speed
108
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::CutOutWindSpeed);
109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
110 ✗ wind.setCutOutWindSpeed(*d);
111 }
112
113 // Fraction system Efficiency
114
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::FractionsystemEfficiency);
115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
116 ✗ wind.setFractionSystemEfficiency(*d);
117 }
118
119 // Maximum Tip Speed Ratio
120
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::MaximumTipSpeedRatio);
121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
122 ✗ wind.setMaximumTipSpeedRatio(*d);
123 }
124
125 // Maximum Power Coefficient
126
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::MaximumPowerCoefficient);
127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
128 ✗ wind.setMaximumPowerCoefficient(*d);
129 }
130
131 // Annual Local Average Wind Speed
132
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::AnnualLocalAverageWindSpeed);
133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
134 ✗ wind.setAnnualLocalAverageWindSpeed(*d);
135 }
136
137 // Height for Local Average Wind Speed
138
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::HeightforLocalAverageWindSpeed);
139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
140 ✗ wind.setHeightforLocalAverageWindSpeed(*d);
141 }
142
143 // Blade Chord Area
144
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::BladeChordArea);
145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
146 ✗ wind.setBladeChordArea(*d);
147 }
148
149 // Blade Drag Coefficient
150
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::BladeDragCoefficient);
151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
152 ✗ wind.setBladeDragCoefficient(*d);
153 }
154
155 // Blade Lift Coefficient
156
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::BladeLiftCoefficient);
157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
158 ✗ wind.setBladeLiftCoefficient(*d);
159 }
160
161 // Power Coefficient C1
162
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC1);
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
164 ✗ wind.setPowerCoefficientC1(*d);
165 }
166
167 // Power Coefficient C2
168
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC2);
169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
170 ✗ wind.setPowerCoefficientC2(*d);
171 }
172
173 // Power Coefficient C3
174
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC3);
175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
176 ✗ wind.setPowerCoefficientC3(*d);
177 }
178
179 // Power Coefficient C4
180
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC4);
181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
182 ✗ wind.setPowerCoefficientC4(*d);
183 }
184
185 // Power Coefficient C5
186
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC5);
187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
188 ✗ wind.setPowerCoefficientC5(*d);
189 }
190
191 // Power Coefficient C6
192
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Generator_WindTurbineFields::PowerCoefficientC6);
193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
194 ✗ wind.setPowerCoefficientC6(*d);
195 }
196
197
1/1
✓ Branch 1 taken 2 times.
2 return wind;
198 2 }
199
200 } // namespace energyplus
201
202 } // namespace openstudio
203