コード例 #1
0
ファイル: AVL.py プロジェクト: Aircraft-Design-UniNa/SUAVE
    def evaluate_conditions(self,run_conditions):
        """ process vehicle to setup geometry, condititon and configuration

            Inputs:
                run_conditions - DataDict() of aerodynamic conditions; until input
                method is finalized, will just assume mass_properties are always as 
                defined in self.features

            Outputs:
                results - a DataDict() of type 
                SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics(), augmented with
                case data on moment coefficients and control derivatives

            Assumptions:

        """
        
        # unpack
        run_folder = os.path.abspath(self.settings.filenames.run_folder)
        output_template = self.settings.filenames.output_template
        batch_template  = self.settings.filenames.batch_template
        deck_template   = self.settings.filenames.deck_template
        
        # update current status
        self.current_status.batch_index += 1
        batch_index = self.current_status.batch_index
        self.current_status.batch_file = batch_template.format(batch_index)
        self.current_status.deck_file = deck_template.format(batch_index)
        
        # translate conditions
        cases = translate_conditions_to_cases(self,run_conditions)
        self.current_status.cases = cases        
        
        # case filenames
        for case in cases:
            case.result_filename = output_template.format(case.tag)

        # write the input files
        with redirect.folder(run_folder,force=False):
            write_geometry(self)
            write_run_cases(self)
            write_input_deck(self)

            # RUN AVL!
            results_avl = run_analysis(self)

        # translate results
        results = translate_results_to_conditions(cases,results_avl)

        if not self.keep_files:
            rmtree( run_folder )

        return results
コード例 #2
0
ファイル: AVL.py プロジェクト: michK/SUAVE
    def evaluate_conditions(self,run_conditions):
        """Process vehicle to setup geometry, condititon, and configuration.

        Assumptions:
        None

        Source:
        N/A

        Inputs:
        run_conditions <SUAVE data type> aerodynamic conditions; until input
                method is finalized, will assume mass_properties are always as 
                defined in self.features

        Outputs:
        results        <SUAVE data type>

        Properties Used:
        self.settings.filenames.
          run_folder
          output_template
          batch_template
          deck_template
        self.current_status.
          batch_index
          batch_file
          deck_file
          cases
        """  

        # unpack
        run_folder                       = os.path.abspath(self.settings.filenames.run_folder)
        output_template                  = self.settings.filenames.output_template
        batch_template                   = self.settings.filenames.batch_template
        deck_template                    = self.settings.filenames.deck_template
        spanwise_vortices_per_meter      = self.settings.spanwise_vortex_density

        # update current status
        self.current_status.batch_index += 1
        batch_index                      = self.current_status.batch_index
        self.current_status.batch_file   = batch_template.format(batch_index)
        self.current_status.deck_file    = deck_template.format(batch_index)

        # control surfaces
        num_cs = 0       
        for wing in self.geometry.wings:
            for segment in wing.Segments:
                wing_segment =  wing.Segments[segment]
                section_cs = len(wing_segment.control_surfaces)
                if section_cs != 0:
                    cs_shift = True
                num_cs =  num_cs + section_cs

        # translate conditions
        cases                            = translate_conditions_to_cases(self,run_conditions)    
        for case in cases:
            cases[case].stability_and_control.number_control_surfaces = num_cs
        self.current_status.cases        = cases 
        

        # case filenames
        for case in cases:
            cases[case].result_filename  = output_template.format(case)
            #case.eigen_result_filename  = stability_output_template.format(batch_index) # SUAVE-AVL dynamic stability under development 


        # write the input files
        with redirect.folder(run_folder,force=False):
            write_geometry(self,spanwise_vortices_per_meter)
            write_run_cases(self)
            write_input_deck(self)

            # RUN AVL!
            results_avl = run_analysis(self)

        # translate results
        results = translate_results_to_conditions(cases,results_avl)

        if not self.keep_files:
            rmtree( run_folder )

        return results
