コード例 #1
0
 def setup_class(self):
     temperature_2m = np.array([[267], [268]])
     temperature_10m = np.array([[267], [266]])
     pressure_0m = np.array([[101125], [101000]])
     wind_speed_8m = np.array([[4.0], [5.0]])
     wind_speed_10m = np.array([[5.0], [6.5]])
     roughness_length = np.array([[0.15], [0.15]])
     self.weather_df = pd.DataFrame(np.hstack(
         (temperature_2m, temperature_10m, pressure_0m, wind_speed_8m,
          wind_speed_10m, roughness_length)),
                                    index=[0, 1],
                                    columns=[
                                        np.array([
                                            'temperature', 'temperature',
                                            'pressure', 'wind_speed',
                                            'wind_speed', 'roughness_length'
                                        ]),
                                        np.array([2, 10, 0, 8, 10, 0])
                                    ])
     self.test_turbine = {
         'hub_height': 100,
         'rotor_diameter': 80,
         'turbine_type': 'E-126/4200'
     }
     self.test_turbine_2 = {
         'hub_height': 90,
         'rotor_diameter': 60,
         'turbine_type': 'V90/2000',
         'nominal_power': 2000000.0
     }
     self.test_farm = {
         'wind_turbine_fleet': [{
             'wind_turbine':
             wt.WindTurbine(**self.test_turbine),
             'number_of_turbines':
             3
         }]
     }
     self.test_farm_2 = {
         'name':
         'test farm',
         'wind_turbine_fleet': [{
             'wind_turbine':
             wt.WindTurbine(**self.test_turbine),
             'number_of_turbines':
             3
         }, {
             'wind_turbine':
             wt.WindTurbine(**self.test_turbine_2),
             'number_of_turbines':
             3
         }]
     }
     self.test_cluster = {
         'name':
         'example_cluster',
         'wind_farms':
         [wf.WindFarm(**self.test_farm),
          wf.WindFarm(**self.test_farm_2)]
     }
コード例 #2
0
    def test_density_hub(self):
        # Test modelchain with density_model='barometric'
        test_mc = mc.ModelChain(wt.WindTurbine(**self.test_turbine))
        # Test modelchain with density_model='ideal_gas'
        test_mc_2 = mc.ModelChain(wt.WindTurbine(**self.test_turbine),
                                  density_model="ideal_gas")
        # Test modelchain with density_model='interpolation_extrapolation'
        test_mc_3 = mc.ModelChain(
            wt.WindTurbine(**self.test_turbine),
            density_model="interpolation_extrapolation",
        )

        # Parameters for tests
        temperature_2m = np.array([[267], [268]])
        temperature_10m = np.array([[267], [266]])
        pressure_0m = np.array([[101125], [101000]])
        weather_df = pd.DataFrame(
            np.hstack((temperature_2m, temperature_10m, pressure_0m)),
            index=[0, 1],
            columns=[
                np.array(["temperature", "temperature", "pressure"]),
                np.array([2, 10, 0]),
            ],
        )

        # temperature_10m is closer to hub height than temperature_2m
        rho_exp = pd.Series(data=[1.30591, 1.30919])
        assert_series_equal(test_mc.density_hub(weather_df), rho_exp)
        rho_exp = pd.Series(data=[1.30595575725, 1.30923554056])
        assert_series_equal(test_mc_2.density_hub(weather_df), rho_exp)

        # change heights of temperatures so that old temperature_2m is now used
        weather_df.columns = [
            np.array(["temperature", "temperature", "pressure"]),
            np.array([10, 200, 0]),
        ]
        rho_exp = pd.Series(data=[1.30591, 1.29940])
        assert_series_equal(test_mc.density_hub(weather_df), rho_exp)
        rho_exp = pd.Series(data=[1.30595575725, 1.29944375221])
        assert_series_equal(test_mc_2.density_hub(weather_df), rho_exp)

        # temperature at hub height
        weather_df.columns = [
            np.array(["temperature", "temperature", "pressure"]),
            np.array([100, 10, 0]),
        ]
        rho_exp = pd.Series(data=[1.30305, 1.29657])
        assert_series_equal(test_mc.density_hub(weather_df), rho_exp)

        # density interpolation
        density_10m = np.array([[1.30591], [1.29940]])
        density_150m = np.array([[1.30305], [1.29657]])
        weather_df = pd.DataFrame(
            np.hstack((density_10m, density_150m)),
            index=[0, 1],
            columns=[np.array(["density", "density"]),
                     np.array([10, 150])],
        )
        rho_exp = pd.Series(data=[1.304071, 1.297581])
        assert_series_equal(test_mc_3.density_hub(weather_df), rho_exp)
コード例 #3
0
 def test_tc_modelchain_with_power_curve_as_dict(self):
     """Test power curves as dict in TurbineClusterModelChain.run_model()"""
     my_turbine = {
         'nominal_power': 3e6,
         'hub_height': 105,
         'power_curve': {
             'value':
             [p * 1000 for p in [0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]],
             'wind_speed': [0.0, 3.0, 5.0, 10.0, 15.0, 25.0]
         }
     }
     my_farm = {
         'wind_turbine_fleet': [{
             'wind_turbine': wt.WindTurbine(**my_turbine),
             'number_of_turbines': 3
         }, {
             'wind_turbine':
             wt.WindTurbine(**self.test_turbine),
             'number_of_turbines':
             3
         }]
     }
     my_cluster = {
         'wind_farms':
         [wf.WindFarm(**my_farm),
          wf.WindFarm(**self.test_farm)]
     }
     power_output_exp = pd.Series(
         data=[10853277.966972714, 21731814.593688786],
         name='feedin_power_plant')
     # run model with my_cluster
     test_tc_mc = tc_mc.TurbineClusterModelChain(
         power_plant=wtc.WindTurbineCluster(**my_cluster))
     test_tc_mc.run_model(self.weather_df)
     assert_series_equal(test_tc_mc.power_output, power_output_exp)
