88__copyright__ = "Copyright oemof developer group"
99__license__ = "GPLv3"
1010
11- from windpowerlib import tools , power_curves
11+ from windpowerlib import tools , power_curves , WindTurbine
1212import numpy as np
1313import pandas as pd
1414import logging
@@ -23,8 +23,10 @@ class WindFarm(object):
2323 wind_turbine_fleet : list(dict)
2424 Wind turbines of wind farm. Dictionaries must have 'wind_turbine'
2525 (contains a :class:`~.wind_turbine.WindTurbine` object) and
26- 'number_of_turbines' (number of wind turbines of the same turbine type
27- in the wind farm) as keys.
26+ either 'number_of_turbines' (number of wind turbines of the same
27+ turbine type in the wind farm) or 'total_capacity' (installed capacity
28+ of wind turbines of the same turbine type in the wind farm) as keys.
29+ See example below.
2830 efficiency : float or :pandas:`pandas.DataFrame<frame>` or None (optional)
2931 Efficiency of the wind farm. Provide as either constant (float) or
3032 power efficiency curve (pd.DataFrame) containing 'wind_speed' and
@@ -73,7 +75,12 @@ class WindFarm(object):
7375 >>> example_farm = wind_farm.WindFarm(**example_farm_data)
7476 >>> print(example_farm.nominal_power)
7577 25200000.0
76-
78+ >>> example_farm_data = {
79+ ... 'wind_turbine_fleet': [{'wind_turbine': e126,
80+ ... 'total_capacity': 8.4e6}]}
81+ >>> example_farm = wind_farm.WindFarm(**example_farm_data)
82+ >>> print(example_farm.nominal_power)
83+ 8400000.0
7784 """
7885
7986 def __init__ (self , wind_turbine_fleet , efficiency = None , name = '' , ** kwargs ):
@@ -86,6 +93,40 @@ def __init__(self, wind_turbine_fleet, efficiency=None, name='', **kwargs):
8693 self ._nominal_power = None
8794 self .power_curve = None
8895
96+ # check integrity of given wind turbine fleet
97+ for turbine_type in self .wind_turbine_fleet :
98+ turbine_keys = list (turbine_type .keys ())
99+ # check wind turbine
100+ if 'wind_turbine' in turbine_keys :
101+ if not isinstance (turbine_type ['wind_turbine' ], WindTurbine ):
102+ raise ValueError (
103+ 'Wind turbine must be provided as WindTurbine object '
104+ 'but was provided as {}.' .format (
105+ type (turbine_type ['wind_turbine' ])))
106+ else :
107+ raise ValueError ('Missing wind_turbine key in wind turbine '
108+ 'fleet entry {}.' .format (turbine_type ))
109+ # check if number of turbines is provided
110+ if not 'number_of_turbines' in turbine_keys :
111+ if 'total_capacity' in turbine_keys :
112+ try :
113+ turbine_type ['number_of_turbines' ] = \
114+ turbine_type ['total_capacity' ] / \
115+ turbine_type ['wind_turbine' ].nominal_power
116+ except :
117+ raise ValueError (
118+ 'Number of turbines of type {turbine} can not be '
119+ 'deduced from total capacity. Please either '
120+ 'provide `number_of_turbines` in the turbine '
121+ 'fleet definition or set the nominal power of the '
122+ 'wind turbine.' .format (
123+ turbine = turbine_type ['wind_turbine' ]))
124+ else :
125+ raise ValueError (
126+ 'Please provide `number_of_turbines` or '
127+ '`total_capacity` for wind turbine {} in wind farm '
128+ 'definition.' .format (turbine_type ['wind_turbine' ]))
129+
89130 def __repr__ (self ):
90131
91132 if self .name is not '' :
0 commit comments