|
1 | 1 | from firedrake import * |
| 2 | +from scipy.special import hyp2f1 as sp_hyp2f1 |
2 | 3 | import numpy as np |
3 | | -import scipy |
4 | 4 | import pytest |
5 | 5 |
|
6 | 6 |
|
7 | | -@pytest.mark.skipif(utils.complex_mode, reason="Complex bessel functions are not implemented.") |
8 | 7 | def test_hypergeometric_function(): |
9 | | - sp_hyp2f1 = scipy.special.hyp2f1 |
10 | | - a = 1 |
11 | | - b = 1 |
12 | | - c = 1 |
13 | 8 | mesh = UnitDiskMesh(3) |
14 | 9 | V = FunctionSpace(mesh, "CG", 1) |
15 | | - |
16 | 10 | x, y = SpatialCoordinate(mesh) |
17 | 11 |
|
18 | | - expr = x / 10 |
19 | | - uexact = hyp2f1(a, b, c, expr) |
20 | | - assert np.allclose(assemble(Function(V).interpolate(uexact)).dat.data, |
21 | | - sp_hyp2f1(a, b, c, assemble(Function(V).interpolate(expr)).dat.data)) |
22 | | - |
23 | | - expr = sqrt(x**2+y**2) / 10 |
24 | | - uexact = hyp2f1(a, b, c, expr) |
25 | | - assert np.allclose(assemble(Function(V).interpolate(uexact)).dat.data, |
26 | | - sp_hyp2f1(a, b, c, assemble(Function(V).interpolate(expr)).dat.data)) |
| 12 | + expressions = [((1/3, 1/2, 1), Constant(0.9999) * x), |
| 13 | + ((1/2, 1/2, 1), Constant(0.9999) * sqrt(x**2+y**2)), |
| 14 | + ((-1/2, 1/2, 1), Constant(0.4999) * sqrt(x*x + y*y))] |
27 | 15 |
|
28 | | - expr = sqrt(x*x + y*y) / 10 |
29 | | - uexact = hyp2f1(a, b, c, expr) |
30 | | - assert np.allclose(assemble(Function(V).interpolate(uexact)).dat.data, |
31 | | - sp_hyp2f1(a, b, c, assemble(Function(V).interpolate(expr)).dat.data)) |
| 16 | + for (a, b, c), expr in expressions: |
| 17 | + uexact = hyp2f1(a, b, c, expr) |
| 18 | + result = assemble(Function(V).interpolate(uexact)).dat.data |
| 19 | + expect = sp_hyp2f1(a, b, c, assemble(Function(V).interpolate(expr)).dat.data) |
| 20 | + assert np.allclose(result, expect) |
0 commit comments