Skip to content

Commit

Permalink
housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Oct 19, 2019
1 parent be5cb12 commit 8e5be93
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions Tune_Cases/tune_NREL15MW.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,72 +21,59 @@
file_processing = wtc_controller.FileProcessing()

# Fast input file and Cp surface text file
# FAST_InputFile = 'NREL15mw_OpenFAST_prelim_v4.fst'
# FAST_directory = '/Users/nabbas/Documents/TurbineModels/NREL-15MW-Offshore-Reference-Turbine/OpenFAST/NREL15mw_OpenFAST_prelim_v4'
# txt_filename = 'Cp_Ct_Cq.txt'

FAST_InputFile = '5MW_Land.fst'
FAST_directory = '/Users/nabbas/Documents/TurbineModels/NREL_5MW/5MW_Land'
FAST_InputFile = 'IEA-15-240-RWT.fst'
FAST_directory = '/Users/nabbas/Documents/TurbineModels/IEA-15-240-RWT/OpenFAST'
txt_filename = 'Cp_Ct_Cq.txt'

# rotor_inertia = 354810226.448 # Available from Elastodyn I/O
# generator_inertia = 17159301.77
# gb_ratio = 97
# drivetrain_inertia = rotor_inertia + generator_inertia* gb_ratio**2

drivetrain_inertia = 40469564.444

# turbine.load('NREL15MW_turbine.p')
rotor_inertia = 354810226.448 # Available from Elastodyn I/O
generator_inertia = 17159301.77
gb_ratio = 1
drivetrain_inertia = rotor_inertia + generator_inertia* gb_ratio**2

# Load Turbine
# turbine.load_from_fast(FAST_InputFile,FAST_directory,drivetrain_inertia,dev_branch=True,rot_source='txt',txt_filename=txt_filename)
turbine.load_from_fast(FAST_InputFile,FAST_directory,drivetrain_inertia,dev_branch=True,rot_source=None,txt_filename=txt_filename)
turbine.load_from_fast(FAST_InputFile,FAST_directory,drivetrain_inertia,dev_branch=True,rot_source=None)
# Tune controller
controller.tune_controller(turbine)
# Save turbine
turbine.save('NREL15MW_turbine.p')

# Save turbine
# turbine.save('NREL15MW_turbine.p')

#%%
turbine.write_rotorperformance(txt_filename='Cp_Ct_Cq.txt')

# Write parameter input file
param_file = 'DISCON.IN'
file_processing.write_param_file(param_file,turbine,controller,new_file=True)


#%% Load Saved Turbine
# turbine.load('NREL15MW_turbine.p')

#%% Tiny sim
# Tiny Sim
from WTC_toolbox import control_interface as ci

# Load controller
lib_name = '../DRC_Fortran/DISCON/DISCON_glin64.so'
# lib_name = '/Users/pfleming/Desktop/git_tools/floating/DRC_Fortran/DISCON//DISCON_glin64.so'
controller_int = ci.ConInt(lib_name)

# Load the simulator
sim = wtc_sim.Sim(turbine,controller_int)

# Define a wind speed history
dt = 0.1
tlen = 500 # length of time to simulate (s)
ws0 = 9 # initial wind speed (m/s)
tlen = 1000 # length of time to simulate (s)
ws0 = 5 # initial wind speed (m/s)
t= np.arange(0,tlen,dt)
ws = np.ones_like(t) * ws0
# add steps at every 100s
# for i in range(len(t)):
# ws[i] = ws[i] + t[i]//100
for i in range(len(t)):
ws[i] = ws[i] + t[i]//100


# Run simulator
sim.sim_ws_series(t,ws)
sim.sim_ws_series(t,ws,rotor_rpm_init=turbine.RRspeed)
plt.show()

#%%
plt.figure(1)
plt.plot(controller.pc_gain_schedule.Kp)
plt.show()

print(controller.v_rated)
plt.figure(2)
plt.plot(controller.pitch_op_pc, controller.pc_gain_schedule.Kp)
plt.show()

0 comments on commit 8e5be93

Please sign in to comment.