Skip to content

Commit

Permalink
Bug fix: cast reference_wind_height to float (#507)
Browse files Browse the repository at this point in the history
* Change reference_wind_height to float

* Change input converter from int to float for reference_wind_height

* Make reference hub height compatible with float inputs, avoid exact comparisons
  • Loading branch information
Bartdoekemeijer authored Nov 14, 2022
1 parent 0c2adf3 commit f450e3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion floris/simulation/flow_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FlowField(FromDictMixin):
wind_shear: float = field(converter=float)
air_density: float = field(converter=float)
turbulence_intensity: float = field(converter=float)
reference_wind_height: int = field(converter=int)
reference_wind_height: float = field(converter=float)
time_series : bool = field(default=False)

n_wind_speeds: int = field(init=False)
Expand Down
6 changes: 3 additions & 3 deletions floris/tools/floris_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def __init__(self, configuration: dict | str | Path, het_map=None):
self.floris.flow_field.het_map = het_map

# If ref height is -1, assign the hub height
if self.floris.flow_field.reference_wind_height == -1:
if np.abs(self.floris.flow_field.reference_wind_height + 1.0) < 1.0e-6:
self.assign_hub_height_to_ref_height()

# Make a check on reference height and provide a helpful warning
unique_heights = np.unique(self.floris.farm.hub_heights)
if (len(unique_heights) == 1) and (self.floris.flow_field.reference_wind_height != unique_heights[0]):
unique_heights = np.unique(np.round(self.floris.farm.hub_heights, decimals=6))
if (len(unique_heights) == 1) and (np.abs(self.floris.flow_field.reference_wind_height - unique_heights[0]) > 1.0e-6):
err_msg = "The only unique hub-height is not the equal to the specified reference wind height. If this was unintended use -1 as the reference hub height to indicate use of hub-height as reference wind height."
self.logger.warning(err_msg, stack_info=True)

Expand Down

0 comments on commit f450e3c

Please sign in to comment.