-
Recently, I have been working on optimizing turbine layouts and calculating the Annual Energy Production (AEP) for various turbine configurations using FLORIS. However, I have come across an error that prevents me from completing these tasks. The specific error I am facing is as follows:
The issue occurs when attempting to perform the optimization for a layout with 20 turbines and also when calculating the AEP for specific layout configurations. From my understanding, FLORIS is trying to interpolate a velocity field at the turbine locations to calculate certain parameters. However, I am unsure about the specifics of this interpolation process and how it can be optimized or enhanced. The following is the setup used. import os
import numpy as np
from floris.tools import FlorisInterface
from floris.tools.optimization.layout_optimization.layout_optimization_scipy import (
LayoutOptimizationScipy,
)
import pandas as pd
from scipy.interpolate import NearestNDInterpolator
import time
file_dir = os.path.dirname(os.path.abspath(__file__))
fi = FlorisInterface('inputs/gch.yaml')
df_wr = pd.read_csv("inputs/wind_rose2.csv")
wd_array = np.array(df_wr["wd"].unique(), dtype=float)
ws_array = np.array(df_wr["ws"].unique(), dtype=float)
wd_grid, ws_grid = np.meshgrid(wd_array, ws_array, indexing="ij")
freq_interp = NearestNDInterpolator(df_wr[["wd", "ws"]], df_wr["freq_val"])
freq = freq_interp(wd_grid, ws_grid)
freq = freq / np.sum(freq)
fi.reinitialize(wind_directions=wd_array, wind_speeds=ws_array)
boundaries = [(0.0, 0.0), (0.0, 1400.0), (1400.0, 1400.0), (1400.0, 0.0)]
Dis = 300.0
n = 20
layout = np.zeros((n, 2))
k = 0
for i in range(4):
for j in range(5):
layout[k][0] = Dis*i
layout[k][1] = Dis*j
k +=1
print(layout[:,0])
print(layout)
fi.reinitialize(layout_x=layout[:,0], layout_y=layout[:,1])
layout_opt = LayoutOptimizationScipy(fi, boundaries, freq=freq)
sol = layout_opt.optimize()
print(f'Optimal layout: {sol}') And this resulted in the following error.
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Hi @jam3pa Please include a minimum working example of your script and the stack trace from the error. It's best to copy / paste the text into the discussion comment. Try to describe your issue as if the reader has no context. I'm happy to help, and I'll look out for an update to your original post. |
Beta Was this translation helpful? Give feedback.
-
@jam3pa I think I've found the cause of this error but not yet the solution. The error message suggests that floris is finding a negative velocity somewhere in the flow field. The first thing I did was plot the farm as you've input it with one of the conditions in your wind rose (I chose wd = 0.0 and ws = 10.0). Here's the code to plot and the plots below. fi.reinitialize(layout_x=layout[:,0], layout_y=layout[:,1])
# Inspect the layout and simple wake calculations
wakeviz.plot_turbines_with_fi(fi)
horizontal_plane = fi.calculate_horizontal_plane(90.0, wd=[0.0], ws=[10])
wakeviz.visualize_cut_plane(horizontal_plane, color_bar=True)
cross_plane = fi.calculate_cross_plane(0.0, wd=[0.0], ws=[10])
wakeviz.visualize_cut_plane(cross_plane, color_bar=True)
wakeviz.show_plots() The following are plots of the layout, a horizontal plane at hub height, and a vertical profile to get an idea of how the wind shear profile looks. Indeed, the horizontal plane has negative velocities but they are in the near wake and very close to the upstream turbine, so that isn't the cause of this problem. So, then I thought to understand what the optimizer is doing. Since it's a layout optimization, I wondered what the layout at that particular optimization step was, so I put a print-statement in the objective function in def _obj_func(self, locs):
locs_unnorm = [
self._unnorm(valx, self.xmin, self.xmax)
for valx in locs[0 : self.nturbs]
] + [
self._unnorm(valy, self.ymin, self.ymax)
for valy in locs[self.nturbs : 2 * self.nturbs]
]
self._change_coordinates(locs_unnorm)
print(locs_unnorm) # <-- HERE
return -1 * self.fi.get_farm_AEP(self.freq) / self.initial_AEP That gave me a lot of output since it prints at every iteration, but the output I care about is the last one to print before the error. You can find the format for the layout coordinates in
Finally, dropping that into the script to plot show that multiple turbines are on top of each other. As we can see in the plots above, that means some turbines will certainly be in the near wake of other turbines. So that's what is happening, but I'm not familiar enough with the optimization routines to know why it's happening and what to do to avoid this. @Bartdoekemeijer @bayc do you have any thoughts? |
Beta Was this translation helpful? Give feedback.
-
@jam3pa this issue has now been addressed (by #678), which will be included in the next release of FLORIS. If you would like to start using the fix, please use the develop branch until we release version 3.5 |
Beta Was this translation helpful? Give feedback.
@jam3pa this issue has now been addressed (by #678), which will be included in the next release of FLORIS. If you would like to start using the fix, please use the develop branch until we release version 3.5