Skip to content

Commit 7806242

Browse files
committed
Add wake losses module which contains functions for modelling wake losses
1 parent 51fa5a5 commit 7806242

File tree

2 files changed

+150
-118
lines changed

2 files changed

+150
-118
lines changed

windpowerlib/wake_losses.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
"""
2+
The ``wake_losses`` module contains functions to TODO: add
3+
4+
"""
5+
6+
__copyright__ = "Copyright oemof developer group"
7+
__license__ = "GPLv3"
8+
9+
import numpy as np
10+
import pandas as pd
11+
import os
12+
13+
try:
14+
from matplotlib import pyplot as plt
15+
except ImportError:
16+
plt = None
17+
18+
def reduce_wind_speed(wind_speed, wind_efficiency_curve='dena_mean'):
19+
"""
20+
Reduces wind speed by a wind efficiency curve.
21+
22+
The wind efficiency curves are provided in the windpowerlib and were
23+
calculated in the dena-Netzstudie II and in the work of Knorr
24+
(see references).
25+
26+
Parameters
27+
----------
28+
wind_speed
29+
30+
wind_efficiency_curve
31+
32+
Returns
33+
-------
34+
reduced_wind_speed : pd.Series or np.array
35+
By wind efficiency curve reduced wind speed.
36+
37+
TODO add references
38+
"""
39+
# Get wind efficiency curve
40+
wind_efficiency_curve = get_wind_efficiency_curve(
41+
curve_name=wind_efficiency_curve)
42+
# Get by wind efficiency reduced wind speed
43+
reduced_wind_speed = wind_speed * np.interp(wind_speed, wind_efficiency_curve['wind_speed'], wind_efficiency_curve['efficiency'])
44+
if isinstance(wind_speed, pd.Series):
45+
reduced_wind_speed = pd.Series(data=wind_speed, index=wind_speed.index,
46+
name='reduced_wind_speed')
47+
return reduced_wind_speed
48+
49+
50+
def get_wind_efficiency_curve(curve_name='dena_mean'):
51+
r"""
52+
Reads the in `curve_name` specified wind efficiency curve.
53+
54+
Parameters
55+
----------
56+
curve_name : String
57+
Specifies the curve.
58+
Possibilities: 'dena_mean', 'knorr_mean', 'dena_extreme1',
59+
'dena_extreme2', 'knorr_extreme1', 'knorr_extreme2', 'knorr_extreme3'.
60+
Default: 'dena_mean'.
61+
plot : Boolean
62+
If True the wind efficiency curve is plotted. Default: False.
63+
64+
Returns
65+
-------
66+
efficiency_curve : pd.DataFrame
67+
Wind efficiency curve. Contains 'wind_speed' and 'efficiency' columns
68+
with wind speed in m/s and wind farm efficiency (dimensionless).
69+
70+
Notes
71+
-----
72+
The wind efficiency curves were calculated in the "Dena Netzstudie" and in
73+
the disseration of Kaspar Knorr. For more information see [1]_ and [2]_.
74+
75+
References
76+
----------
77+
.. [1] Kohler et.al.: "dena-Netzstudie II. Integration erneuerbarer
78+
Energien in die deutsche Stromversorgung im Zeitraum 2015 – 2020
79+
mit Ausblick 2025.", Deutsche Energie-Agentur GmbH (dena),
80+
Tech. rept., 2010, p. 101
81+
.. [2] Knorr, K.: "Modellierung von raum-zeitlichen Eigenschaften der
82+
Windenergieeinspeisung für wetterdatenbasierte
83+
Windleistungssimulationen". Universität Kassel, Diss., 2016,
84+
p. 124
85+
86+
"""
87+
path = os.path.join(os.path.dirname(__file__), 'data',
88+
'wind_efficiency_curves_{}.csv'.format(
89+
curve_name.split('_')[0]))
90+
# Read all curves from file
91+
wind_efficiency_curves = pd.read_csv(path)
92+
efficiency_curve = wind_efficiency_curves[['wind_speed', curve_name]]
93+
efficiency_curve.columns = ['wind_speed', 'efficiency']
94+
return efficiency_curve
95+
96+
97+
def display_wind_efficiency_curves():
98+
r"""
99+
Plots or prints all efficiency curves available in the windpowerlib.
100+
101+
Notes
102+
-----
103+
The wind efficiency curves were calculated in the "Dena Netzstudie" and in
104+
the disseration of Kaspar Knorr. For more information see [1]_ and [2]_.
105+
106+
References
107+
----------
108+
.. [1] Kohler et.al.: "dena-Netzstudie II. Integration erneuerbarer
109+
Energien in die deutsche Stromversorgung im Zeitraum 2015 – 2020
110+
mit Ausblick 2025.", Deutsche Energie-Agentur GmbH (dena),
111+
Tech. rept., 2010, p. 101
112+
.. [2] Knorr, K.: "Modellierung von raum-zeitlichen Eigenschaften der
113+
Windenergieeinspeisung für wetterdatenbasierte
114+
Windleistungssimulationen". Universität Kassel, Diss., 2016,
115+
p. 124
116+
117+
"""
118+
path = os.path.join(os.path.dirname(__file__), 'data',
119+
'wind_efficiency_curves.csv')
120+
# Read all curves from file
121+
wind_efficiency_curves = pd.read_csv(path)
122+
# Initialize data frame for plot
123+
curves_df = pd.DataFrame()
124+
for curve_name in [col for col in list(wind_efficiency_curves) if
125+
'x_' not in col]:
126+
# Get wind efficiency curve for standard wind speeds from
127+
# read_wind_efficiency_curve() and add to data frame
128+
efficiency_curve = get_wind_efficiency_curve(
129+
curve_name).rename(
130+
columns={'efficiency': curve_name.replace('_', ' '),
131+
'wind_speed': 'wind speed m/s'}).set_index(
132+
'wind speed m/s')
133+
curves_df = pd.concat([curves_df, efficiency_curve], axis=1)
134+
# Create separate data frames for origin of curve
135+
knorr_df = curves_df[[column_name for column_name in curves_df if
136+
'knorr' in column_name]]
137+
dena_df = curves_df[[column_name for column_name in curves_df if
138+
'dena' in column_name]]
139+
if plt:
140+
fig, ax = plt.subplots()
141+
dena_df.plot(ax=ax, legend=True, marker='x', markersize=3)
142+
knorr_df.plot(ax=ax, legend=True, marker='o', markersize=3)
143+
plt.ylabel('Wind farm efficiency')
144+
plt.show()
145+
else:
146+
print(dena_df)
147+
print(knorr_df)
148+
149+
if __name__ == "__main__":
150+
display_wind_efficiency_curves()

