示例#1
0
    def set_openfast_data(self):
        # Openfast
        if self.modeling_options['Level3']['flag'] == True:
            fast                = InputReader_OpenFAST(FAST_ver='OpenFAST')
            self.modeling_options['openfast']['fst_vt'] = {}
            self.modeling_options['openfast']['fst_vt']['outlist'] = fast.fst_vt['outlist']

            if self.modeling_options['openfast']['file_management']['FAST_directory'] != 'none':
                # Load Input OpenFAST model variable values
                fast.FAST_InputFile = self.modeling_options['openfast']['file_management']['FAST_InputFile']
                if os.path.isabs(self.modeling_options['openfast']['file_management']['FAST_directory']):
                    fast.FAST_directory = self.modeling_options['openfast']['file_management']['FAST_directory']
                else:
                    fast.FAST_directory = os.path.join(os.path.dirname(self.modeling_options['fname_input_modeling']), self.modeling_options['openfast']['file_management']['FAST_directory'])

            # Find the controller
            run_dir = os.path.dirname( os.path.dirname( os.path.dirname( os.path.realpath(__file__) ) ) ) + os.sep
            if platform.system() == 'Windows':
                path2dll = os.path.join(run_dir, 'local/lib/libdiscon.dll')
            elif platform.system() == 'Darwin':
                path2dll = os.path.join(run_dir, 'local/lib/libdiscon.dylib')
            else:
                path2dll = os.path.join(run_dir, 'local/lib/libdiscon.so')
            if self.modeling_options['openfast']['file_management']['path2dll'] == 'none':
                self.modeling_options['openfast']['file_management']['path2dll'] = path2dll
                
            if os.path.isabs(self.modeling_options['openfast']['file_management']['path2dll']) == False:
                self.modeling_options['openfast']['file_management']['path2dll'] = os.path.join(os.path.dirname(self.modeling_options['fname_input_modeling']), self.modeling_options['openfast']['file_management']['path2dll'])

            if self.modeling_options['openfast']['file_management']['FAST_directory'] != 'none':
                fast.path2dll = self.modeling_options['openfast']['file_management']['path2dll']
                fast.execute()
            
            if self.modeling_options['openfast']['analysis_settings']['Analysis_Level'] == 2 and self.modeling_options['openfast']['dlc_settings']['run_power_curve'] == False and self.modeling_options['openfast']['dlc_settings']['run_IEC'] == False:
                raise Exception('WEIS is set to run OpenFAST, but both flags for power curve and IEC cases are set to False among the modeling options. Set at least one of the two to True to proceed.')
        
        # XFoil
        if not os.path.isfile(self.modeling_options["xfoil"]["path"]) and self.modeling_options['Level3']['ROSCO']['Flp_Mode']:
            raise Exception("A distributed aerodynamic control device is defined in the geometry yaml, but the path to XFoil in the modeling options is not defined correctly")
示例#2
0
    def set_openfast_data(self):
        # Openfast
        if self.modeling_options['Analysis_Flags']['OpenFAST'] == True:
            # Load Input OpenFAST model variable values
            fast = InputReader_OpenFAST(FAST_ver='OpenFAST')
            fast.FAST_InputFile = self.modeling_options['openfast'][
                'file_management']['FAST_InputFile']
            if os.path.isabs(self.modeling_options['openfast']
                             ['file_management']['FAST_directory']):
                fast.FAST_directory = self.modeling_options['openfast'][
                    'file_management']['FAST_directory']
            else:
                fast.FAST_directory = os.path.join(
                    os.path.dirname(
                        self.modeling_options['fname_input_modeling']),
                    self.modeling_options['openfast']['file_management']
                    ['FAST_directory'])

            # Find the controller
            run_dir = os.path.dirname(
                os.path.dirname(os.path.dirname(
                    os.path.realpath(__file__)))) + os.sep
            if platform.system() == 'Windows':
                path2dll = os.path.join(run_dir, 'local/lib/libdiscon.dll')
            elif platform.system() == 'Darwin':
                path2dll = os.path.join(run_dir, 'local/lib/libdiscon.dylib')
            else:
                path2dll = os.path.join(run_dir, 'local/lib/libdiscon.so')
            if self.modeling_options['openfast']['file_management'][
                    'path2dll'] != 'none':
                if os.path.isabs(self.modeling_options['openfast']
                                 ['file_management']['path2dll']):
                    fast.path2dll = self.modeling_options['openfast'][
                        'file_management']['path2dll']
                else:
                    fast.path2dll = os.path.join(
                        os.path.dirname(
                            self.modeling_options['fname_input_modeling']),
                        self.modeling_options['openfast']['file_management']
                        ['path2dll'])
            else:
                fast.path2dll = path2dll

            fast.execute()
            self.modeling_options['openfast']['fst_vt'] = fast.fst_vt

            if os.path.isabs(self.modeling_options['openfast']
                             ['file_management']['Simulation_Settings_File']):
                path2settings = self.modeling_options['openfast'][
                    'file_management']['Simulation_Settings_File']
            else:
                path2settings = os.path.join(
                    os.path.dirname(
                        self.modeling_options['fname_input_modeling']),
                    self.modeling_options['openfast']['file_management']
                    ['Simulation_Settings_File'])
            if os.path.exists(path2settings):
                self.modeling_options['openfast']['fst_settings'] = dict(
                    sch.load_yaml(path2settings))
            else:
                print(
                    'WARNING: OpenFAST is called, but no file with settings is found.'
                )
                self.modeling_options['openfast']['fst_settings'] = {}

            if os.path.isabs(self.modeling_options['xfoil']['path']):
                self.modeling_options['airfoils'][
                    'xfoil_path'] = self.modeling_options['xfoil']['path']
            else:
                self.modeling_options['airfoils']['xfoil_path'] = os.path.join(
                    os.path.dirname(
                        self.modeling_options['fname_input_modeling']),
                    self.modeling_options['xfoil']['path'])
            if self.modeling_options['openfast']['analysis_settings'][
                    'Analysis_Level'] == 2 and self.modeling_options[
                        'openfast']['dlc_settings'][
                            'run_power_curve'] == False and self.modeling_options[
                                'openfast']['dlc_settings']['run_IEC'] == False:
                raise ValueError(
                    'WEIS is set to run OpenFAST, but both flags for power curve and IEC cases are set to False among the modeling options. Set at least one of the two to True to proceed.'
                )
        else:
            self.modeling_options['openfast']['fst_vt'] = {}
            self.modeling_options['airfoils']['xfoil_path'] = ''