Beispiel #1
0
    def test_to_file_exists(self):

        file_name = join(this_directory, "test_file.txt")
        trim_case = avl.TrimCase(1)
        trim_case.to_file(file_name)
        self.assertTrue(exists(file_name))

        remove(file_name)
Beispiel #2
0
 def test_missing_kwarg_instance(self):
     """
     test that an invalid kwarg raises an error when instancing
     """
     try:
         trim_case = avl.TrimCase(1, hey = 5)
     except avl.InvalidCaseParamError:
         pass
Beispiel #3
0
    def test_error_getting_missing_param(self):
        """
        test that an invalid kwarg raises an error
        """
        trim_case = avl.TrimCase(1, velocity = 5)

        try:
            trim_case["hey"]
        except avl.InvalidCaseParamError:
            pass
Beispiel #4
0
    def test_error_setting_cl(self):
        """
        test that an invalid kwarg raises an error
        """
        trim_case = avl.TrimCase(1, velocity = 5)

        try:
            trim_case["cl"] = 5
        except avl.InvalidCaseParamError:
            pass
    def create(self):

        # create a surface file ------------------------------------------------
        surface = avl.Surface("main")
        surface.define_mesh(20, 30, 1.0, 1.0)

        cord1 = 0.8
        section1 = avl.Section(cord1)
        section1.aerofoil = aerofoil.Aerofoil.develop_aerofoil(
            0.2, -0.2, 0.2, 0.5, 0)

        cord2 = 0.3
        section2 = avl.Section(cord2)
        section2.translation_bias(cord1 - cord2, 0.3, 0)
        section2.twist_angle = -1
        section2.aerofoil = aerofoil.Aerofoil.develop_aerofoil(
            0.2, -0.2, 0.2, 0.5, 0)

        cord3 = 0.05
        section3 = avl.Section(cord3)
        section3.twist_angle = -1
        section3.translation_bias(cord1 - cord3, 0.85, 0)
        section3.aerofoil = aerofoil.Aerofoil.develop_aerofoil(
            0.2, -0.2, 0.2, 0.5, 0)

        control_surface = avl.ControlSurface(
            "elevator", 0.3, [0, 1, 0], avl.ControlDeflectionType.SYMMETRIC)
        surface.add_section(section1, section2, section3)
        surface.add_control_surface(control_surface, 1, 2)
        surface.reflect_surface = True
        plane = avl.Plane("UAV", surface)

        # create a mass file ---------------------------------------------------
        # create sustructure from wing
        structure_creator = layout.StructureFactory(
            layout.StructuralModelType.HOLLOWFOAM)
        structural_model = structure_creator(surface, wall_thickness=1)
        structural_clone = structural_model.clone(reflect_y=True)

        # add some more weights and arrangement
        battery = layout.MassObject(layout.Cuboid(0.1, 0.1, 0.1), 1)
        battery.location = layout.Point(0, -0.05, -0.05)

        arrangement = layout.Arrangement("plane arrangement", battery,
                                         structural_model, structural_clone)

        # create case file -----------------------------------------------------
        case = avl.TrimCase(surface.area * 2,
                            velocity=22,
                            mass=arrangement.total_mass)

        return plane, case, arrangement
Beispiel #6
0
    def test_to_file_content(self):

        file_name = join(this_directory, "test_file.txt")
        trim_case = avl.TrimCase(1)
        trim_case.to_file(file_name)

        expected_string = get_resource_content("case_to_file.txt")

        with open(file_name) as open_file:
            actual_string = open_file.read()
        self.maxDiff = None

        self.assertEqual(expected_string.strip(), actual_string.strip())
        remove(file_name)
Beispiel #7
0
 def test_cl_update(self):
     """
     test that the coefficient of lift updates when kwargs update
     """
     trim_case = avl.TrimCase(1, velocity = 1, mass = 1, gravity = 1, density = 1)
     self.assertEqual(trim_case["cl"], 2)
