Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching harmonic sums #202

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c14b43e
Split math of status quo
felixhekhorn Jan 11, 2023
85c2da6
Move ads to new layout
felixhekhorn Jan 12, 2023
10d2240
Add pytest coverage
felixhekhorn Jan 12, 2023
8fd5436
fix init name
giacomomagni Jan 16, 2023
4678da7
Start reshuffling OME
felixhekhorn Jan 16, 2023
694a239
Move ad benchmark
felixhekhorn Jan 16, 2023
ec04696
Move OME
felixhekhorn Jan 17, 2023
febd415
Add missing init file
felixhekhorn Jan 17, 2023
bb6af22
propagate polarized and time-like from op card to op.__init__
giacomomagni Jan 16, 2023
3db8696
Add switch for OME
felixhekhorn Jan 17, 2023
7a74ddb
Fix function names
felixhekhorn Jan 17, 2023
1126089
Fix runcard translation
felixhekhorn Jan 26, 2023
9226ccc
Init cache at LO
felixhekhorn Jan 26, 2023
45b95a5
Update src/ekore/harmonics/cache.py
felixhekhorn Jan 27, 2023
764d876
added all harmonic sums that are currently implemented to new cache, …
t7phy Jan 30, 2023
d2fd535
with pre-commit
t7phy Jan 30, 2023
3d766ba
change imports to use eko.constants
t7phy Jan 30, 2023
26f1ddb
added fractional harmonic sums and g functions to cache
t7phy Jan 31, 2023
611f3bb
harmonic sums Smx using cache
t7phy Feb 1, 2023
e88edf9
removal of recursive imports while preserving use of already computed…
t7phy Feb 1, 2023
0168fa1
g3p1 and g3p2 added to cache
t7phy Feb 6, 2023
65fee8a
sm21 and pylint error fixes for cache file
t7phy Feb 9, 2023
0d2c8d2
additional cache error fixes
t7phy Feb 9, 2023
51d8ec8
merge master in harmonic-sums-cache
t7phy Feb 9, 2023
0cf143d
merge master in harmonic-sums-cache
t7phy Feb 9, 2023
5de8a74
resolve merge conflicts
t7phy Feb 9, 2023
07eec29
resolve merge conflicts
t7phy Feb 9, 2023
12fbe7a
complete implementation of new harmonic sums cachefor spacelike case
t7phy Feb 10, 2023
1f4e9b5
some error fixes
t7phy Feb 10, 2023
1e3adf9
new cache consistency fixes
t7phy Feb 10, 2023
483107c
fixed some tests to work with new cache
t7phy Feb 10, 2023
0d5fd14
Merge branch 'master' into harmonic-sums-cache
giacomomagni Feb 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extras/harmonics_w5/src/harmonics_w5/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import numba as nb

from eko.constants import log2, zeta2, zeta3, zeta4, zeta5
from ekore.harmonics import S5, Sm5
from ekore.harmonics.constants import log2, zeta2, zeta3, zeta4, zeta5
from ekore.harmonics.polygamma import cern_polygamma, symmetry_factor
from ekore.harmonics.polygamma import symmetry_factor

from . import f_functions as f

Expand Down
104 changes: 55 additions & 49 deletions extras/harmonics_w5/tests/test_f_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
import harmonics_w5 as w5
import numpy as np

from ekore import harmonics
from ekore.harmonics import cache as c

zeta2 = harmonics.constants.zeta2
zeta3 = harmonics.constants.zeta3
zeta4 = harmonics.constants.zeta4
zeta5 = harmonics.constants.zeta5
log2 = np.log(2)

# reference values coming fom Mathematica:
Expand Down Expand Up @@ -60,107 +56,117 @@
# F19, F20,F21 are not present in that paper.
def test_F9():
for N, vals in zip(testN, refvals["S41"]):
S1 = harmonics.S1(N)
S2 = harmonics.S2(N)
S3 = harmonics.S3(N)
cache = c.reset()
S1 = c.get(c.S1, cache, N, None)
S2 = c.get(c.S2, cache, N, None)
S3 = c.get(c.S3, cache, N, None)
S41 = w5.S41(N, S1, S2, S3)
np.testing.assert_allclose(S41, vals, atol=1e-05)


