Skip to content

Commit

Permalink
Merge pull request #6 from NREL/develop
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
nikhar-abbas authored Jan 30, 2020
2 parents d2fe32b + 791816f commit a4b3c7c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ROSCO
Submodule ROSCO updated 1 files
+36 −31 src/Filters.f90
19 changes: 10 additions & 9 deletions ROSCO_toolbox/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def tune_controller(self, turbine):

# Define minimum pitch saturation to be at Cp-maximizing pitch angle if not specifically defined
if not self.min_pitch:
self.min_pitch = pitch_op[0]
self.min_pitch = 0.0
self.min_pitch = max(self.min_pitch,pitch_op[0])

# Full Cp surface gradients
dCp_dbeta = dCp_beta/np.diff(pitch_initial_rad)[0]
Expand Down Expand Up @@ -260,17 +261,17 @@ def tune_controller(self, turbine):

# --- Floating feedback term ---
if self.Fl_Mode == 1: # Floating feedback
Kpf = (dtau_dv/dtau_dbeta)*turbine.TowerHt * Ng * 2.0 * pi;
self.Kpf = Kpf[len(v_below_rated)]
else:
self.Kpf = 0.0

# And check for .yaml input inconsistencies
if self.Fl_Mode > 0:
Kp_float = (dtau_dv/dtau_dbeta)*turbine.TowerHt * Ng * 2.0 * pi;
self.Kp_float = Kp_float[len(v_below_rated)]

# And check for .yaml input inconsistencies
if turbine.twr_freq == 0.0 or turbine.ptfm_freq == 0.0:
print('WARNING: twr_freq and ptfm_freq should be defined for floating turbine control!!')
# Turn on the notch filter if floating
self.F_NotchType == 1
self.F_NotchType = 2
else:
self.Kp_float = 0.0



class ControllerBlocks():
Expand Down
16 changes: 9 additions & 7 deletions ROSCO_toolbox/turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import datetime
from wisdem.ccblade import CCAirfoil, CCBlade
from wisdem.aeroelasticse.FAST_reader import InputReader_OpenFAST
from scipy import interpolate, gradient
from scipy import interpolate
from numpy import gradient
import pickle
import matplotlib.pyplot as plt

Expand Down Expand Up @@ -128,6 +129,7 @@ def load(filename):
'''
turbine = pickle.load(open(filename,'rb'))
return turbine

# Load data from fast input deck
def load_from_fast(self, FAST_InputFile,FAST_directory, FAST_ver='OpenFAST',dev_branch=True,rot_source=None, txt_filename=None):
"""
Expand Down Expand Up @@ -249,11 +251,11 @@ def load_from_ccblade(self,fast):
# Use airfoil data from FAST file read, assumes AeroDyn 15, assumes 1 Re num per airfoil
af_dict = {}
for i, _ in enumerate(fast.fst_vt['AeroDyn15']['af_data']):
Re = [fast.fst_vt['AeroDyn15']['af_data'][i]['Re']]
Alpha = fast.fst_vt['AeroDyn15']['af_data'][i]['Alpha']
Cl = fast.fst_vt['AeroDyn15']['af_data'][i]['Cl']
Cd = fast.fst_vt['AeroDyn15']['af_data'][i]['Cd']
Cm = fast.fst_vt['AeroDyn15']['af_data'][i]['Cm']
Re = [fast.fst_vt['AeroDyn15']['af_data'][i][0]['Re']]
Alpha = fast.fst_vt['AeroDyn15']['af_data'][i][0]['Alpha']
Cl = fast.fst_vt['AeroDyn15']['af_data'][i][0]['Cl']
Cd = fast.fst_vt['AeroDyn15']['af_data'][i][0]['Cd']
Cm = fast.fst_vt['AeroDyn15']['af_data'][i][0]['Cm']
af_dict[i] = CCAirfoil(Alpha, Re, Cl, Cd, Cm)
# define airfoils for CCBlade
af = [0]*len(r)
Expand Down Expand Up @@ -388,7 +390,7 @@ def __init__(self,performance_table, pitch_initial_rad, TSR_initial):
# -- 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
TSR_ind = np.arange(0,len(TSR_initial))
TSR_fine_ind = np.linspace(TSR_initial[0],TSR_initial[-1],(TSR_initial[-1] - TSR_initial[0])*100)
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
TSR_fine = f_TSR(TSR_fine_ind)
f_performance = interpolate.interp1d(TSR_initial,performance_beta_max,bounds_error='False',kind='quadratic') # interpolate function for Cp(tsr) values
Expand Down
4 changes: 2 additions & 2 deletions ROSCO_toolbox/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def write_param_file(self, turbine, controller, param_file='DISCON.IN', txt_file
file.write('{:<13.1f} ! WE_GearboxRatio - Gearbox ratio [>=1], [-]\n'.format(turbine.Ng))
file.write('{:<014.5f} ! WE_Jtot - Total drivetrain inertia, including blades, hub and casted generator inertia to LSS, [kg m^2]\n'.format(turbine.J))
file.write('{:<13.3f} ! WE_RhoAir - Air density, [kg m^-3]\n'.format(turbine.rho))
file.write( '"{}" ! PerfFileName - File containing rotor performance tables (Cp,Ct,Cq)\n'.format(turbine.rotor_performance_filename))
file.write( '"{}" ! PerfFileName - File containing rotor performance tables (Cp,Ct,Cq)\n'.format(txt_filename))
file.write('{:<7d} {:<10d} ! PerfTableSize - Size of rotor performance tables, first number refers to number of blade pitch angles, second number referse to number of tip-speed ratios\n'.format(len(turbine.Cp.pitch_initial_rad),len(turbine.Cp.TSR_initial)))
file.write('{:<11d} ! WE_FOPoles_N - Number of first-order system poles used in EKF\n'.format(len(controller.A)))
file.write('{} ! WE_FOPoles_v - Wind speeds corresponding to first-order system poles [m/s]\n'.format(''.join('{:<4.2f} '.format(controller.v[i]) for i in range(len(controller.v)))))
Expand Down Expand Up @@ -532,7 +532,7 @@ def write_param_file(self, turbine, controller, param_file='DISCON.IN', txt_file
file.write('{:<014.5f} ! SD_CornerFreq - Cutoff Frequency for first order low-pass filter for blade pitch angle, [rad/s]\n'.format(controller.sd_cornerfreq))
file.write('\n')
file.write('!------- Floating -------------------------------------------\n')
file.write('{:<014.5f} ! Fl_Kp - Nacelle velocity proportional feedback gain [s]\n'.format(controller.Kpf))
file.write('{:<014.5f} ! Fl_Kp - Nacelle velocity proportional feedback gain [s]\n'.format(controller.Kp_float))
file.close()

def write_rotor_performance(self,turbine,txt_filename='Cp_Ct_Cq.txt'):
Expand Down

0 comments on commit a4b3c7c

Please sign in to comment.