예제 #1
0
def test_Selig_Airfoil_Assertions():
    # Test that a non-string raises a type error
    with pytest.raises(TypeError):
        Af = Airfoil(SeligProfile=100)
    # Test that a non existant Selig Airfoil raises an error
    with pytest.raises(AssertionError):
        Af = Airfoil(SeligProfile='SomeImaginaryAirfoil')
예제 #2
0
def my_InterpAirfoilFunction_multiple(eps):
    # I'll use three airfoil sections, located at eps=0, eps=0.5, eps=1.
    # Currently, this is safest using airfoils with equal numbers of points,
    # TODO: make this work for non-matching numbers of points (cubic interp?)
    af_1 = Airfoil(Naca4Profile='0012')
    af_2 = Airfoil(Naca4Profile='0025')
    af_3 = Airfoil(Naca4Profile='2408')

    if eps < 0.5:
        profile_dict = {
            'InterpProfile': True,
            'Epsilon': eps,
            'Af1': af_1,
            'Af2': af_2,
            'Eps1': 0,
            'Eps2': 0.5
        }
    elif eps <= 1:
        profile_dict = {
            'InterpProfile': True,
            'Epsilon': eps,
            'Af1': af_2,
            'Af2': af_3,
            'Eps1': 0.5,
            'Eps2': 1
        }

    return profile_dict
예제 #3
0
def test_CRM_Airfoil_Assertions():
    # Test that an out of range epsilon produces an error
    with pytest.raises(AssertionError):
        Af = Airfoil(CRM_Epsilon=10)
    # Test that a string containing letters con raises a type error
    with pytest.raises(ValueError):
        Af = Airfoil(CRM_Epsilon='d')
예제 #4
0
def test_Airfoil_manual(airfoil_examples):
    # Unwrap parametrised arguments from the pytest.fixture
    ProfileType, Profile = airfoil_examples

    Af = Airfoil()
    # This is probably a dirty way of doing this, but couldn't think of another
    if ProfileType == 'Naca4Profile':
        Af.AddNACA4(Profile)
    elif ProfileType == 'SeligProfile':
        Af.AddAirfoilFromSeligFile(Profile)
    elif ProfileType == 'CRM_Epsilon':
        Af.AddCRMLinear(Profile)
    else:
        raise NotImplementedError(
            '{} is not an Implemented Airfoil type'.format(ProfileType))

    # Test the Airfoil.Profile is the expected dictionary
    assert (ProfileType in Af.Profile.keys())
    assert (Af.Profile[ProfileType] == str(Profile))

    # Test the Curve has been generated
    assert (Af.Curve is not None)

    # Test the python-occ spline object:
    assert (type(Af.Curve) == OCC.Geom.Handle_Geom_BSplineCurve)
    assert (Af.Curve.IsNull() == False)

    # Check the Trailing Edge X is roughly equal to the chord length
    start_pt = get_Airfoil_startpoint(Af)
    assert ((np.abs(start_pt[0] - Af.ChordLength) / Af.ChordLength) < 0.01)
예제 #5
0
def test_Airfoil_emptystring():
    # Test that an empty profile string creates an 'empty' airfoil
    Af = Airfoil(Naca4Profile='')
    assert (not Af.Curve)

    # Also check Selig airfoils:
    Af = Airfoil(SeligProfile='')
    assert (not Af.Curve)
예제 #6
0
def my_InterpAirfoilFunction(eps):
    af_root = Airfoil(Naca4Profile='0012')
    af_tip = Airfoil(Naca4Profile='0025')

    profile_dict = {
        'InterpProfile': True,
        'Epsilon': eps,
        'Af1': af_root,
        'Af2': af_tip,
        'Eps1': 0,
        'Eps2': 1
    }
    return profile_dict
예제 #7
0
def myAirfoilFunction(eps):
    af_root = Airfoil(SeligProfile='naca63a418')
    af_tip = Airfoil(SeligProfile='naca63a412')

    profile_dict = {
        'InterpProfile': True,
        'Epsilon': eps,
        'Af1': af_root,
        'Af2': af_tip,
        'Eps1': 0,
        'Eps2': 1
    }
    return profile_dict
예제 #8
0
def test_Null_Airfoil():
    # Generate Empty Airfoil
    Af = Airfoil()
    assert (Af.LE == [0., 0., 0.])
    assert (Af.Rotation == 0)
    assert (Af.Twist == 0)
    assert (Af.ChordLength == 1)
    assert (Af.Profile is None)
    assert (Af.Curve is None)
예제 #9
0
def test_nonzero_rotation():
    # Use Start Point of untwisted, unrotated, unit chord, LE in origin NACA4
    # Airfoil as reference
    default_SP = np.array([1., 0., 0.00126])

    # Test Non-Zero Rotation (Around X axis):
    Af = Airfoil(ChordLength=1, Naca4Profile='0012', Rotation=10)
    start_pt = get_Airfoil_startpoint(Af)
    # Miscellaneous function for creating rotation matrix of th around X axis
    gamma = Af.Rotation * np.pi / 180.
    SP_ref = roll_matrix(gamma).dot(default_SP)
    assert (np.all((start_pt - SP_ref) < 1e-10))
예제 #10
0
def test_nonzero_twist():
    # Use Start Point of untwisted, unrotated, unit chord, LE in origin NACA4
    # Airfoil as reference
    default_SP = np.array([1., 0., 0.00126])

    # Test Non-zero Twist (around Y axis):
    Af = Airfoil(ChordLength=1, Naca4Profile='0012', Twist=10)
    start_pt = get_Airfoil_startpoint(Af)

    beta = Af.Twist * np.pi / 180.
    SP_ref = twist_matrix(-beta).dot(default_SP)
    assert (np.all((start_pt - SP_ref) < 1e-10))
예제 #11
0
def test_nonzero_LE():
    # Use Start Point of untwisted, unrotated, unit chord, LE in origin NACA4
    # Airfoil as reference
    default_SP = np.array([1., 0., 0.00126])

    # Non-Zero leading edge:
    Af = Airfoil(LeadingEdgePoint=[1., 1., 1.],
                 ChordLength=1,
                 Naca4Profile='0012')
    start_pt = get_Airfoil_startpoint(Af)
    SP_ref = default_SP + np.array([1., 1., 1.])
    assert (np.all((start_pt - SP_ref) < 1e-10))
예제 #12
0
def test_Transform_Airfoil():
    # Use Start Point of untwisted, unrotated, unit chord, LE in origin NACA4
    # Airfoil as reference
    default_SP = np.array([1., 0., 0.00126])

    # Test Translation, Rotation and Twist :
    Af = Airfoil(LeadingEdgePoint=[1., 1., 1.],
                 ChordLength=1,
                 Naca4Profile='0012',
                 Rotation=10,
                 Twist=5)
    start_pt = get_Airfoil_startpoint(Af)
    beta = Af.Twist * np.pi / 180.
    gamma = Af.Rotation * np.pi / 180.
    Yrot_mat = twist_matrix(-beta)
    Xrot_mat = roll_matrix(gamma)
    rotation = Yrot_mat.dot(Xrot_mat)
    SP_ref = rotation.dot(default_SP) + np.array([1., 1., 1.])
    assert (np.all((start_pt - SP_ref) < 1e-10))
예제 #13
0
def test_overdefined_Airfoil():
    # Test that two or more specified profiles raises an error
    with pytest.raises(AssertionError):
        Af = Airfoil(SeligProfile='b707a', Naca4Profile='0012')