def test_heigths_as_string(self):
        """Test run_model if data heights are of type string."""

        # 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_mc = tc_mc.TurbineClusterModelChain(
            power_plant=wtc.WindTurbineCluster(**self.test_cluster))
        test_mc.run_model(string_weather)
 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)
Exemplo n.º 3
0
 def test_wind_turbine_cluster_repr_with_name(self):
     """Test string representation of WindTurbineCluster with a name."""
     assert 'Wind turbine cluster:' in repr(
         wtc.WindTurbineCluster(**self.test_cluster))
Exemplo n.º 4
0
    def test_run_model_turbine_cluster(self):
        parameters = {
            'wake_losses_model': 'dena_mean',
            'smoothing': False,
            'standard_deviation_method': 'turbulence_intensity',
            'smoothing_order': 'wind_farm_power_curves'
        }

        # Test modelchain with default values
        power_output_exp = pd.Series(
            data=[10363047.755401008, 21694496.68221325],
            name='feedin_power_plant')
        test_tc_mc = tc_mc.TurbineClusterModelChain(
            power_plant=wtc.WindTurbineCluster(**self.test_cluster),
            **parameters)
        test_tc_mc.run_model(self.weather_df)
        assert_series_equal(test_tc_mc.power_output, power_output_exp)

        # Test constant efficiency
        parameters['wake_losses_model'] = 'wind_farm_efficiency'
        test_cluster = wtc.WindTurbineCluster(**self.test_cluster)
        for farm in test_cluster.wind_farms:
            farm.efficiency = 0.9
        power_output_exp = pd.Series(
            data=[10920128.570572512, 21273144.336885825],
            name='feedin_power_plant')
        test_tc_mc = tc_mc.TurbineClusterModelChain(power_plant=test_cluster,
                                                    **parameters)
        test_tc_mc.run_model(self.weather_df)
        assert_series_equal(test_tc_mc.power_output, power_output_exp)

        # Test smoothing
        parameters['smoothing'] = 'True'
        test_cluster = wtc.WindTurbineCluster(**self.test_cluster)
        for farm in test_cluster.wind_farms:
            farm.efficiency = 0.9
        power_output_exp = pd.Series(
            data=[11360309.77979467, 20328652.64490018],
            name='feedin_power_plant')
        test_tc_mc = tc_mc.TurbineClusterModelChain(power_plant=test_cluster,
                                                    **parameters)
        test_tc_mc.run_model(self.weather_df)
        assert_series_equal(test_tc_mc.power_output, power_output_exp)

        # Test wind farm with different turbine types (smoothing)
        test_cluster = wtc.WindTurbineCluster(**self.test_cluster)
        for farm in test_cluster.wind_farms:
            farm.efficiency = 0.9
        power_output_exp = pd.Series(
            data=[11360309.77979467, 20328652.64490018],
            name='feedin_power_plant')
        test_tc_mc = tc_mc.TurbineClusterModelChain(power_plant=test_cluster,
                                                    **parameters)
        test_tc_mc.run_model(self.weather_df)
        assert_series_equal(test_tc_mc.power_output, power_output_exp)

        # Test other smoothing order
        parameters['smoothing_order'] = 'turbine_power_curves'
        test_cluster = wtc.WindTurbineCluster(**self.test_cluster)
        for farm in test_cluster.wind_farms:
            farm.efficiency = 0.9
        power_output_exp = pd.Series(
            data=[11373183.797085874, 20325877.105744187],
            name='feedin_power_plant')
        test_tc_mc = tc_mc.TurbineClusterModelChain(power_plant=test_cluster,
                                                    **parameters)
        test_tc_mc.run_model(self.weather_df)
        assert_series_equal(test_tc_mc.power_output, power_output_exp)