Exemplo n.º 1
0
def test_improved_hypersingular():
    mesh = simple_line_mesh(1, (0, 0), (1, 0))
    mapping = PolynomialMapping(mesh.elements[0])
    degree = 7
    bf = gll_basis(degree)
    one = ConstantBasis(np.ones(2))

    quad_info_exact = gauss(100)

    a = 0.01
    b = 0.05

    mapped_ay = map_singular_pt(a, 0.0, 1.0)
    mapped_by = map_distance_to_interval(b, 0.0, 1.0)
    quad_deg = degree + 4

    moments_xa0_r0 = legendre.legendre_integrals(quad_deg)
    moments_xa0_r2 = modify_divide_r2(
        quad_deg, moments_xa0_r0, mapped_ay, mapped_by, mu_2_0(mapped_ay, mapped_by), mu_2_1(mapped_ay, mapped_by)
    )
    moments_xa0_r4 = modify_divide_r2(
        quad_deg, moments_xa0_r2, mapped_ay, mapped_by, mu_4_0(mapped_ay, mapped_by), mu_4_1(mapped_ay, mapped_by)
    )
    moments_xa0_r6 = modify_divide_r2(
        quad_deg, moments_xa0_r4, mapped_ay, mapped_by, mu_6_0(mapped_ay, mapped_by), mu_6_1(mapped_ay, mapped_by)
    )
    moments_xa1_r6 = modify_times_x_minus_a(len(moments_xa0_r6) - 2, moments_xa0_r6, mapped_ay)
    moments_xa2_r6 = modify_times_x_minus_a(len(moments_xa1_r6) - 2, moments_xa1_r6, mapped_ay)
    moments_xa3_r6 = modify_times_x_minus_a(len(moments_xa2_r6) - 2, moments_xa2_r6, mapped_ay)
    moments_xa4_r6 = modify_times_x_minus_a(len(moments_xa3_r6) - 2, moments_xa3_r6, mapped_ay)

    est = [[0, 0], [0, 0]]
    x, w = recursive_quad(moments_xa0_r6[: degree + 1])
    x, w = map_pts_wts(x, w, 0.0, 1.0)
    w = map_weights_by_inv_power(w, 6.0, 0.0, 1.0) * ((-b / 2) ** 2) * ((-2 * b) ** 2)
    est[1][1] = w[0]

    x, w = recursive_quad(moments_xa1_r6[: degree + 1])
    x, w = map_pts_wts(x, w, 0.0, 1.0)
    w = map_weights_by_inv_power(w, 6.0, 0.0, 1.0) * ((-b / 2) ** 2) * ((-2 * b) ** 1)
    est[0][1] = w[0]
    est[1][0] = w[0]
    x, w = recursive_quad(moments_xa2_r6[: degree + 1])
    x, w = map_pts_wts(x, w, 0.0, 1.0)
    w = map_weights_by_inv_power(w, 6.0, 0.0, 1.0) * ((-b / 2) ** 2) * ((-2 * b) ** 0)
    est[0][0] = w[0]

    # qi = QuadratureInfo(a, x, w)

    kernelv1 = HypersingularPart1V1()
    kernelv2 = HypersingularPart1V2()

    pt = [a, b]
    normal = [0.0, 1.0]
    kernelv1.set_interior_data(pt, normal)
    kernelv2.set_interior_data(pt, normal)

    integrate = lambda qi, k: single_integral(mapping.eval, k, one, bf, qi, 0, 0)
    exact = integrate(quad_info_exact, kernelv1)
    np.testing.assert_almost_equal(np.array(exact), np.array(est), 10)
Exemplo n.º 2
0
def test_x_minus_a_over_r2():
    moments = legendre_integrals(9)
    a = 0.5
    b = 1.2
    xma = modify_times_x_minus_a(8, moments, a)
    correct = [-0.3904489645587269, 0.2557597125953320, 0.06865217632870157, \
        -0.008511531192587127, -0.007950872775398451, -0.0007266762296354132, \
        0.0006627180067297806, 0.0002093149470004469, -0.00002794901652839316]
    est = modify_divide_r2(8, xma, a, b, correct[0], correct[1])
    np.testing.assert_almost_equal(correct, est)
Exemplo n.º 3
0
def test_div_x_minus_a():
    moments = legendre_integrals(5)
    a = 0.5
    first_term = log((1 - a) / (1 + a))
    est = modify_divide_x_minus_a(4, moments, a, first_term)
    correct = [
        -1.098612288668138, 1.450693855665931, 1.637326536083517,
        0.3973095429589644, -0.8803490519735331
    ]
    np.testing.assert_almost_equal(correct, est)