def test_F11():
for N, vals in zip(testN, refvals["S311"]):
S1 = harmonics.S1(N)
S2 = harmonics.S2(N)
cache = c.reset()
S1 = c.get(c.S1, cache, N, None)
S2 = c.get(c.S2, cache, N, None)
S311 = w5.S311(N, S1, S2)
np.testing.assert_allclose(S311, vals, atol=1e-05)


def test_F13():
for N, vals in zip(testN, refvals["S221"]):
S1 = harmonics.S1(N)
S2 = harmonics.S2(N)
S21 = harmonics.S21(N, S1, S2)
cache = c.reset()
S1 = c.get(c.S1, cache, N, None)
S2 = c.get(c.S2, cache, N, None)
S21 = c.get(c.S21, cache, N, None)
S221 = w5.S221(N, S1, S2, S21)
np.testing.assert_allclose(S221, vals, atol=1e-05)


def test_F12_F14():
# here there is a typo in eq (9.25) of Bl_mlein_2009
for N, vals in zip(testN, refvals["Sm221"]):
S1 = harmonics.S1(N)
S2 = harmonics.S2(N)
Sm1 = harmonics.Sm1(N, S1)
S21 = harmonics.S21(N, S1, S2)
Sm21 = harmonics.Sm21(N, S1, Sm1)
cache = c.reset()
S1 = c.get(c.S1, cache, N, None)
S2 = c.get(c.S2, cache, N, None)
Sm1 = c.get(c.Sm1, cache, N, None)
S21 = c.get(c.S21, cache, N, None)
Sm21 = c.get(c.Sm21, cache, N, None)
Sm221 = w5.Sm221(N, S1, Sm1, S21, Sm21)
np.testing.assert_allclose(Sm221, vals, atol=1e-05)


def test_F16():
for N, vals in zip(testN, refvals["S21m2"]):
S1 = harmonics.S1(N)
S2 = harmonics.S2(N)
S3 = harmonics.S3(N)
Sm1 = harmonics.Sm1(N, S1)
Sm2 = harmonics.Sm2(N, S2)
Sm3 = harmonics.Sm3(N, S3)
S21 = harmonics.S21(N, S1, S2)
S2m1 = harmonics.S2m1(N, S2, Sm1, Sm2)
Sm21 = harmonics.Sm21(N, S1, Sm1)
cache = c.reset()
S1 = c.get(c.S1, cache, N, None)
S2 = c.get(c.S2, cache, N, None)
S3 = c.get(c.S3, cache, N, None)
Sm1 = c.get(c.Sm1, cache, N, None)
Sm2 = c.get(c.Sm2, cache, N, None)
Sm3 = c.get(c.Sm3, cache, N, None)
S21 = c.get(c.S21, cache, N, None)
S2m1 = c.get(c.S2m1, cache, N, None)
Sm21 = c.get(c.Sm21, cache, N, None)
S21m2 = w5.S21m2(N, S1, S2, Sm1, Sm2, Sm3, S21, Sm21, S2m1)
np.testing.assert_allclose(S21m2, vals, atol=1e-04)


def test_F17():
for N, vals in zip(testN, refvals["S2111"]):
S1 = harmonics.S1(N)
S2 = harmonics.S2(N)
S3 = harmonics.S3(N)
cache = c.reset()
S1 = c.get(c.S1, cache, N, None)
S2 = c.get(c.S2, cache, N, None)
S3 = c.get(c.S3, cache, N, None)
S2111 = w5.S2111(N, S1, S2, S3)
np.testing.assert_allclose(S2111, vals, atol=1e-05)


