Skip to content

Commit 59e53a6

Browse files
committed
Bug fix: Finalize Farm attributes (#665)
* Arrange attribute declarations by shape and sort * Add missing attribute declarations * Remove unused attribute * Add comments requesting more info * Bug fix: unsort arrays Update version to v3.4.1
1 parent 5e5bb7f commit 59e53a6

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
FLORIS is a controls-focused wind farm simulation software incorporating
44
steady-state engineering wake models into a performance-focused Python
55
framework. It has been in active development at NREL since 2013 and the latest
6-
release is [FLORIS v3.4](https://github.com/NREL/floris/releases/latest).
6+
release is [FLORIS v3.4.1](https://github.com/NREL/floris/releases/latest).
77
Online documentation is available at https://nrel.github.io/floris.
88

99
The software is in active development and engagement with the development team

floris/simulation/farm.py

+35-5
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,39 @@ class Farm(BaseClass):
6262
)
6363

6464
turbine_definitions: list = field(init=False, validator=iter_validator(list, dict))
65+
coordinates: List[Vec3] = field(init=False)
66+
turbine_fCts: tuple = field(init=False, default=[])
67+
turbine_fTilts: list = field(init=False, default=[])
68+
6569
yaw_angles: NDArrayFloat = field(init=False)
6670
yaw_angles_sorted: NDArrayFloat = field(init=False)
71+
6772
tilt_angles: NDArrayFloat = field(init=False)
6873
tilt_angles_sorted: NDArrayFloat = field(init=False)
69-
coordinates: List[Vec3] = field(init=False)
74+
7075
hub_heights: NDArrayFloat = field(init=False)
7176
hub_heights_sorted: NDArrayFloat = field(init=False, default=[])
72-
turbine_fCts: tuple = field(init=False, default=[])
77+
78+
turbine_type_map: NDArrayObject = field(init=False, default=[])
7379
turbine_type_map_sorted: NDArrayObject = field(init=False, default=[])
80+
81+
rotor_diameters: NDArrayFloat = field(init=False, default=[])
7482
rotor_diameters_sorted: NDArrayFloat = field(init=False, default=[])
83+
84+
TSRs: NDArrayFloat = field(init=False, default=[])
7585
TSRs_sorted: NDArrayFloat = field(init=False, default=[])
86+
7687
pPs: NDArrayFloat = field(init=False, default=[])
7788
pPs_sorted: NDArrayFloat = field(init=False, default=[])
89+
7890
pTs: NDArrayFloat = field(init=False, default=[])
7991
pTs_sorted: NDArrayFloat = field(init=False, default=[])
92+
8093
ref_tilt_cp_cts: NDArrayFloat = field(init=False, default=[])
8194
ref_tilt_cp_cts_sorted: NDArrayFloat = field(init=False, default=[])
95+
8296
correct_cp_ct_for_tilt: NDArrayFloat = field(init=False, default=[])
8397
correct_cp_ct_for_tilt_sorted: NDArrayFloat = field(init=False, default=[])
84-
turbine_fTilts: list = field(init=False, default=[])
8598

8699
def __attrs_post_init__(self) -> None:
87100
# Turbine definitions can be supplied in three ways:
@@ -301,15 +314,16 @@ def expand_farm_properties(
301314
sorted_coord_indices,
302315
axis=2
303316
)
317+
318+
# NOTE: Tilt angles are sorted twice - here and in initialize()
304319
self.tilt_angles_sorted = np.take_along_axis(
305320
self.tilt_angles * template_shape,
306321
sorted_coord_indices,
307322
axis=2
308323
)
309-
self.turbine_type_names_sorted = [turb["turbine_type"] for turb in self.turbine_definitions]
310324
self.turbine_type_map_sorted = np.take_along_axis(
311325
np.reshape(
312-
self.turbine_type_names_sorted * n_wind_directions,
326+
[turb["turbine_type"] for turb in self.turbine_definitions] * n_wind_directions,
313327
np.shape(sorted_coord_indices)
314328
),
315329
sorted_coord_indices,
@@ -366,6 +380,22 @@ def finalize(self, unsorted_indices):
366380
unsorted_indices[:,:,:,0,0],
367381
axis=2
368382
)
383+
# TODO: do these need to be unsorted? Maybe we should just for completeness...
384+
self.ref_density_cp_cts = np.take_along_axis(
385+
self.ref_density_cp_cts_sorted,
386+
unsorted_indices[:,:,:,0,0],
387+
axis=2
388+
)
389+
self.ref_tilt_cp_cts = np.take_along_axis(
390+
self.ref_tilt_cp_cts_sorted,
391+
unsorted_indices[:,:,:,0,0],
392+
axis=2
393+
)
394+
self.correct_cp_ct_for_tilt = np.take_along_axis(
395+
self.correct_cp_ct_for_tilt_sorted,
396+
unsorted_indices[:,:,:,0,0],
397+
axis=2
398+
)
369399
self.pPs = np.take_along_axis(
370400
self.pPs_sorted,
371401
unsorted_indices[:,:,:,0,0],

floris/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.4
1+
3.4.1

0 commit comments

Comments
 (0)