2525from rosco .toolbox .utilities import write_DISCON
2626from rosco .toolbox .inputs .validation import load_rosco_yaml
2727
28+ this_dir = os .path .dirname (os .path .abspath (__file__ ))
29+ tune_dir = os .path .join (this_dir ,'Tune_Cases' )
30+ example_out_dir = os .path .join (this_dir ,'examples_out' )
31+ os .makedirs (example_out_dir , exist_ok = True )
32+
2833def main ():
34+ # Inputs: tuning yaml (will point to openfast model file)
35+ parameter_filename = os .path .join (tune_dir ,'IEA15MW.yaml' )
36+
37+ # Output: controller DISCON input file
38+ param_file = os .path .join (example_out_dir ,'IEA15MW_DISCON.IN' )
39+
2940 # Load yaml file
30- this_dir = os .path .dirname (os .path .abspath (__file__ ))
31- tune_dir = os .path .join (this_dir ,'Tune_Cases' )
32- parameter_filename = os .path .join (tune_dir ,'NREL5MW.yaml' )
3341 inps = load_rosco_yaml (parameter_filename )
3442 path_params = inps ['path_params' ]
3543 turbine_params = inps ['turbine_params' ]
3644 controller_params = inps ['controller_params' ]
45+ yaml_dir = os .path .dirname (parameter_filename )
3746
3847 # Instantiate turbine, controller, and file processing classes
3948 turbine = ROSCO_turbine .Turbine (turbine_params )
4049 controller = ROSCO_controller .Controller (controller_params )
4150
4251 # Load turbine data from OpenFAST and rotor performance text file
43- cp_filename = os .path .join (tune_dir ,path_params ['rotor_performance_filename' ])
52+ cp_filename = os .path .join (yaml_dir ,path_params ['rotor_performance_filename' ])
4453 turbine .load_from_fast (
4554 path_params ['FAST_InputFile' ],
46- os .path .join (tune_dir ,path_params ['FAST_directory' ]),
55+ os .path .join (yaml_dir ,path_params ['FAST_directory' ]),
4756 rot_source = 'txt' ,txt_filename = cp_filename
4857 )
4958
5059 # Tune controller
5160 controller .tune_controller (turbine )
5261
5362 # Write parameter input file
54- example_out_dir = os .path .join (this_dir ,'examples_out' )
55- param_file = os .path .join (example_out_dir ,'03_DISCON.IN' )
56- write_DISCON (turbine ,controller ,
57- param_file = param_file ,
58- txt_filename = cp_filename
59- )
63+ write_DISCON (
64+ turbine ,controller ,
65+ param_file = param_file ,
66+ txt_filename = cp_filename
67+ )
6068
6169 # Plot gain schedule
6270 fig , ax = plt .subplots (2 ,2 ,constrained_layout = True ,sharex = True )
@@ -76,9 +84,7 @@ def main():
7684 ax [3 ].set_ylabel ('Integral Gain' )
7785
7886 plt .suptitle ('Pitch Controller Gains' )
79-
80- if not os .path .isdir (example_out_dir ):
81- os .makedirs (example_out_dir )
87+
8288
8389 if False :
8490 plt .show ()
0 commit comments