def test_power_coefficient_curve_output_types(self): """ Test wind_speed as np.array with density and power_coefficient_curve as np.array and pd.Series """ assert isinstance(power_coefficient_curve(**self.parameters), pd.Series) self.parameters["wind_speed"] = np.array(self.parameters["wind_speed"]) assert isinstance(power_coefficient_curve(**self.parameters), np.ndarray)
def test_power_coefficient_curve_2(self): """TODO: Explain this test""" parameters = self.parameters power_output_exp = np.array([0.0, 244615.399, 0.0]) parameters["wind_speed"] = np.array(parameters["wind_speed"]) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) parameters["density"] = pd.Series(data=parameters["density"]) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray) parameters["power_coefficient_curve_wind_speeds"] = pd.Series( data=parameters["power_coefficient_curve_wind_speeds"]) parameters["power_coefficient_curve_values"] = pd.Series( data=parameters["power_coefficient_curve_values"]) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray)
def test_power_coefficient_curve_1(self): """ Test wind_speed as pd.Series with density and power_coefficient_curve as pd.Series and np.array """ power_output_exp = pd.Series(data=[0.0, 244615.399, 0.0], name="feedin_power_plant") assert_series_equal(power_coefficient_curve(**self.parameters), power_output_exp) parameters = self.parameters parameters["density"].to_numpy() assert_series_equal(power_coefficient_curve(**parameters), power_output_exp) parameters["power_coefficient_curve_values"] = np.array( parameters["power_coefficient_curve_values"]) parameters["power_coefficient_curve_wind_speeds"] = np.array( parameters["power_coefficient_curve_wind_speeds"]) assert_series_equal(power_coefficient_curve(**parameters), power_output_exp)
def test_power_coefficient_curve(self): parameters = {'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]), 'density': pd.Series(data=[1.3, 1.3, 1.3]), 'rotor_diameter': 80, 'power_coefficient_curve_wind_speeds': pd.Series([4.0, 5.0, 6.0]), 'power_coefficient_curve_values': pd.Series([0.3, 0.4, 0.5])} # Test wind_speed as pd.Series with density and power_coefficient_curve # as pd.Series and np.array power_output_exp = pd.Series(data=[0.0, 244615.399, 0.0], name='feedin_power_plant') assert_series_equal(power_coefficient_curve(**parameters), power_output_exp) parameters['density'] = np.array(parameters['density']) assert_series_equal(power_coefficient_curve(**parameters), power_output_exp) parameters['power_coefficient_curve_values'] = np.array( parameters['power_coefficient_curve_values']) parameters['power_coefficient_curve_wind_speeds'] = np.array( parameters['power_coefficient_curve_wind_speeds']) assert_series_equal(power_coefficient_curve(**parameters), power_output_exp) # Test wind_speed as np.array with density and power_coefficient_curve # as np.array and pd.Series power_output_exp = np.array([0.0, 244615.399, 0.0]) parameters['wind_speed'] = np.array(parameters['wind_speed']) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray) parameters['density'] = pd.Series(data=parameters['density']) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray) parameters['power_coefficient_curve_wind_speeds'] = pd.Series( data=parameters['power_coefficient_curve_wind_speeds']) parameters['power_coefficient_curve_values'] = pd.Series( data=parameters['power_coefficient_curve_values']) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray)
def calculate_power_output(self, wind_speed_hub, density_hub): r""" Calculates the power output of the wind power plant. The method specified by the parameter `power_output_model` is used. Parameters ---------- wind_speed_hub : :pandas:`pandas.Series<series>` or numpy.array Wind speed at hub height in m/s. density_hub : :pandas:`pandas.Series<series>` or numpy.array Density of air at hub height in kg/m³. Returns ------- :pandas:`pandas.Series<series>` Electrical power output of the wind turbine in W. """ if self.power_output_model == "power_curve": if self.power_plant.power_curve is None: raise TypeError("Power curve values of {} are missing.".format( self.power_plant)) logging.debug("Calculating power output using power curve.") return power_output.power_curve( wind_speed_hub, self.power_plant.power_curve["wind_speed"], self.power_plant.power_curve["value"], density_hub, self.density_correction, ) elif self.power_output_model == "power_coefficient_curve": if self.power_plant.power_coefficient_curve is None: raise TypeError("Power coefficient curve values of {} are " "missing.".format(self.power_plant)) logging.debug("Calculating power output using power coefficient " "curve.") return power_output.power_coefficient_curve( wind_speed_hub, self.power_plant.power_coefficient_curve["wind_speed"], self.power_plant.power_coefficient_curve["value"], self.power_plant.rotor_diameter, density_hub, ) else: raise ValueError( "'{0}' is an invalid value. ".format(self.power_output_model) + "`power_output_model` must be " + "'power_curve' or 'power_coefficient_curve'.")
def calculate_power_output(self, wind_speed_hub, density_hub): r""" Calculates the power output of the wind power plant. The method specified by the parameter `power_output_model` is used. Parameters ---------- wind_speed_hub : pandas.Series or numpy.array Wind speed at hub height in m/s. density_hub : pandas.Series or numpy.array Density of air at hub height in kg/m³. Returns ------- pandas.Series Electrical power output of the wind turbine in W. """ if self.power_output_model == 'power_curve': if self.power_plant.power_curve is None: raise TypeError("Power curve values of " + self.power_plant.name + " are missing.") logging.debug('Calculating power output using power curve.') return (power_output.power_curve( wind_speed_hub, self.power_plant.power_curve['wind_speed'], self.power_plant.power_curve['value'], density_hub, self.density_correction)) elif self.power_output_model == 'power_coefficient_curve': if self.power_plant.power_coefficient_curve is None: raise TypeError("Power coefficient curve values of " + self.power_plant.name + " are missing.") logging.debug('Calculating power output using power coefficient ' 'curve.') return (power_output.power_coefficient_curve( wind_speed_hub, self.power_plant.power_coefficient_curve['wind_speed'], self.power_plant.power_coefficient_curve['value'], self.power_plant.rotor_diameter, density_hub)) else: raise ValueError( "'{0}' is an invalid value. ".format(self.power_output_model) + "`power_output_model` must be " + "'power_curve' or 'power_coefficient_curve'.")
def test_power_coefficient_curve(self): parameters = { 'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]), 'density': pd.Series(data=[1.3, 1.3, 1.3]), 'rotor_diameter': 80, 'power_coefficient_curve_wind_speeds': pd.Series([4.0, 5.0, 6.0]), 'power_coefficient_curve_values': pd.Series([0.3, 0.4, 0.5]) } # Tests without density correction: # Test wind_speed as pd.Series with density and power_coefficient_curve # as pd.Series and np.array power_output_exp = pd.Series(data=[0.0, 244615.399, 0.0], name='feedin_wind_turbine') assert_series_equal(power_coefficient_curve(**parameters), power_output_exp) parameters['density'] = np.array(parameters['density']) assert_series_equal(power_coefficient_curve(**parameters), power_output_exp) parameters['power_coefficient_curve_values'] = np.array( parameters['power_coefficient_curve_values']) parameters['power_coefficient_curve_wind_speeds'] = np.array( parameters['power_coefficient_curve_wind_speeds']) assert_series_equal(power_coefficient_curve(**parameters), power_output_exp) # Test wind_speed as np.array with density and power_coefficient_curve # as np.array and pd.Series power_output_exp = np.array([0.0, 244615.399, 0.0]) parameters['wind_speed'] = np.array(parameters['wind_speed']) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray) parameters['density'] = pd.Series(data=parameters['density']) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray) parameters['power_coefficient_curve_wind_speeds'] = pd.Series( data=parameters['power_coefficient_curve_wind_speeds']) parameters['power_coefficient_curve_values'] = pd.Series( data=parameters['power_coefficient_curve_values']) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray) # Tests with density correction: # Test wind_speed as np.array with density and power_coefficient_curve # as pd.Series and np.array power_output_exp = np.array([0.0, 262869.785, 0.0]) parameters['density_correction'] = True assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray) parameters['density'] = np.array(parameters['density']) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray) parameters['power_coefficient_curve_values'] = np.array( parameters['power_coefficient_curve_values']) parameters['power_coefficient_curve_wind_speeds'] = np.array( parameters['power_coefficient_curve_wind_speeds']) assert_allclose(power_coefficient_curve(**parameters), power_output_exp) assert isinstance(power_coefficient_curve(**parameters), np.ndarray) # Test wind_speed as pd.Series with density and power_coefficient_curve # as np. array and pd.Series power_output_exp = pd.Series(data=[0.0, 262869.785, 0.0], name='feedin_wind_turbine') parameters['wind_speed'] = pd.Series(data=parameters['wind_speed']) assert_series_equal(power_coefficient_curve(**parameters), power_output_exp) parameters['density'] = pd.Series(data=parameters['density']) assert_series_equal(power_coefficient_curve(**parameters), power_output_exp) parameters['power_coefficient_curve_wind_speeds'] = pd.Series( data=parameters['power_coefficient_curve_wind_speeds']) parameters['power_coefficient_curve_values'] = pd.Series( data=parameters['power_coefficient_curve_values']) assert_series_equal(power_coefficient_curve(**parameters), power_output_exp) # Raise TypeErrors due to wrong type of `density_correction` with pytest.raises(TypeError): parameters['density'] = 'wrong_type' power_coefficient_curve(**parameters)