NREL / floris

A controls-oriented engineering wake model.
http://nrel.github.io/floris
BSD 3-Clause "New" or "Revised" License
204 stars 155 forks source link

Standardize shapes of `hub_heights`, `rotor_diameters`, etc. on Farm object. #847

Open misi9170 opened 6 months ago

misi9170 commented 6 months ago

And issue (#833) was raised which was caused by a change in the dimensions of Farm.hub_heights during the Farm.finalize() call. Essentially, some attributes which might be expected to have a single dimension of length n_turbines are "finalized" with dimensions (n_findex x n_turbines). The following code demonstrates this change:

import numpy as np
from floris import FlorisModel

fmodel = FlorisModel("inputs/gch.yaml")

# Before run(), hub_heights has the same dimensions as the layout
fmodel.set(layout_x=[0, 500.0], layout_y=[0.0, 0.0])
fmodel.set(wind_directions=np.array([270.0, 270.0, 270.0, 270.0]),
        wind_speeds=[8.0, 8.0, 10.0, 10.0],
        turbulence_intensities=np.array([0.06, 0.06, 0.06, 0.06]))
print("Prior to run():", fmodel.core.farm.hub_heights.shape)

# After run(), the dimensions of hub_heights have been expanded
fmodel.run()
print("After run():", fmodel.core.farm.hub_heights.shape)

Under the hood, FLORIS is using a _sorted version of hub_heights that does need to have shape (n_findex, n_turbines). However, as far as I can tell, there is no need for the "unsorted" hub_heights to also take that shape.

For simplicity, I suggest we keep any ("unsorted") attribute that is not obviously related to the number of conditions being evaluated to length n_turbines. This affects:

misi9170 commented 6 months ago

Note that the high-level bug in #833 has been addressed in #846 , but the underlying inconsistency on the dimensions of hub_height remains.