From d96e5759f3814cce4ee184c1b6ca4aa48fcdabf9 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Mon, 3 Apr 2023 15:15:44 +0200 Subject: [PATCH 1/3] Make LHA running --- src/eko/io/runcards.py | 29 ++++++++++----------- src/ekomark/benchmark/external/LHA_utils.py | 2 +- tests/eko/io/test_runcards.py | 29 +++++++++++++++++++++ 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/eko/io/runcards.py b/src/eko/io/runcards.py index d8afdfc32..408f88617 100644 --- a/src/eko/io/runcards.py +++ b/src/eko/io/runcards.py @@ -288,33 +288,32 @@ def new_theory(self): new["order"] = [old["PTO"] + 1, old["QED"]] alphaem = self.fallback(old.get("alphaqed"), old.get("alphaem"), default=0.0) - if "QrefQED" not in old: - qedref = nan - else: - qedref = old["QrefQED"] new["couplings"] = dict( - alphas=(old["alphas"], old["Qref"]), - alphaem=(alphaem, qedref), + alphas=old["alphas"], + alphaem=alphaem, + scale=old["Qref"], num_flavs_ref=old["nfref"], max_num_flavs=old["MaxNfAs"], ) - new["num_flavs_init"] = old["nf0"] - new["num_flavs_max_pdf"] = old["MaxNfPdf"] + new["heavy"] = { + "num_flavs_init": old["nf0"], + "num_flavs_max_pdf": old["MaxNfPdf"], + "matching_ratios": self.heavies("k%sThr", old), + "masses_scheme": old["HQ"], + } intrinsic = [] for idx, q in enumerate(hq.FLAVORS): if old.get(f"i{q}".upper()) == 1: intrinsic.append(idx + 4) - new["intrinsic_flavors"] = intrinsic - new["matching"] = self.heavies("k%sThr", old) - new["quark_masses_scheme"] = old["HQ"] + new["heavy"]["intrinsic_flavors"] = intrinsic ms = self.heavies("m%s", old) mus = self.heavies("Qm%s", old) if old["HQ"] == "POLE": - new["quark_masses"] = [[m, nan] for m in ms] + new["heavy"]["masses"] = [[m, nan] for m in ms] elif old["HQ"] == "MSBAR": - new["quark_masses"] = [[m, mu] for m, mu in zip(ms, mus)] + new["heavy"]["masses"] = [[m, mu] for m, mu in zip(ms, mus)] else: - raise ValueError() + raise ValueError(f"Unkown quark mass sceme '{old['HQ']}'") new["xif"] = old["XIF"] @@ -409,4 +408,4 @@ def flavored_mugrid(mugrid: list, masses: list, matching_ratios: list): masses=(np.array(masses) ** 2).tolist(), thresholds_ratios=(np.array(matching_ratios) ** 2).tolist(), ) - return [(mu, tc.nf(mu**2)) for mu in mugrid] + return [(mu, int(tc.nf(mu**2))) for mu in mugrid] diff --git a/src/ekomark/benchmark/external/LHA_utils.py b/src/ekomark/benchmark/external/LHA_utils.py index 4ee88c70e..39043394e 100644 --- a/src/ekomark/benchmark/external/LHA_utils.py +++ b/src/ekomark/benchmark/external/LHA_utils.py @@ -126,7 +126,7 @@ def compute_LHA_data(theory, operators, rotate_to_evolution_basis=False): """ polarized = operators["polarized"] - mu2grid = operators["mu2grid"] + mu2grid = np.power(operators["mugrid"], 2.0) if not np.allclose(mu2grid, [1e4]): raise ValueError("mu2grid has to be [1e4]") order = theory["PTO"] diff --git a/tests/eko/io/test_runcards.py b/tests/eko/io/test_runcards.py index 22352604b..237f814fb 100644 --- a/tests/eko/io/test_runcards.py +++ b/tests/eko/io/test_runcards.py @@ -1,10 +1,15 @@ +import copy from dataclasses import fields +from io import StringIO import numpy as np import pytest +import yaml +from banana.data.theories import default_card as theory_card from eko import interpolation from eko.io import runcards as rc +from ekomark.data.operators import default_card as operator_card class TestRotations: @@ -50,3 +55,27 @@ def test_flavored_mu2grid(): flavored = rc.flavored_mugrid(mugrid, masses, ratios) assert pytest.approx([flav for _, flav in flavored]) == [3, 3, 4, 4, 5, 5, 6, 6] + + # check we can dump + stream = StringIO() + ser = yaml.safe_dump(flavored, stream) + stream.seek(0) + deser = yaml.safe_load(stream) + assert len(flavored) == len(deser) + # after deserialization on is now list instead of tuple + for t, l in zip(flavored, deser): + assert len(t) == len(l) + assert t == tuple(l) + + +def test_runcards_ekomark(): + # check conversion + tc = copy.deepcopy(theory_card) + oc = copy.deepcopy(operator_card) + nt, no = rc.update(tc, oc) + assert isinstance(nt, rc.TheoryCard) + assert isinstance(no, rc.OperatorCard) + # check is idempotent + nnt, nno = rc.update(nt, no) + assert nnt == nt + assert nno == no From 0e9339cf7f3f4450c92ecc7bffc9540a0a577948 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Mon, 3 Apr 2023 17:58:09 +0200 Subject: [PATCH 2/3] Fix typo --- src/eko/io/runcards.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eko/io/runcards.py b/src/eko/io/runcards.py index 408f88617..0db1c299d 100644 --- a/src/eko/io/runcards.py +++ b/src/eko/io/runcards.py @@ -313,7 +313,7 @@ def new_theory(self): elif old["HQ"] == "MSBAR": new["heavy"]["masses"] = [[m, mu] for m, mu in zip(ms, mus)] else: - raise ValueError(f"Unkown quark mass sceme '{old['HQ']}'") + raise ValueError(f"Unknown mass scheme '{old['HQ']}'") new["xif"] = old["XIF"] From 51d66ac71dfb951058da5af9b4a58878e494eaf9 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Tue, 4 Apr 2023 11:07:38 +0200 Subject: [PATCH 3/3] Remove more Q2grid-s --- benchmarks/lha_paper_bench.py | 2 +- doc/source/code/IO.rst | 4 ++-- src/ekomark/navigator/navigator.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/benchmarks/lha_paper_bench.py b/benchmarks/lha_paper_bench.py index e5826c946..71ddf3550 100644 --- a/benchmarks/lha_paper_bench.py +++ b/benchmarks/lha_paper_bench.py @@ -252,7 +252,7 @@ def run_lha(self, theory_updates): theory_updates, [ { - "Q2grid": [1e4], + "mugrid": [1e2], "ev_op_iterations": 10, "interpolation_xgrid": lambertgrid(60).tolist(), "polarized": True, diff --git a/doc/source/code/IO.rst b/doc/source/code/IO.rst index 32713077c..1bdc77c12 100644 --- a/doc/source/code/IO.rst +++ b/doc/source/code/IO.rst @@ -126,9 +126,9 @@ The benchmark settings are available at :mod:`ekomark.data.operators`. * - ``interpolation_xgrid`` - :py:obj:`list(float)` - x-grid at which the |EKO| is computed. - * - ``Q2grid`` + * - ``mugrid`` - :py:obj:`list(float)` - - Q2-grid at which the |EKO| is computed (in GeV^2). + - target grid at which the |EKO| is computed (in GeV). * - ``interpolation_is_log`` - :py:obj:`bool` - If ``True`` use logarithmic interpolation. diff --git a/src/ekomark/navigator/navigator.py b/src/ekomark/navigator/navigator.py index f60c30ed6..c624c0737 100644 --- a/src/ekomark/navigator/navigator.py +++ b/src/ekomark/navigator/navigator.py @@ -76,7 +76,7 @@ def fill_operators(self, op, obj): + f"{'log' if op['interpolation_is_log'] else 'x'}" + f"^{op['interpolation_polynomial_degree']}" ) - obj["Q2grid"] = op["Q2grid"] + obj["mugrid"] = op["mugrid"] obj["max_ord"] = op["ev_op_max_order"] obj["iters"] = op["ev_op_iterations"] obj["skip_ns"] = op["debug_skip_non_singlet"]