コード例 #4
0
def check_theoretical_power(df, year, start=None, end=None):
    r"""
    This function was used to compare the theoretical power of ArgeNetz wind
    farms with the simulated power when the measured wind speed (of ArgeNetz
    data) is used.

    As no wind speed is added to the data of 2015 this function can only be
    used for the year 2015.

    """
    wind_farm_names = ['wf_1', 'wf_3', 'wf_4', 'wf_5']
    wind_turbine_amount = [(0, 16), (4, 13), (0, 22), (0, 14)]
    # Turbine data
    enerconE70 = {
        'turbine_name': 'ENERCON E 70 2300',
        'hub_height': 64,  # in m
        'rotor_diameter': 71  # in m
    }
    enerconE66 = {
        'turbine_name': 'ENERCON E 66 1800',
        'hub_height': 65,  # in m
        'rotor_diameter': 70  # in m
        }
    # Initialize WindTurbine objects
    e70 = wt.WindTurbine(**enerconE70)
    e66 = wt.WindTurbine(**enerconE66)
    for name, turbine_amount in zip(wind_farm_names, wind_turbine_amount):
        indices = tools.get_indices_for_series(1, 'Europe/Berlin', year)
        power_output_theo = df[name + '_theoretical_power'] / 1000
        power_output_theo = pd.Series(data=power_output_theo.values,
                                      index=indices)
        power_output_by_wind_speed = (
            turbine_amount[0] * power_output.power_curve(
                df[name + '_wind_speed'], e66.power_curve['wind_speed'],
                e66.power_curve['power']) +
            turbine_amount[1] * power_output.power_curve(
                df[name + '_wind_speed'], e70.power_curve['wind_speed'],
                e70.power_curve['power'])) / (1*10**6)
        power_output_by_wind_speed = pd.Series(
            data=power_output_by_wind_speed.values, index=indices)
        val_obj = analysis_tools.ValidationObject(
            'validate_arge_4919', power_output_theo,
            power_output_by_wind_speed,
            weather_data_name='calculated by wind speed',
            validation_name='P_W theoretical')
        val_obj.output_method = 'power_output'
        visualization_tools.plot_feedin_comparison(
            val_obj, filename='../Plots/Test_Arge/{0}_{1}_feedin'.format(
                year, name),
            title='{0}'.format(name), start=start, end=end)
        visualization_tools.plot_correlation(
            val_obj, filename='../Plots/Test_Arge/{0}_{1}_corr'.format(
                year, name),
            title='{0}'.format(name))
コード例 #5
0
    def test_wind_speed_hub(self):
        # Test modelchain with wind_speed_model='logarithmic'
        test_mc = mc.ModelChain(wt.WindTurbine(**self.test_turbine))
        # Test modelchain with wind_speed_model='hellman'
        test_mc_2 = mc.ModelChain(wt.WindTurbine(**self.test_turbine),
                                  wind_speed_model="hellman")
        # Test modelchain with wind_speed_model='interpolation_extrapolation'
        test_mc_3 = mc.ModelChain(
            wt.WindTurbine(**self.test_turbine),
            wind_speed_model="interpolation_extrapolation",
        )
        # Test modelchain with
        # wind_speed_model='log_interpolation_extrapolation'
        test_mc_4 = mc.ModelChain(
            wt.WindTurbine(**self.test_turbine),
            wind_speed_model="log_interpolation_extrapolation",
        )

        # Parameters for tests
        wind_speed_8m = np.array([[4.0], [5.0]])
        wind_speed_10m = np.array([[5.0], [6.5]])
        roughness_length = np.array([[0.15], [0.15]])
        weather_df = pd.DataFrame(
            np.hstack((wind_speed_8m, wind_speed_10m, roughness_length)),
            index=[0, 1],
            columns=[
                np.array(["wind_speed", "wind_speed", "roughness_length"]),
                np.array([8, 10, 0]),
            ],
        )

        # wind_speed_10m is closer to hub height than wind_speed_8m
        v_wind_exp = pd.Series(data=[7.74137, 10.06377])
        assert_series_equal(test_mc.wind_speed_hub(weather_df), v_wind_exp)
        v_wind_exp = pd.Series(data=[7.12462, 9.26201])
        assert_series_equal(test_mc_2.wind_speed_hub(weather_df), v_wind_exp)
        v_wind_exp = pd.Series(data=[50.0, 74.0])
        assert_series_equal(test_mc_3.wind_speed_hub(weather_df), v_wind_exp)
        v_wind_exp = pd.Series(data=[15.3188511585, 21.9782767378])
        assert_series_equal(test_mc_4.wind_speed_hub(weather_df), v_wind_exp)

        # wind_speed is given at hub height
        weather_df.columns = [
            np.array(["wind_speed", "wind_speed", "roughness_length"]),
            np.array([10, 100, 0]),
        ]
        v_wind_exp = pd.Series(data=[5.0, 6.5], name=100)
        assert_series_equal(test_mc.wind_speed_hub(weather_df), v_wind_exp)
