def setUp(self):
     geometry = layout.Cuboid(1,2,3)
     self.mass1 = layout.MassObject(geometry, 1, "name1")
     self.mass2 = layout.MassObject(geometry, 2, "name2")
     self.mass3 = layout.MassObject(geometry, 3, "name3")
     self.mass4 = layout.MassObject(geometry, 4, "name4")
     self.mass_list = [self.mass1, self.mass2, self.mass3, self.mass4]
 def test_cog(self):
     """
     test the center of gravity is initially the centroid
     """
     mass_object = layout.MassObject(self.geometry, 1, "name")
     self.assertEqual(mass_object.center_of_gravity,
                       layout.Point(0.5, 1, 1.5))
    def test_clone_reflect_y(self):
        self.geometry = layout.Cuboid(1,2,3)
        mass_object = layout.MassObject(self.geometry, 1, "name")
        cloned_mass = mass_object.clone(reflect_y = True)
        self.assertEqual(cloned_mass.geometry.x_size, 1)
        self.assertEqual(cloned_mass.geometry.y_size,  -2)
        self.assertEqual(cloned_mass.geometry.z_size, 3)

        self.assertEqual(cloned_mass.center_of_gravity, layout.Point(0.5, -1, 1.5))
    def test_create_mass_string(self):
        """
        test the create mass string method works with a shifted mass
        """
        mass_object = layout.MassObject(self.geometry, 1, "name")
        mass_object.location = layout.Point(1,1,1) # apply shift

        expected_string = "6   1.5   2.0   2.5    6.5   5.0   2.5"
        self.assertEqual(mass_object.avl_mass_string, expected_string)
 def test_location_setting(self):
     """
     test the mass_object can be given a location and cog change
     """
     mass_object = layout.MassObject(self.geometry, 1, "name")
     mass_object.location = layout.Point(1,2,3)
     self.assertEqual(mass_object.location, layout.Point(1,2,3))
     self.assertEqual(mass_object.center_of_gravity_global,
                       layout.Point(1.5, 3, 4.5))
 def test_center_of_gravity_global(self):
     """
     tests the calculation of the center of gravity global
     """
     self.mass1.location = layout.Point(6, 5, 4)
     geometry = layout.Cuboid(1,2,3)
     mass2 = layout.MassObject(geometry, 1, "name2")
     arrangement = layout.Arrangement("arrangement1", self.mass1, mass2)
     arrangement.location = layout.Point(1, 2, 3)
     self.assertEqual(arrangement.center_of_gravity_global,
                      layout.Point(4.5, 5.5, 6.5))
 def test_center_of_gravity_negative(self):
     """
     tests the calculation of the center of gravity with masses in different
     locations
     """
     self.mass1.location = layout.Point(-6, -5, -4)
     geometry = layout.Cuboid(1,2,3)
     mass2 = layout.MassObject(geometry, 1, "name2")
     arrangement = layout.Arrangement("arrangement1", self.mass1, mass2)
     self.assertEqual(arrangement.center_of_gravity,
                      layout.Point(-2.5, -1.5, -0.5))
    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
    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
Esempio n. 10
0
def create(input_dict, name="uav"):

    surface = avl.Surface(name)
    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(layout.Cuboid(0.1, 0.1, 0.1), 1)
    battery.location = layout.Point(input_dict["battery_x_loc"] * cord1, -0.05,
                                    -0.05)

    motor = layout.MassObject(layout.Cuboid(0.1, 0.1, 0.1), 1)
    motor.location = layout.Point(cord1, -0.05, -0.05)

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

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

    return surface, arrangement, case

    case.to_file(self.run_file)
    layout.create_mass_file(self.mass_file, arrangement, case)
Esempio n. 11
0
 def test_equal(self):
     mass1 = layout.MassObject(self.geometry, 1, "name")
     mass2 = layout.MassObject(self.geometry, 1, "name")
     self.assertEqual(mass1, mass2)
Esempio n. 12
0
 def test_default_location(self):
     """
     test the mass_object can be given a location
     """
     mass_object = layout.MassObject(self.geometry, 1, "name")
     self.assertEqual(mass_object.location, layout.Point(0,0,0))
    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()