diff --git a/tests/test_wind_turbine.py b/tests/test_wind_turbine.py index 5ba627a2..c8766208 100644 --- a/tests/test_wind_turbine.py +++ b/tests/test_wind_turbine.py @@ -97,3 +97,14 @@ def test_wrongly_defined_to_group_method(self): match="The 'number' and the 'total_capacity' " "parameter are mutually exclusive."): e_t_1.to_group(5, 3000) + + def test_create_unphysical_turbine(self): + err_msg = "1/2rotor_diameter cannot be greater than hub_height" + char = { + 'hub_height': 80, + 'rotor_diameter': 160, + 'turbine_type': 'DUMMY 3', + 'path': self.source + } + with pytest.raises(ValueError, match=err_msg): + WindTurbine(**char) diff --git a/windpowerlib/wind_turbine.py b/windpowerlib/wind_turbine.py index a4210895..851ea306 100644 --- a/windpowerlib/wind_turbine.py +++ b/windpowerlib/wind_turbine.py @@ -163,6 +163,11 @@ def __init__(self, hub_height, nominal_power=None, path='oedb', if self.rotor_diameter is None and turbine_data is not None: self.rotor_diameter = float(turbine_data['rotor_diameter']) + if self.rotor_diameter: + if self.hub_height <= 0.5*self.rotor_diameter: + msg = "1/2rotor_diameter cannot be greater than hub_height" + raise ValueError(msg) + if self.power_curve is None and self.power_coefficient_curve is None: msg = ("The WindTurbine has been initialised without a power curve" " and without a power coefficient curve.\nYou will not be"