コード例 #6
0
    def test_heigths_as_string(self):
        """Test run_model if data heights are of type string."""
        test_turbine = {
            "hub_height": 100,
            "rotor_diameter": 80,
            "turbine_type": "E-126/4200",
        }

        # Convert data heights to str
        string_weather = self.weather_df.copy()
        string_weather.columns = pd.MultiIndex.from_arrays([
            string_weather.columns.get_level_values(0),
            string_weather.columns.get_level_values(1).astype(str),
        ])

        # Heights in the original DataFrame are of type np.int64
        assert isinstance(
            self.weather_df.columns.get_level_values(1)[0], np.int64)
        assert isinstance(string_weather.columns.get_level_values(1)[0], str)

        test_modelchain = {
            "power_output_model": "power_curve",
            "density_corr": True,
        }
        test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                **test_modelchain)
        test_mc.run_model(string_weather)
コード例 #7
0
 def test_wrong_density_correction_type(self):
     """Raise TypeErrors due to wrong type of `density_correction`"""
     with pytest.raises(TypeError):
         test_modelchain = {'power_output_model': 'power_curve',
                            'density_correction': 'wrong_type'}
         test_mc = mc.ModelChain(wt.WindTurbine(**self.test_turbine),
                                 **test_modelchain)
         test_mc.run_model(self.weather_df)
コード例 #8
0
 def test_wrong_spelling_wind_speed_model(self):
     """Raise ValueErrors due to wrong spelling of wind_speed_model"""
     with pytest.raises(ValueError):
         test_modelchain = {'wind_speed_model': 'wrong_spelling',
                            'power_output_model': 'power_coefficient_curve',
                            'density_correction': False}
         test_mc = mc.ModelChain(wt.WindTurbine(**self.test_turbine),
                                 **test_modelchain)
         test_mc.run_model(self.weather_df)
コード例 #9
0
    def test_temperature_hub(self):
        # Test modelchain with temperature_model='linear_gradient'
        test_mc = mc.ModelChain(wt.WindTurbine(**self.test_turbine))
        # Test modelchain with temperature_model='interpolation_extrapolation'
        test_mc_2 = mc.ModelChain(
            wt.WindTurbine(**self.test_turbine),
            temperature_model="interpolation_extrapolation",
        )

        # Parameters for tests
        temperature_2m = np.array([[267], [268]])
        temperature_10m = np.array([[267], [266]])
        weather_df = pd.DataFrame(
            np.hstack((temperature_2m, temperature_10m)),
            index=[0, 1],
            columns=[
                np.array(["temperature", "temperature"]),
                np.array([2, 10]),
            ],
        )

        # temperature_10m is closer to hub height than temperature_2m
        temp_exp = pd.Series(data=[266.415, 265.415], name=10)
        assert_series_equal(test_mc.temperature_hub(weather_df), temp_exp)
        temp_exp = pd.Series(data=[267.0, 243.5])
        assert_series_equal(test_mc_2.temperature_hub(weather_df), temp_exp)

        # change heights of temperatures so that old temperature_2m is now used
        weather_df.columns = [
            np.array(["temperature", "temperature"]),
            np.array([10, 200]),
        ]
        temp_exp = pd.Series(data=[266.415, 267.415], name=10)
        assert_series_equal(test_mc.temperature_hub(weather_df), temp_exp)
        temp_exp = pd.Series(data=[267.0, 267.052632])
        assert_series_equal(test_mc_2.temperature_hub(weather_df), temp_exp)

        # temperature at hub height
        weather_df.columns = [
            np.array(["temperature", "temperature"]),
            np.array([100, 10]),
        ]
        temp_exp = pd.Series(data=[267, 268], name=100)
        assert_series_equal(test_mc.temperature_hub(weather_df), temp_exp)
コード例 #10
0
 def test_with_default_parameter(self):
     """Test with default parameters of modelchain (power curve)"""
     test_turbine = {'hub_height': 100,
                     'rotor_diameter': 80,
                     'turbine_type': 'E-126/4200'}
     power_output_exp = pd.Series(data=[1637405.4840444783,
                                        3154438.3894902095],
                                  name='feedin_power_plant')
     test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine))
     test_mc.run_model(self.weather_df)
     assert_series_equal(test_mc.power_output, power_output_exp)
コード例 #11
0
 def test_wrong_spelling_power_output_model(self):
     """Raise ValueErrors due to wrong spelling of power_output_model"""
     with pytest.raises(ValueError):
         test_modelchain = {
             "wind_speed_model": "hellman",
             "power_output_model": "wrong_spelling",
             "density_correction": False,
         }
         test_mc = mc.ModelChain(wt.WindTurbine(**self.test_turbine),
                                 **test_modelchain)
         test_mc.run_model(self.weather_df)
