Fix farm orientation(north up) and plot turbine with fi #530
Replies: 5 comments 10 replies
-
Hi @dhcho347 Thanks for making these changes and sharing! Could you open a draft pull request to the develop branch so that we can start to understand the code changes? |
Beta Was this translation helpful? Give feedback.
-
Hi, Thanks for all the work done in rotating back the wind farm for plots. I have one minor comment. This method only works if the center of rotations are small or zero. If the center of rotation increases it will cause the turbines locations in the farm to be inaccurate with the current approach. I suggest updating the rotate_coordinates_rel_west to the following : def rotate_coordinates_rel_west(wind_directions, coordinates, inv_rot=False,layout_x=0,layout_y=0):
# Calculate the difference in given wind direction from 270 / West
wind_deviation_from_west = wind_delta(wind_directions)
wind_deviation_from_west = np.reshape(wind_deviation_from_west, (len(wind_directions), 1, 1))
# Construct the arrays storing the turbine locations
# x_coordinates, y_coordinates, z_coordinates = coordinates.T
if isinstance(coordinates, (np.ndarray, np.generic) ) :
x_coordinates, y_coordinates, z_coordinates = coordinates.T
else :
x_coordinates, y_coordinates, z_coordinates = coordinates #dh. to handle additional input type (mesh grid)
if inv_rot :
wind_deviation_from_west = -wind_deviation_from_west #dh. for inverse rotation
x_center_of_rotation = (np.min(layout_x) + np.max(layout_x)) / 2
y_center_of_rotation = (np.min(layout_y) + np.max(layout_y)) / 2
else:
# Find center of rotation - this is the center of box bounding all of the turbines
x_center_of_rotation = (np.min(x_coordinates) + np.max(x_coordinates)) / 2
y_center_of_rotation = (np.min(y_coordinates) + np.max(y_coordinates)) / 2
# Rotate turbine coordinates about the center
x_coord_offset = x_coordinates - x_center_of_rotation
y_coord_offset = y_coordinates - y_center_of_rotation
if inv_rot :
x_coord_rotated = (
x_coord_offset * cosd(wind_deviation_from_west)
- y_coord_offset * sind(wind_deviation_from_west)
)
# pdb.set_trace()
x_coord_rotated =x_coord_rotated + x_center_of_rotation
y_coord_rotated = (
x_coord_offset * sind(wind_deviation_from_west)
+ y_coord_offset * cosd(wind_deviation_from_west)
)
y_coord_rotated =y_coord_rotated + y_center_of_rotation
else:
x_coord_rotated = (
x_coord_offset * cosd(wind_deviation_from_west)
- y_coord_offset * sind(wind_deviation_from_west)
+ x_center_of_rotation
)
y_coord_rotated = (
x_coord_offset * sind(wind_deviation_from_west)
+ y_coord_offset * cosd(wind_deviation_from_west)
+ y_center_of_rotation
)
z_coord_rotated = np.ones_like(wind_deviation_from_west) * z_coordinates
return x_coord_rotated, y_coord_rotated, z_coord_rotated Also updating the line calling the rotate_coordinates_rel_west function within the get_plane_of_points function to the following: x_flat2, y_flat2, z_flat2 = rotate_coordinates_rel_west(self.floris.flow_field.wind_directions, (x_flat, y_flat, z_flat), inv_rot=True ,layout_x=self.floris.farm.layout_x,layout_y=self.floris.farm.layout_y) |
Beta Was this translation helpful? Give feedback.
-
Hi @MYMahfouz. Thanks for doing this, that is super helpful! Could you open a pull request to get your work merged in to the develop branch? |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Hi @dhcho347 I believe this discussion has been resolved ultimately by #578 and #663. Can you confirm that this is true? If so, we can close this issue and your open pull request #533. By the way, thank you very much for documenting this so well and creating the pull request with a suggested fix. It was very helpful in arriving at the final implementation. |
Beta Was this translation helpful? Give feedback.
-
a. before change
b. after change (without planar flowfield broaden)
c. after change with flowfield broaden (0,90,180,270 deg)
(0,90,180,270 deg)+45deg
d. change things
e. myCode
v grid.py: class flowfiledplanar Grid method set_grid (Braoden flowfield, rotate mesh grid)
v utilities.py: minor change to ftn rotate_coordinates_rel_west()
v floris_interface.py: method get_plane_of_points() (reverse rotating to north up)
f. refer: #348, #357, #372
a. before change yaw angle (with fi.reinitialize)
b. after change (with fi.reinitialize)
c. after change. different WTG types
d. myCode
v visualization.py: ftn plot_turbines
v fi update before fi.calculate_horizontal_plane() to maintain cal results to use texting
e. refer: #448, #451, #455, #512
Beta Was this translation helpful? Give feedback.
All reactions