wind-python / windpowerlib

The windpowerlib is a library to model the output of wind turbines and farms.
https://oemof.org/
MIT License
332 stars 105 forks source link

Feature/add to_group method for wind turbine #68

Closed uvchik closed 5 years ago

uvchik commented 5 years ago

Fixes #65

In contrast to the original plan I did not provided a new class WindTurbineGroup but a method to create a group as a dictionary with the following form:

>>> vestasV90 = {
...     'hub_height': 90,
...     'turbine_type': 'V90/2000',
...     'nominal_power': 2e6}
>>> v90 = WindTurbine(**vestasV90)
>>> v90.to_group(10)
{'wind_turbine': v90, 'number_of_turbines': 10}
>>> v90.to_group(total_capacity=12e6)['number_of_turbines']
6

This can be used to calculate the number of turbines providing the total capacity or to define a group that can be used to define a WindFarm object.

>>> enerconE126 = {
...    'hub_height': 135,
...    'rotor_diameter': 127,
...    'turbine_type': 'E-126/4200'}
>>> wind_turbine_fleet = [e126.to_group(number_turbines=6),
...                       v90.to_group(total_capacity=3 * 2e6)]
>>> example_farm = wind_farm.WindFarm(wind_turbine_fleet)
>>> print(example_farm.nominal_power)
31200000.0

Furthermore I fixed some PEP8 issues. Sorry, I was to lazy to open an extra PR :smirk:

uvchik commented 5 years ago

As I fixed some documentation issues I found out that it is easier to document the WindTurbineGroup as a data class. So it is treated as a class in the documentation and therefore easy to understand but still a NamedTuple and therefore easy to handle/maintain.

I did not added it to the "Classes" in the documentation.

uvchik commented 5 years ago

I created a rendered documentation to make it easier to check the docs.

Please have a look at the wind_fleet parameter of the WindFarm class and follow the links to the WindTurbineGroup and the to_group method. Furthermore, check the example of the WindFarm class.

uvchik commented 5 years ago

I changed the examples a little bit to have the same parameters for all variants.