コード例 #12
0
    def test_error_raising(self):

        # Raise ValueError when aggregated wind farm power curve needs to be
        # calculated but turbine does not have a power curve
        test_turbine_data = {
            "hub_height": 100,
            "rotor_diameter": 98,
            "turbine_type": "V90/2000",
        }
        test_turbine = wt.WindTurbine(**test_turbine_data)
        test_turbine.power_curve = True
        test_farm = {
            "wind_turbine_fleet": [
                {
                    "wind_turbine": wt.WindTurbine(**self.test_turbine),
                    "number_of_turbines": 3,
                },
                {
                    "wind_turbine": test_turbine,
                    "number_of_turbines": 3
                },
            ]
        }
        test_tc_mc = tc_mc.TurbineClusterModelChain(power_plant=wf.WindFarm(
            **test_farm))
        with pytest.raises(ValueError):
            test_tc_mc.run_model(self.weather_df)

        # Raise ValueError when neither turbulence intensity nor roughness
        # length are provided to apply power curve smoothing with standard
        # deviation method 'turbulence_intensity'
        parameters = {
            "smoothing": True,
            "standard_deviation_method": "turbulence_intensity",
        }
        test_tc_mc = tc_mc.TurbineClusterModelChain(
            power_plant=wf.WindFarm(**self.test_farm), **parameters)
        weather_df = self.weather_df.copy()
        weather_df.pop("roughness_length")
        with pytest.raises(ValueError):
            test_tc_mc.run_model(weather_df)
コード例 #13
0
 def test_missing_p_values(self):
     """Raise TypeErrors due to missing p-values"""
     test_turbine = {'hub_height': 100,
                     'rotor_diameter': 80,
                     'turbine_type': 'E-126/4205'}
     msg = "Power curve values of"
     with pytest.raises(TypeError, match=msg):
         test_modelchain = {'power_output_model': 'power_curve',
                            'density_corr': True}
         test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                 **test_modelchain)
         test_mc.run_model(self.weather_df)
コード例 #14
0
    def test_error_raising(self):

        # Raise ValueError when aggregated wind farm power curve needs to be
        # calculated but turbine does not have a power curve
        test_turbine_data = {
            'hub_height': 100,
            'rotor_diameter': 98,
            'turbine_type': 'V90/2000'
        }
        test_turbine = wt.WindTurbine(**test_turbine_data)
        test_turbine.power_curve = True
        test_farm = {
            'wind_turbine_fleet': [{
                'wind_turbine':
                wt.WindTurbine(**self.test_turbine),
                'number_of_turbines':
                3
            }, {
                'wind_turbine': test_turbine,
                'number_of_turbines': 3
            }]
        }
        test_tc_mc = tc_mc.TurbineClusterModelChain(power_plant=wf.WindFarm(
            **test_farm))
        with pytest.raises(ValueError):
            test_tc_mc.run_model(self.weather_df)

        # Raise ValueError when neither turbulence intensity nor roughness
        # length are provided to apply power curve smoothing with standard
        # deviation method 'turbulence_intensity'
        parameters = {
            'smoothing': True,
            'standard_deviation_method': 'turbulence_intensity'
        }
        test_tc_mc = tc_mc.TurbineClusterModelChain(
            power_plant=wf.WindFarm(**self.test_farm), **parameters)
        weather_df = self.weather_df.copy()
        weather_df.pop('roughness_length')
        with pytest.raises(ValueError):
            test_tc_mc.run_model(weather_df)
コード例 #15
0
 def test_tc_modelchain_with_power_curve_as_dict(self):
     """Test power curves as dict in TurbineClusterModelChain.run_model()"""
     my_turbine = {
         "nominal_power": 3e6,
         "hub_height": 105,
         "power_curve": {
             "value":
             [p * 1000 for p in [0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]],
             "wind_speed": [0.0, 3.0, 5.0, 10.0, 15.0, 25.0],
         },
     }
     my_farm = {
         "wind_turbine_fleet": [
             {
                 "wind_turbine": wt.WindTurbine(**my_turbine),
                 "number_of_turbines": 3,
             },
             {
                 "wind_turbine": wt.WindTurbine(**self.test_turbine),
                 "number_of_turbines": 3,
             },
         ]
     }
     my_cluster = {
         "wind_farms": [
             wf.WindFarm(**my_farm),
             wf.WindFarm(**self.test_farm),
         ]
     }
     power_output_exp = pd.Series(
         data=[10853277.966972714, 21731814.593688786],
         name="feedin_power_plant",
     )
     # run model with my_cluster
     test_tc_mc = tc_mc.TurbineClusterModelChain(
         power_plant=wtc.WindTurbineCluster(**my_cluster))
     test_tc_mc.run_model(self.weather_df)
     assert_series_equal(test_tc_mc.power_output, power_output_exp)
コード例 #16
0
 def test_with_power_coefficient_curve_and_hellman(self):
     """Test with power coefficient curve and hellman"""
     test_turbine = {'hub_height': 100,
                     'rotor_diameter': 80,
                     'turbine_type': 'E-126/4200'}
     power_output_exp = pd.Series(data=[534137.5112701517,
                                        1103611.1736067757],
                                  name='feedin_power_plant')
     test_modelchain = {'wind_speed_model': 'hellman',
                        'power_output_model': 'power_coefficient_curve',
                        'density_correction': False}
     test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                             **test_modelchain)
     test_mc.run_model(self.weather_df)
     assert_series_equal(test_mc.power_output, power_output_exp)
コード例 #17
0
 def test_with_density_corrected_power_curve_and_hellman(self):
     """Test with density corrected power curve and hellman"""
     test_turbine = {'hub_height': 100,
                     'rotor_diameter': 80,
                     'turbine_type': 'E-126/4200'}
     test_modelchain = {'wind_speed_model': 'hellman',
                        'power_output_model': 'power_curve',
                        'density_correction': True}
     power_output_exp = pd.Series(data=[1366958.544547462,
                                        2823402.837201821],
                                  name='feedin_power_plant')
     test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                             **test_modelchain)
     test_mc.run_model(self.weather_df)
     assert_series_equal(test_mc.power_output, power_output_exp)
