<commit_before>import numpy as np
from wingstructure.aero.liftingline import multhopp

def test_multhopp_schlichting():
    Λ = 6 # aspect ratio of wing
    
    b = 15 # m span width
    cs = [b/Λ]*2 # depth of wing
    ys = [0,b/2] # section positions

    αs = [1]*2 # angle of attack
    dcls = [2*np.pi]*2

    # reference result
    ηs_ref = [0,0.3827,0.7071,0.9239,1]
    γs_ref = [0.4320,0.4192,0.3710,0.2485,0]

    # coarse calculation
    M = 7

    res = multhopp(αs, cs, ys, dcls, M = M, mode='gamma')

    assert np.isclose(res[0][M//2:]/b*2, ηs_ref[:-1], atol=1e-4).all()
    assert np.isclose(res[1][M//2:], γs_ref[:-1], atol=1e-4).all()

def test_multhopp_dcls_nan():
    Λ = 6 # aspect ratio of wing
    
    b = 15 # m span width
    cs = [b/Λ]*2 # depth of wing
    ys = [0,b/2] # section positions

    αs = [1]*2 # angle of attack
    dcls = np.nan

    # reference result
    ηs_ref = [0,0.3827,0.7071,0.9239,1]
    γs_ref = [0.4320,0.4192,0.3710,0.2485,0]

    # coarse calculation
    M = 7

    res = multhopp(αs, cs, ys, dcls, M = M, mode='gamma')

    assert np.isclose(res[0][M//2:]/b*2, ηs_ref[:-1], atol=1e-4).all()
    assert np.isclose(res[1][M//2:], γs_ref[:-1], atol=1e-4).all()

def test_multhopp_no_interp():
    Λ = 6 # aspect ratio of wing
    
    b = 15 # m span width
    cs = [b/Λ]*2 # depth of wing
    ys = [0,b/2] # section positions

    αs = [1]*2 # angle of attack
    dcls = np.nan

    # reference result
    ηs_ref = [0,0.3827,0.7071,0.9239,1]
    γs_ref = [0.4320,0.4192,0.3710,0.2485,0]

    # coarse calculation
    M = 7

    res = multhopp(αs, cs, ys, dcls, M = M, mode='gamma', interp=False)

    assert np.isclose(res[0][M//2:]/b*2, ηs_ref[:-1], atol=1e-4).all()
    assert np.isclose(res[1][M//2:], γs_ref[:-1], atol=1e-4).all()

def test_multhopp_coefficients():
    
    Λ = 6 # aspect ratio of wing
    
    b = 15 # m span width
    cs = [b/Λ]*2 # depth of wing
    ys = [0,b/2] # section positions

    αs = [np.radians(1)]*2 # angle of attack
    dcls = [2*np.pi]*2

    res = multhopp(αs, cs, ys, dcls, M = 91)

    A = b * cs[0]

    C_L = np.trapz(res.c_ls, res.ys)/b

    # ensure lift coefficient matches local lift coefficents
    assert np.isclose(C_L, res.C_L, rtol=1e-3)<commit_msg>make multhopp tests use np.array<commit_after>import numpy as np
from wingstructure.aero.liftingline import multhopp

def test_multhopp_schlichting():
    Λ = 6 # aspect ratio of wing
    
    b = 15 # m span width
    cs = np.array([b/Λ]*2) # depth of wing
    ys = np.array([0,b/2]) # section positions

    αs = np.array([1]*2) # angle of attack
    dcls = np.array([2*np.pi]*2)

    # reference result
    ηs_ref = np.array([0,0.3827,0.7071,0.9239,1])
    γs_ref = np.array([0.4320,0.4192,0.3710,0.2485,0])

    # coarse calculation
    M = 7

    res = multhopp(αs, cs, ys, dcls, M = M, mode='gamma')

    assert np.isclose(res[0][M//2:]/b*2, ηs_ref[:-1], atol=1e-4).all()
    assert np.isclose(res[1][M//2:], γs_ref[:-1], atol=1e-4).all()

def test_multhopp_dcls_nan():
    Λ = 6 # aspect ratio of wing
    
    b = 15 # m span width
    cs = np.array([b/Λ]*2) # depth of wing
    ys = np.array([0,b/2]) # section positions

    αs = np.array([1]*2) # angle of attack
    dcls = np.nan

    # reference result
    ηs_ref = np.array([0,0.3827,0.7071,0.9239,1])
    γs_ref = np.array([0.4320,0.4192,0.3710,0.2485,0])

    # coarse calculation
    M = 7

    res = multhopp(αs, cs, ys, dcls, M = M, mode='gamma')

    assert np.isclose(res[0][M//2:]/b*2, ηs_ref[:-1], atol=1e-4).all()
    assert np.isclose(res[1][M//2:], γs_ref[:-1], atol=1e-4).all()

def test_multhopp_no_interp():
    Λ = 6 # aspect ratio of wing
    
    b = 15 # m span width
    cs = np.array([b/Λ]*2) # depth of wing
    ys = np.array([0,b/2]) # section positions

    αs = np.array([1]*2) # angle of attack
    dcls = np.nan

    # reference result
    ηs_ref = np.array([0,0.3827,0.7071,0.9239,1])
    γs_ref = np.array([0.4320,0.4192,0.3710,0.2485,0])

    # coarse calculation
    M = 7

    res = multhopp(αs, cs, ys, dcls, M = M, mode='gamma', interp=False)

    assert np.isclose(res[0][M//2:]/b*2, ηs_ref[:-1], atol=1e-4).all()
    assert np.isclose(res[1][M//2:], γs_ref[:-1], atol=1e-4).all()

def test_multhopp_coefficients():
    
    Λ = 6 # aspect ratio of wing
    
    b = 15 # m span width
    cs = [b/Λ]*2 # depth of wing
    ys = [0,b/2] # section positions

    αs = [np.radians(1)]*2 # angle of attack
    dcls = [2*np.pi]*2

    res = multhopp(αs, cs, ys, dcls, M = 91)

    A = b * cs[0]

    C_L = np.trapz(res.c_ls, res.ys)/b

    # ensure lift coefficient matches local lift coefficents
    assert np.isclose(C_L, res.C_L, rtol=1e-3)
{'fraction_non_alphanumeric': 0.17707223524398039, 'fraction_numerical': 0.08139782655018112, 'mean_word_length': 2.6052227342549923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3712303', 'n_tokens_mistral': 2242, 'n_tokens_neox': 2072, 'n_words': 457}