windpowerlib/wind_farm.py

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99
__license__ = "GPLv3"
1010

1111
import numpy as np
12-
import pandas as pd
13-
import os
14-
15-
try:
16-
from matplotlib import pyplot as plt
17-
except ImportError:
18-
plt = None
1912

2013

2114
class WindFarm(object):
@@ -128,114 +121,3 @@ def get_installed_power(self):
128121
wind_dict['wind_turbine'].nominal_power *
129122
wind_dict['number_of_turbines']
130123
for wind_dict in self.wind_turbine_fleet)
131-
132-
133-
def read_wind_efficiency_curve(curve_name='dena_mean', plot=False):
134-
r"""
135-
Reads the in `curve_name` specified wind efficiency curve.
136-
137-
Parameters
138-
----------
139-
curve_name : String
140-
Specifies the curve.
141-
Possibilities: 'dena_mean', 'knorr_mean', 'dena_extreme1',
142-
'dena_extreme2', 'knorr_extreme1', 'knorr_extreme2', 'knorr_extreme3'.
143-
Default: 'dena_mean'.
144-
plot : Boolean
145-
If True the wind efficiency curve is plotted. Default: False.
146-
147-
Returns
148-
-------
149-
efficiency_curve : pd.DataFrame
150-
Wind efficiency curve. Contains 'wind_speed' and 'efficiency' columns
151-
with wind speed in m/s and wind farm efficiency (dimensionless).
152-
153-
Notes
154-
-----
155-
The wind efficiency curves were calculated in the "Dena Netzstudie" and in
156-
the disseration of Kaspar Knorr. For more information see [1]_ and [2]_.
157-
158-
References
159-
----------
160-
.. [1] Kohler et.al.: "dena-Netzstudie II. Integration erneuerbarer
161-
Energien in die deutsche Stromversorgung im Zeitraum 2015 – 2020
162-
mit Ausblick 2025.", Deutsche Energie-Agentur GmbH (dena),
163-
Tech. rept., 2010, p. 101
164-
.. [2] Knorr, K.: "Modellierung von raum-zeitlichen Eigenschaften der
165-
Windenergieeinspeisung für wetterdatenbasierte
166-
Windleistungssimulationen". Universität Kassel, Diss., 2016,
167-
p. 124
168-
169-
"""
170-
path = os.path.join(os.path.dirname(__file__), 'data',
171-
'wind_efficiency_curves.csv')
172-
# Read all curves from file
173-
wind_efficiency_curves = pd.read_csv(path)
174-
efficiency_curve = wind_efficiency_curves[['wind_speed', curve_name]]
175-
efficiency_curve.columns = ['wind_speed', 'efficiency']
176-
if plot:
177-
efficiency_curve.rename(columns={'wind_speed': 'wind speed m/s'},
178-
inplace=True)
179-
efficiency_curve.set_index('wind speed m/s').plot(
180-
legend=False, title="Wind efficiency curve '{}'".format(
181-
curve_name))
182-
plt.ylabel('Efficiency')
183-
plt.show()
184-
return efficiency_curve
185-
186-
187-
def display_wind_efficiency_curves():
188-
r"""
189-
Plots or prints all efficiency curves available in the windpowerlib.
190-
191-
Notes
192-
-----
193-
The wind efficiency curves were calculated in the "Dena Netzstudie" and in
194-
the disseration of Kaspar Knorr. For more information see [1]_ and [2]_.
195-
196-
References
197-
----------
198-
.. [1] Kohler et.al.: "dena-Netzstudie II. Integration erneuerbarer
199-
Energien in die deutsche Stromversorgung im Zeitraum 2015 – 2020
200-
mit Ausblick 2025.", Deutsche Energie-Agentur GmbH (dena),
201-
Tech. rept., 2010, p. 101
202-
.. [2] Knorr, K.: "Modellierung von raum-zeitlichen Eigenschaften der
203-
Windenergieeinspeisung für wetterdatenbasierte
204-
Windleistungssimulationen". Universität Kassel, Diss., 2016,
205-
p. 124
206-
207-
"""
208-
path = os.path.join(os.path.dirname(__file__), 'data',
209-
'wind_efficiency_curves.csv')
210-
# Read all curves from file
211-
wind_efficiency_curves = pd.read_csv(path)
212-
# Initialize data frame for plot
213-
curves_df = pd.DataFrame()
214-
for curve_name in [col for col in list(wind_efficiency_curves) if
215-
'x_' not in col]:
216-
# Get wind efficiency curve for standard wind speeds from
217-
# read_wind_efficiency_curve() and add to data frame
218-
efficiency_curve = read_wind_efficiency_curve(
219-
curve_name).rename(
220-
columns={'efficiency': curve_name.replace('_', ' '),
221-
'wind_speed': 'wind speed m/s'}).set_index(
222-
'wind speed m/s')
223-
curves_df = pd.concat([curves_df, efficiency_curve], axis=1)
224-
# Create separate data frames for origin of curve
225-
knorr_df = curves_df[[column_name for column_name in curves_df if
226-
'knorr' in column_name]]
227-
dena_df = curves_df[[column_name for column_name in curves_df if
228-
'dena' in column_name]]
229-
if plt:
230-
fig, ax = plt.subplots()
231-
dena_df.plot(ax=ax, legend=True, marker='x', markersize=3)
232-
knorr_df.plot(ax=ax, legend=True, marker='o', markersize=3)
233-
plt.ylabel('Wind farm efficiency')
234-
plt.show()
235-
# fig.savefig('wind_eff_curves.pdf')
236-
else:
237-
print(dena_df)
238-
print(knorr_df)
239-
240-
if __name__ == "__main__":
241-
display_wind_efficiency_curves()

0 commit comments

Comments
 (0)