コード例 #3
0
    def evaluate_conditions(self, run_conditions, trim_aircraft):
        """Process vehicle to setup geometry, condititon, and configuration.

        Assumptions:
        None

        Source:
        N/A

        Inputs:
        run_conditions <SUAVE data type> aerodynamic conditions; until input
                method is finalized, will assume mass_properties are always as 
                defined in self.features

        Outputs:
        results        <SUAVE data type>

        Properties Used:
        self.settings.filenames.
          run_folder
          output_template
          batch_template
          deck_template
        self.current_status.
          batch_index
          batch_file
          deck_file
          cases
        """

        # unpack
        run_folder = os.path.abspath(self.settings.filenames.run_folder)
        run_script_path = run_folder.rstrip('avl_files').rstrip('/')
        aero_results_template_1 = self.settings.filenames.aero_output_template_1  # 'stability_axis_derivatives_{}.dat'
        aero_results_template_2 = self.settings.filenames.aero_output_template_2  # 'surface_forces_{}.dat'
        aero_results_template_3 = self.settings.filenames.aero_output_template_3  # 'strip_forces_{}.dat'
        aero_results_template_4 = self.settings.filenames.aero_output_template_4  # 'body_axis_derivatives_{}.dat'
        dynamic_results_template_1 = self.settings.filenames.dynamic_output_template_1  # 'eigen_mode_{}.dat'
        dynamic_results_template_2 = self.settings.filenames.dynamic_output_template_2  # 'system_matrix_{}.dat'
        batch_template = self.settings.filenames.batch_template
        deck_template = self.settings.filenames.deck_template

        # rename defaul avl aircraft tag
        self.tag = 'avl_analysis_of_{}'.format(self.geometry.tag)
        self.settings.filenames.features = self.geometry._base.tag + '.avl'
        self.settings.filenames.mass_file = self.geometry._base.tag + '.mass'

        # update current status
        self.current_status.batch_index += 1
        batch_index = self.current_status.batch_index
        self.current_status.batch_file = batch_template.format(batch_index)
        self.current_status.deck_file = deck_template.format(batch_index)

        # control surfaces
        num_cs = 0
        cs_names = []
        cs_functions = []

        for wing in self.geometry.wings:  # this parses through the wings to determine how many control surfaces does the vehicle have
            if wing.control_surfaces:
                wing = populate_control_sections(wing)
                num_cs_on_wing = len(wing.control_surfaces)
                num_cs += num_cs_on_wing
                for cs in wing.control_surfaces:
                    ctrl_surf = wing.control_surfaces[cs]
                    cs_names.append(ctrl_surf.tag)
                    if (type(ctrl_surf) == Slat):
                        ctrl_surf_function = 'slat'
                    elif (type(ctrl_surf) == Flap):
                        ctrl_surf_function = 'flap'
                    elif (type(ctrl_surf) == Aileron):
                        ctrl_surf_function = 'aileron'
                    elif (type(ctrl_surf) == Elevator):
                        ctrl_surf_function = 'elevator'
                    elif (type(ctrl_surf) == Rudder):
                        ctrl_surf_function = 'rudder'
                    cs_functions.append(ctrl_surf_function)

        # translate conditions
        cases = translate_conditions_to_cases(self, run_conditions)
        for case in cases:
            cases[case].stability_and_control.number_control_surfaces = num_cs
            cases[case].stability_and_control.control_surface_names = cs_names
        self.current_status.cases = cases

        # write case filenames using the templates defined in MACE/Analyses/AVL/AVL_Data_Classes/Settings.py
        for case in cases:
            cases[
                case].aero_result_filename_1 = aero_results_template_1.format(
                    case)  # 'stability_axis_derivatives_{}.dat'
            cases[
                case].aero_result_filename_2 = aero_results_template_2.format(
                    case)  # 'surface_forces_{}.dat'
            cases[
                case].aero_result_filename_3 = aero_results_template_3.format(
                    case)  # 'strip_forces_{}.dat'
            cases[
                case].aero_result_filename_4 = aero_results_template_4.format(
                    case)  # 'body_axis_derivatives_{}.dat'
            cases[
                case].eigen_result_filename_1 = dynamic_results_template_1.format(
                    case)  # 'eigen_mode_{}.dat'
            cases[
                case].eigen_result_filename_2 = dynamic_results_template_2.format(
                    case)  # 'system_matrix_{}.dat'

        # write the input files
        with redirect.folder(run_folder, force=False):
            write_geometry(self, run_script_path)
            write_mass_file(self, run_conditions)
            write_run_cases(self, trim_aircraft)
            write_input_deck(self, trim_aircraft)

            # RUN AVL!
            results_avl = run_analysis(self)

        # translate results
        results = translate_results_to_conditions(cases, results_avl)

        if not self.keep_files:
            rmtree(run_folder)

        return results