Beispiel #8
0
 def test_kwargs(self):
     """
     tests that key word arguments update the case parameter dictionary
     """
     trim_case = avl.TrimCase(1, velocity = 5)
     self.assertEqual(trim_case._case_parameters["velocity"], 5)
    def create(self, input_dict, name  = "UAV"):

        surface = avl.Surface("main_wing")
        surface.define_mesh(15, 20, 1.0, 1.0)

        main_cord1 = input_dict["cord_1"]
        section1 = avl.Section(main_cord1)
        thickness = input_dict["aerofoil_1_thickness"]
        section1.aerofoil = aerofoil.Aerofoil.develop_aerofoil(thickness,
                                                               -1 * thickness,
                                                               input_dict["aerofoil_1_thickness"],
                                                               input_dict["aerofoil_1_thickness_loc"],
                                                               input_dict["aerofoil_1_camber"])

        cord2 = input_dict["cord_2"]
        section2 = avl.Section(cord2)
        section2.twist_angle = input_dict["twist_angle_2"]
        wing_shift_1 = input_dict["wing_shift_1"]
        section2.translation_bias(main_cord1  - cord2 - wing_shift_1, input_dict["span_section_1"], 0)
        thickness = input_dict["aerofoil_2_thickness"]
        section2.aerofoil = aerofoil.Aerofoil.develop_aerofoil(thickness,
                                                               -1 * thickness,
                                                               input_dict["aerofoil_2_thickness"],
                                                               input_dict["aerofoil_2_thickness_loc"],
                                                               input_dict["aerofoil_2_camber"])

        cord3 = input_dict["cord_3"]
        section3 = avl.Section(cord3)
        section3.twist_angle = input_dict["twist_angle_3"]
        wing_shift_2 = input_dict["wing_shift_2"]
        section3.translation_bias(main_cord1 - cord3 - wing_shift_1 - wing_shift_2, input_dict["span_section_2"], 0)
        thickness = input_dict["aerofoil_3_thickness"]
        section3.aerofoil = aerofoil.Aerofoil.develop_aerofoil(thickness,
                                                               -1 * thickness,
                                                               input_dict["aerofoil_3_camber"],
                                                               input_dict["aerofoil_3_thickness_loc"],
                                                               input_dict["aerofoil_3_camber"])


        surface.add_section(section1, section2, section3)
        surface.reflect_surface = True

        # design tail
        tail_surface = avl.Surface("tail")
        tail_surface.angle_bias = input_dict["tail_twist"]
        tail_surface.define_translation_bias(input_dict["elevator_distance"], 0, 0)
        tail_surface.define_mesh(10, 15, 1.0, 1.0)
        thickness = input_dict["tail_thickness"]
        tail_aerofoil = aerofoil.Aerofoil.develop_aerofoil(0.5*thickness,
                                                       -1 * 0.5*thickness,
                                                       input_dict["tail_thickness"],
                                                       input_dict["tail_thickness_loc"],
                                                       input_dict["tail_camber"])
        cord1 = input_dict["tail_cord_1"]
        tail_section1 = avl.Section(cord1)
        tail_section1.aerofoil = tail_aerofoil

        cord2 = input_dict["tail_cord_2"]
        tail_section2 = avl.Section(cord2)
        tail_section2.translation_bias(0, input_dict["boom_width"]*0.5, 0)
        tail_section2.aerofoil = tail_aerofoil

        cord3 = input_dict["tail_cord_3"]
        tail_section3 = avl.Section(cord3)
        tail_section3.translation_bias(0, input_dict["boom_width"]*0.5 + input_dict["elevator_span"], 0)
        tail_section3.aerofoil = tail_aerofoil

        tail_surface.add_section(tail_section1, tail_section2, tail_section3)
        tail_surface.reflect_surface = True
        control_surface = avl.ControlSurface("elevator", input_dict["elevator_size"], [0, 1, 0], avl.ControlDeflectionType.SYMMETRIC)
        tail_surface.add_control_surface(control_surface, 0, 2)

        # design verticle_tail
        """
        vtail_surface = avl.Surface("verticle_tail")
        vtail_surface.define_translation_bias(input_dict["elevator_distance"], 0, 0)
        vtail_surface.define_mesh(10, 15, 1.0, 1.0)

        cord1 = input_dict["vtail_cord_1"]
        vtail_section1 = avl.Section(cord1)
        vtail_section1.translation_bias(0, input_dict["boom_width"]*0.5, 0)
        vtail_section1.aerofoil = tail_aerofoil

        cord2 = input_dict["vtail_cord_2"]
        vtail_section2 = avl.Section(cord2)
        vtail_section2.translation_bias(0, input_dict["boom_width"]*0.5, input_dict["vtail_height"])
        tail_section2.aerofoil = tail_aerofoil

        vtail_surface.add_section(vtail_section1, vtail_section2)
        vtail_surface.reflect_surface = True
        """

        # create a mass file ---------------------------------------------------
        # create sustructure from wing
        structure_creator  = layout.StructureFactory(layout.StructuralModelType.HOLLOWFOAM)
        structural_model = structure_creator(surface, wall_thickness = input_dict["wall_thickness"])
        structural_clone =  structural_model.clone(reflect_y = True)

        # create structure for tail
        tail_structural_model = structure_creator(tail_surface, wall_thickness = input_dict["tail_wall_thickness"])
        tail_structural_model.location = layout.Point(tail_surface.x, tail_surface.y, tail_surface.z)
        tail_structural_clone =  tail_structural_model.clone(reflect_y = True)

        # add some more weights and arrangement
        battery = layout.MassObject.from_mass(layout.Cuboid(0.19, 0.035, 0.07), 0.306)
        battery.location = layout.Point(input_dict['battery_loc'], -0.05, -0.05)
        battery2 = battery.clone(reflect_y = True)

        motor = layout.MassObject.from_mass(layout.Cuboid(0.092, 0.042, 0.042), 0.231)
        motor.location = layout.Point(-0.092, input_dict["span_section_2"], -0.05)
        motor2 = motor.clone(reflect_y = True)

        # motor controller
        motor_controller = layout.MassObject.from_mass(layout.Cuboid(0.08, 0.017, 0.031), 0.08)
        motor_controller.location = layout.Point(main_cord1, -0.05, -0.05)

        # add landing gear
        landing_gear = layout.MassObject.from_mass(layout.Cuboid(0.105 + 0.238, 0.05, 0.065), 0.274)
        landing_gear.location = layout.Point(0.8*main_cord1, input_dict["span_section_2"], -0.05)
        landing_gear2 = landing_gear.clone(reflect_y = True)

        # add two hollow booms
        boom1 = layout.MassObject.from_mass(layout.HollowCylinder(0.012, 0.9, 0.005), 0.02727)
        boom1.location = layout.Point(0.25*main_cord1, -0.05, -0.05)
        boom1_ref = boom1.clone(reflect_y = True)

        boom2 = layout.MassObject(layout.HollowCylinder(0.012, 0.9, 0.005), 0.02727)
        boom2.location = layout.Point(0.6*main_cord1, -0.05, -0.05)
        boom2_ref = boom2.clone(reflect_y = True)

        # add horizontal booms
        horizontal_boom1 = layout.MassObject.from_mass(layout.Cuboid( input_dict["elevator_distance"] + 0.5, 0.012, 0.012), 0.03636)
        horizontal_boom1.location = layout.Point(-0.5, 0.1, 0)
        horizontal_boom2 = horizontal_boom1.clone(reflect_y = True)

        # wing box
        box = layout.MassObject.from_mass(layout.Cuboid( 0.47, 0.1, 0.05), 0.284)
        box.location = layout.Point(0, input_dict["span_section_2"], 0)
        box2 = box.clone(reflect_y = True)

        # fuselage box top
        length = input_dict['fuselage_length']
        fuselage = layout.MassObject.from_mass(layout.Cuboid(length, 0.3, 0.09), length * 0.38727)
        fuselage.location = layout.Point(0.4 - length, -0.3*0.5, -0.09)

        fuselage_bottom = layout.MassObject.from_mass(layout.Cuboid(length, 0.3, 0.09), length * 0.54)
        fuselage_bottom.location = layout.Point(0.4 - length, -0.3*0.5, -0.3)

        from_bulk_head = layout.MassObject.from_mass(layout.Cuboid(0.06, 0.24, 0.3), 0.161)
        from_bulk_head.location = layout.Point(0.4 - length, -0.3*0.5, -0.3)

        nose_cone = layout.MassObject.from_mass(layout.Cuboid(0.3, 0.3, 0.3), 0.221)
        nose_cone.location = layout.Point(0.4 - length, -0.3*0.5, -0.3)

        # ribs
        rib_center = layout.MassObject.from_mass(layout.Cuboid(input_dict["cord_1"], 0.06, input_dict["aerofoil_2_thickness"]), 0.02)
        rib_center.location = layout.Point(0, 0, 0)

        rib_outer = layout.MassObject.from_mass(layout.Cuboid(input_dict["cord_2"], 0.03, input_dict["aerofoil_3_thickness"]), 0.01)
        rib_outer.location = layout.Point(0, input_dict["span_section_2"], 0)
        rib_outer_mirror = rib_outer.clone(reflect_y = True)

        arrangement = layout.Arrangement("plane arrangement", battery,
                                                              battery2,
                                                              motor, motor2,
                                                              landing_gear, landing_gear2,
                                                              boom1, boom1_ref,
                                                              boom2, boom2_ref,
                                                              box, box2,
                                                              fuselage, fuselage_bottom,
                                                              horizontal_boom1, horizontal_boom2,
                                                              rib_center, rib_outer, rib_outer_mirror,
                                                              from_bulk_head,
                                                              structural_model,
                                                              structural_clone,
                                                              nose_cone,
                                                              tail_structural_model,
                                                              tail_structural_clone)


        # create case file -----------------------------------------------------
        case = avl.TrimCase(surface.area, velocity = input_dict['velocity'],
                            mass = arrangement.total_mass)

        plane = avl.Plane(name, surface, tail_surface)

        return plane, case, arrangement
