Example #1
0
def power_output_density_corr(wind_turbine_fleet, weather_df, data_height):
    r"""
#    Calculate power output of several wind turbines ......
#
#    Simplest way to calculate the power output of a wind farm or other
#    gathering of wind turbines. For the power_output of the single turbines
#    a power_curve without density correction is used. The wind speed at hub
#    height is calculated by the logarithmic wind profile.

    Parameters
    ----------
    wind_turbine_fleet : List of Dictionaries
        Wind turbines of wind farm. Dictionaries must have 'wind_turbine'
        (contains wind turbine object) and 'number_of_turbines' (number of
        turbine type in wind farm) as keys.
    weather_df : pandas.DataFrame
        DataFrame with time series for wind speed `wind_speed` in m/s and
        roughness length `roughness_length` in m.
    data_height : Dictionary
        Contains the heights of the weather measurements or weather
        model in meters with the keys of the data parameter.

    Returns
    -------
    pd.Series
        Simulated power output of wind farm.

    """
    for turbine_type in wind_turbine_fleet:
        wind_speed_hub = wind_speed.logarithmic_profile(
            weather_df.wind_speed,
            data_height['wind_speed'],
            turbine_type['wind_turbine'].hub_height,
            weather_df.roughness_length,
            obstacle_height=0.0)
        temperature_hub = temperature.linear_gradient(
            weather_df.temperature, data_height['temperature'],
            turbine_type['wind_turbine'].hub_height)
        density_hub = density.ideal_gas(
            weather_df.pressure, data_height['pressure'],
            turbine_type['wind_turbine'].hub_height, temperature_hub)
        turbine_type['wind_turbine'].power_output = (
            power_output.power_curve_density_correction(
                wind_speed_hub,
                turbine_type['wind_turbine'].power_curve['wind_speed'],
                turbine_type['wind_turbine'].power_curve['power'],
                density_hub))
    return power_output_simple_aggregation(wind_turbine_fleet, weather_df,
                                           data_height)
Example #2
0
def power_output_simple(wind_turbine_fleet, weather_df, data_height):
    # TODO: add weather_data_name to these functions and use modelchain for
    #       open_FRED data as there are different heights and this is easier
    #       with the multiindex dataframe
    r"""
    Calculate power output of several wind turbines by a simple method.

    Simplest way to calculate the power output of a wind farm or other
    gathering of wind turbines. For the power_output of the single turbines
    a power_curve without density correction is used. The wind speed at hub
    height is calculated by the logarithmic wind profile. The power output of
    the wind farm is calculated by aggregation of the power output of the
    single turbines.

    Parameters
    ----------
    wind_turbine_fleet : List of Dictionaries
        Wind turbines of wind farm. Dictionaries must have 'wind_turbine'
        (contains wind turbine object) and 'number_of_turbines' (number of
        turbine type in wind farm) as keys.
    weather_df : pandas.DataFrame
        DataFrame with time series for wind speed `wind_speed` in m/s and
        roughness length `roughness_length` in m.
    data_height : Dictionary
        Contains the heights of the weather measurements or weather
        model in meters with the keys of the data parameter.

    Returns
    -------
    pd.Series
        Simulated power output of wind farm.

    """
    for turbine_type in wind_turbine_fleet:
        wind_speed_hub = wind_speed.logarithmic_profile(
            weather_df.wind_speed,
            data_height['wind_speed'],
            turbine_type['wind_turbine'].hub_height,
            weather_df.roughness_length,
            obstacle_height=0.0)
        turbine_type['wind_turbine'].power_output = (power_output.power_curve(
            wind_speed_hub,
            turbine_type['wind_turbine'].power_curve['wind_speed'],
            turbine_type['wind_turbine'].power_curve['power']))
    return power_output_simple_aggregation(wind_turbine_fleet)
