-
Notifications
You must be signed in to change notification settings - Fork 171
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
"hub_heights" becomes list of list when using "sample_flow_at_points" #833
Comments
@jfrederik-nrel what version of FLORIS is this? If you aren't on a specific version, then please post the commit hash. |
Just a bit of clarification on versions here---the below runs (from the examples directory) to completion on main branch (31fe1b6) but NOT on develop (c7f8f36): from floris.tools import FlorisInterface
import numpy as np
fi = FlorisInterface("inputs/emgauss.yaml")
D = 126
N = 3
fi.reinitialize(
wind_directions=270 * np.ones(N),
wind_speeds=[7.5],
layout_x=[0],
layout_y=[0]
)
yaw_angles = np.zeros((1, 1, N * N))
yaw_angles = np.array([[[0]], [[10]], [[20]]])
fi.calculate_wake(yaw_angles = yaw_angles)
# Define plane at hub height with turbine width
x = np.linspace(-1*D, 10*D, 111)
y = np.linspace(-0.5*D, 0.5*D, 25)
points_x, points_y = np.meshgrid(x, y)
points_x = points_x.flatten()
points_y = points_y.flatten()
points_z = 150*np.ones_like(points_x)
# Collect the points
u_at_points = fi.sample_flow_at_points(points_x, points_y, points_z)
Note that |
I think I've found the source of the bug, but I'm not 100% sure what the right solution is. When self.hub_heights = np.take_along_axis(
self.hub_heights_sorted,
unsorted_indices[:,:,:,0,0],
axis=2
) This expands self.hub_heights from a list of length Later in the code, I see two solutions for this:
if len(self.hub_heights.shape) == 3:
hub_heights = self.hub_heights[0,0,:]
else:
hub_heights = self.hub_heights Do those fixes work?
@property
def coordinates(self):
if len(self.hub_heights.shape) == 1:
return np.array([
np.array([x, y, z]) for x, y, z in zip(self.layout_x, self.layout_y, self.hub_heights)
])
else:
return np.array([
np.array([x, y, z]) for x, y, z in zip(self.layout_x, self.layout_y, self.hub_heights[0,0])
]) (the script runs and all tests pass) @rafmudaf , do you have a preference between these? If implementing the first fix, I'd also consider removing code that expands the dimensions of |
Hi @rafmudaf, any guidance on which of the above fixes you prefer? If you don't have a strong opinion at this stage, I can open a pull request with one of the fixes and we can discuss there. |
@misi9170 Thanks for diving into this and documenting it clearly. In my opinion, it would be simplest for all of the attributes on the Farm class to have the data type and one of three shapes:
Part of the intent of #751 was to start to align all the attributes with consistent shapes and data types, but like you said it can be pretty invasive. My preference is to have any attribute that FLORIS creates (i.e. anything that isn't loaded directly from the input file or dictionary) be a |
Thanks @rafmudaf ---I'll take a quick pass at option 1 to see how invasive it is; if it ends up being complicated I'll revert to option 2 for now, as you suggest, and open an issue to reconsider option 1 for v4. |
I'm running my own version of example 28, where I want to extract the wind speed over a subset of the horizontal plane at hub height. I run a case with identical wind conditions but different turbine settings (e.g., yaw angles).
When running the function "sample_flow_at_points", I get the following error:
In line 426 of farm.py, the variable
self.hub_heights
has the size of the number of yaw angles set incalculate_wake
(but the function expects size 1 since there is only one turbine). I can circumvent this by manually settingfi.floris.farm.hub_heights = [150]
before runningfi.sample_flow_at_points
, but that hardly seems the proper way to do things.Here's a snippet of my code:
The text was updated successfully, but these errors were encountered: