Skip to content

Commit 240fb5c

Browse files
committed
Adapt to wind/power efficiency curve
1 parent 5e1ae93 commit 240fb5c

File tree

1 file changed

+36
-16
lines changed

1 file changed

+36
-16
lines changed

windpowerlib/turbine_cluster_modelchain.py

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ class TurbineClusterModelChain(object):
2424
representing the wind turbine cluster.
2525
wake_losses_method : String
2626
Defines the method for talking wake losses within the farm into
27-
consideration. Options: 'wind_efficiency_curve', 'constant_efficiency'
28-
or None. Default: 'wind_efficiency_curve'.
27+
consideration. Options: 'power_efficiency_curve',
28+
'constant_efficiency', 'dena_mean', 'knorr_mean' or None. # TODO all curves in WPL
29+
Default: 'dena_mean'.
2930
smoothing : Boolean
3031
If True the power curves will be smoothed before the summation.
3132
Default: True.
@@ -52,8 +53,9 @@ class TurbineClusterModelChain(object):
5253
representing the wind turbine cluster.
5354
wake_losses_method : String
5455
Defines the method for talking wake losses within the farm into
55-
consideration. Options: 'wind_efficiency_curve', 'constant_efficiency'
56-
or None. Default: 'wind_efficiency_curve'.
56+
consideration. Options: 'power_efficiency_curve',
57+
'constant_efficiency', 'dena_mean', 'knorr_mean' or None. # TODO all curves in WPL
58+
Default: 'dena_mean'.
5759
smoothing : Boolean
5860
If True the power curves will be smoothed before the summation.
5961
Default: True.
@@ -75,7 +77,7 @@ class TurbineClusterModelChain(object):
7577
Default: 'wind_farm_power_curves'.
7678
7779
"""
78-
def __init__(self, wind_object, wake_losses_method='wind_efficiency_curve',
80+
def __init__(self, wind_object, wake_losses_method='dena_mean',
7981
smoothing=True, block_width=0.5,
8082
standard_deviation_method='turbulence_intensity',
8183
smoothing_order='wind_farm_power_curves'):
@@ -140,15 +142,16 @@ def wind_farm_power_curve(self, wind_farm, **kwargs):
140142
"'turbulence_intensity' as " +
141143
"`standard_deviation_method` if " +
142144
"`turbulence_intensity` is not given")
143-
if self.wake_losses_method is not None:
144-
if wind_farm.efficiency is None:
145-
raise KeyError(
146-
"wind_farm_efficiency is needed if " +
147-
"`wake_losses_method´ is '{0}', but ".format(
148-
self.wake_losses_method) +
149-
" `wind_farm_efficiency` of {0} is {1}.".format(
150-
self.wind_object.object_name,
151-
self.wind_object.efficiency))
145+
if ((self.wake_losses_method == 'power_efficiency_curves' or
146+
self.wake_losses_method == 'constant_efficiency') and
147+
wind_farm.efficiency is None):
148+
raise KeyError(
149+
"wind farm efficiency is needed if " +
150+
"`wake_losses_method´ is '{0}', but ".format(
151+
self.wake_losses_method) +
152+
" `efficiency` of {0} is {1}.".format(
153+
self.wind_object.object_name,
154+
self.wind_object.efficiency))
152155
# Get original power curve
153156
power_curve = pd.DataFrame(
154157
turbine_type_dict['wind_turbine'].power_curve)
@@ -188,14 +191,15 @@ def wind_farm_power_curve(self, wind_farm, **kwargs):
188191
standard_deviation_method=self.standard_deviation_method,
189192
**kwargs)
190193
if (self.wake_losses_method == 'constant_efficiency' or
191-
self.wake_losses_method == 'wind_efficiency_curve'):
194+
self.wake_losses_method == 'power_efficiency_curve'):
192195
summarized_power_curve_df = (
193196
power_curves.wake_losses_to_power_curve(
194197
summarized_power_curve_df['wind_speed'].values,
195198
summarized_power_curve_df['power'].values,
196199
wake_losses_method=self.wake_losses_method,
197200
wind_farm_efficiency=self.wind_object.efficiency))
198201
return summarized_power_curve_df
202+
199203
def turbine_cluster_power_curve(self, **kwargs):
200204
r"""
201205
Caluclates the power curve of a wind turbine cluster.
@@ -384,7 +388,23 @@ def run_model(self, weather_df, **kwargs):
384388
# Get modelchain parameters
385389
modelchain_data = self.get_modelchain_data(**kwargs)
386390
# Run modelchain
391+
if (self.wake_losses_method != 'power_efficiency_curve' and
392+
self.wake_losses_method != 'constant_efficiency' and
393+
isinstance(self.wind_object, wind_farm.WindFarm)):
394+
# Assign efficiency of wind farm to variable passed to modelchain
395+
wind_efficiency_curve_name = self.wake_losses_method
396+
elif (self.wake_losses_method != 'power_efficiency_curve' and
397+
self.wake_losses_method != 'constant_efficiency' and
398+
isinstance(self.wind_object,
399+
wind_turbine_cluster.WindTurbineCluster)):
400+
raise ValueError("´wake_losses_method´ 'wind_efficiency_curve'" +
401+
"cannot be applied to object of " +
402+
"WindTurbineCluster object.")
403+
else:
404+
wind_efficiency_curve_name = None
387405
mc = modelchain.ModelChain(
388-
self.wind_object, **modelchain_data).run_model(weather_df)
406+
self.wind_object, **modelchain_data).run_model(
407+
weather_df,
408+
wind_efficiency_curve_name=wind_efficiency_curve_name)
389409
self.power_output = mc.power_output
390410
return self

0 commit comments

Comments
 (0)