コード例 #18
0
 def test_missing_p_values(self):
     """Raise TypeErrors due to missing p-values"""
     test_turbine = {
         "hub_height": 100,
         "rotor_diameter": 80,
         "turbine_type": "E-126/4205",
     }
     msg = "Power curve values of"
     with pytest.raises(TypeError, match=msg):
         test_modelchain = {
             "power_output_model": "power_curve",
             "density_corr": True,
         }
         test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                 **test_modelchain)
         test_mc.run_model(self.weather_df)
コード例 #19
0
 def test_modelchain_with_power_curve_as_dict(self):
     """Test power curves as dict"""
     my_turbine = {'nominal_power': 3e6, 'hub_height': 105,
                   'rotor_diameter': 70,
                   'power_curve': {
                       'value': [p * 1000 for p in [
                           0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]],
                       'wind_speed': [0.0, 3.0, 5.0, 10.0, 15.0, 25.0]},
                   'power_coefficient_curve': {
                       'value': [0.0, 0.43, 0.45, 0.35, 0.12, 0.03],
                       'wind_speed': [0.0, 3.0, 5.0, 10.0, 15.0, 25.0]}}
     power_output_exp = pd.Series(data=[919055.54840,
                                        1541786.60559],
                                  name='feedin_power_plant')
     test_mc = mc.ModelChain(wt.WindTurbine(**my_turbine))
     test_mc.run_model(self.weather_df)
     assert_series_equal(test_mc.power_output, power_output_exp)
コード例 #20
0
    def test_smooth_power_curve(self):
        test_curve = wt.WindTurbine(**self.test_turbine).power_curve
        parameters = {
            'power_curve_wind_speeds': test_curve['wind_speed'],
            'power_curve_values': test_curve['value'],
            'standard_deviation_method': 'turbulence_intensity'
        }

        # Raise ValueError - `turbulence_intensity` missing
        with pytest.raises(ValueError):
            parameters['standard_deviation_method'] = 'turbulence_intensity'
            smooth_power_curve(**parameters)

        # Test turbulence_intensity method
        parameters['turbulence_intensity'] = 0.5
        wind_speed_values_exp = pd.Series([6.0, 7.0, 8.0, 9.0, 10.0],
                                          name='wind_speed')
        power_values_exp = pd.Series([
            1141906.9806766496, 1577536.8085282773, 1975480.993355767,
            2314059.4022704284, 2590216.6802602503
        ],
                                     name='value')
        smoothed_curve_exp = pd.DataFrame(
            data=pd.concat([wind_speed_values_exp, power_values_exp], axis=1))
        smoothed_curve_exp.index = np.arange(5, 10, 1)
        assert_frame_equal(
            smooth_power_curve(**parameters)[5:10], smoothed_curve_exp)

        # Test Staffel_Pfenninger method
        parameters['standard_deviation_method'] = 'Staffell_Pfenninger'
        power_values_exp = pd.Series([
            929405.1348918702, 1395532.5468724659, 1904826.6851982325,
            2402659.118305521, 2844527.1732449625
        ],
                                     name='value')
        smoothed_curve_exp = pd.DataFrame(
            data=pd.concat([wind_speed_values_exp, power_values_exp], axis=1))
        smoothed_curve_exp.index = np.arange(5, 10, 1)
        assert_frame_equal(
            smooth_power_curve(**parameters)[5:10], smoothed_curve_exp)

        # Raise ValueError - misspelling
        with pytest.raises(ValueError):
            parameters['standard_deviation_method'] = 'misspelled'
            smooth_power_curve(**parameters)
コード例 #21
0
 def test_with_power_coefficient_curve_and_hellman(self):
     """Test with power coefficient curve and hellman"""
     test_turbine = {
         "hub_height": 100,
         "rotor_diameter": 80,
         "turbine_type": "E-126/4200",
     }
     power_output_exp = pd.Series(
         data=[534137.5112701517, 1103611.1736067757],
         name="feedin_power_plant",
     )
     test_modelchain = {
         "wind_speed_model": "hellman",
         "power_output_model": "power_coefficient_curve",
         "density_correction": False,
     }
     test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                             **test_modelchain)
     test_mc.run_model(self.weather_df)
     assert_series_equal(test_mc.power_output, power_output_exp)
コード例 #22
0
 def test_weather_with_nan_values(self, recwarn):
     """Test warning if weather data contain nan values."""
     test_turbine = {
         "hub_height": 100,
         "rotor_diameter": 80,
         "turbine_type": "E-126/4200",
     }
     nan_weather = self.weather_df.copy()
     nan_weather.loc[1, ("temperature", 10)] = np.nan
     test_modelchain = {
         "power_output_model": "power_curve",
         "density_corr": True,
     }
     test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                             **test_modelchain)
     msg = "'temperature', 10"
     with pytest.warns(WindpowerlibUserWarning, match=msg):
         test_mc.run_model(nan_weather)
     test_mc.run_model(self.weather_df)
     assert len(recwarn) == 0
