Skip to content

Commit 98b3865

Browse files
committed
Merge branch 'restructure/classes' into dev
2 parents 3c3ef66 + 24e3242 commit 98b3865

File tree

12 files changed

+448
-566
lines changed

12 files changed

+448
-566
lines changed

example/basic_example.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
"# specification of own wind turbine (Note: power coefficient values and\n",
178178
"# nominal power have to be in Watt)\n",
179179
"myTurbine = {\n",
180-
" 'object_name': 'myTurbine',\n",
180+
" 'name': 'myTurbine',\n",
181181
" 'nominal_power': 3e6, # in W\n",
182182
" 'hub_height': 105, # in m\n",
183183
" 'rotor_diameter': 90, # in m\n",
@@ -202,7 +202,7 @@
202202
"# if you want to use the power coefficient curve change the value of\n",
203203
"# 'fetch_curve' to 'power_coefficient_curve'\n",
204204
"enerconE126 = {\n",
205-
" 'object_name': 'ENERCON E 126 7500', # turbine name as in register\n",
205+
" 'name': 'ENERCON E 126 7500', # turbine name as in register\n",
206206
" 'hub_height': 135, # in m\n",
207207
" 'rotor_diameter': 127, # in m\n",
208208
" 'fetch_curve': 'power_curve' # fetch power curve\n",

example/basic_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def initialise_wind_turbines():
9797
# specification of own wind turbine (Note: power coefficient values and
9898
# nominal power have to be in Watt)
9999
myTurbine = {
100-
'object_name': 'myTurbine',
100+
'name': 'myTurbine',
101101
'nominal_power': 3e6, # in W
102102
'hub_height': 105, # in m
103103
'rotor_diameter': 90, # in m
@@ -113,7 +113,7 @@ def initialise_wind_turbines():
113113
# if you want to use the power coefficient curve change the value of
114114
# 'fetch_curve' to 'power_coefficient_curve'
115115
enerconE126 = {
116-
'object_name': 'ENERCON E 126 7500', # turbine name as in register
116+
'name': 'ENERCON E 126 7500', # turbine name as in register
117117
'hub_height': 135, # in m
118118
'rotor_diameter': 127, # in m
119119
'fetch_curve': 'power_curve' # fetch power curve

tests/test_modelchain.py

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TestModelChain:
1313
def setup_class(self):
1414
self.test_turbine = {'hub_height': 100,
1515
'rotor_diameter': 80,
16-
'object_name': 'ENERCON E 126 7500',
16+
'name': 'ENERCON E 126 7500',
1717
'fetch_curve': 'power_curve'}
1818

1919
def test_temperature_hub(self):
@@ -185,12 +185,12 @@ def test_run_model(self):
185185

186186
test_turbine = {'hub_height': 100,
187187
'rotor_diameter': 80,
188-
'object_name': 'ENERCON E 126 7500',
188+
'name': 'ENERCON E 126 7500',
189189
'fetch_curve': 'power_curve'}
190190

191191
# Test with default parameters of modelchain (power curve)
192192
power_output_exp = pd.Series(data=[1731887.39768, 3820152.27489],
193-
name='feedin_wind_turbine')
193+
name='feedin_power_plant')
194194
test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine))
195195
test_mc.run_model(weather_df)
196196
assert_series_equal(test_mc.power_output, power_output_exp)
@@ -200,15 +200,15 @@ def test_run_model(self):
200200
'power_output_model': 'power_curve',
201201
'density_correction': True}
202202
power_output_exp = pd.Series(data=[1433937.37959, 3285183.55084],
203-
name='feedin_wind_turbine')
203+
name='feedin_power_plant')
204204
test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
205205
**test_modelchain)
206206
test_mc.run_model(weather_df)
207207
assert_series_equal(test_mc.power_output, power_output_exp)
208208

209209
# Test with power coefficient curve and hellman
210210
power_output_exp = pd.Series(data=[559060.36156, 1251143.98621],
211-
name='feedin_wind_turbine')
211+
name='feedin_power_plant')
212212
test_turbine['fetch_curve'] = 'power_coefficient_curve'
213213
test_modelchain = {'wind_speed_model': 'hellman',
214214
'power_output_model': 'power_coefficient_curve',
@@ -218,18 +218,6 @@ def test_run_model(self):
218218
test_mc.run_model(weather_df)
219219
assert_series_equal(test_mc.power_output, power_output_exp)
220220

221-
# Ideal gas equation and density corrected power coefficient curve
222-
power_output_exp = pd.Series(data=[569117.952419, 1302746.06501],
223-
name='feedin_wind_turbine')
224-
test_modelchain = {'wind_speed_model': 'hellman',
225-
'density_model': 'ideal_gas',
226-
'power_output_model': 'power_coefficient_curve',
227-
'density_correction': True}
228-
test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
229-
**test_modelchain)
230-
test_mc.run_model(weather_df)
231-
assert_series_equal(test_mc.power_output, power_output_exp)
232-
233221
# Raise ValueErrors due to wrong spelling of parameters
234222
with pytest.raises(ValueError):
235223
test_modelchain['power_output_model'] = 'wrong_spelling'
@@ -259,18 +247,12 @@ def test_run_model(self):
259247
test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
260248
**test_modelchain)
261249
test_mc.run_model(weather_df)
262-
with pytest.raises(TypeError):
263-
test_modelchain = {'power_output_model': 'power_coefficient_curve',
264-
'density_correction': 'wrong_type'}
265-
test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
266-
**test_modelchain)
267-
test_mc.run_model(weather_df)
268250

