Skip to content

Commit

Permalink
adding expressions derived using complete instead of incomplete ellip…
Browse files Browse the repository at this point in the history
…tic integrals
  • Loading branch information
rahulgaur104 committed Feb 17, 2025
1 parent 89cedb4 commit 59da3fd
Showing 1 changed file with 45 additions and 9 deletions.
54 changes: 45 additions & 9 deletions tests/test_integrals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from numpy.polynomial.legendre import leggauss
from scipy import integrate
from scipy.interpolate import CubicHermiteSpline
from scipy.special import ellipe, ellipkm1
from scipy.special import ellipe, ellipk, ellipkm1
from tests.test_interp_utils import _f_1d, _f_1d_nyquist_freq, _f_2d, _f_2d_nyquist_freq
from tests.test_plotting import tol_1d

Expand Down Expand Up @@ -995,14 +995,50 @@ def elliptic_incomplete(k2):
E, TestBounceQuadrature._fixed_elliptic(E_integrand, k, 10)
)

I_0 = 4 / k * K
I_1 = 4 * k * E
I_2 = 16 * k * E
I_3 = 16 * k / 9 * (2 * (-1 + 2 * k2) * E - (-1 + k2) * K)
I_4 = 16 * k / 3 * ((-1 + 2 * k2) * E - 2 * (-1 + k2) * K)
I_5 = 32 * k / 30 * (2 * (1 - k2 + k2**2) * E - (1 - 3 * k2 + 2 * k2**2) * K)
I_6 = 4 / k * (2 * k2 * E + (1 - 2 * k2) * K)
I_7 = 2 * k / 3 * ((-2 + 4 * k2) * E - 4 * (-1 + k2) * K)
E0 = ellipe(k2)
K0 = ellipk(k2)

I_00 = 4 / k * K # Incomplete integral
I_0 = 4 * K0 # Complete integral

I_10 = 4 * k * E
I_1 = 4 * (E0 + (k2 - 1) * K0)

I_20 = 16 * k * E
I_2 = 16 * (E0 + (k2 - 1) * K0)

I_30 = 16 * k / 9 * (2 * (-1 + 2 * k2) * E - (-1 + k2) * K)
I_3 = 16 / 9 * (2 * (-1 + 2 * k2) * (E0 + (k2 - 1) * K0) - (-1 + k2) * k2 * K0)

I_40 = 16 * k / 3 * ((-1 + 2 * k2) * E - 2 * (-1 + k2) * K)
I_4 = 16 / 3 * ((-1 + 2 * k2) * E0 - (-1 + k2) * K0)

I_50 = 32 * k / 30 * (2 * (1 - k2 + k2**2) * E - (1 - 3 * k2 + 2 * k2**2) * K)
I_5 = (
32
/ 30
* (
2 * (1 - k2 + k2**2) * (E0 + (k2 - 1) * K0)
- (1 - 3 * k2 + 2 * k2**2) * k2 * K0
)
)

I_60 = 4 / k * (2 * k2 * E + (1 - 2 * k2) * K)
I_6 = 4 * (2 * E0 - K0)

I_70 = 2 * k / 3 * ((-2 + 4 * k2) * E - 4 * (-1 + k2) * K)
I_7 = 4 / 3 * ((2 * k2 - 1) * E0 - (k2 - 1) * K0)

# Check if incomplete integral expressions match the complete integrals
np.testing.assert_allclose(I_0, I_00)
np.testing.assert_allclose(I_1, I_10)
np.testing.assert_allclose(I_2, I_20)
np.testing.assert_allclose(I_3, I_30)
np.testing.assert_allclose(I_4, I_40)
np.testing.assert_allclose(I_5, I_50)
np.testing.assert_allclose(I_6, I_60)
np.testing.assert_allclose(I_7, I_70)

# Check for math mistakes.
np.testing.assert_allclose(
I_2,
Expand Down

0 comments on commit 59da3fd

Please sign in to comment.