diff --git a/Examples/example_05.py b/Examples/example_05.py index af3895afe..e11e14a47 100644 --- a/Examples/example_05.py +++ b/Examples/example_05.py @@ -22,6 +22,16 @@ from ROSCO_toolbox import turbine as ROSCO_turbine from ROSCO_toolbox import sim as ROSCO_sim from ROSCO_toolbox import control_interface as ROSCO_ci +from ROSCO_toolbox.utilities import write_DISCON + +# Load yaml file +this_dir = os.path.dirname(os.path.abspath(__file__)) +tune_dir = os.path.join(this_dir,'../Tune_Cases') +parameter_filename = os.path.join(tune_dir,'NREL5MW.yaml') +inps = yaml.safe_load(open(parameter_filename)) +path_params = inps['path_params'] +turbine_params = inps['turbine_params'] +controller_params = inps['controller_params'] # Specify controller dynamic library path and name this_dir = os.path.dirname(os.path.abspath(__file__)) @@ -36,11 +46,27 @@ else: lib_name = os.path.join(this_dir, '../ROSCO/build/libdiscon.so') +# # Load turbine model from saved pickle +turbine = ROSCO_turbine.Turbine +turbine = turbine.load(os.path.join(example_out_dir,'01_NREL5MW_saved.p')) +# controller = ROSCO_controller.Controller(controller_params) + +# Load turbine data from OpenFAST and rotor performance text file +turbine.load_from_fast( + path_params['FAST_InputFile'], + os.path.join(tune_dir,path_params['FAST_directory']), + dev_branch=True, + rot_source='txt',txt_filename=os.path.join(tune_dir,path_params['rotor_performance_filename']) + ) + +# Tune controller +controller = ROSCO_controller.Controller(controller_params) +controller.tune_controller(turbine) + +# Write parameter input file param_filename = os.path.join(this_dir,'DISCON.IN') +write_DISCON(turbine,controller,param_file=param_filename, txt_filename=os.path.join(tune_dir,path_params['rotor_performance_filename'])) -# Load turbine model from saved pickle -turbine = ROSCO_turbine.Turbine -turbine = turbine.load(os.path.join(example_out_dir,'01_NREL5MW_saved.p')) # Load controller library controller_int = ROSCO_ci.ControllerInterface(lib_name,param_filename=param_filename)