269251
# Raise TypeErrors due to missing cp- or p-values
270252
with pytest.raises(TypeError):
271253
test_turbine = {'hub_height': 100,
272254
'rotor_diameter': 80,
273-
'object_name': 'ENERCON E 126 7500',
255+
'name': 'ENERCON E 126 7500',
274256
'fetch_curve': 'power_curve'}
275257
test_modelchain = {'power_output_model': 'power_coefficient_curve',
276258
'density_correction': True}
@@ -280,7 +262,7 @@ def test_run_model(self):
280262
with pytest.raises(TypeError):
281263
test_turbine = {'hub_height': 100,
282264
'rotor_diameter': 80,
283-
'object_name': 'ENERCON E 126 7500',
265+
'name': 'ENERCON E 126 7500',
284266
'fetch_curve': 'power_coefficient_curve'}
285267
test_modelchain = {'power_output_model': 'power_curve',
286268
'density_corr': True}

tests/test_power_output.py

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ def test_power_coefficient_curve(self):
2020
'power_coefficient_curve_values':
2121
pd.Series([0.3, 0.4, 0.5])}
2222

23-
# Tests without density correction:
2423
# Test wind_speed as pd.Series with density and power_coefficient_curve
2524
# as pd.Series and np.array
2625
power_output_exp = pd.Series(data=[0.0, 244615.399, 0.0],
27-
name='feedin_wind_turbine')
26+
name='feedin_power_plant')
2827
assert_series_equal(power_coefficient_curve(**parameters),
2928
power_output_exp)
3029
parameters['density'] = np.array(parameters['density'])
@@ -55,48 +54,6 @@ def test_power_coefficient_curve(self):
5554
power_output_exp)
5655
assert isinstance(power_coefficient_curve(**parameters), np.ndarray)
5756

58-
# Tests with density correction:
59-
# Test wind_speed as np.array with density and power_coefficient_curve
60-
# as pd.Series and np.array
61-
power_output_exp = np.array([0.0, 262869.785, 0.0])
62-
parameters['density_correction'] = True
63-
assert_allclose(power_coefficient_curve(**parameters),
64-
power_output_exp)
65-
assert isinstance(power_coefficient_curve(**parameters), np.ndarray)
66-
parameters['density'] = np.array(parameters['density'])
67-
assert_allclose(power_coefficient_curve(**parameters),
68-
power_output_exp)
69-
assert isinstance(power_coefficient_curve(**parameters), np.ndarray)
70-
parameters['power_coefficient_curve_values'] = np.array(
71-
parameters['power_coefficient_curve_values'])
72-
parameters['power_coefficient_curve_wind_speeds'] = np.array(
73-
parameters['power_coefficient_curve_wind_speeds'])
74-
assert_allclose(power_coefficient_curve(**parameters),
75-
power_output_exp)
76-
assert isinstance(power_coefficient_curve(**parameters), np.ndarray)
77-
78-
# Test wind_speed as pd.Series with density and power_coefficient_curve
79-
# as np. array and pd.Series
80-
power_output_exp = pd.Series(data=[0.0, 262869.785, 0.0],
81-
name='feedin_wind_turbine')
82-
parameters['wind_speed'] = pd.Series(data=parameters['wind_speed'])
83-
assert_series_equal(power_coefficient_curve(**parameters),
84-
power_output_exp)
85-
parameters['density'] = pd.Series(data=parameters['density'])
86-
assert_series_equal(power_coefficient_curve(**parameters),
87-
power_output_exp)
88-
parameters['power_coefficient_curve_wind_speeds'] = pd.Series(
89-
data=parameters['power_coefficient_curve_wind_speeds'])
90-
parameters['power_coefficient_curve_values'] = pd.Series(
91-
data=parameters['power_coefficient_curve_values'])
92-
assert_series_equal(power_coefficient_curve(**parameters),
93-
power_output_exp)
94-
95-
# Raise TypeErrors due to wrong type of `density_correction`
96-
with pytest.raises(TypeError):
97-
parameters['density'] = 'wrong_type'
98-
power_coefficient_curve(**parameters)
99-
10057
def test_power_curve(self):
10158
parameters = {'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]),
10259
'density': pd.Series(data=[1.3, 1.3, 1.3]),
@@ -111,7 +68,7 @@ def test_power_curve(self):
11168
# Test wind_speed as pd.Series and power_curve as pd.Series and
11269
# np.array
11370
power_output_exp = pd.Series(data=[0.0, 450.0, 0.0],
114-
name='feedin_wind_turbine')
71+
name='feedin_power_plant')
11572
assert_series_equal(power_curve(**parameters), power_output_exp)
11673
parameters['power_curve_values'] = np.array(
11774
parameters['power_curve_values'])
@@ -152,7 +109,7 @@ def test_power_curve(self):
152109
# Test wind_speed as pd.Series with density and power_curve as
153110
# np. array and pd.Series
154111
power_output_exp = pd.Series(data=[0.0, 461.00290572, 0.0],
155-
name='feedin_wind_turbine')
112+
name='feedin_power_plant')
156113
parameters['wind_speed'] = pd.Series(data=parameters['wind_speed'])
157114
assert_series_equal(power_curve(**parameters), power_output_exp)
158115
parameters['density'] = pd.Series(data=parameters['density'])
@@ -182,7 +139,7 @@ def test_power_curve_density_correction(self):
182139
# Test wind_speed as pd.Series with density and power_curve as
183140
# pd.Series and np.array
184141
power_output_exp = pd.Series(data=[0.0, 461.00290572, 0.0],
185-
name='feedin_wind_turbine')
142+
name='feedin_power_plant')
186143
assert_series_equal(power_curve_density_correction(**parameters),
187144
power_output_exp)
188145
parameters['density'] = np.array(parameters['density'])

0 commit comments

Comments
 (0)