def test_wind_feedin_scaling(self, windpowerlib_turbine, windpowerlib_weather): """ Test that wind feedin timeseries are scaled correctly. """ test_turbine = WindPowerPlant(**windpowerlib_turbine) feedin = test_turbine.feedin(weather=windpowerlib_weather, scaling='nominal_power') assert 833050.32551 / 3e6 == pytest.approx(feedin.values[0], 1e-5)
def test_windpowerlib_turbine_cluster_feedin(self, windpowerlib_turbine_cluster, windpowerlib_weather): """ Test basic feedin calculation using windpowerlib wind turbine cluster modelchain for a wind turbine cluster. """ test_cluster = WindPowerPlant(**windpowerlib_turbine_cluster, model=WindpowerlibTurbineCluster) feedin = test_cluster.feedin(weather=windpowerlib_weather) assert 7285008.02048 == pytest.approx(feedin.values[0], 1e-5)
def test_windpowerlib_single_turbine_feedin_with_optional_pp_parameter( self, windpowerlib_turbine, windpowerlib_weather): """ Test basic feedin calculation using windpowerlib single turbine and using optional parameters for power plant and modelchain. """ windpowerlib_turbine['rotor_diameter'] = 82 test_turbine = WindPowerPlant(**windpowerlib_turbine) feedin = test_turbine.feedin( weather=windpowerlib_weather, power_output_model='power_coefficient_curve') assert 847665.85209 == pytest.approx(feedin.values[0], 1e-5)
def test_windpowerlib_single_turbine_feedin(self, windpowerlib_turbine, windpowerlib_weather): """ Test basic feedin calculation using windpowerlib single turbine. It is also tested if dictionary with turbine parameters remains the same to make sure it could be further used to calculate feed-in with a different model. """ test_copy = deepcopy(windpowerlib_turbine) test_turbine = WindPowerPlant(**windpowerlib_turbine) feedin = test_turbine.feedin(weather=windpowerlib_weather) assert 833050.32551 == pytest.approx(feedin.values[0], 1e-5) assert test_copy == windpowerlib_turbine
def test_windpowerlib_windfarm_feedin_with_optional_parameters( self, windpowerlib_farm, windpowerlib_weather): """ Test basic feedin calculation using windpowerlib wind turbine cluster modelchain and supplying an optional power plant and modelchain parameter. """ # test optional parameter test_farm = windpowerlib_farm test_farm['efficiency'] = 0.9 farm = WindPowerPlant(**test_farm, model=WindpowerlibTurbineCluster) feedin = farm.feedin(weather=windpowerlib_weather, wake_losses_model='wind_farm_efficiency') assert 6892957.24764 == pytest.approx(feedin.values[0], 1e-5)
def windpowerlib_farm_3(self, windpowerlib_turbine, windpowerlib_turbine_2): """ Returns a test wind farm to use in tests for windpowerlib model. """ return { 'wind_turbine_fleet': pd.DataFrame({ 'wind_turbine': [ WindPowerPlant(**windpowerlib_turbine), WindPowerPlant(**windpowerlib_turbine_2) ], 'number_of_turbines': [6, 3] }) }
def test_windpowerlib_windfarm_feedin_2(self, windpowerlib_farm_3, windpowerlib_weather): """ Test basic feedin calculation using windpowerlib wind turbine cluster modelchain for a wind farm where wind turbines are provided as feedinlib WindPowerPlant objects. It is also tested if dataframe with wind turbine fleet remains the same to make sure it could be further used to calculate feed-in with a different model. """ test_copy = deepcopy(windpowerlib_farm_3) farm = WindPowerPlant(**windpowerlib_farm_3, model=WindpowerlibTurbineCluster) feedin = farm.feedin(weather=windpowerlib_weather, wake_losses_model=None) assert 7658841.386277 == pytest.approx(feedin.values[0], 1e-5) assert_frame_equal(test_copy['wind_turbine_fleet'], windpowerlib_farm_3['wind_turbine_fleet'])
def test_windpowerlib_missing_powerplant_parameter(self, windpowerlib_turbine): """ Test if initialization of powerplant fails in case of missing power plant parameter. """ del (windpowerlib_turbine['turbine_type']) msg = "The specified model 'windpowerlib_single_turbine' requires" with pytest.raises(AttributeError, match=msg): WindPowerPlant(**windpowerlib_turbine)
def windpower_timeseries(wind_data, turbine_name, weather_dir, hub_height, scale=True): """Generate windpower feedin time-series.""" # The available in turbine types and specification can found in the oemof database. # "https://github.com/wind-python/windpowerlib/blob/dev/windpowerlib/oedb/turbine_data.csv" turbine_spec = {'turbine_type': turbine_name, 'hub_height': hub_height} wind_turbine = WindPowerPlant(**turbine_spec) if scale: feedin_wind = wind_turbine.feedin(weather=wind_data, scaling="nominal_power") else: feedin_wind = wind_turbine.feedin(weather=wind_data) norminal_power_wind = wind_turbine.nominal_power windpower = feedin_wind.to_frame().rename( columns={"feedin_power_plant": "wind"}) windpower.to_csv(weather_dir + "wind_power.csv") logging.info("Wind feedin timeseries generated.") return norminal_power_wind
def test_windpowerlib_turbine_equals_windfarm(self, windpowerlib_turbine, windpowerlib_farm_2, windpowerlib_weather): """ Test if wind turbine feedin calculation yields the same as wind farm calculation with one turbine. """ # turbine feedin test_turbine = WindPowerPlant(**windpowerlib_turbine) feedin = test_turbine.feedin(weather=windpowerlib_weather) # farm feedin test_farm = WindPowerPlant(**windpowerlib_farm_2, model=WindpowerlibTurbineCluster) feedin_farm = test_farm.feedin(weather=windpowerlib_weather, wake_losses_model=None) assert feedin.values[0] == pytest.approx(feedin_farm.values[0], 1e-5)
def test_windpowerlib_windfarm_equals_cluster(self, windpowerlib_farm, windpowerlib_weather): """ Test if windfarm feedin calculation yields the same as turbine cluster calculation with one wind farm. """ # farm feedin test_farm = WindPowerPlant(**windpowerlib_farm, model=WindpowerlibTurbineCluster) feedin_farm = test_farm.feedin(weather=windpowerlib_weather) # turbine cluster test_cluster = {'wind_farms': [windpowerlib_farm]} test_cluster = WindPowerPlant(**test_cluster, model=WindpowerlibTurbineCluster) feedin_cluster = test_cluster.feedin(weather=windpowerlib_weather) assert feedin_farm.values[0] == pytest.approx(feedin_cluster.values[0], 1e-5)
# plot feedin.fillna(0).plot(title='PV feedin') plt.xlabel('Time') plt.ylabel('Power in W') plt.show() # ######## WindpowerlibTurbine model ######### # specify wind turbine enerconE126 = { 'turbine_type': 'E-82/3000', # turbine name as in register 'hub_height': 135 # in m } # instantiate feedinlib WindPowerPlant object (single turbine) e126 = WindPowerPlant(**enerconE126) # calculate feedin feedin = e126.feedin(weather=weather_df_wind, location=(52, 13)) feedin_scaled = e126.feedin(weather=weather_df_wind, location=(52, 13), scaling='capacity', scaling_value=5e6) feedin_scaled.fillna(0).plot(legend=True, label='scaled to 5 MW', title='Wind turbine feedin') feedin.fillna(0).plot(legend=True, label='single turbine') plt.xlabel('Time') plt.ylabel('Power in W') plt.show()