コード例 #23
0
 def test_with_density_corrected_power_curve_and_hellman(self):
     """Test with density corrected power curve and hellman"""
     test_turbine = {
         "hub_height": 100,
         "rotor_diameter": 80,
         "turbine_type": "E-126/4200",
     }
     test_modelchain = {
         "wind_speed_model": "hellman",
         "power_output_model": "power_curve",
         "density_correction": True,
     }
     power_output_exp = pd.Series(
         data=[1366958.544547462, 2823402.837201821],
         name="feedin_power_plant",
     )
     test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                             **test_modelchain)
     test_mc.run_model(self.weather_df)
     assert_series_equal(test_mc.power_output, power_output_exp)
コード例 #24
0
    def test_wake_losses_to_power_curve(self):
        test_curve = wt.WindTurbine(**self.test_turbine).power_curve
        parameters = {
            'power_curve_wind_speeds': test_curve['wind_speed'],
            'power_curve_values': test_curve['value'],
            'wind_farm_efficiency': 0.9,
            'wake_losses_model': 'constant_efficiency'
        }

        # Test constant efficiency
        power_curve_exp = test_curve.copy(deep=True)
        power_curve_exp['value'] = power_curve_exp['value'].values * 0.9
        assert_frame_equal(wake_losses_to_power_curve(**parameters),
                           power_curve_exp)

        # Raise TypeError if wind farm efficiency is not float
        with pytest.raises(TypeError):
            parameters['wind_farm_efficiency'] = 1
            wake_losses_to_power_curve(**parameters)

        # Test efficiency curve
        parameters['wake_losses_model'] = 'power_efficiency_curve'
        parameters['wind_farm_efficiency'] = pd.DataFrame(
            pd.concat([
                pd.Series(np.arange(1, 26, 1)),
                pd.Series([
                    1.0, 1.0, 1.0, 0.84, 0.85, 0.86, 0.85, 0.85, 0.85, 0.86,
                    0.87, 0.89, 0.92, 0.95, 0.95, 0.96, 0.99, 0.95, 0.98, 0.97,
                    0.99, 1.0, 1.0, 1.0, 1.0
                ])
            ],
                      axis=1))
        parameters['wind_farm_efficiency'].columns = [
            'wind_speed', 'efficiency'
        ]
        power_curve_exp = test_curve.copy(deep=True)
        power_curve_exp['value'] = (
            power_curve_exp['value'].values *
            parameters['wind_farm_efficiency']['efficiency'])
        assert_frame_equal(wake_losses_to_power_curve(**parameters),
                           power_curve_exp)
コード例 #25
0
 def test_modelchain_with_power_curve_as_dict(self):
     """Test power curves as dict"""
     my_turbine = {
         "nominal_power": 3e6,
         "hub_height": 105,
         "rotor_diameter": 70,
         "power_curve": {
             "value":
             [p * 1000 for p in [0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]],
             "wind_speed": [0.0, 3.0, 5.0, 10.0, 15.0, 25.0],
         },
         "power_coefficient_curve": {
             "value": [0.0, 0.43, 0.45, 0.35, 0.12, 0.03],
             "wind_speed": [0.0, 3.0, 5.0, 10.0, 15.0, 25.0],
         },
     }
     power_output_exp = pd.Series(data=[919055.54840, 1541786.60559],
                                  name="feedin_power_plant")
     test_mc = mc.ModelChain(wt.WindTurbine(**my_turbine))
     test_mc.run_model(self.weather_df)
     assert_series_equal(test_mc.power_output, power_output_exp)
