From dbcff1bf53f81632d0b3b71e40d908e6a5b4f6b6 Mon Sep 17 00:00:00 2001 From: niclaurenti Date: Mon, 17 Jul 2023 22:50:53 +0200 Subject: [PATCH 1/6] Import changes from produce_eko_photon --- n3fit/src/evolven3fit_new/eko_utils.py | 84 ++++++++++++------- n3fit/src/n3fit/scripts/evolven3fit_new.py | 65 ++++++++++++-- .../tests/photon/test_structurefunctions.py | 8 +- 3 files changed, 118 insertions(+), 39 deletions(-) diff --git a/n3fit/src/evolven3fit_new/eko_utils.py b/n3fit/src/evolven3fit_new/eko_utils.py index d636b82354..ef746b717f 100644 --- a/n3fit/src/evolven3fit_new/eko_utils.py +++ b/n3fit/src/evolven3fit_new/eko_utils.py @@ -39,6 +39,8 @@ def construct_eko_cards( x_grid, op_card_dict: Optional[Dict[str, Any]] = None, theory_card_dict: Optional[Dict[str, Any]] = None, + q_gamma = None, + is_eko_photon = False ): """ Return the theory and operator cards used to construct the eko. @@ -68,8 +70,13 @@ def construct_eko_cards( if "nfref" not in theory: theory["nfref"] = NFREF_DEFAULT + # if is eko_photon then mu0 = q_gamma + if not is_eko_photon: + mu0 = theory["Q0"] + else: + mu0 = q_gamma + # Set nf_0 according to the fitting scale unless set explicitly - mu0 = theory["Q0"] if "nf0" not in theory: if mu0 < theory["mc"] * thresholds["c"]: theory["nf0"] = 3 @@ -87,18 +94,31 @@ def construct_eko_cards( legacy_class = runcards.Legacy(theory, {}) theory_card = legacy_class.new_theory - # 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, - q_points, - { - theory["mc"]: thresholds["c"], - theory["mb"]: thresholds["b"], - theory["mt"]: thresholds["t"], - }, - theory["nf0"], - ) + if not is_eko_photon: + # 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, + q_points, + { + theory["mc"]: thresholds["c"], + theory["mb"]: thresholds["b"], + theory["mt"]: thresholds["t"], + }, + theory["nf0"], + ) + else: + q_fin = theory["Q0"] + # Generate the q2grid, if q_fin and q_points are None, use `nf0` to select a default + q2_grid = [q_fin] + if q_fin < theory["mc"] * thresholds["c"]: + nf_fin = 3 + elif q_fin < theory["mb"] * thresholds["b"]: + nf_fin = 4 + elif q_fin < theory["mt"] * thresholds["t"]: + nf_fin = 5 + else: + nf_fin = 6 # construct operator card op_card = default_op_card @@ -110,27 +130,31 @@ def construct_eko_cards( origin=(mu0**2, theory["nf0"]), ) - # Create the eko operator q2grid - # This is a grid which contains information on (q, nf) - # in VFNS values at the matching scales need to be doubled so that they are considered in both sides - - ep = 1e-4 - mugrid = [] - for q2 in q2_grid: - q = float(np.sqrt(q2)) - if nf_default(q2 + ep, atlas) != nf_default(q2 - ep, atlas): - nf_l = int(nf_default(q2 - ep, atlas)) - nf_u = int(nf_default(q2 + ep, atlas)) - mugrid.append((q, nf_l)) - mugrid.append((q, nf_u)) - else: - mugrid.append((q, int(nf_default(q2, atlas)))) - - op_card.update({"mu0": theory["Q0"], "mugrid": mugrid}) + if not is_eko_photon: + # Create the eko operator q2grid + # This is a grid which contains information on (q, nf) + # in VFNS values at the matching scales need to be doubled so that they are considered in both sides + ep = 1e-4 + mugrid = [] + for q2 in q2_grid: + q = float(np.sqrt(q2)) + if nf_default(q2 + ep, atlas) != nf_default(q2 - ep, atlas): + nf_l = int(nf_default(q2 - ep, atlas)) + nf_u = int(nf_default(q2 + ep, atlas)) + mugrid.append((q, nf_l)) + mugrid.append((q, nf_u)) + else: + mugrid.append((q, int(nf_default(q2, atlas)))) + + op_card.update({"mu0": theory["Q0"], "mugrid": mugrid}) + else: + op_card.update({"mu0": mu0, "mugrid": [(q_fin, nf_fin)]}) op_card["xgrid"] = x_grid # Specific defaults for evolven3fit evolution if theory["ModEv"] == "TRN": + if op_card_dict["configs"]["ev_op_iterations"]: + _logger.warning("Provided ev_op_iterations for a TRN theory. It will be unused") op_card["configs"].update(EVOLVEN3FIT_CONFIGS_DEFAULTS_TRN) if theory["ModEv"] == "EXA": op_card["configs"].update(EVOLVEN3FIT_CONFIGS_DEFAULTS_EXA) diff --git a/n3fit/src/n3fit/scripts/evolven3fit_new.py b/n3fit/src/n3fit/scripts/evolven3fit_new.py index 71de3960d8..e1ea7dd915 100644 --- a/n3fit/src/n3fit/scripts/evolven3fit_new.py +++ b/n3fit/src/n3fit/scripts/evolven3fit_new.py @@ -49,6 +49,47 @@ def construct_eko_parser(subparsers): ) return parser +def construct_eko_photon_parser(subparsers): + parser = subparsers.add_parser( + "produce_eko_photon", + help=( + """Produce the eko_photon for the specified theory. + The q_gamma will be the provided one. + The x_grid starts at x_grid_ini and ends at 1.0 and contains the + provided number of points. The eko will be dumped in the provided path.""" + ), + ) + parser.add_argument( + "theoryID", type=int, help="ID of the theory used to produce the eko" + ) + parser.add_argument( + "dump", + type=pathlib.Path, + help="Path where the EKO is dumped", + ) + parser.add_argument( + "-i", + "--x-grid-ini", + default=None, + type=float, + help="Starting point of the x-grid", + ) + parser.add_argument( + "-p", + "--x-grid-points", + default=None, + type=int, + help="Number of points of the x-grid", + ) + parser.add_argument( + "-g", + "--q-gamma", + default=100, + type=float, + help="Scale at which the photon is generated", + ) + return parser + def construct_evolven3fit_parser(subparsers): parser = subparsers.add_parser( @@ -107,13 +148,22 @@ def main(): default=1, help="Number of cores to be used", ) + parser.add_argument( + "-e", + "--ev-op-iterations", + type=int, + default=30, + help="ev_op_iterations for the EXA theory", + ) subparsers = parser.add_subparsers(title="actions", dest="actions") eko_parser = construct_eko_parser(subparsers) + eko_photon_parser = construct_eko_photon_parser(subparsers) evolven3fit_parser = construct_evolven3fit_parser(subparsers) args = parser.parse_args() op_card_info = { "configs" : { - "n_integration_cores": args.n_cores,} + "n_integration_cores": args.n_cores, + "ev_op_iterations": args.ev_op_iterations,} } theory_card_info = {} if args.actions == "evolve": @@ -127,7 +177,7 @@ def main(): args.load, args.force, ) - elif args.actions == "produce_eko": + else: stdout_log = logging.StreamHandler(sys.stdout) stdout_log.setLevel(evolve.LOGGING_SETTINGS["level"]) stdout_log.setFormatter(evolve.LOGGING_SETTINGS["formatter"]) @@ -148,9 +198,14 @@ def main(): ) else: x_grid = np.geomspace(args.x_grid_ini, 1.0, args.x_grid_points) - tcard, opcard = eko_utils.construct_eko_cards( - args.theoryID, args.q_fin, args.q_points, x_grid, op_card_info, theory_card_info - ) + if args.actions == "produce_eko": + tcard, opcard = eko_utils.construct_eko_cards( + args.theoryID, args.q_fin, args.q_points, x_grid, op_card_info, theory_card_info + ) + elif args.actions == "produce_eko_photon": + tcard, opcard = eko_utils.construct_eko_cards( + args.theoryID, args.q_fin, args.q_points, x_grid, op_card_info, theory_card_info, args.q_gamma, is_eko_photon = True + ) runner.solve(tcard, opcard, args.dump) diff --git a/validphys2/src/validphys/tests/photon/test_structurefunctions.py b/validphys2/src/validphys/tests/photon/test_structurefunctions.py index 879f552c73..0d80df9fd5 100644 --- a/validphys2/src/validphys/tests/photon/test_structurefunctions.py +++ b/validphys2/src/validphys/tests/photon/test_structurefunctions.py @@ -77,8 +77,8 @@ def test_params(): replica = 1 test_theory = API.theoryid(theoryid=THEORY_QED) theory = test_theory.get_description() - for channel in ["F2", "FL"]: - tmp = "fastkernel/FIATLUX_DIS_" + channel + ".pineappl.lz4" + for kind in ["F2", "FL"]: + tmp = "fastkernel/FIATLUX_DIS_" + kind + ".pineappl.lz4" path_to_fktable = test_theory.path / tmp struct_func = sf.InterpStructureFunction(path_to_fktable, pdfs.members[replica]) np.testing.assert_allclose(struct_func.q2_max, 1e8) @@ -93,8 +93,8 @@ def test_interpolation_grid(): pdfs = PDFset(PDF).load() test_theory = API.theoryid(theoryid=THEORY_QED) for replica in [1, 2, 3]: - for channel in ["F2", "FL"]: - tmp = "fastkernel/FIATLUX_DIS_" + channel + ".pineappl.lz4" + for kind in ["F2", "FL"]: + tmp = "fastkernel/FIATLUX_DIS_" + kind + ".pineappl.lz4" path_to_fktable = test_theory.path / tmp fktable = pineappl.fk_table.FkTable.read(path_to_fktable) x = np.unique(fktable.bin_left(1)) From 84577ccd3f1c8f38a9f0efba944e1b1857987b4b Mon Sep 17 00:00:00 2001 From: niclaurenti Date: Tue, 18 Jul 2023 10:19:10 +0200 Subject: [PATCH 2/6] Fix tests --- n3fit/src/evolven3fit_new/eko_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/n3fit/src/evolven3fit_new/eko_utils.py b/n3fit/src/evolven3fit_new/eko_utils.py index ef746b717f..9f3be6f4ed 100644 --- a/n3fit/src/evolven3fit_new/eko_utils.py +++ b/n3fit/src/evolven3fit_new/eko_utils.py @@ -153,7 +153,7 @@ def construct_eko_cards( op_card["xgrid"] = x_grid # Specific defaults for evolven3fit evolution if theory["ModEv"] == "TRN": - if op_card_dict["configs"]["ev_op_iterations"]: + if "ev_op_iterations" in op_card_dict["configs"]: _logger.warning("Provided ev_op_iterations for a TRN theory. It will be unused") op_card["configs"].update(EVOLVEN3FIT_CONFIGS_DEFAULTS_TRN) if theory["ModEv"] == "EXA": From cb37e8563b887fae97bf4f7fb4eec601f5eca0b0 Mon Sep 17 00:00:00 2001 From: niclaurenti Date: Tue, 18 Jul 2023 10:41:52 +0200 Subject: [PATCH 3/6] Remove default from -e option --- n3fit/src/evolven3fit_new/eko_utils.py | 11 ++++++++--- n3fit/src/n3fit/scripts/evolven3fit_new.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/n3fit/src/evolven3fit_new/eko_utils.py b/n3fit/src/evolven3fit_new/eko_utils.py index 9f3be6f4ed..b99b7a72f6 100644 --- a/n3fit/src/evolven3fit_new/eko_utils.py +++ b/n3fit/src/evolven3fit_new/eko_utils.py @@ -153,8 +153,6 @@ def construct_eko_cards( op_card["xgrid"] = x_grid # Specific defaults for evolven3fit evolution if theory["ModEv"] == "TRN": - if "ev_op_iterations" in op_card_dict["configs"]: - _logger.warning("Provided ev_op_iterations for a TRN theory. It will be unused") op_card["configs"].update(EVOLVEN3FIT_CONFIGS_DEFAULTS_TRN) if theory["ModEv"] == "EXA": op_card["configs"].update(EVOLVEN3FIT_CONFIGS_DEFAULTS_EXA) @@ -167,6 +165,13 @@ def construct_eko_cards( op_card[key].update(op_card_dict[key]) elif key in op_card_dict: _logger.warning("Entry %s is not a dictionary and will be ignored", key) - + + # if no -e was given, take ev_op_iterations from EVOLVEN3FIT_CONFIGS_DEFAULTS_{TRN,EXA} + if op_card['configs']['ev_op_iterations'] is None: + if theory["ModEv"] == "TRN": + op_card['configs']['ev_op_iterations'] = EVOLVEN3FIT_CONFIGS_DEFAULTS_TRN["ev_op_iterations"] + if theory["ModEv"] == "EXA": + op_card['configs']['ev_op_iterations'] = EVOLVEN3FIT_CONFIGS_DEFAULTS_EXA["ev_op_iterations"] + op_card = runcards.OperatorCard.from_dict(op_card) return theory_card, op_card diff --git a/n3fit/src/n3fit/scripts/evolven3fit_new.py b/n3fit/src/n3fit/scripts/evolven3fit_new.py index e1ea7dd915..43f9a6b0e4 100644 --- a/n3fit/src/n3fit/scripts/evolven3fit_new.py +++ b/n3fit/src/n3fit/scripts/evolven3fit_new.py @@ -152,7 +152,7 @@ def main(): "-e", "--ev-op-iterations", type=int, - default=30, + default=None, help="ev_op_iterations for the EXA theory", ) subparsers = parser.add_subparsers(title="actions", dest="actions") From 25d41abcdd953213293a8450d211e251882143fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Tue, 18 Jul 2023 16:28:52 +0200 Subject: [PATCH 4/6] Split function constuct_eko_cards in two functions --- n3fit/src/evolven3fit_new/eko_utils.py | 226 +++++++++++++-------- n3fit/src/n3fit/scripts/evolven3fit_new.py | 4 +- 2 files changed, 143 insertions(+), 87 deletions(-) diff --git a/n3fit/src/evolven3fit_new/eko_utils.py b/n3fit/src/evolven3fit_new/eko_utils.py index b99b7a72f6..aaf70438ff 100644 --- a/n3fit/src/evolven3fit_new/eko_utils.py +++ b/n3fit/src/evolven3fit_new/eko_utils.py @@ -39,8 +39,6 @@ def construct_eko_cards( x_grid, op_card_dict: Optional[Dict[str, Any]] = None, theory_card_dict: Optional[Dict[str, Any]] = None, - q_gamma = None, - is_eko_photon = False ): """ Return the theory and operator cards used to construct the eko. @@ -50,16 +48,124 @@ def construct_eko_cards( op_card_dict and theory_card_dict are optional updates that can be provided respectively to the operator card and to the theory card. """ + theory, thresholds = load_theory(theoryID, theory_card_dict) + + # if is eko_photon then mu0 = q_gamma + mu0 = theory["Q0"] + + # Set nf_0 according to the fitting scale unless set explicitly + if "nf0" not in theory: + theory["nf0"] = set_nf0(mu0, theory, thresholds) + + # The Legacy function is able to construct a theory card for eko starting from an NNPDF theory + legacy_class = runcards.Legacy(theory, {}) + theory_card = legacy_class.new_theory + + # construct mugrid + + # 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, + q_points, + { + theory["mc"]: thresholds["c"], + theory["mb"]: thresholds["b"], + theory["mt"]: thresholds["t"], + }, + theory["nf0"], + ) + + masses = np.array([theory["mc"], theory["mb"], theory["mt"]]) ** 2 + thresholds_ratios = np.array([thresholds["c"], thresholds["b"], thresholds["t"]]) ** 2 + + atlas = Atlas( + matching_scales=MatchingScales(masses * thresholds_ratios), + origin=(mu0**2, theory["nf0"]), + ) + + # Create the eko operator q2grid + # This is a grid which contains information on (q, nf) + # in VFNS values at the matching scales need to be doubled so that they are considered in both sides + ep = 1e-4 + mugrid = [] + for q2 in q2_grid: + q = float(np.sqrt(q2)) + if nf_default(q2 + ep, atlas) != nf_default(q2 - ep, atlas): + nf_l = int(nf_default(q2 - ep, atlas)) + nf_u = int(nf_default(q2 + ep, atlas)) + mugrid.append((q, nf_l)) + mugrid.append((q, nf_u)) + else: + mugrid.append((q, int(nf_default(q2, atlas)))) + + # construct operator card + op_card = build_opcard(op_card_dict, theory, x_grid, mu0, mugrid) + + return theory_card, op_card + + +def construct_eko_photon_cards( + theoryID, + q_fin, + x_grid, + q_gamma, + op_card_dict: Optional[Dict[str, Any]] = None, + theory_card_dict: Optional[Dict[str, Any]] = None, +): + """ + Return the theory and operator cards used to construct the eko_photon. + theoryID is the ID of the theory for which we are computing the theory and operator card. + q_fin is the final point of the q grid while q_points is the number of points of the grid. + x_grid is the x grid to be used. + op_card_dict and theory_card_dict are optional updates that can be provided respectively to the + operator card and to the theory card. + """ + theory, thresholds = load_theory(theoryID, theory_card_dict) + + # if is eko_photon then mu0 = q_gamma + mu0 = q_gamma + + # Set nf_0 according to mu0 unless set explicitly + if "nf0" not in theory: + theory["nf0"] = set_nf0(mu0, theory, thresholds) + + # The Legacy function is able to construct a theory card for eko starting from an NNPDF theory + legacy_class = runcards.Legacy(theory, {}) + theory_card = legacy_class.new_theory + + q_fin = theory["Q0"] + + if q_fin < theory["mc"] * thresholds["c"]: + nf_fin = 3 + elif q_fin < theory["mb"] * thresholds["b"]: + nf_fin = 4 + elif q_fin < theory["mt"] * thresholds["t"]: + nf_fin = 5 + else: + nf_fin = 6 + + # construct mugrid + mugrid = [(q_fin, nf_fin)] + + # construct operator card + op_card = build_opcard(op_card_dict, theory, x_grid, mu0, mugrid) + + return theory_card, op_card + + +def load_theory(theoryID, theory_card_dict): + """loads and returns the theory dictionary and the thresholds""" if theory_card_dict is None: theory_card_dict = {} - if op_card_dict is None: - op_card_dict = {} - # theory_card construction theory = Loader().check_theoryID(theoryID).get_description() theory.pop("FNS") theory.update(theory_card_dict) + if "nfref" not in theory: + theory["nfref"] = NFREF_DEFAULT + # Prepare the thresholds according to MaxNfPdf thresholds = {"c": theory["kcThr"], "b": theory["kbThr"], "t": theory["ktThr"]} if theory["MaxNfPdf"] < 5: @@ -67,88 +173,20 @@ def construct_eko_cards( if theory["MaxNfPdf"] < 6: thresholds["t"] = np.inf - if "nfref" not in theory: - theory["nfref"] = NFREF_DEFAULT - - # if is eko_photon then mu0 = q_gamma - if not is_eko_photon: - mu0 = theory["Q0"] - else: - mu0 = q_gamma - - # Set nf_0 according to the fitting scale unless set explicitly - if "nf0" not in theory: - if mu0 < theory["mc"] * thresholds["c"]: - theory["nf0"] = 3 - elif mu0 < theory["mb"] * thresholds["b"]: - theory["nf0"] = 4 - elif mu0 < theory["mt"] * thresholds["t"]: - theory["nf0"] = 5 - else: - theory["nf0"] = 6 - # Setting the thresholds in the theory card to inf if necessary theory.update({"kbThr": thresholds["b"], "ktThr": thresholds["t"]}) - # The Legacy function is able to construct a theory card for eko starting from an NNPDF theory - legacy_class = runcards.Legacy(theory, {}) - theory_card = legacy_class.new_theory + return theory, thresholds - if not is_eko_photon: - # 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, - q_points, - { - theory["mc"]: thresholds["c"], - theory["mb"]: thresholds["b"], - theory["mt"]: thresholds["t"], - }, - theory["nf0"], - ) - else: - q_fin = theory["Q0"] - # Generate the q2grid, if q_fin and q_points are None, use `nf0` to select a default - q2_grid = [q_fin] - if q_fin < theory["mc"] * thresholds["c"]: - nf_fin = 3 - elif q_fin < theory["mb"] * thresholds["b"]: - nf_fin = 4 - elif q_fin < theory["mt"] * thresholds["t"]: - nf_fin = 5 - else: - nf_fin = 6 - # 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 +def build_opcard(op_card_dict, theory, x_grid, mu0, mugrid): + """builds the opcard""" + if op_card_dict is None: + op_card_dict = {} - atlas = Atlas( - matching_scales=MatchingScales(masses * thresholds_ratios), - origin=(mu0**2, theory["nf0"]), - ) + op_card = default_op_card - if not is_eko_photon: - # Create the eko operator q2grid - # This is a grid which contains information on (q, nf) - # in VFNS values at the matching scales need to be doubled so that they are considered in both sides - ep = 1e-4 - mugrid = [] - for q2 in q2_grid: - q = float(np.sqrt(q2)) - if nf_default(q2 + ep, atlas) != nf_default(q2 - ep, atlas): - nf_l = int(nf_default(q2 - ep, atlas)) - nf_u = int(nf_default(q2 + ep, atlas)) - mugrid.append((q, nf_l)) - mugrid.append((q, nf_u)) - else: - mugrid.append((q, int(nf_default(q2, atlas)))) - - op_card.update({"mu0": theory["Q0"], "mugrid": mugrid}) - else: - op_card.update({"mu0": mu0, "mugrid": [(q_fin, nf_fin)]}) + op_card.update({"mu0": mu0, "mugrid": mugrid}) op_card["xgrid"] = x_grid # Specific defaults for evolven3fit evolution @@ -165,13 +203,31 @@ def construct_eko_cards( op_card[key].update(op_card_dict[key]) elif key in op_card_dict: _logger.warning("Entry %s is not a dictionary and will be ignored", key) - + # if no -e was given, take ev_op_iterations from EVOLVEN3FIT_CONFIGS_DEFAULTS_{TRN,EXA} if op_card['configs']['ev_op_iterations'] is None: if theory["ModEv"] == "TRN": - op_card['configs']['ev_op_iterations'] = EVOLVEN3FIT_CONFIGS_DEFAULTS_TRN["ev_op_iterations"] + op_card['configs']['ev_op_iterations'] = EVOLVEN3FIT_CONFIGS_DEFAULTS_TRN[ + "ev_op_iterations" + ] if theory["ModEv"] == "EXA": - op_card['configs']['ev_op_iterations'] = EVOLVEN3FIT_CONFIGS_DEFAULTS_EXA["ev_op_iterations"] - + op_card['configs']['ev_op_iterations'] = EVOLVEN3FIT_CONFIGS_DEFAULTS_EXA[ + "ev_op_iterations" + ] + op_card = runcards.OperatorCard.from_dict(op_card) - return theory_card, op_card + + return op_card + + +def set_nf0(mu0, theory, thresholds): + """compute nf0""" + if mu0 < theory["mc"] * thresholds["c"]: + nf0 = 3 + elif mu0 < theory["mb"] * thresholds["b"]: + nf0 = 4 + elif mu0 < theory["mt"] * thresholds["t"]: + nf0 = 5 + else: + nf0 = 6 + return nf0 diff --git a/n3fit/src/n3fit/scripts/evolven3fit_new.py b/n3fit/src/n3fit/scripts/evolven3fit_new.py index 43f9a6b0e4..b98565d6f9 100644 --- a/n3fit/src/n3fit/scripts/evolven3fit_new.py +++ b/n3fit/src/n3fit/scripts/evolven3fit_new.py @@ -203,8 +203,8 @@ def main(): args.theoryID, args.q_fin, args.q_points, x_grid, op_card_info, theory_card_info ) elif args.actions == "produce_eko_photon": - tcard, opcard = eko_utils.construct_eko_cards( - args.theoryID, args.q_fin, args.q_points, x_grid, op_card_info, theory_card_info, args.q_gamma, is_eko_photon = True + tcard, opcard = eko_utils.construct_eko_photon_cards( + args.theoryID, args.q_fin, x_grid, args.q_gamma, op_card_info, theory_card_info, ) runner.solve(tcard, opcard, args.dump) From 70b37e9ab0245ee3628eb43a7a043de8351a9bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Wed, 19 Jul 2023 09:46:04 +0200 Subject: [PATCH 5/6] rename set_nf -> find_nf --- n3fit/src/evolven3fit_new/eko_utils.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/n3fit/src/evolven3fit_new/eko_utils.py b/n3fit/src/evolven3fit_new/eko_utils.py index aaf70438ff..ac9da40f8e 100644 --- a/n3fit/src/evolven3fit_new/eko_utils.py +++ b/n3fit/src/evolven3fit_new/eko_utils.py @@ -55,7 +55,7 @@ def construct_eko_cards( # Set nf_0 according to the fitting scale unless set explicitly if "nf0" not in theory: - theory["nf0"] = set_nf0(mu0, theory, thresholds) + theory["nf0"] = find_nf(mu0, theory, thresholds) # The Legacy function is able to construct a theory card for eko starting from an NNPDF theory legacy_class = runcards.Legacy(theory, {}) @@ -128,7 +128,7 @@ def construct_eko_photon_cards( # Set nf_0 according to mu0 unless set explicitly if "nf0" not in theory: - theory["nf0"] = set_nf0(mu0, theory, thresholds) + theory["nf0"] = find_nf(mu0, theory, thresholds) # The Legacy function is able to construct a theory card for eko starting from an NNPDF theory legacy_class = runcards.Legacy(theory, {}) @@ -136,14 +136,7 @@ def construct_eko_photon_cards( q_fin = theory["Q0"] - if q_fin < theory["mc"] * thresholds["c"]: - nf_fin = 3 - elif q_fin < theory["mb"] * thresholds["b"]: - nf_fin = 4 - elif q_fin < theory["mt"] * thresholds["t"]: - nf_fin = 5 - else: - nf_fin = 6 + nf_fin = find_nf(q_fin, theory, thresholds) # construct mugrid mugrid = [(q_fin, nf_fin)] @@ -220,7 +213,7 @@ def build_opcard(op_card_dict, theory, x_grid, mu0, mugrid): return op_card -def set_nf0(mu0, theory, thresholds): +def find_nf(mu0, theory, thresholds): """compute nf0""" if mu0 < theory["mc"] * thresholds["c"]: nf0 = 3 From 139dfb55012fae16099df53e79f5befd5ef4b9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Wed, 19 Jul 2023 09:48:41 +0200 Subject: [PATCH 6/6] Rename varibles in find_nf --- n3fit/src/evolven3fit_new/eko_utils.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/n3fit/src/evolven3fit_new/eko_utils.py b/n3fit/src/evolven3fit_new/eko_utils.py index ac9da40f8e..9bd8985f01 100644 --- a/n3fit/src/evolven3fit_new/eko_utils.py +++ b/n3fit/src/evolven3fit_new/eko_utils.py @@ -213,14 +213,14 @@ def build_opcard(op_card_dict, theory, x_grid, mu0, mugrid): return op_card -def find_nf(mu0, theory, thresholds): - """compute nf0""" - if mu0 < theory["mc"] * thresholds["c"]: - nf0 = 3 - elif mu0 < theory["mb"] * thresholds["b"]: - nf0 = 4 - elif mu0 < theory["mt"] * thresholds["t"]: - nf0 = 5 +def find_nf(mu, theory, thresholds): + """compute nf for a given mu""" + if mu < theory["mc"] * thresholds["c"]: + nf = 3 + elif mu < theory["mb"] * thresholds["b"]: + nf = 4 + elif mu < theory["mt"] * thresholds["t"]: + nf = 5 else: - nf0 = 6 - return nf0 + nf = 6 + return nf