Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix turbine #92

Merged
merged 3 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/test_wind_turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use the match attribute to make sure the right ValueError is raised.

 with pytest.raises(ValueError, match=regex)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented. However, I had a problem with match when there was an asterisk symbol in the string so I modified the error message slightly.

5 changes: 5 additions & 0 deletions windpowerlib/wind_turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

@uvchik uvchik Jan 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a native speaker but as I know it in a mathematical sense one value is GREATER than another not HIGHER.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.


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"
Expand Down