diff --git a/ROSCO_testing/ROSCO_testing.py b/ROSCO_testing/ROSCO_testing.py index 20f10000d..26ef0ccd5 100644 --- a/ROSCO_testing/ROSCO_testing.py +++ b/ROSCO_testing/ROSCO_testing.py @@ -35,7 +35,7 @@ def __init__(self, **kwargs): # Setup simulation parameters - self.runDir = 'testruns' # directory to run simulations in + self.runDir = os.path.join(os.path.dirname( os.path.realpath(__file__) ), 'testing' ) # directory to run simulations in self.windDir = None self.namebase = 'ROtest' # root name for output simulations self.FAST_exe = 'openfast_single' # name of openfast executable (may need full path) @@ -49,7 +49,7 @@ def __init__(self, **kwargs): self.dev_branch = True # openfast dev branch? self.debug_level = 2 # debug level. 0 - no outputs, 1 - minimal outputs, 2 - all outputs self.overwrite = False # overwrite existing files? - self.cores = 0 # number of cores to use + self.cores = 4 # number of cores to use self.mpi_run = False self.mpi_comm_map_down = [] self.outfile_fmt = 2 # 1 = .txt, 2 = binary, 3 = both @@ -89,7 +89,7 @@ def __init__(self, **kwargs): super(ROSCO_testing, self).__init__() - def ROSCO_Test_lite(self, more_case_inputs=None, U=[]): + def ROSCO_Test_lite(self, more_case_inputs={}, U=[]): ''' DLC 1.1 - 5 wind speeds, 60s @@ -105,7 +105,7 @@ def ROSCO_Test_lite(self, more_case_inputs=None, U=[]): if ('Fst','TMax') in more_case_inputs.keys(): TMax = np.max(more_case_inputs[('Fst','TMax')]['vals']) else: - TMax = 360 + TMax = 10 #360 if len(U) > 0: WindSpeeds = U @@ -153,7 +153,7 @@ def ROSCO_Test_lite(self, more_case_inputs=None, U=[]): iec.Turbsim_exe = self.Turbsim_exe iec.debug_level = self.debug_level iec.cores = self.cores - iec.run_dir = os.path.join(self.runDir,'wind') + iec.run_dir = self.runDir iec.overwrite = self.overwrite # iec.overwrite = False if self.cores > 1: @@ -240,7 +240,7 @@ def ROSCO_Test_lite(self, more_case_inputs=None, U=[]): fastBatch.run_serial() - def ROSCO_Test_heavy(self, more_case_inputs=None): + def ROSCO_Test_heavy(self, more_case_inputs={}, U=[]): ''' Run extensive DLCs for ROSCO - DLC 1.3 - Cutin-Cutout, 2 seeds @@ -248,9 +248,22 @@ def ROSCO_Test_heavy(self, more_case_inputs=None): more_case_inputs: dict Additional case inputs + U: list-like + List like with two lists of wind speeds, first entry for DLC 1.3 and second entry for DLC 1.4 ''' - TMax = 10 + # Check for time and wind inputs + if ('Fst','TMax') in more_case_inputs.keys(): + TMax = np.max(more_case_inputs[('Fst','TMax')]['vals']) + else: + TMax = 630 + + if len(U) > 0: + WindSpeeds = U + if len(U) != 2: + ValueError('For a user defined input, U, two sets of wind speeds must be defined.') + else: + WindSpeeds = [[4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], [8.88, 12.88]] fastRead = InputReader_OpenFAST( FAST_ver=self.FAST_ver, dev_branch=self.dev_branch) @@ -278,7 +291,7 @@ def ROSCO_Test_heavy(self, more_case_inputs=None): iec.dlc_inputs = {} iec.dlc_inputs['DLC'] = [1.3, 1.4] - iec.dlc_inputs['U'] = [[4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], [8.88, 12.88]] + iec.dlc_inputs['U'] = WindSpeeds iec.dlc_inputs['Seeds'] = [[991235, 5123], []] iec.dlc_inputs['Yaw'] = [[], []] iec.transient_dir_change = '-' # '+','-','both': sign for transient events in EDC, EWS @@ -332,8 +345,8 @@ def ROSCO_Test_heavy(self, more_case_inputs=None): if more_case_inputs: case_inputs.update(more_case_inputs) - case_list, case_name_list = iec.execute(case_inputs=case_inputs) - + case_list, case_name_list, _ = iec.execute(case_inputs=case_inputs) + # Ensure proper output channels var_out = self.var_out @@ -376,7 +389,7 @@ def ROSCO_Test_heavy(self, more_case_inputs=None): else: fastBatch.run_serial() - def ROSCO_Controller_Comp(self, controller_paths, testtype='light', more_case_inputs=[], U=[]): + def ROSCO_Controller_Comp(self, controller_paths, testtype='light', more_case_inputs={}, U=[]): ''' Heavy or light testing for n controllers, n = len(controller_paths) @@ -443,3 +456,53 @@ def ROSCO_DISCON_Comp(self, DISCON_filenames, testtype='light'): # reset self self.runDir = run_dir_init self.windDir = wind_dir_init + +if __name__=='__main__': + rt = ROSCO_testing() + + + ## =================== INITIALIZATION =================== + # Setup simulation parameters + rt.runDir = '/Users/nabbas/Documents/Projects/ROSCO_dev/WSE_updates/WSE_Testing' # directory for FAST simulations + rt.namebase = 'IEA-15MW' # Base name for FAST files + rt.FAST_exe = '/Users/nabbas/Documents/WindEnergyToolbox/WEIS/local/bin/openfast' # OpenFAST executable path + rt.Turbsim_exe = '/Users/nabbas/openfast/install/bin/turbsim_single' # Turbsim executable path + rt.FAST_ver = 'OpenFAST' # FAST version + rt.rosco_path = ['/Users/nabbas/Documents/WindEnergyToolbox/ROSCO/build-master/libdiscon.dylib', + '/Users/nabbas/Documents/WindEnergyToolbox/ROSCO/build-wse/libdiscon.dylib', + ] # path to compiled ROSCO controller + rt.dev_branch = True # dev branch of Openfast? + rt.debug_level = 2 # debug level. 0 - no outputs, 1 - minimal outputs, 2 - all outputs + rt.overwrite = True # overwite fast sims? + rt.cores = 4 # number of cores if multiprocessings + rt.mpi_run = False # run using mpi + rt.mpi_comm_map_down = [] # core mapping for MPI + rt.outfile_fmt = 2 # 1 = .txt, 2 = binary, 3 = both + rt.dev_branch= 'True' + # Post Processing Parameters + reCrunch = True # re-run pCrunch? + + # Setup turbine + rt.Turbine_Class = 'I' + rt.Turbulence_Class = 'B' + rt.FAST_directory = '/Users/nabbas/Documents/WindEnergyToolbox/WEIS/examples/OpenFAST_models/IEA-15-240-RWT/IEA-15-240-RWT-Monopile' + rt.FAST_InputFile = 'IEA-15-240-RWT-Monopile.fst' + + # Additional inputs + # ---- DT for this test! ---- + case_inputs={} + case_inputs[('Fst', 'TMax')] = {'vals': [330], 'group': 0} + case_inputs[('Fst', 'DT')] = {'vals': [0.01], 'group': 0} + case_inputs[('Fst', 'CompElast')] = {'vals': [1], 'group': 0} + + case_inputs[('DISCON_in', 'PC_ControlMode')] = {'vals': [1], 'group': 0} + case_inputs[('DISCON_in', 'PS_Mode')] = {'vals': [0], 'group': 0} + case_inputs[('DISCON_in', 'VS_ControlMode')] = {'vals': [2], 'group': 0} + case_inputs[('DISCON_in', 'WE_Mode')] = {'vals': [2], 'group': 0} + + # Wind Speeds + U = [5, 9, 12, 15] + + # Run test + rt.ROSCO_Controller_Comp(rt.rosco_path, testtype='light', more_case_inputs=case_inputs, U=U) +