Beispiel #10
0
    def create(self, input_dict, name="UAV"):

        surface = avl.Surface("main_wing")
        surface.define_mesh(20, 30, 1.0, 1.0)

        cord1 = input_dict["cord_1"]
        section1 = avl.Section(cord1)
        thickness = input_dict["aerofoil_1_thickness"]
        section1.aerofoil = aerofoil.Aerofoil.develop_aerofoil(
            thickness, -1 * thickness, input_dict["aerofoil_1_thickness"],
            input_dict["aerofoil_1_thickness_loc"],
            input_dict["aerofoil_1_camber"])

        cord2 = input_dict["cord_2"]
        section2 = avl.Section(cord2)
        section2.twist_angle = input_dict["twist_angle_2"]
        wing_shift_1 = input_dict["wing_shift_1"]
        section2.translation_bias(cord1 - cord2 - wing_shift_1,
                                  input_dict["span_section_1"], 0)
        thickness = input_dict["aerofoil_2_thickness"]
        section2.aerofoil = aerofoil.Aerofoil.develop_aerofoil(
            thickness, -1 * thickness, input_dict["aerofoil_2_thickness"],
            input_dict["aerofoil_2_thickness_loc"],
            input_dict["aerofoil_2_camber"])

        cord3 = input_dict["cord_3"]
        section3 = avl.Section(cord3)
        section3.twist_angle = input_dict["twist_angle_3"]
        wing_shift_2 = input_dict["wing_shift_2"]
        section3.translation_bias(cord1 - cord3 - wing_shift_1 - wing_shift_2,
                                  input_dict["span_section_2"], 0)
        thickness = input_dict["aerofoil_3_thickness"]
        section3.aerofoil = aerofoil.Aerofoil.develop_aerofoil(
            thickness, -1 * thickness, input_dict["aerofoil_3_camber"],
            input_dict["aerofoil_3_thickness_loc"],
            input_dict["aerofoil_3_camber"])

        control_surface = avl.ControlSurface(
            "elevator", input_dict["elevator_size"], [0, 1, 0],
            avl.ControlDeflectionType.SYMMETRIC)
        surface.add_section(section1, section2, section3)
        surface.add_control_surface(control_surface, 1, 2)
        surface.reflect_surface = True

        # create a mass file ---------------------------------------------------
        # create sustructure from wing
        """structure_creator  = layout.StructureFactory(layout.StructuralModelType.HOLLOWFOAM)
        structural_model = structure_creator(surface, wall_thickness = input_dict["wall_thickness"])
        structural_clone =  structural_model.clone(reflect_y = True)"""

        # add some more weights and arrangement
        battery = layout.MassObject.from_mass(layout.Cuboid(0.19, 0.035, 0.07),
                                              0.306)
        battery.location = layout.Point(input_dict["battery_x_loc"] * cord1,
                                        -0.035 * 0.5, -0.07 * 0.5)

        motor = layout.MassObject.from_mass(layout.Cuboid(0.092, 0.042, 0.042),
                                            0.231 * 2)
        motor.location = layout.Point(cord1, -0.042 * 0.5, -0.042 * 0.5)

        structure = layout.MassObject.from_mass(
            layout.Cuboid(0.01, 0.01, 0.01), 6)
        structure.location = layout.Point(cord1 * 0.6, -0.005, -0.005)

        arrangement = layout.Arrangement("plane arrangement", battery, motor,
                                         structure)

        # create case file -----------------------------------------------------
        print('AREA ', surface.area)
        print('mass ', arrangement.total_mass)
        case = avl.TrimCase(surface.area,
                            velocity=22,
                            mass=arrangement.total_mass)

        plane = avl.Plane(name, surface)

        return plane, case, arrangement
    def test_integration(self):

        # create a surface file ------------------------------------------------
        surface = avl.Surface("UAV")
        surface.define_mesh(20, 30, 1.0, 1.0)

        cord1 = 0.8
        section1 = avl.Section(cord1)
        section1.aerofoil = aerofoil.Aerofoil.develop_aerofoil(
            0.2, -0.2, 0.2, 0.5, 0)

        cord2 = 0.3
        section2 = avl.Section(cord2)
        section2.translation_bias(cord1 - cord2, 0.3, 0)
        section2.aerofoil = aerofoil.Aerofoil.develop_aerofoil(
            0.2, -0.2, 0.2, 0.5, 0)

        cord3 = 0.05
        section3 = avl.Section(cord3)
        section3.translation_bias(cord1 - cord3, 0.85, 0)
        section3.aerofoil = aerofoil.Aerofoil.develop_aerofoil(
            0.2, -0.2, 0.2, 0.5, 0)

        control_surface = avl.ControlSurface(
            "elevator", 0.3, [0, 1, 0], avl.ControlDeflectionType.SYMMETRIC)
        surface.add_section(section1, section2, section3)
        surface.add_control_surface(control_surface, 1, 2)
        surface.reflect_surface = True
        plane = avl.Plane("UAV", surface)

        avl_input, aerofoil_files = plane.dump_avl_files(self.test_folder)

        # create a mass file ---------------------------------------------------
        # create sustructure from wing
        structure_creator = layout.StructureFactory(
            layout.StructuralModelType.HOLLOWFOAM)
        structural_model = structure_creator(surface, wall_thickness=1)
        structural_clone = structural_model.clone(reflect_y=True)

        # add some more weights and arrangement
        battery = layout.MassObject(layout.Cuboid(0.1, 0.1, 0.1), 1)
        battery.location = layout.Point(0, -0.05, -0.05)

        arrangement = layout.Arrangement("plane arrangement", battery,
                                         structural_model, structural_clone)

        # create case file -----------------------------------------------------
        case = avl.TrimCase(surface.area * 2,
                            velocity=22,
                            mass=arrangement.total_mass)
        case.to_file(self.run_file)
        layout.create_mass_file(self.mass_file, arrangement, case)

        # run through athena
        avl_runner = avl.AVLRunner()
        avl_runner.setup_analysis(avl_input, self.mass_file, self.run_file,
                                  *aerofoil_files)
        results = avl_runner.generate_results(self.results_dir)
        self.assertEqual(results.alpha, 6.70371)
        self.assertEqual(results.elevator_deflection, 26.68316)

        if self.plot:
            plot = plt.subplot(111)
            surface.plot_xy(plot, "g_")
            arrangement.plot_xy(plot, True, "r-")
            plt.show()