SPDX-FileCopyrightText: 2019 oemof developer group contact@oemof.org
SPDX-License-Identifier: MIT
SPDX-License-Identifier: CC-BY-4.0
This example shows you how to calculate the power output of wind farms and wind turbine clusters using the windpowerlib. A cluster can be useful if you want to calculate the feed-in of a region for which you want to use one single weather data point.
Functions that are used in the ModelChain example, like the initialization of wind turbines, are imported and used without further explanation.
The import of weather data and the initialization of wind turbines is done as in the modelchain_example
. Be aware that currently for wind farm and wind cluster calculations wind turbines need to have a power curve as some calculations do not work with the power coefficient curve.
In [1]:
import pandas as pd
import modelchain_example as mc_e
from windpowerlib import TurbineClusterModelChain, WindTurbineCluster, WindFarm
import logging
logging.getLogger().setLevel(logging.DEBUG)
In [2]:
# Get weather data
weather = mc_e.get_weather_data('weather.csv')
print(weather[['wind_speed', 'temperature', 'pressure']][0:3])
# Initialize wind turbines
my_turbine, e126, my_turbine2 = mc_e.initialize_wind_turbines()
print()
print('nominal power of my_turbine: {}'.format(my_turbine.nominal_power))
In [3]:
# specification of wind farm data where turbine fleet is provided in a
# pandas.DataFrame
# for each turbine type you can either specify the number of turbines of
# that type in the wind farm (float values are possible as well) or the
# total installed capacity of that turbine type in W
wind_turbine_fleet = pd.DataFrame(
{'wind_turbine': [my_turbine, e126], # as windpowerlib.WindTurbine
'number_of_turbines': [6, None],
'total_capacity': [None, 12.6e6]}
)
# initialize WindFarm object
example_farm = WindFarm(name='example_farm',
wind_turbine_fleet=wind_turbine_fleet)
Following, a wind farm with a constant efficiency is defined. A wind farm efficiency can also be dependent on the wind speed in which case it needs to be provided as a dataframe with 'wind_speed' and 'efficiency' columns containing wind speeds in m/s and the corresponding dimensionless wind farm efficiency.
In [4]:
# specification of wind farm data (2) containing a wind farm efficiency
# wind turbine fleet is provided using the to_group function
example_farm_2_data = {
'name': 'example_farm_2',
'wind_turbine_fleet': [my_turbine.to_group(6),
e126.to_group(total_capacity=12.6e6)],
'efficiency': 0.9}
# initialize WindFarm object
example_farm_2 = WindFarm(**example_farm_2_data)
print('nominal power of first turbine type of example_farm_2: {}'.format(
example_farm_2.wind_turbine_fleet.loc[0, 'wind_turbine'].nominal_power))
In [5]:
# specification of cluster data
example_cluster_data = {
'name': 'example_cluster',
'wind_farms': [example_farm, example_farm_2]}
# initialize WindTurbineCluster object
example_cluster = WindTurbineCluster(**example_cluster_data)
The TurbineClusterModelChain is a class that provides all necessary steps to calculate the power output of a wind farm or wind turbine cluster.
Like the ModelChain (see basic example) you can use the TurbineClusterModelChain with default parameters as shown in this example for the wind farm or specify custom parameters as done here for the cluster. If you use the 'run_model' method first the aggregated power curve and the mean hub height of the wind farm/cluster is calculated, then inherited functions of the ModelChain are used to calculate the wind speed and density (if necessary) at hub height. After that, depending on the parameters, wake losses are applied and at last the power output is calculated.
In [6]:
# power output calculation for example_farm
# initialize TurbineClusterModelChain with default parameters and use
# run_model method to calculate power output
mc_example_farm = TurbineClusterModelChain(example_farm).run_model(weather)
# write power output time series to WindFarm object
example_farm.power_output = mc_example_farm.power_output
In [7]:
# set efficiency of example_farm to apply wake losses
example_farm.efficiency = 0.9
# power output calculation for turbine_cluster
# own specifications for TurbineClusterModelChain setup
modelchain_data = {
'wake_losses_model': 'wind_farm_efficiency', #
# 'dena_mean' (default), None,
# 'wind_farm_efficiency' or name
# of another wind efficiency curve
# see :py:func:`~.wake_losses.get_wind_efficiency_curve`
'smoothing': True, # False (default) or True
'block_width': 0.5, # default: 0.5
'standard_deviation_method': 'Staffell_Pfenninger', #
# 'turbulence_intensity' (default)
# or 'Staffell_Pfenninger'
'smoothing_order': 'wind_farm_power_curves', #
# 'wind_farm_power_curves' (default) or
# 'turbine_power_curves'
'wind_speed_model': 'logarithmic', # 'logarithmic' (default),
# 'hellman' or
# 'interpolation_extrapolation'
'density_model': 'ideal_gas', # 'barometric' (default), 'ideal_gas' or
# 'interpolation_extrapolation'
'temperature_model': 'linear_gradient', # 'linear_gradient' (def.) or
# 'interpolation_extrapolation'
'power_output_model': 'power_curve', # 'power_curve' (default) or
# 'power_coefficient_curve'
'density_correction': True, # False (default) or True
'obstacle_height': 0, # default: 0
'hellman_exp': None} # None (default) or None
# initialize TurbineClusterModelChain with own specifications and use
# run_model method to calculate power output
mc_example_cluster = TurbineClusterModelChain(
example_cluster, **modelchain_data).run_model(weather)
# write power output time series to WindTurbineCluster object
example_cluster.power_output = mc_example_cluster.power_output
In [8]:
# try to import matplotlib
logging.getLogger().setLevel(logging.WARNING)
try:
from matplotlib import pyplot as plt
# matplotlib inline needed in notebook to plot inline
%matplotlib inline
except ImportError:
plt = None
In [9]:
# plot turbine power output
if plt:
example_cluster.power_output.plot(legend=True, label='example cluster')
example_farm.power_output.plot(legend=True, label='example farm')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power in W')
plt.show()
In [10]:
# plot aggregated (and smoothed) power curve of example_cluster
if plt:
example_cluster.power_curve.plot(
x='wind_speed', y='value', style='*')
plt.xlabel('Wind speed in m/s')
plt.ylabel('Power in W')
plt.show()
In [ ]: