Skip to content

Commit

Permalink
Bug fix: sort turbulence intensity field in post-calculation step (#564)
Browse files Browse the repository at this point in the history
* corrections to sort TI from turbines

* change version number to v3.2.2
  • Loading branch information
bayc committed Feb 8, 2023
1 parent 875c344 commit 8436fd7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

<!-- Release checklist:
- Update the version in
- [ ] README.rst
- [ ] docs/index.rst
- [ ] README.md
- [ ] docs/index.md
- [ ] floris/VERSION
- [ ] Verify readthedocs builds correctly
- [ ] Verify docs builds correctly
- [ ] Create a tag in the NREL/FLORIS repository
-->
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
FLORIS is a controls-focused wind farm simulation software incorporating
steady-state engineering wake models into a performance-focused Python
framework. It has been in active development at NREL since 2013 and the latest
release is [FLORIS v3.2.1](https://github.com/NREL/floris/releases/latest)
in March 2022.
release is [FLORIS v3.2.2](https://github.com/NREL/floris/releases/latest).

The software is in active development and engagement with the development team
is highly encouraged. If you are interested in using FLORIS to conduct studies
Expand Down
3 changes: 1 addition & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ permalink: /
FLORIS is a controls-focused wind farm simulation software incorporating
steady-state engineering wake models into a performance-focused Python
framework. It has been in active development at NREL since 2013 and the latest
release is [FLORIS v3.2.1](https://github.com/NREL/floris/releases/latest)
in March 2022.
release is [FLORIS v3.2.2](https://github.com/NREL/floris/releases/latest).

The software is in active development and engagement with the development team
is highly encouraged. If you are interested in using FLORIS to conduct studies
Expand Down
7 changes: 7 additions & 0 deletions floris/simulation/flow_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class FlowField(FromDictMixin):
dudz_initial_sorted: NDArrayFloat = field(init=False, default=np.array([]))

turbulence_intensity_field: NDArrayFloat = field(init=False, default=np.array([]))
turbulence_intensity_field_sorted: NDArrayFloat = field(init=False, default=np.array([]))
turbulence_intensity_field_sorted_avg: NDArrayFloat = field(init=False, default=np.array([]))

@wind_speeds.validator
def wind_speeds_validator(self, instance: attrs.Attribute, value: NDArrayFloat) -> None:
Expand Down Expand Up @@ -112,11 +114,16 @@ def initialize_velocity_field(self, grid: Grid) -> None:
self.v_sorted = self.v_initial_sorted.copy()
self.w_sorted = self.w_initial_sorted.copy()

self.turbulence_intensity_field = self.turbulence_intensity * np.ones((self.n_wind_directions, self.n_wind_speeds, len(grid.x_sorted), 1, 1))
self.turbulence_intensity_field_sorted = self.turbulence_intensity_field.copy()

def finalize(self, unsorted_indices):
self.u = np.take_along_axis(self.u_sorted, unsorted_indices, axis=2)
self.v = np.take_along_axis(self.v_sorted, unsorted_indices, axis=2)
self.w = np.take_along_axis(self.w_sorted, unsorted_indices, axis=2)

self.turbulence_intensity_field = np.mean(np.take_along_axis(self.turbulence_intensity_field_sorted, unsorted_indices, axis=2), axis=(3,4))

def calculate_speed_ups(self, het_map, x, y, z=None):
if z is not None:
# Calculate the 3-dimensional speed ups; reshape is needed as the generator adds an extra dimension
Expand Down
18 changes: 9 additions & 9 deletions floris/simulation/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ def sequential_solver(farm: Farm, flow_field: FlowField, grid: TurbineGrid, mode
flow_field.v_sorted += v_wake
flow_field.w_sorted += w_wake

flow_field.turbulence_intensity_field = np.mean(turbine_turbulence_intensity, axis=(3,4))
flow_field.turbulence_intensity_field = flow_field.turbulence_intensity_field[:,:,:,None,None]
flow_field.turbulence_intensity_field_sorted = turbine_turbulence_intensity
flow_field.turbulence_intensity_field_sorted_avg = np.mean(turbine_turbulence_intensity, axis=(3,4))[:, :, :, None, None]


def full_flow_sequential_solver(farm: Farm, flow_field: FlowField, flow_field_grid: FlowFieldGrid, model_manager: WakeModelManager) -> None:
Expand Down Expand Up @@ -283,7 +283,7 @@ def full_flow_sequential_solver(farm: Farm, flow_field: FlowField, flow_field_gr
ix_filter=[i],
)
axial_induction_i = axial_induction_i[:, :, 0:1, None, None] # Since we are filtering for the i'th turbine in the axial induction function, get the first index here (0:1)
turbulence_intensity_i = turbine_grid_flow_field.turbulence_intensity_field[:, :, i:i+1]
turbulence_intensity_i = turbine_grid_flow_field.turbulence_intensity_field_sorted_avg[:, :, i:i+1]
yaw_angle_i = turbine_grid_farm.yaw_angles_sorted[:, :, i:i+1, None, None]
hub_height_i = turbine_grid_farm.hub_heights_sorted[: ,:, i:i+1, None, None]
rotor_diameter_i = turbine_grid_farm.rotor_diameters_sorted[: ,:, i:i+1, None, None]
Expand Down Expand Up @@ -538,8 +538,8 @@ def cc_solver(farm: Farm, flow_field: FlowField, grid: TurbineGrid, model_manage
flow_field.w_sorted += w_wake
flow_field.u_sorted = turb_inflow_field

flow_field.turbulence_intensity_field = np.mean(turbine_turbulence_intensity, axis=(3,4))
flow_field.turbulence_intensity_field = flow_field.turbulence_intensity_field[:,:,:,None,None]
flow_field.turbulence_intensity_field_sorted = turbine_turbulence_intensity
flow_field.turbulence_intensity_field_sorted_avg = np.mean(turbine_turbulence_intensity, axis=(3,4))


def full_flow_cc_solver(farm: Farm, flow_field: FlowField, flow_field_grid: FlowFieldGrid, model_manager: WakeModelManager) -> None:
Expand Down Expand Up @@ -618,7 +618,7 @@ def full_flow_cc_solver(farm: Farm, flow_field: FlowField, flow_field_grid: Flow
)
axial_induction_i = axial_induction_i[:, :, :, None, None]

turbulence_intensity_i = turbine_grid_flow_field.turbulence_intensity_field[:, :, i:i+1]
turbulence_intensity_i = turbine_grid_flow_field.turbulence_intensity_field_sorted_avg[:, :, i:i+1]
yaw_angle_i = turbine_grid_farm.yaw_angles_sorted[:, :, i:i+1, None, None]
hub_height_i = turbine_grid_farm.hub_heights_sorted[: ,:, i:i+1, None, None]
rotor_diameter_i = turbine_grid_farm.rotor_diameters_sorted[: ,:, i:i+1, None, None]
Expand Down Expand Up @@ -681,7 +681,7 @@ def full_flow_cc_solver(farm: Farm, flow_field: FlowField, flow_field_grid: Flow
u_i,
deflection_field,
yaw_angle_i,
turbine_grid_flow_field.turbulence_intensity_field,
turbine_grid_flow_field.turbulence_intensity_field_sorted_avg,
turb_Cts,
turbine_grid_farm.rotor_diameters_sorted[:, :, :, None, None],
turb_u_wake,
Expand Down Expand Up @@ -887,8 +887,8 @@ def turbopark_solver(farm: Farm, flow_field: FlowField, grid: TurbineGrid, model
flow_field.v_sorted += v_wake
flow_field.w_sorted += w_wake

flow_field.turbulence_intensity_field = np.mean(turbine_turbulence_intensity, axis=(3,4))
flow_field.turbulence_intensity_field = flow_field.turbulence_intensity_field[:,:,:,None,None]
flow_field.turbulence_intensity_field_sorted = turbine_turbulence_intensity
flow_field.turbulence_intensity_field_sorted_avg = np.mean(turbine_turbulence_intensity, axis=(3,4))


def full_flow_turbopark_solver(farm: Farm, flow_field: FlowField, flow_field_grid: FlowFieldGrid, model_manager: WakeModelManager) -> None:
Expand Down
2 changes: 1 addition & 1 deletion floris/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.1
3.2.2

0 comments on commit 8436fd7

Please sign in to comment.