def test_F18():
for N, vals in zip(testN, refvals["Sm2111"]):
S1 = harmonics.S1(N)
S2 = harmonics.S2(N)
S3 = harmonics.S3(N)
Sm1 = harmonics.Sm1(N, S1)
cache = c.reset()
S1 = c.get(c.S1, cache, N, None)
S2 = c.get(c.S2, cache, N, None)
S3 = c.get(c.S3, cache, N, None)
Sm1 = c.get(c.Sm1, cache, N, None)
Sm2111 = w5.Sm2111(N, S1, S2, S3, Sm1)
np.testing.assert_allclose(Sm2111, vals, atol=1e-05)


# different parametrization, less accurate
def test_F19():
for N, vals in zip(testN, refvals["S23"]):
S1 = harmonics.S1(N)
S2 = harmonics.S2(N)
S3 = harmonics.S3(N)
cache = c.reset()
S1 = c.get(c.S1, cache, N, None)
S2 = c.get(c.S2, cache, N, None)
S3 = c.get(c.S3, cache, N, None)
S23 = w5.S23(N, S1, S2, S3)
np.testing.assert_allclose(S23, vals, rtol=2e-03)


# different parametrization, less accurate
def test_F20():
for N, vals in zip(testN, refvals["Sm23"]):
S1 = harmonics.S1(N)
S2 = harmonics.S2(N)
S3 = harmonics.S3(N)
Sm3 = harmonics.Sm3(N, S3)
Sm2 = harmonics.Sm2(N, S2)
Sm1 = harmonics.Sm1(N, S1)
cache = c.reset()
S1 = c.get(c.S1, cache, N, None)
S2 = c.get(c.S2, cache, N, None)
S3 = c.get(c.S3, cache, N, None)
Sm3 = c.get(c.Sm3, cache, N, None)
Sm2 = c.get(c.Sm2, cache, N, None)
Sm1 = c.get(c.Sm1, cache, N, None)
Sm23 = w5.Sm23(N, Sm1, Sm2, Sm3)
np.testing.assert_allclose(Sm23, vals, rtol=1e-03)


# different parametrization, less accurate
def test_F21():
for N, vals in zip(testN, refvals["S2m3"]):
S1 = harmonics.S1(N)
S2 = harmonics.S2(N)
S3 = harmonics.S3(N)
Sm3 = harmonics.Sm3(N, S3)
Sm2 = harmonics.Sm2(N, S2)
Sm1 = harmonics.Sm1(N, S1)
cache = c.reset()
S1 = c.get(c.S1, cache, N, None)
S2 = c.get(c.S2, cache, N, None)
S3 = c.get(c.S3, cache, N, None)
Sm3 = c.get(c.Sm3, cache, N, None)
Sm2 = c.get(c.Sm2, cache, N, None)
Sm1 = c.get(c.Sm1, cache, N, None)
S2m3 = w5.S2m3(N, S2, Sm1, Sm2, Sm3)
np.testing.assert_allclose(S2m3, vals, rtol=1e-03)
3 changes: 2 additions & 1 deletion src/eko/beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import numba as nb

from eko.constants import zeta3

from . import constants
from ekore.harmonics.constants import zeta3


@nb.njit(cache=True)
Expand Down
19 changes: 19 additions & 0 deletions src/eko/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""This files sets the physical constants."""

import numba as nb
import numpy as np
from scipy.special import zeta

NC = 3
"""The number of colors."""
Expand Down Expand Up @@ -29,6 +31,23 @@
ed2 = 1.0 / 9
"""Down quarks charge squared."""

zeta2 = zeta(2)
r""":math:`\zeta(2)`"""

zeta3 = zeta(3)
r""":math:`\zeta(3)`"""

zeta4 = zeta(4)
r""":math:`\zeta(4)`"""

zeta5 = zeta(5)
r""":math:`\zeta(5)`"""

log2 = np.log(2)
r""":math:`\ln(2)`"""

li4half = 0.517479
""":math:`Li_{4}(1/2)`"""

def update_colors(nc):
"""Updates the number of colors to :math:`NC = nc`.
Expand Down
Loading