From e0d001b285c94d6e330cba27ed0e947a44191430 Mon Sep 17 00:00:00 2001 From: Xianping Du <38188001+Seager1989@users.noreply.github.com> Date: Wed, 16 Jun 2021 12:12:22 -0400 Subject: [PATCH] Update turbine.py (#56) * Update turbine.py This add several lines for fixing the problem of repeated maximum values in the performance tables. This will cause the error (' the length of x and y is different.') of 'interpolate.interp1d.' * Add comments and catch when there are multiple optimal pitch angles Co-authored-by: dzalkind --- ROSCO_toolbox/turbine.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ROSCO_toolbox/turbine.py b/ROSCO_toolbox/turbine.py index d9869e2ab..739553a91 100644 --- a/ROSCO_toolbox/turbine.py +++ b/ROSCO_toolbox/turbine.py @@ -607,7 +607,14 @@ def __init__(self,performance_table, pitch_initial_rad, TSR_initial): # --- Find TSR --- # Make finer mesh for Tip speed ratios at "optimal" blade pitch angle, do a simple lookup. # -- nja: this seems to work a little better than interpolating - performance_beta_max = np.ndarray.flatten(performance_table[:,self.max_ind[1]]) # performance metric at maximizing pitch angle + + # Find the 1D performance table when pitch is at the maximum part of the Cx surface: + performance_beta_max = np.ndarray.flatten(performance_table[:,self.max_ind[1][-1]]) # performance metric at the last maximizing pitch angle + + # If there is more than one max pitch angle: + if len(self.max_ind[1]) > 1: + print('ROSCO_toolbox Warning: repeated maximum values in a performance table and the last one @ pitch = {} rad. was taken...'.format(self.pitch_opt[-1])) + TSR_ind = np.arange(0,len(TSR_initial)) TSR_fine_ind = np.linspace(TSR_initial[0],TSR_initial[-1],int(TSR_initial[-1] - TSR_initial[0])*100) f_TSR = interpolate.interp1d(TSR_initial,TSR_initial,bounds_error='False',kind='quadratic') # interpolate function for Cp(tsr) values