def test_flatten_arrangement_2layer_locations_complicated(self):
        """
        test flatten applies correct locations
        """
        self.mass1.location = layout.Point(4, -5, 6)
        self.mass2.location = layout.Point(3, 2, 1)

        arrangement = layout.Arrangement("arrangement1", *[self.mass1, self.mass2])
        arrangement.location = layout.Point(3, -2, 7)
        arrangement2 = layout.Arrangement("arrangement2", *[self.mass3, self.mass4])
        arrangement2.location = layout.Point(-5, 0, 12)
        arrangement3 = layout.Arrangement("arrangement3", arrangement,
                                                          arrangement2,
                                                          self.mass1)
        arrangement3.location = layout.Point(1, 7, 0)

        flattened_arrangement = arrangement3.flatten()
        mass_list = flattened_arrangement.all_mass_objects
        expected_mass_list = self.mass_list + [self.mass1]

        self.assertEqual(mass_list[0].location, layout.Point(8, 0 , 13))
        self.assertEqual(mass_list[1].location, layout.Point(7, 7 , 8))
        self.assertEqual(mass_list[2].location, layout.Point(-4, 7 , 12))
        self.assertEqual(mass_list[3].location, layout.Point(-4, 7 , 12))
        self.assertEqual(mass_list[4].location, layout.Point(5, 2, 6))
    def test_total_mass_nested(self):
        arrangement = layout.Arrangement("arrangement1", *self.mass_list[0:2])
        arrangement2 = layout.Arrangement("arrangement2", *self.mass_list[2:])
        arrangement3 = layout.Arrangement("arrangement3", arrangement,
                                                          arrangement2,
                                                          self.mass_list[0])

        self.assertEqual(arrangement3.mass, 66)
    def test_all_mass_objects_nested(self):
        """
        tests obtaining all mass objects within an arrangement, with nested
        arrangements all with their own locations
        """
        sub_arrangement = layout.Arrangement("arrangement1", *self.mass_list)
        sub_arrangement.location = layout.Point(0, 0, 1)
        arrangement = layout.Arrangement("arrangement2", sub_arrangement)
        mass_list = arrangement.all_mass_objects

        self.assertEqual(len(mass_list), len(self.mass_list))
        for i in range(len(self.mass_list)):
            self.assertEqual(mass_list[i], self.mass_list[i])
 def test_center_of_gravity(self):
     """
     tests the calculation of the center of gravity
     """
     arrangement = layout.Arrangement("arrangement1", *self.mass_list)
     self.assertEqual(arrangement.center_of_gravity,
                      layout.Point(0.5, 1, 1.5))
 def test_create_mass_list(self):
     arrangement = layout.Arrangement("arrangement1", *self.mass_list)
     expected_list = ["6   0.5   1.0   1.5    6.5   5.0   2.5",
                      "12   0.5   1.0   1.5    13.0   10.0   5.0",
                      "18   0.5   1.0   1.5    19.5   15.0   7.5",
                      "24   0.5   1.0   1.5    26.0   20.0   10.0"]
     self.assertEqual(arrangement.avl_mass_list, expected_list)
    def test_creation(self):

        component1 = DummyMass()
        component2 = DummyMass()

        arrangement = layout.Arrangement("arrangement1", component1, component2)
        self.assertEqual(arrangement.objects[0], component1)
        self.assertEqual(arrangement.objects[1], component2)
    def test_flatten_arrangement_2layer(self):
        """
        test flatten maintains arrangement when the arrangement only contains
        multiple layers of masses
        """
        arrangement = layout.Arrangement("arrangement1", *self.mass_list[0:2])
        arrangement2 = layout.Arrangement("arrangement2", *self.mass_list[2:])
        arrangement3 = layout.Arrangement("arrangement3", arrangement,
                                                          arrangement2,
                                                          self.mass_list[0])
        flattened_arrangement = arrangement3.flatten()
        mass_list = flattened_arrangement.all_mass_objects
        expected_mass_list = self.mass_list + [self.mass1]

        self.assertEqual(len(flattened_arrangement), 5)
        for i in range(len(mass_list)):
            self.assertEqual(mass_list[i], expected_mass_list[i])
    def test_clone(self):
        """
        test clone method
        """
        arrangement = layout.Arrangement("arrangement1", *self.mass_list)

        arrangement_clone = arrangement.clone()

        self.assertEqual(arrangement.center_of_gravity,
                        arrangement_clone.center_of_gravity)
 def test_flatten_arrangement_clones(self):
     """
     tests the  method clones the masses it outputs
     """
     arrangement = layout.Arrangement("arrangement1", *self.mass_list)
     flattened_arrangement = arrangement.flatten()
     mass_list = flattened_arrangement.all_mass_objects
     self.assertEqual(len(flattened_arrangement), 4)
     for i in range(len(mass_list)):
         self.assertNotEqual(id(mass_list[i]), id(self.mass_list[i]))
    def test_all_mass_objects_not_clones(self):
        """
        tests the all mass objects method does not clone the masses it outputs
        """
        arrangement = layout.Arrangement("arrangement1", *self.mass_list)
        mass_list = arrangement.all_mass_objects

        for i in range(len(mass_list)):

            self.assertEqual(id(mass_list[i]), id(self.mass_list[i]))
 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 test_all_mass_objects_nested_twice(self):
        """
        tests obtaining all mass objects within an arrangement, with nested
        arrangements
        """
        sub_arrangement = layout.Arrangement("arrangement1", *[self.mass1,
                                                              self.mass2,
                                                              ])
        sub_arrangement2 = layout.Arrangement("arrangement2", *[self.mass3,
                                                               self.mass4,
                                                               ])
        arrangement = layout.Arrangement("arrangement3", *[sub_arrangement,
                                                          sub_arrangement2,
                                                          ])

        mass_list = arrangement.all_mass_objects

        self.assertEqual(len(mass_list), len(self.mass_list))
        for i in range(len(self.mass_list)):
            self.assertEqual(mass_list[i], self.mass_list[i])
 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_all_mass_objects(self):
        """
        tests obtaining all mass objects within an arrangement, without nested
        arrangements
        """
        arrangement = layout.Arrangement("arrangement1", *self.mass_list)
        mass_list = arrangement.all_mass_objects

        self.assertEqual(len(mass_list), len(self.mass_list))
        for i in range(len(self.mass_list)):
            self.assertEqual(mass_list[i], self.mass_list[i])
    def test_flatten_arrangement_1layer(self):
        """
        test flatten maintains arrangement when the arrangement only contains
        one layer of masses
        """
        arrangement = layout.Arrangement("arrangement1", *self.mass_list)
        flattened_arrangement = arrangement.flatten()
        mass_list = flattened_arrangement.all_mass_objects

        for i in range(len(mass_list)):
            self.assertEqual(mass_list[i], self.mass_list[i])
    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 test_flatten_arrangement_2layer_locations(self):
        """
        test flatten applies correct locations
        """
        arrangement = layout.Arrangement("arrangement1", *self.mass_list[0:2])
        arrangement.location = layout.Point(0, 0, 1)
        arrangement2 = layout.Arrangement("arrangement2", *self.mass_list[2:])
        arrangement2.location = layout.Point(0, 0, 2)
        arrangement3 = layout.Arrangement("arrangement3", arrangement,
                                                          arrangement2,
                                                          self.mass_list[0])
        arrangement3.location = layout.Point(1, 7, 0)

        flattened_arrangement = arrangement3.flatten()
        mass_list = flattened_arrangement.all_mass_objects
        expected_mass_list = self.mass_list + [self.mass1]

        self.assertEqual(mass_list[0].location, layout.Point(1, 7 , 1))
        self.assertEqual(mass_list[1].location, layout.Point(1, 7 , 1))
        self.assertEqual(mass_list[2].location, layout.Point(1, 7 , 2))
        self.assertEqual(mass_list[3].location, layout.Point(1, 7 , 2))
        self.assertEqual(mass_list[4].location, layout.Point(1, 7 , 0))
    def test_reflect_y_offset(self):
        """
        tests that the y refelection method creates a new arrangement reflected
        in the y axis
        """
        arrangement = layout.Arrangement("arrangement1", *self.mass_list)

        # offset the masses within the arrangement
        for mass in self.mass_list:
            mass.location = layout.Point(0, 10, 0)

        arrangement_reflect = arrangement.clone(reflect_y = True)

        self.assertEqual(arrangement_reflect.center_of_gravity.x, 0.5)
        self.assertEqual(arrangement_reflect.center_of_gravity.y, -11)
        self.assertEqual(arrangement_reflect.center_of_gravity.z, 1.5)
    def test_reflect_y(self):
        """
        tests that the y refelection method creates a new arrangement reflected
        in the y axis
        """
        arrangement = layout.Arrangement("arrangement1", *self.mass_list)

        # create expected reflected coordinates for center of gravity
        x = arrangement.center_of_gravity.x
        y = -1 * arrangement.center_of_gravity.y
        z = arrangement.center_of_gravity.z
        reflected_cog = layout.Point(x, y, z)

        arrangement_reflect = arrangement.clone(reflect_y = True)

        self.assertEqual(arrangement_reflect.center_of_gravity.x, reflected_cog.x)
        self.assertEqual(arrangement_reflect.center_of_gravity.y, reflected_cog.y)
        self.assertEqual(arrangement_reflect.center_of_gravity.z, reflected_cog.z)
Beispiel #20
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)
    def test_getitem_missing(self):
        arrangement = layout.Arrangement("arrangement1", *self.mass_list)

        with self.assertRaises(KeyError):
            self.assertEqual(arrangement["name"], self.mass1)
 def test_getitem(self):
     arrangement = layout.Arrangement("arrangement1", *self.mass_list)
     self.assertEqual(arrangement["name1"][0],  self.mass1)
 def test_total_mass(self):
     arrangement = layout.Arrangement("arrangement1", *self.mass_list)
     self.assertEqual(arrangement.mass, 60)
Beispiel #24
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_len(self):
     arrangement = layout.Arrangement("arrangement1", *self.mass_list)
     self.assertEqual(len(arrangement), 4)
    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
    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()