コード例 #26
0
    def test_run_model(self):

        temperature_2m = np.array([[267], [268]])
        temperature_10m = np.array([[267], [266]])
        pressure_0m = np.array([[101125], [101000]])
        wind_speed_8m = np.array([[4.0], [5.0]])
        wind_speed_10m = np.array([[5.0], [6.5]])
        roughness_length = np.array([[0.15], [0.15]])
        weather_df = pd.DataFrame(np.hstack((temperature_2m,
                                             temperature_10m,
                                             pressure_0m,
                                             wind_speed_8m,
                                             wind_speed_10m,
                                             roughness_length)),
                                  index=[0, 1],
                                  columns=[np.array(['temperature',
                                                     'temperature',
                                                     'pressure',
                                                     'wind_speed',
                                                     'wind_speed',
                                                     'roughness_length']),
                                           np.array([2, 10, 0, 8, 10, 0])])

        test_turbine = {'hub_height': 100,
                        'rotor_diameter': 80,
                        'name': 'E-126/4200',
                        'fetch_curve': 'power_curve'}

        # Test with default parameters of modelchain (power curve)
        power_output_exp = pd.Series(data=[1637405.4840444783,
                                           3154438.3894902095],
                                     name='feedin_power_plant')
        test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine))
        test_mc.run_model(weather_df)
        assert_series_equal(test_mc.power_output, power_output_exp)

        # Test with density corrected power curve and hellman
        test_modelchain = {'wind_speed_model': 'hellman',
                           'power_output_model': 'power_curve',
                           'density_correction': True}
        power_output_exp = pd.Series(data=[1366958.544547462,
                                           2823402.837201821],
                                     name='feedin_power_plant')
        test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                **test_modelchain)
        test_mc.run_model(weather_df)
        assert_series_equal(test_mc.power_output, power_output_exp)

        # Test with power coefficient curve and hellman
        power_output_exp = pd.Series(data=[534137.5112701517,
                                           1103611.1736067757],
                                     name='feedin_power_plant')
        test_turbine['fetch_curve'] = 'power_coefficient_curve'
        test_modelchain = {'wind_speed_model': 'hellman',
                           'power_output_model': 'power_coefficient_curve',
                           'density_correction': False}
        test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                **test_modelchain)
        test_mc.run_model(weather_df)
        assert_series_equal(test_mc.power_output, power_output_exp)

        # Raise ValueErrors due to wrong spelling of parameters
        with pytest.raises(ValueError):
            test_modelchain['power_output_model'] = 'wrong_spelling'
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
        with pytest.raises(ValueError):
            test_modelchain['density_model'] = 'wrong_spelling'
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
        with pytest.raises(ValueError):
            test_modelchain['temperature_model'] = 'wrong_spelling'
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
        with pytest.raises(ValueError):
            test_modelchain['wind_speed_model'] = 'wrong_spelling'
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)

        # Raise TypeErrors due to wrong type of `density_correction`
        with pytest.raises(TypeError):
            test_modelchain = {'power_output_model': 'power_curve',
                               'density_correction': 'wrong_type'}
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)

        # Raise TypeErrors due to missing cp- or p-values
        with pytest.raises(TypeError):
            test_turbine = {'hub_height': 100,
                            'rotor_diameter': 80,
                            'name': 'E-126/4200',
                            'fetch_curve': 'power_curve'}
            test_modelchain = {'power_output_model': 'power_coefficient_curve',
                               'density_correction': True}
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
        with pytest.raises(TypeError):
            test_turbine = {'hub_height': 100,
                            'rotor_diameter': 80,
                            'name': 'E-126/4200',
                            'fetch_curve': 'power_coefficient_curve'}
            test_modelchain = {'power_output_model': 'power_curve',
                               'density_corr': True}
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
コード例 #27
0
    def test_run_model(self):

        temperature_2m = np.array([[267], [268]])
        temperature_10m = np.array([[267], [266]])
        pressure_0m = np.array([[101125], [101000]])
        wind_speed_8m = np.array([[4.0], [5.0]])
        wind_speed_10m = np.array([[5.0], [6.5]])
        roughness_length = np.array([[0.15], [0.15]])
        weather_df = pd.DataFrame(np.hstack(
            (temperature_2m, temperature_10m, pressure_0m, wind_speed_8m,
             wind_speed_10m, roughness_length)),
                                  index=[0, 1],
                                  columns=[
                                      np.array([
                                          'temperature', 'temperature',
                                          'pressure', 'wind_speed',
                                          'wind_speed', 'roughness_length'
                                      ]),
                                      np.array([2, 10, 0, 8, 10, 0])
                                  ])

        test_turbine = {
            'hub_height': 100,
            'rotor_diameter': 80,
            'turbine_name': 'ENERCON E 126 7500',
            'fetch_curve': 'power_curve'
        }

        # Test with default parameters of modelchain (power curve)
        power_output_exp = pd.Series(data=[1731887.39768, 3820152.27489],
                                     name='feedin_wind_turbine')
        test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine))
        test_mc.run_model(weather_df)
        assert_series_equal(test_mc.power_output, power_output_exp)

        # Test with density corrected power curve and hellman
        test_modelchain = {
            'wind_speed_model': 'hellman',
            'power_output_model': 'power_curve',
            'density_correction': True
        }
        power_output_exp = pd.Series(data=[1433937.37959, 3285183.55084],
                                     name='feedin_wind_turbine')
        test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                **test_modelchain)
        test_mc.run_model(weather_df)
        assert_series_equal(test_mc.power_output, power_output_exp)

        # Test with power coefficient curve and hellman
        power_output_exp = pd.Series(data=[559060.36156, 1251143.98621],
                                     name='feedin_wind_turbine')
        test_turbine['fetch_curve'] = 'power_coefficient_curve'
        test_modelchain = {
            'wind_speed_model': 'hellman',
            'power_output_model': 'power_coefficient_curve',
            'density_correction': False
        }
        test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                **test_modelchain)
        test_mc.run_model(weather_df)
        assert_series_equal(test_mc.power_output, power_output_exp)

        # Ideal gas equation and density corrected power coefficient curve
        power_output_exp = pd.Series(data=[569117.952419, 1302746.06501],
                                     name='feedin_wind_turbine')
        test_modelchain = {
            'wind_speed_model': 'hellman',
            'density_model': 'ideal_gas',
            'power_output_model': 'power_coefficient_curve',
            'density_correction': True
        }
        test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                **test_modelchain)
        test_mc.run_model(weather_df)
        assert_series_equal(test_mc.power_output, power_output_exp)

        # Raise ValueErrors due to wrong spelling of parameters
        with pytest.raises(ValueError):
            test_modelchain['power_output_model'] = 'wrong_spelling'
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
        with pytest.raises(ValueError):
            test_modelchain['density_model'] = 'wrong_spelling'
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
        with pytest.raises(ValueError):
            test_modelchain['temperature_model'] = 'wrong_spelling'
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
        with pytest.raises(ValueError):
            test_modelchain['wind_speed_model'] = 'wrong_spelling'
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)

        # Raise TypeErrors due to wrong type of `density_correction`
        with pytest.raises(TypeError):
            test_modelchain = {
                'power_output_model': 'power_curve',
                'density_correction': 'wrong_type'
            }
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
        with pytest.raises(TypeError):
            test_modelchain = {
                'power_output_model': 'power_coefficient_curve',
                'density_correction': 'wrong_type'
            }
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)

        # Raise TypeErrors due to missing cp- or p-values
        with pytest.raises(TypeError):
            test_turbine = {
                'hub_height': 100,
                'rotor_diameter': 80,
                'turbine_name': 'ENERCON E 126 7500',
                'fetch_curve': 'power_curve'
            }
            test_modelchain = {
                'power_output_model': 'power_coefficient_curve',
                'density_correction': True
            }
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
        with pytest.raises(TypeError):
            test_turbine = {
                'hub_height': 100,
                'rotor_diameter': 80,
                'turbine_name': 'ENERCON E 126 7500',
                'fetch_curve': 'power_coefficient_curve'
            }
            test_modelchain = {
                'power_output_model': 'power_curve',
                'density_corr': True
            }
            test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
                                    **test_modelchain)
            test_mc.run_model(weather_df)
