diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index fb9edea8bf..d2c41ea803 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -51,7 +51,7 @@ requirements: - sphinxcontrib-bibtex - curio >=1.0 - pineappl >=0.5.8 - - eko >=0.13.4,<0.14 + - eko >=0.13.5,<0.14 - banana-hep >=0.6.8 - fiatlux diff --git a/n3fit/src/evolven3fit_new/eko_utils.py b/n3fit/src/evolven3fit_new/eko_utils.py index 7eabc1b009..4203a3b128 100644 --- a/n3fit/src/evolven3fit_new/eko_utils.py +++ b/n3fit/src/evolven3fit_new/eko_utils.py @@ -87,7 +87,7 @@ def construct_eko_cards( legacy_class = runcards.Legacy(theory, {}) theory_card = legacy_class.new_theory - # construct operator card + # Generate the q2grid, if q_fin and q_points are None, use `nf0` to select a default q2_grid = utils.generate_q2grid( mu0, q_fin, @@ -99,6 +99,8 @@ def construct_eko_cards( }, theory["nf0"], ) + + # construct operator card op_card = default_op_card masses = np.array([theory["mc"], theory["mb"], theory["mt"]]) ** 2 thresholds_ratios = np.array([thresholds["c"], thresholds["b"], thresholds["t"]]) ** 2 @@ -144,22 +146,3 @@ def construct_eko_cards( op_card = runcards.OperatorCard.from_dict(op_card) return theory_card, op_card - - -def split_evolgrid(evolgrid): - """Split the evolgrid in blocks according to the number of flavors.""" - evolgrid_index_list = [] - evolgrid.sort() - starting_nf = evolgrid[0][1] - for evo_point in evolgrid: - current_nf = evo_point[1] - if current_nf != starting_nf: - evolgrid_index_list.append(evolgrid.index(evo_point)) - starting_nf = current_nf - start_index = 0 - evolgrid_list = [] - for index in evolgrid_index_list: - evolgrid_list.append(evolgrid[start_index:index]) - start_index = index - evolgrid_list.append(evolgrid[start_index:]) - return evolgrid_list diff --git a/n3fit/src/evolven3fit_new/evolve.py b/n3fit/src/evolven3fit_new/evolve.py index 8cf5e28cc6..8caab4e3e2 100644 --- a/n3fit/src/evolven3fit_new/evolve.py +++ b/n3fit/src/evolven3fit_new/evolve.py @@ -1,3 +1,4 @@ +from collections import defaultdict import logging import pathlib import sys @@ -178,19 +179,27 @@ def evolve_exportgrid(exportgrid, eko, x_grid, qed): # generate block to dump targetgrid = eko.bases.targetgrid.tolist() - def ev_pdf(pid, x, Q2): - return x * evolved_pdf[Q2]["pdfs"][pid][targetgrid.index(x)] + # Finally separate by nf block (and order per nf/q) + by_nf = defaultdict(list) + for q, nf in sorted(eko.evolgrid, key=lambda ep: ep[1]): + by_nf[nf].append(q) + q2block_per_nf = {nf: sorted(qs) for nf, qs in by_nf.items()} - evolgrid_list = eko_utils.split_evolgrid(eko.evolgrid) blocks = [] - for evgrid in evolgrid_list: + for nf, q2grid in q2block_per_nf.items(): + + def pdf_xq2(pid, x, Q2): + x_idx = targetgrid.index(x) + return x * evolved_pdf[(Q2, nf)]["pdfs"][pid][x_idx] + block = genpdf.generate_block( - ev_pdf, + pdf_xq2, xgrid=targetgrid, - evolgrid=evgrid, + sorted_q2grid=q2grid, pids=basis_rotation.flavor_basis_pids, ) blocks.append(block) + return blocks