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

Evolven3fit new w eko 0.13 #1742

Merged
merged 7 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ requirements:
- sphinxcontrib-bibtex
- curio >=1.0
- pineappl >=0.5.8
- eko >=0.12.2
- eko >=0.13.2,<0.14
- banana-hep >=0.6.8
- fiatlux

Expand Down
12 changes: 10 additions & 2 deletions n3fit/src/evolven3fit_new/eko_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import numpy as np
from eko.io import runcards
from eko.matchings import Atlas, nf_default
from eko.quantities.heavy_quarks import MatchingScales
from ekobox.cards import _operator as default_op_card
from validphys.loader import Loader

Expand Down Expand Up @@ -68,13 +70,19 @@ def construct_eko_cards(
{theory["mb"]: theory["kbThr"], theory["mt"]: theory["ktThr"]},
)
op_card = default_op_card
masses = np.array([theory["mc"],theory["mb"],theory["mt"]]) ** 2
thresholds_ratios=np.array([theory["kcThr"],theory["kbThr"],theory["ktThr"]]) ** 2
atlas = Atlas(
matching_scales=MatchingScales(masses * thresholds_ratios),
origin=(theory["Q0"]**2, theory["nf0"])
)
op_card.update(
{
"mu0": theory["Q0"],
"_mugrid": np.sqrt(q2_grid).tolist(),
"mugrid": [(float(np.sqrt(q2)), int(nf_default(q2, atlas))) for q2 in q2_grid],
}
)
op_card["rotations"]["xgrid"] = x_grid
op_card["xgrid"] = x_grid
# Specific defaults for evolven3fit evolution
if theory["ModEv"] == "TRN":
op_card["configs"].update(EVOLVEN3FIT_CONFIGS_DEFAULTS_TRN)
Expand Down
9 changes: 3 additions & 6 deletions n3fit/src/evolven3fit_new/evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def evolve_fit(
initial_PDFs_dict = load_fit(usr_path)
x_grid = np.array(
initial_PDFs_dict[list(initial_PDFs_dict.keys())[0]]["xgrid"]
).astype(np.float)
).astype(float)
theoryID = utils.get_theoryID_from_runcard(usr_path)
theory, op = eko_utils.construct_eko_cards(
theoryID, q_fin, q_points, x_grid, op_card_dict, theory_card_dict
Expand All @@ -105,9 +105,6 @@ def evolve_fit(
info["XMin"] = float(x_grid[0])
info["XMax"] = float(x_grid[-1])
with eko.EKO.read(eko_path) as eko_op:
if eko.__version__ >= "0.13":
raise ModuleNotFoundError("Please, fix evolven3fit np.sqrt(Q) hack")
info["AlphaS_Qs"] = np.sqrt(info["AlphaS_Qs"]).tolist()
dump_info_file(usr_path, info)
for replica in initial_PDFs_dict.keys():
evolved_block = evolve_exportgrid(initial_PDFs_dict[replica], eko_op, x_grid, qed)
Expand Down Expand Up @@ -169,15 +166,15 @@ def evolve_exportgrid(exportgrid, eko, x_grid, qed):
# evolve pdf
evolved_pdf = apply.apply_pdf(eko, pdf_to_evolve, qed=qed)
# generate block to dump
targetgrid = eko.rotations.targetgrid.tolist()
targetgrid = eko.bases.targetgrid.tolist()

def ev_pdf(pid, x, Q2):
return x * evolved_pdf[Q2]["pdfs"][pid][targetgrid.index(x)]

block = genpdf.generate_block(
ev_pdf,
xgrid=targetgrid,
Q2grid=list(eko.mu2grid),
evolgrid=eko.evolgrid,
pids=basis_rotation.flavor_basis_pids,
)
return block
Expand Down
12 changes: 6 additions & 6 deletions n3fit/src/n3fit/tests/test_evolven3fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ def test_eko_utils(tmp_path):
assert (
t_card_dict["order"][0] == pto + 1
) # This is due to a different convention in eko orders due to QED
assert_allclose(op_card_dict["rotations"]["xgrid"], x_grid)
assert_allclose(op_card_dict["_mugrid"][0], 1.65)
assert_allclose(op_card_dict["_mugrid"][-1], q_fin)
assert_allclose(op_card_dict["xgrid"], x_grid)
assert_allclose(op_card_dict["mugrid"][0], (1.65, 4))
assert_allclose(op_card_dict["mugrid"][-1], (q_fin, 5))
scarlehoff marked this conversation as resolved.
Show resolved Hide resolved
# In this case there are not enough points to have twice the bottom matching scale
assert_allclose(op_card_dict["_mugrid"][1], 4.92)
assert_allclose(op_card_dict["mugrid"][1], (4.92, 5))
# Testing computation of eko
save_path = tmp_path / "ekotest.tar"
runner.solve(t_card, op_card, save_path)
eko_op = EKO.read(save_path)
assert_allclose(eko_op.operator_card.raw["rotations"]["xgrid"], x_grid)
assert_allclose(list(eko_op.operator_card.raw["_mugrid"]), op_card_dict["_mugrid"])
assert_allclose(eko_op.operator_card.raw["xgrid"], x_grid)
assert_allclose(list(eko_op.operator_card.raw["mugrid"]), op_card_dict["mugrid"])
4 changes: 2 additions & 2 deletions validphys2/src/validphys/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,10 +1026,10 @@ def perreplica_chi2_table(groups_data, groups_chi2, total_chi2_data):
ls = []
for i, ch in enumerate(chs, 1):
th, central, l = ch
total_chis[i] = [central, *th.error_members()]
total_chis[i] = np.concatenate([[central], *th.error_members()])
ls.append(l)
total_rep, total_central, total_n = total_chi2_data
total_chis[0] = [total_central, *total_rep.error_members()]
total_chis[0] = np.concatenate([[total_central], *total_rep.error_members()])
total_chis[0] /= total_n
total_chis[1:, :] /= np.array(ls)[:, np.newaxis]

Expand Down