Ejemplo n.º 1
0
def test_u1_read_in_from_file():
    # Generate airplane from file
    filename = "test/use_cases/u1_from_file/use_case_1.json"
    myPlane = geom.Airplane(inputfile=filename)

    # Generate lifting-line model for airplane
    myLLModel = LLModel(myPlane)

    # Solve the lifting-line model for the given condition
    controls = {
        "aileron": 10.,
        "elevator": 5.,
    }
    aero_state = {"V_mag": 100., "alpha": 5., "rho": 1.}
    results = myLLModel.solve(stype="linear",
                              control_state=controls,
                              aero_state=aero_state)

    # compare results with expected values
    if myLLModel._machup_compare:
        test = np.array([
            498.563823789387015, -355.559967409590001, -22164.650382783511304,
            -15767.900012819352924, -6069.667491323640206, -485.172664364582431
        ])
    else:
        test = np.array([
            488.73383601455544, -355.57437639926093, -22143.208875850567,
            -15767.798773697272, -6079.3470120008151, -485.09007262607491
        ])

    assert np.allclose(results["FX"], test[0], rtol=0., atol=1e-10) is True
    assert np.allclose(results["FY"], test[1], rtol=0., atol=1e-10) is True
    assert np.allclose(results["FZ"], test[2], rtol=0., atol=1e-10) is True
    assert np.allclose(results["l"], test[3], rtol=0., atol=1e-10) is True
    assert np.allclose(results["m"], test[4], rtol=0., atol=1e-10) is True
    assert np.allclose(results["n"], test[5], rtol=0., atol=1e-10) is True
Ejemplo n.º 2
0
def test_u2_simple_monowing():
    myPlane = geom.Airplane()
    myPlane.cg_location(-0.29, 0., 0.25)

    # add main wing and aileron control surface
    mainWing = myPlane.add_wing("main_wing",
                                position=[0., 0., 0.],
                                semispan=4.,
                                root_chord=1.,
                                tip_chord=0.5,
                                dihedral=3.)

    mainWing.airfoil("NACA2412",
                     alpha_L0=-0.036899751,
                     CL_alpha=6.283185307,
                     Cm_L0=-0.0527,
                     Cm_alpha=-0.08,
                     CD0=0.0055,
                     CD0_L=-0.0045,
                     CD0_L2=0.01,
                     CL_max=1.4)

    mainWing.control_surface(percent_span=(0.4, 0.9),
                             percent_chord=0.25,
                             mix={"aileron": 1.})

    # add horizontal tail and elevator control surface
    horizontalTail = myPlane.add_wing("horizontal_tail",
                                      position=[-4., 0., 0.],
                                      semispan=1.,
                                      root_chord=1.,
                                      tip_chord=0.5,
                                      mount_angle=1.,
                                      sweep=20.)

    horizontalTail.airfoil("NACA0012",
                           alpha_L0=0.,
                           CL_alpha=6.283185307,
                           Cm_L0=0.,
                           Cm_alpha=0.,
                           CD0=0.0055,
                           CD0_L=-0.0045,
                           CD0_L2=0.01,
                           CL_max=1.)

    horizontalTail.control_surface(percent_span=(0., 1.),
                                   percent_chord=(0.25, 0.5),
                                   mix={"elevator": 1.})

    # add vertical tail and rudder control surface
    verticalTail = myPlane.add_wing("vertical_tail",
                                    position=[-4., 0., 0.],
                                    side="right",
                                    semispan=0.8,
                                    root_chord=1.,
                                    tip_chord=0.5,
                                    sweep=25.,
                                    dihedral=90.)

    verticalTail.airfoil("NACA0012",
                         alpha_L0=0.,
                         CL_alpha=6.283185307,
                         Cm_L0=0.,
                         Cm_alpha=0.,
                         CD0=0.0055,
                         CD0_L=-0.0045,
                         CD0_L2=0.01,
                         CL_max=1.)

    verticalTail.control_surface(percent_span=(0., 1.),
                                 percent_chord=(0.25, 0.5),
                                 mix={"rudder": 1.})

    # Generate lifting-line model for airplane
    myLLModel = LLModel(myPlane)

    # Solve the lifting-line model for the given condition
    controls = {
        "aileron": 10.,
        "elevator": 5.,
    }
    aero_state = {"V_mag": 100., "alpha": 5., "rho": 1.}
    results = myLLModel.solve(stype="linear",
                              control_state=controls,
                              aero_state=aero_state)

    # compare results with expected values
    if myLLModel._machup_compare:
        test = np.array([
            498.563823789387015, -355.559967409590001, -22164.650382783511304,
            -15767.900012819352924, -6069.667491323640206, -485.172664364582431
        ])
    else:
        test = np.array([
            488.73383601455544, -355.57437639926093, -22143.208875850567,
            -15767.798773697272, -6079.3470120008151, -485.09007262607491
        ])

    assert np.allclose(results["FX"], test[0], rtol=0., atol=1e-10) is True
    assert np.allclose(results["FY"], test[1], rtol=0., atol=1e-10) is True
    assert np.allclose(results["FZ"], test[2], rtol=0., atol=1e-10) is True
    assert np.allclose(results["l"], test[3], rtol=0., atol=1e-10) is True
    assert np.allclose(results["m"], test[4], rtol=0., atol=1e-10) is True
    assert np.allclose(results["n"], test[5], rtol=0., atol=1e-10) is True