コード例 #28
0
def initialize_turbines(turbine_types, plot_wind_turbines=False):
    # TODO: scale power curves??
    """
    Initializes specified turbine types and returns them as objects in a list.

    Parameters
    ----------
    turbine_types : List
        Contains strings of turbine types to be initialized.
        Options: 'enerconE70', 'enerconE66_1800_65' feel free to add.
    plot_wind_turbines : Boolean
        Decision of plotting (or printing) turbine data (True) or not (False).
        Default: False.

    """
    # Turbine data specification - feel free to add
    turbine_dict = {
        'enerconE70': {
            'object_name':
            'ENERCON E 70 2300',  # NOTE: Peak power should be 2.37 MW - is 2,31 for turbine in windpowerlib
            'hub_height': 64,  # in m
            'rotor_diameter': 71  # in m    source: www.wind-turbine-models.com
        },
        'enerconE66_1800_65': {
            'object_name':
            'ENERCON E 66 1800',  # NOTE: Peak power should be 1.86 MW - ist 1,8 for turbine in windpowerlib
            'hub_height': 65,  # in m
            'rotor_diameter': 70  # in m    source: www.wind-turbine-models.com
        },
        'enerconE66_1800_98': {
            'object_name': 'ENERCON E 66 1800',
            'hub_height': 98,  # in m
            'rotor_diameter': 70  # in m
        },
        'enerconE66_2000': {
            'object_name': 'ENERCON E 66 2000',
            'hub_height': 138.3,  # in m
            'rotor_diameter': 82  # in m
        },
        'vestasV90': {
            'object_name': 'VESTAS V 90 2000',
            'hub_height': 105,  # in m
            'rotor_diameter': 90  # in m    source: www.wind-turbine-models.com
        },
        'vestasV80': {
            'object_name': 'VESTAS V 80 2000',
            'hub_height': 60,  # in m
            'rotor_diameter': 80  # in m    source: www.wind-turbine-models.com
        },
        'ge_1500': {
            'object_name': 'GE 1,5 SLE',
            'hub_height': 100,  # in m
            'rotor_diameter': 77  # in m
        }
    }

    turbine_list = []
    # Initialize WindTurbine objects
    for turbine_type in turbine_types:
        turbine = wt.WindTurbine(**turbine_dict[turbine_type])
        turbine_list.append(turbine)
        if plot_wind_turbines:
            visualization_tools.plot_or_print_turbine(turbine)
    return turbine_list
コード例 #29
0
 def setup_class(self):
     temperature_2m = np.array([[267], [268]])
     temperature_10m = np.array([[267], [266]])
     pressure_0m = np.array([[101125], [101000]])
     wind_speed_8m = np.array([[4.0], [5.0]])
     wind_speed_10m = np.array([[5.0], [6.5]])
     roughness_length = np.array([[0.15], [0.15]])
     self.weather_df = pd.DataFrame(
         np.hstack((
             temperature_2m,
             temperature_10m,
             pressure_0m,
             wind_speed_8m,
             wind_speed_10m,
             roughness_length,
         )),
         index=[0, 1],
         columns=[
             np.array([
                 "temperature",
                 "temperature",
                 "pressure",
                 "wind_speed",
                 "wind_speed",
                 "roughness_length",
             ]),
             np.array([2, 10, 0, 8, 10, 0]),
         ],
     )
     self.test_turbine = {
         "hub_height": 100,
         "rotor_diameter": 80,
         "turbine_type": "E-126/4200",
     }
     self.test_turbine_2 = {
         "hub_height": 90,
         "rotor_diameter": 60,
         "turbine_type": "V90/2000",
         "nominal_power": 2000000.0,
     }
     self.test_farm = {
         "wind_turbine_fleet": [{
             "wind_turbine":
             wt.WindTurbine(**self.test_turbine),
             "number_of_turbines":
             3,
         }]
     }
     self.test_farm_2 = {
         "name":
         "test farm",
         "wind_turbine_fleet": [
             {
                 "wind_turbine": wt.WindTurbine(**self.test_turbine),
                 "number_of_turbines": 3,
             },
             {
                 "wind_turbine": wt.WindTurbine(**self.test_turbine_2),
                 "number_of_turbines": 3,
             },
         ],
     }
     self.test_cluster = {
         "name":
         "example_cluster",
         "wind_farms": [
             wf.WindFarm(**self.test_farm),
             wf.WindFarm(**self.test_farm_2),
         ],
     }