|
| 1 | +import pytest |
1 | 2 | import pandas as pd |
2 | 3 | import numpy as np |
3 | 4 | from pandas.util.testing import assert_series_equal |
@@ -187,3 +188,36 @@ def test_run_model_turbine_cluster(self): |
187 | 188 | power_plant=test_cluster, **parameters) |
188 | 189 | test_tc_mc.run_model(self.weather_df) |
189 | 190 | assert_series_equal(test_tc_mc.power_output, power_output_exp) |
| 191 | + |
| 192 | + def test_error_raising(self): |
| 193 | + |
| 194 | + # Raise ValueError when aggregated wind farm power curve needs to be |
| 195 | + # calculated but turbine does not have a power curve |
| 196 | + test_turbine = { |
| 197 | + 'hub_height': 100, |
| 198 | + 'rotor_diameter': 98, |
| 199 | + 'turbine_type': 'V90/2000', |
| 200 | + 'power_coefficient_curve': True} |
| 201 | + test_farm = {'wind_turbine_fleet': |
| 202 | + [{'wind_turbine': |
| 203 | + wt.WindTurbine(**self.test_turbine), |
| 204 | + 'number_of_turbines': 3}, |
| 205 | + {'wind_turbine': |
| 206 | + wt.WindTurbine(**test_turbine), |
| 207 | + 'number_of_turbines': 3}]} |
| 208 | + test_tc_mc = tc_mc.TurbineClusterModelChain( |
| 209 | + power_plant=wf.WindFarm(**test_farm)) |
| 210 | + with pytest.raises(ValueError): |
| 211 | + test_tc_mc.run_model(self.weather_df) |
| 212 | + |
| 213 | + # Raise ValueError when neither turbulence intensity nor roughness |
| 214 | + # length are provided to apply power curve smoothing with standard |
| 215 | + # deviation method 'turbulence_intensity' |
| 216 | + parameters = {'smoothing': True, |
| 217 | + 'standard_deviation_method': 'turbulence_intensity'} |
| 218 | + test_tc_mc = tc_mc.TurbineClusterModelChain( |
| 219 | + power_plant=wf.WindFarm(**self.test_farm), **parameters) |
| 220 | + weather_df = self.weather_df.copy() |
| 221 | + weather_df.pop('roughness_length') |
| 222 | + with pytest.raises(ValueError): |
| 223 | + test_tc_mc.run_model(weather_df) |
0 commit comments