def __init__(self, name, position, length, width, atmosphere): span = self.calculate_span(width) area = self.calculate_area(span, length) aspect_ratio = self.calculate_aspect_ratio(span, area) lift_curve = lift.PlateEmpirical(aspect_ratio) drag_curve = drag.FlatPlate(aspect_ratio) Surface.__init__(self, name, position, length, Angle(0), area, lift_curve, drag_curve, atmosphere)
def __init__(self, position, velocity): atmosphere = Atmosphere() state = State(position, velocity, Angle(0), 0) Airplane.__init__(self, state, self._mass(), self._mass_moment_of_inertia(), atmosphere) wing_lift_curve = lift.Linear(6.98, 0.29, 5.5) wing_drag_curve = drag.LiftingLine(6.98, 0.0305, 0.75) self._wing = Surface("wing", Vector2D(0, 0), 0, Angle(2.4), 510.97, wing_lift_curve, wing_drag_curve, atmosphere) stab_lift_curve = lift.LiftingLine(3.62) stab_drag_curve = drag.LiftingLine(3.62, efficiency_factor=0.6) self._horizontal_stabilizer = Surface("stabilizer", Vector2D(-33, 0), 0, Angle(0), 136, stab_lift_curve, stab_drag_curve, atmosphere) fusilage_drag_curve = drag.Parasitic(0.27) # 747 cabin = ~19x6 meters self._fusilage = Surface("fusilage", self.cg(), 0, Angle(0), 118, None, fusilage_drag_curve, atmosphere) self._surfaces = [] self._surfaces.append(self._wing) self._surfaces.append(self._horizontal_stabilizer) self._surfaces.append(self._fusilage) # don't have yaw forces (or a 3rd axis) to put engines out on wings # so they all go at cg self._engines = [] self._engines.append(Engine("engine 1", self.cg(), Angle(0), 0, 275000)) self._engines.append(Engine("engine 2", self.cg(), Angle(0), 0, 275000)) self._engines.append(Engine("engine 3", self.cg(), Angle(0), 0, 275000)) self._engines.append(Engine("engine 4", self.cg(), Angle(0), 0, 275000))
def __init__(self, initial_pos, initial_vel, atmosphere): # setup physical properties radius = 3.66 / 2 # meters # ignore the side boosters for now - and use fins with a drag and lift # curve area = math.pi * radius**2 # I'm not sure about these numbers. Not sure why thrust is ~20x weight # fully loaded. For now set throttle to 5 or 6% to get realistic # acceleration mass = 1420000 / 9.8 # kg thrust = 22241102 # N length = 70 # m # cylinder # 1/12 * mass * length^2 + 1/4 * mass * radius^2 moment = 1 / 12 * mass * length**2 + 1 / 4 * mass * radius**2 state = physics.State(position=initial_pos, velocity=initial_vel, orientation=Angle(90)) Airplane.__init__(self, state, mass, moment, atmosphere) # setup aerodynamic properties drag_curve = drag.Parasitic(.35) surface = flight.Surface("rocket", atmosphere=atmosphere, drag_curve=drag_curve, area=area) stab_lift_curve = lift.LiftingLine(3.62) stab_drag_curve = drag.LiftingLine(3.62, efficiency_factor=0.6) stab = Surface("stabilizer", Vector2D(-33, 0), 0, Angle(0), 136, stab_lift_curve, stab_drag_curve, atmosphere) self._surfaces = [surface, stab] engine = Engine("1d merlin", Vector2D(-21, 0), Angle(0), 0, thrust) engine.set_throttle(100) self._engines = [engine]
def get_cessna_wing(self): wing_lift_curve = lift.LiftingLine(7.37) wing_drag_curve = drag.LiftingLine(7.37, 0.027, 0.75) return Surface("cessna 172 wing", Vector2D(0, 0), 0, Angle(0), 16.2, wing_lift_curve, wing_drag_curve, Atmosphere())
def get_boeing_wing(self): wing_lift_curve = lift.Linear(6.98, 0.29, 5.5) wing_drag_curve = drag.LiftingLine(6.98, 0.0305, 0.75) return Surface("boeing wing", Vector2D(0, 0), 0, Angle(2.4), 510.97, wing_lift_curve, wing_drag_curve, Atmosphere())
def test_lift_unit_trailing_edge_negative_aoa(self): velocity = Vector2D(-1, 1) surface = self.get_surface(0) lift_unit = Surface.get_lift_unit(surface.aoa(velocity), velocity) self.assertAlmostEqual(.7071, lift_unit.x, 4) self.assertAlmostEqual(.7071, lift_unit.y, 4)
def get_flat_plate(self): wing_lift_curve = lift.PlateEmpirical(0) wing_drag_curve = drag.FlatPlate(0) return Surface("plate", Vector2D(0, 0), 0, Angle(0), 10, wing_lift_curve, wing_drag_curve, Atmosphere())
def test_lift_unit_leading_edge_positive_aoa(self): velocity = Vector2D(1, -1) surface = self.get_surface(0) lift_unit = Surface.get_lift_unit(surface.aoa(velocity), velocity) self.assertAlmostEqual(.7071, lift_unit.x, 4) self.assertAlmostEqual(.7071, lift_unit.y, 4)
def get_surface(self, relative_degrees): return Surface("test", Vector2D(0, 0), 0, Angle(relative_degrees), 10, None, None, Atmosphere())