コード例 #4
0
ファイル: AVL.py プロジェクト: nevesgeovana/TCC
class AVL(Aero_Analysis):
    """ SUAVE.Analyses.Aerodynamics.AVL
        aerodynamic model that performs a vortex lattice analysis using AVL
        (Athena Vortex Lattice, by Mark Drela of MIT).

        this class is callable, see self.__call__

    """

    def __defaults__(self):
        self.tag        = 'avl'
        self.keep_files = True

        self.settings = Settings()

        self.current_status = Data()
        self.current_status.batch_index = 0
        self.current_status.batch_file  = None
        self.current_status.deck_file   = None
        self.current_status.cases       = None
        
        self.features = None


    def finalize(self):

        features = self.features
        self.tag      = 'avl_analysis_of_{}'.format(features.tag)

        run_folder = self.settings.filenames.run_folder
        if os.path.exists(run_folder):
            if self.keep_files:
                warn('deleting old avl run files',Warning)
            rmtree(run_folder)
        os.mkdir(run_folder)

        return


    def evaluate(self,state,**args):
        
        # unpack
        conditions = state.conditions
        results = self.evaluate_conditions(conditions)
        
        # pack conditions
        state.conditions.aerodynamics.lift_coefficient         = results.conditions.aerodynamics.lift_coefficient
        state.conditions.aerodynamics.drag_coefficient         = results.conditions.aerodynamics.drag_coefficient
        state.conditions.aerodynamics.pitch_moment_coefficient = results.conditions.aerodynamics.pitch_moment_coefficient

        return results


    def evaluate_conditions(self,run_conditions):
        """ process vehicle to setup geometry, condititon and configuration

            Inputs:
                run_conditions - DataDict() of aerodynamic conditions; until input
                method is finalized, will just assume mass_properties are always as 
                defined in self.features

            Outputs:
                results - a DataDict() of type 
                SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics(), augmented with
                case data on moment coefficients and control derivatives

            Assumptions:

        """
        
        # unpack
        run_folder      = os.path.abspath(self.settings.filenames.run_folder)
        output_template = self.settings.filenames.output_template
        batch_template  = self.settings.filenames.batch_template
        deck_template   = self.settings.filenames.deck_template
        
        # update current status
        self.current_status.batch_index += 1
        batch_index                      = self.current_status.batch_index
        self.current_status.batch_file   = batch_template.format(batch_index)
        self.current_status.deck_file    = deck_template.format(batch_index)
        
        # translate conditions
        cases                     = translate_conditions_to_cases(self,run_conditions)
        self.current_status.cases = cases        
        
        # case filenames
        for case in cases:
            case.result_filename = output_template.format(case.tag)

        # write the input files
        with redirect.folder(run_folder,force=False):
            write_geometry(self)
            write_run_cases(self)
            write_input_deck(self)

            # RUN AVL!
            results_avl = run_analysis(self)

        # translate results
        results = translate_results_to_conditions(cases,results_avl)

        if not self.keep_files:
            rmtree( run_folder )

        return results
