Leverage scipy's quadrature rules
The proposed changes add support for quadrature rules from 'scipy'.
Known issues:
- Using 'scipy' backend by default will result in a test to fail
======================================================================= test session starts =======================================================================
platform linux -- Python 3.6.7, pytest-4.1.1, py-1.7.0, pluggy-0.8.1
rootdir: /home/xywei/Projects/inteq/src/modepy, inifile:
collected 74 items
test_modes.py ........................ [ 32%]
test_nodes.py ............... [ 52%]
test_quadrature.py ........ [ 63%]
test_tools.py F.......................... [100%]
============================================================================ FAILURES =============================================================================
__________________________________________________________ test_modal_decay[jump-1d-test_func0-1-10--1] ___________________________________________________________
case_name = 'jump-1d', test_func = functools.partial(<function jump at 0x7f648f8e26a8>, 0), dims = 1, n = 10, expected_expn = -1
@pytest.mark.parametrize(("case_name", "test_func", "dims", "n", "expected_expn"), [
("jump-1d", partial(jump, 0), 1, 10, -1),
("kink-1d", partial(kink, 0), 1, 10, -1.7), # Slightly off from -2 (same in paper) # noqa
("c1-1d", partial(c1, 0), 1, 10, -3),
# Offset 1D tests
("offset-jump-1d", partial(jump, 0.8), 1, 20, -0.7),
("offset-kink-1d", partial(kink, 0.8), 1, 20, -0.7), # boo
("offset-c1-1d", partial(c1, 0.8), 1, 20, -0.8), # boo
# 2D tests
# A harsh jump introduces high-frequency wiggles transverse to the jump edge.
# Therefore, use a smooth one.
("jump-2d", partial(smooth_jump, -0.1), 2, 15, -1.1),
("kink-2d", partial(kink, 0), 2, 15, -1.6),
("c1-2d", partial(c1, -0.1), 2, 15, -2.3),
])
def test_modal_decay(case_name, test_func, dims, n, expected_expn):
nodes = mp.warp_and_blend_nodes(dims, n)
basis = mp.simplex_onb(dims, n)
vdm = mp.vandermonde(basis, nodes)
f = test_func(nodes[0])
coeffs = la.solve(vdm, f)
if 0:
from modepy.tools import plot_element_values
plot_element_values(n, nodes, f, resample_n=70,
show_nodes=True)
from modepy.modal_decay import fit_modal_decay
expn, _ = fit_modal_decay(coeffs.reshape(1, -1), dims, n)
expn = expn[0]
print(("%s: computed: %g, expected: %g" % (case_name, expn, expected_expn)))
> assert abs(expn-expected_expn) < 0.1
E assert 0.12639562678232985 < 0.1
E + where 0.12639562678232985 = abs((-1.1263956267823299 - -1))
test_tools.py:107: AssertionError
---------------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------------
jump-1d: computed: -1.1264, expected: -1
Edited by Xiaoyu Wei