Ejemplo n.º 3
0
def test_u3_multisegment_wing():
    my_plane = geom.Airplane()

    # add multisegment wing with aileron and flap control surfaces
    main_inboard = my_plane.add_wing("main_inboard",
                                     location=[0., 0., 0.],
                                     semispan=2.,
                                     root_chord=1.,
                                     dihedral=3.)

    main_inboard.airfoil("NACA2412",
                         alpha_L0=-0.036899751,
                         CL_alpha=6.283185307,
                         Cm_L0=-0.0527,
                         Cm_alpha=-0.08,
                         CD0=0.0055,
                         CD0_L=-0.0045,
                         CD0_L2=0.01,
                         CL_max=1.4)

    main_inboard.control_surface(percent_span=[0.2, 0.9],
                                 percent_chord=0.25,
                                 mix={"flap": 1.})

    main_outboard = my_plane.add_wing("main_outboard",
                                      connect_to=("main_inboard", "tip"),
                                      semispan=2.,
                                      root_chord=1.,
                                      tip_chord=0.6,
                                      sweep=-3.)

    main_outboard.airfoil("NACA2412",
                          alpha_L0=-0.036899751,
                          CL_alpha=6.283185307,
                          Cm_L0=-0.0527,
                          Cm_alpha=-0.08,
                          CD0=0.0055,
                          CD0_L=-0.0045,
                          CD0_L2=0.01,
                          CL_max=1.4)

    main_outboard.control_surface(percent_span=[0., 0.8],
                                  percent_chord=0.25,
                                  mix={"aileron": 1.})

    # Generate lifting-line model for airplane
    my_llmodel = LLModel(my_plane)

    # Solve the lifting-line model for the given condition
    controls = {
        "aileron": 4.,
        "flap": 7.,
    }
    aero_state = {
        "V_mag": 100.,
        "alpha": 1.,
        "rho": 1.
    }
    results = my_llmodel.solve(stype="linear",
                               control_state=controls,
                               aero_state=aero_state)

    # compare results with expected values
    if my_llmodel._machup_compare:
        test = np.array([-501.548045209023599,
                         -19.359345013074183,
                         -14896.07014164796783,
                         -5942.396955478406198,
                         -2711.801354010903196,
                         55.816799463192389])
    else:
        test = np.array([-501.76214132311253,
                         -19.339235392302943,
                         -14895.830345852655,
                         -5942.3558470931075,
                         -2719.492748965411,
                         54.85153478517509])

    assert np.allclose(results["FX"], test[0], rtol=0., atol=1e-10) is True
    assert np.allclose(results["FY"], test[1], rtol=0., atol=1e-10) is True
    assert np.allclose(results["FZ"], test[2], rtol=0., atol=1e-10) is True
    assert np.allclose(results["l"], test[3], rtol=0., atol=1e-10) is True
    assert np.allclose(results["m"], test[4], rtol=0., atol=1e-10) is True
    assert np.allclose(results["n"], test[5], rtol=0., atol=1e-10) is True
Ejemplo n.º 4
0
def tapered_control_surface_model():
    """Get a LLModel from the tapered controls example."""
    filename = PLANE_DIR + "tapered_control_5sect.json"
    plane = geom.Airplane(inputfile=filename)
    model = LLModel(plane)
    return model
Ejemplo n.º 5
0
def yoffset_wing_model():
    """Get a LLModel from the yoffset wing example."""
    filename = PLANE_DIR + "yoffset_wing_5sect.json"
    plane = geom.Airplane(inputfile=filename)
    model = LLModel(plane)
    return model
Ejemplo n.º 6
0
def aero_twist_wing_model():
    """Get a LLModel from the aero twist example."""
    filename = PLANE_DIR + "aerodynamic_twist_wing_5sect.json"
    plane = geom.Airplane(inputfile=filename)
    model = LLModel(plane)
    return model
Ejemplo n.º 7
0
def washout_wing_model():
    """Get a LLModel from the washout_wing_5sect.json example."""
    filename = PLANE_DIR + "washout_wing_5sect.json"
    plane = geom.Airplane(inputfile=filename)
    model = LLModel(plane)
    return model
Ejemplo n.º 8
0
def swept_wing_model():
    """Get a LLModel from the swept_wing.json example."""
    filename = PLANE_DIR + "swept_wing.json"
    plane = geom.Airplane(inputfile=filename)
    model = LLModel(plane)
    return model
Ejemplo n.º 9
0
def small_plane_model():
    """Get a LLModel from the straight_simple_plane.json example."""
    filename = PLANE_DIR + "straight_simple_plane.json"
    plane = geom.Airplane(inputfile=filename)
    model = LLModel(plane)
    return model
Ejemplo n.º 10
0
def v2_plane_model():
    """Get a LLModel from the test plane v2 example."""
    filename = PLANE_DIR + "test_plane_v2.json"
    plane = geom.Airplane(inputfile=filename)
    model = LLModel(plane)
    return model