Example #3
0
    def wind_speed_hub(self, weather_df):
        r"""
        Calculates the wind speed at hub height.

        The method specified by the parameter `wind_speed_model` is used.

        Parameters
        ----------
        weather_df : :pandas:`pandas.DataFrame<frame>`
            DataFrame with time series for wind speed `wind_speed` in m/s and
            roughness length `roughness_length` in m.
            The columns of the DataFrame are a MultiIndex where the first level
            contains the variable name (e.g. wind_speed) and the second level
            contains the height at which it applies (e.g. 10, if it was
            measured at a height of 10 m). See documentation of
            :func:`ModelChain.run_model` for an example on how to create the
            weather_df DataFrame.

        Returns
        -------
        :pandas:`pandas.Series<series>` or numpy.array
            Wind speed in m/s at hub height.

        Notes
        -----
        If `weather_df` contains wind speeds at different heights the given
        wind speed(s) closest to the hub height are used.

        """
        if self.power_plant.hub_height in weather_df["wind_speed"]:
            wind_speed_hub = weather_df["wind_speed"][
                self.power_plant.hub_height]
        elif self.wind_speed_model == "logarithmic":
            logging.debug("Calculating wind speed using logarithmic wind "
                          "profile.")
            closest_height = weather_df["wind_speed"].columns[min(
                range(len(weather_df["wind_speed"].columns)),
                key=lambda i: abs(weather_df["wind_speed"].columns[i] - self.
                                  power_plant.hub_height),
            )]
            wind_speed_hub = wind_speed.logarithmic_profile(
                weather_df["wind_speed"][closest_height],
                closest_height,
                self.power_plant.hub_height,
                weather_df["roughness_length"].iloc[:, 0],
                self.obstacle_height,
            )
        elif self.wind_speed_model == "hellman":
            logging.debug("Calculating wind speed using hellman equation.")
            closest_height = weather_df["wind_speed"].columns[min(
                range(len(weather_df["wind_speed"].columns)),
                key=lambda i: abs(weather_df["wind_speed"].columns[i] - self.
                                  power_plant.hub_height),
            )]
            wind_speed_hub = wind_speed.hellman(
                weather_df["wind_speed"][closest_height],
                closest_height,
                self.power_plant.hub_height,
                weather_df["roughness_length"].iloc[:, 0],
                self.hellman_exp,
            )
        elif self.wind_speed_model == "interpolation_extrapolation":
            logging.debug("Calculating wind speed using linear inter- or "
                          "extrapolation.")
            wind_speed_hub = tools.linear_interpolation_extrapolation(
                weather_df["wind_speed"], self.power_plant.hub_height)
        elif self.wind_speed_model == "log_interpolation_extrapolation":
            logging.debug("Calculating wind speed using logarithmic inter- or "
                          "extrapolation.")
            wind_speed_hub = tools.logarithmic_interpolation_extrapolation(
                weather_df["wind_speed"], self.power_plant.hub_height)
        else:
            raise ValueError(
                "'{0}' is an invalid value. ".format(self.wind_speed_model) +
                "`wind_speed_model` must be "
                "'logarithmic', 'hellman', 'interpolation_extrapolation' " +
                "or 'log_interpolation_extrapolation'.")
        return wind_speed_hub
Example #4
0
    def test_logarithmic_profile(self):
        parameters = {
            "wind_speed": pd.Series(data=[5.0, 6.5]),
            "wind_speed_height": 10,
            "hub_height": 100,
            "roughness_length": pd.Series(data=[0.15, 0.15]),
            "obstacle_height": 0,
        }

        # Test wind_speed as pd.Series with roughness_length as pd.Series,
        # np.array and float
        v_wind_hub_exp = pd.Series(data=[7.74136523, 10.0637748])
        assert_series_equal(logarithmic_profile(**parameters), v_wind_hub_exp)
        parameters["roughness_length"] = np.array(
            parameters["roughness_length"])
        assert_series_equal(logarithmic_profile(**parameters), v_wind_hub_exp)
        parameters["roughness_length"] = parameters["roughness_length"][0]
        assert_series_equal(logarithmic_profile(**parameters), v_wind_hub_exp)

        # Test wind_speed as np.array with roughness_length as float, pd.Series
        # and np.array
        v_wind_hub_exp = np.array([7.74136523, 10.0637748])
        parameters["wind_speed"] = np.array(parameters["wind_speed"])
        assert_allclose(logarithmic_profile(**parameters), v_wind_hub_exp)
        assert isinstance(logarithmic_profile(**parameters), np.ndarray)
        parameters["roughness_length"] = pd.Series(data=[
            parameters["roughness_length"],
            parameters["roughness_length"],
        ])
        assert_allclose(logarithmic_profile(**parameters), v_wind_hub_exp)
        assert isinstance(logarithmic_profile(**parameters), np.ndarray)
        parameters["roughness_length"] = np.array(
            parameters["roughness_length"])
        assert_allclose(logarithmic_profile(**parameters), v_wind_hub_exp)
        assert isinstance(logarithmic_profile(**parameters), np.ndarray)

        # Test obstacle_height is not zero
        v_wind_hub_exp = np.array([13.54925281, 17.61402865])
        parameters["obstacle_height"] = 12
        assert_allclose(logarithmic_profile(**parameters), v_wind_hub_exp)

        # Raise ValueError due to 0.7 * `obstacle_height` > `wind_speed_height`
        with pytest.raises(ValueError):
            parameters["obstacle_height"] = 20
            logarithmic_profile(**parameters)