Skip to content

Commit e90ab16

Browse files
authored
Merge pull request #92 from vezeli/fix-turbine
Fix turbine
2 parents 7a79912 + 678f291 commit e90ab16

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

tests/test_wind_turbine.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,14 @@ def test_wrongly_defined_to_group_method(self):
110110
"parameter are mutually exclusive.",
111111
):
112112
e_t_1.to_group(5, 3000)
113+
114+
def test_create_unphysical_turbine(self):
115+
err_msg = "1/2rotor_diameter cannot be greater than hub_height"
116+
char = {
117+
'hub_height': 80,
118+
'rotor_diameter': 160,
119+
'turbine_type': 'DUMMY 3',
120+
'path': self.source
121+
}
122+
with pytest.raises(ValueError, match=err_msg):
123+
WindTurbine(**char)

windpowerlib/wind_turbine.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ def __init__(
175175
if self.rotor_diameter is None and turbine_data is not None:
176176
self.rotor_diameter = float(turbine_data["rotor_diameter"])
177177

178+
if self.rotor_diameter:
179+
if self.hub_height <= 0.5*self.rotor_diameter:
180+
msg = "1/2rotor_diameter cannot be greater than hub_height"
181+
raise ValueError(msg)
182+
178183
if self.power_curve is None and self.power_coefficient_curve is None:
179184
msg = (
180185
"The WindTurbine has been initialised without a power curve"

0 commit comments

Comments
 (0)