コード例 #5
0
    def evaluate_conditions(self, run_conditions):
        """Process vehicle to setup geometry, condititon, and configuration.

        Assumptions:
        None

        Source:
        N/A

        Inputs:
        run_conditions <SUAVE data type> aerodynamic conditions; until input
                method is finalized, will assume mass_properties are always as 
                defined in self.features

        Outputs:
        results        <SUAVE data type>

        Properties Used:
        self.settings.filenames.
          run_folder
          output_template
          batch_template
          deck_template
        self.current_status.
          batch_index
          batch_file
          deck_file
          cases
        """

        # unpack
        run_folder = os.path.abspath(self.settings.filenames.run_folder)
        output_template = self.settings.filenames.output_template
        batch_template = self.settings.filenames.batch_template
        deck_template = self.settings.filenames.deck_template

        # rename defaul avl aircraft tag
        self.settings.filenames.features = self.geometry._base.tag + '.avl'

        # update current status
        self.current_status.batch_index += 1
        batch_index = self.current_status.batch_index
        self.current_status.batch_file = batch_template.format(batch_index)
        self.current_status.deck_file = deck_template.format(batch_index)

        # control surfaces
        num_cs = 0
        for wing in self.geometry.wings:
            for segment in wing.Segments:
                wing_segment = wing.Segments[segment]
                section_cs = len(wing_segment.control_surfaces)
                if section_cs != 0:
                    cs_shift = True
                num_cs = num_cs + section_cs

        # translate conditions
        cases = translate_conditions_to_cases(self, run_conditions)
        for case in cases:
            cases[case].stability_and_control.number_control_surfaces = num_cs

        self.current_status.cases = cases

        # case filenames
        for case in cases:
            cases[case].result_filename = output_template.format(case)

        # write the input files
        with redirect.folder(run_folder, force=False):
            write_geometry(self)
            write_run_cases(self)
            write_input_deck(self)

            # RUN AVL!
            results_avl = run_analysis(self)

        # translate results
        results = translate_results_to_conditions(cases, results_avl)

        if not self.keep_files:
            rmtree(run_folder)

        return results
コード例 #6
0
    def evaluate_conditions(self, run_conditions):
        """Process vehicle to setup geometry, condititon, and configuration.

        Assumptions:
        None

        Source:
        N/A

        Inputs:
        run_conditions <SUAVE data type> aerodynamic conditions; until input
                method is finalized, will assume mass_properties are always as 
                defined in self.features

        Outputs:
        results        <SUAVE data type>

        Properties Used:
        self.settings.filenames.
          run_folder
          output_template
          batch_template
          deck_template
        self.current_status.
          batch_index
          batch_file
          deck_file
          cases
        """

        # unpack
        run_folder = os.path.abspath(self.settings.filenames.run_folder)
        output_template = self.settings.filenames.output_template
        batch_template = self.settings.filenames.batch_template
        deck_template = self.settings.filenames.deck_template

        # stability_output_template = self.settings.filenames.stability_output_template  # SUAVE-AVL dynamic stability under development

        # update current status
        self.current_status.batch_index += 1
        batch_index = self.current_status.batch_index
        self.current_status.batch_file = batch_template.format(batch_index)
        self.current_status.deck_file = deck_template.format(batch_index)

        # translate conditions
        cases = translate_conditions_to_cases(self, run_conditions)
        self.current_status.cases = cases

        # case filenames
        for case in cases:
            cases[case].result_filename = output_template.format(case)
            #case.eigen_result_filename  = stability_output_template.format(batch_index) # SUAVE-AVL dynamic stability under development

        # write the input files
        with redirect.folder(run_folder, force=False):
            write_geometry(self)
            write_run_cases(self)
            write_input_deck(self)

            # RUN AVL!
            results_avl = run_analysis(self)

        # translate results
        results = translate_results_to_conditions(cases, results_avl)

        if not self.keep_files:
            rmtree(run_folder)

        return results
コード例 #7
0
ファイル: AVL_Inviscid.py プロジェクト: lmartinel/SUAVE
            case.aero_result_filename_1 = aero_results_template_1.format(
                case.tag)  # 'stability_axis_derivatives_{}.dat'
            case.aero_result_filename_2 = aero_results_template_2.format(
                case.tag)  # 'surface_forces_{}.dat'
            case.aero_result_filename_3 = aero_results_template_3.format(
                case.tag)  # 'strip_forces_{}.dat'
            case.aero_result_filename_4 = aero_results_template_4.format(
                case.tag)  # 'body_axis_derivatives_{}.dat'
            case.eigen_result_filename_1 = dynamic_results_template_1.format(
                case.tag)  # 'eigen_mode_{}.dat'
            case.eigen_result_filename_2 = dynamic_results_template_2.format(
                case.tag)  # 'system_matrix_{}.dat'

        # write the input files
        with redirect.folder(run_folder, force=False):
            write_geometry(self, run_script_path)
            write_mass_file(self, run_conditions)
            write_run_cases(self, trim_aircraft)
            write_input_deck(self, trim_aircraft)

            # RUN AVL!
            results_avl = run_analysis(self)

        # translate results
        results = translate_results_to_conditions(cases, results_avl)

        if not self.keep_files:
            rmtree(run_folder)

        return results