Exemplo n.º 4
0
def test_x_minus_a_over_r2():
    moments = legendre_integrals(9)
    a = 0.5
    b = 1.2
    xma = modify_times_x_minus_a(8, moments, a)
    correct = [-0.3904489645587269, 0.2557597125953320, 0.06865217632870157, \
        -0.008511531192587127, -0.007950872775398451, -0.0007266762296354132, \
        0.0006627180067297806, 0.0002093149470004469, -0.00002794901652839316]
    est = modify_divide_r2(8, xma, a, b, correct[0], correct[1])
    np.testing.assert_almost_equal(correct, est)
Exemplo n.º 5
0
def test_div_r4():
    moments = legendre_integrals(8)
    a = 0.5
    b = 1.2
    correct = [0.6173845393861046, 0.1483356365409694, -0.03770049188677398, \
    -0.02905919230092682, -0.001801984951851534, 0.003509117545068981, \
    0.001056188292853719, -0.0002247265640304056, -0.0001910931757665019]
    r2 = modify_divide_r2(8, moments, a, b, 1.075705420225906,
                          0.1474037455542261)
    est = modify_divide_r2(8, r2, a, b, correct[0], correct[1])
    np.testing.assert_almost_equal(correct, est)
Exemplo n.º 6
0
def test_div_r2():
    moments = legendre_integrals(8)
    a = 0.5
    b = 1.2
    correct = [
        1.075705420225906, 0.1474037455542261, -0.04366033205431969,
        -0.02023247986691955, 0.0001466495701568366, 0.002006397510960772,
        0.0003847499889184325, -0.0001317394357582433, -0.00006769643570114308
    ]
    est = modify_divide_r2(8, moments, a, b, correct[0], correct[1])
    np.testing.assert_almost_equal(correct, est)
Exemplo n.º 7
0
def test_div_x_minus_a():
    moments = legendre_integrals(5)
    a = 0.5
    first_term = log((1 - a) / (1 + a))
    est = modify_divide_x_minus_a(4, moments, a, first_term)
    correct = [-1.098612288668138,
               1.450693855665931,
               1.637326536083517,
               0.3973095429589644,
               -0.8803490519735331]
    np.testing.assert_almost_equal(correct, est)
Exemplo n.º 8
0
def test_div_r4():
    moments = legendre_integrals(8)
    a = 0.5
    b = 1.2
    correct = [0.6173845393861046, 0.1483356365409694, -0.03770049188677398, \
    -0.02905919230092682, -0.001801984951851534, 0.003509117545068981, \
    0.001056188292853719, -0.0002247265640304056, -0.0001910931757665019]
    r2 = modify_divide_r2(8, moments, a, b,
                          1.075705420225906,
                          0.1474037455542261)
    est = modify_divide_r2(8, r2, a, b, correct[0], correct[1])
    np.testing.assert_almost_equal(correct, est)
Exemplo n.º 9
0
def test_div_r2():
    moments = legendre_integrals(8)
    a = 0.5
    b = 1.2
    correct = [1.075705420225906,
               0.1474037455542261,
               -0.04366033205431969,
               -0.02023247986691955,
               0.0001466495701568366,
               0.002006397510960772,
               0.0003847499889184325,
               -0.0001317394357582433,
               -0.00006769643570114308]
    est = modify_divide_r2(8, moments, a, b, correct[0], correct[1])
    np.testing.assert_almost_equal(correct, est)
Exemplo n.º 10
0
def test_mult_x_minus_a():
    moments = legendre_integrals(5)
    est = modify_times_x_minus_a(4, moments, 0.5)
    correct = [-1.0, 2.0 / 3.0, 0.0, 0.0, 0.0]
    np.testing.assert_almost_equal(correct, est)
Exemplo n.º 11
0
def test_mult_x_minus_a():
    moments = legendre_integrals(5)
    est = modify_times_x_minus_a(4, moments, 0.5)
    correct = [-1.0, 2.0 / 3.0, 0.0, 0.0, 0.0]
    np.testing.assert_almost_equal(correct, est)
Exemplo n.º 12
0
def test_legendre_integrals():
    abc = legendre_integrals(5)
    np.testing.assert_almost_equal(abc, [2.0, 0.0, 0.0, 0.0, 0.0, 0.0])
Exemplo n.º 13
0
def test_legendre_integrals():
    abc = legendre_integrals(5)
    np.testing.assert_almost_equal(abc, [2.0, 0.0, 0.0, 0.0, 0.0, 0.0])