From 2abaa7c45f305391287978bd9705876436105ff4 Mon Sep 17 00:00:00 2001 From: niclaurenti Date: Fri, 14 Jul 2023 15:08:08 +0200 Subject: [PATCH 1/4] Add entry -i to evolven3fit_new --- n3fit/src/evolven3fit_new/eko_utils.py | 2 ++ n3fit/src/n3fit/scripts/evolven3fit_new.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/n3fit/src/evolven3fit_new/eko_utils.py b/n3fit/src/evolven3fit_new/eko_utils.py index d636b82354..016a3e8e1b 100644 --- a/n3fit/src/evolven3fit_new/eko_utils.py +++ b/n3fit/src/evolven3fit_new/eko_utils.py @@ -131,6 +131,8 @@ 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"]: + _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..65ea055195 100644 --- a/n3fit/src/n3fit/scripts/evolven3fit_new.py +++ b/n3fit/src/n3fit/scripts/evolven3fit_new.py @@ -107,13 +107,21 @@ def main(): default=1, help="Number of cores to be used", ) + parser.add_argument( + "-i", + "--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) 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.iterations,} } theory_card_info = {} if args.actions == "evolve": @@ -152,6 +160,8 @@ def main(): args.theoryID, args.q_fin, args.q_points, x_grid, op_card_info, theory_card_info ) runner.solve(tcard, opcard, args.dump) + elif args.actions == "produce_eko_photon": + pass if __name__ == "__main__": From b484695200b4a0d77c4055d6b7de2a290a96e4e8 Mon Sep 17 00:00:00 2001 From: niclaurenti Date: Fri, 14 Jul 2023 16:13:26 +0200 Subject: [PATCH 2/4] Rename iterations --- n3fit/src/n3fit/scripts/evolven3fit_new.py | 40 +++++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/n3fit/src/n3fit/scripts/evolven3fit_new.py b/n3fit/src/n3fit/scripts/evolven3fit_new.py index 65ea055195..5fd8f702e2 100644 --- a/n3fit/src/n3fit/scripts/evolven3fit_new.py +++ b/n3fit/src/n3fit/scripts/evolven3fit_new.py @@ -49,6 +49,25 @@ 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( + "-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( @@ -108,20 +127,21 @@ def main(): help="Number of cores to be used", ) parser.add_argument( - "-i", - "--iterations", + "-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, - "ev_op_iterations": args.iterations,} + "ev_op_iterations": args.ev_op_iterations,} } theory_card_info = {} if args.actions == "evolve": @@ -135,7 +155,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"]) @@ -156,12 +176,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": + #has to produce the correct card for the eko photon + pass runner.solve(tcard, opcard, args.dump) - elif args.actions == "produce_eko_photon": - pass if __name__ == "__main__": From bbdb5221d246bf827c7aed9b1bd8b52076122759 Mon Sep 17 00:00:00 2001 From: niclaurenti Date: Mon, 17 Jul 2023 12:04:46 +0200 Subject: [PATCH 3/4] Modify construct_eko_cards --- n3fit/src/evolven3fit_new/eko_utils.py | 82 ++++++++++++++-------- n3fit/src/n3fit/scripts/evolven3fit_new.py | 27 ++++++- 2 files changed, 77 insertions(+), 32 deletions(-) diff --git a/n3fit/src/evolven3fit_new/eko_utils.py b/n3fit/src/evolven3fit_new/eko_utils.py index 016a3e8e1b..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,23 +130,25 @@ 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 diff --git a/n3fit/src/n3fit/scripts/evolven3fit_new.py b/n3fit/src/n3fit/scripts/evolven3fit_new.py index 5fd8f702e2..e1ea7dd915 100644 --- a/n3fit/src/n3fit/scripts/evolven3fit_new.py +++ b/n3fit/src/n3fit/scripts/evolven3fit_new.py @@ -59,6 +59,28 @@ def construct_eko_photon_parser(subparsers): 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", @@ -181,8 +203,9 @@ def main(): args.theoryID, args.q_fin, args.q_points, x_grid, op_card_info, theory_card_info ) elif args.actions == "produce_eko_photon": - #has to produce the correct card for the eko photon - pass + 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) From 11bfc8991936d85a91afd8f04f2baf736c4e0619 Mon Sep 17 00:00:00 2001 From: niclaurenti Date: Mon, 17 Jul 2023 22:26:02 +0200 Subject: [PATCH 4/4] Rename channel -> kind --- .../src/validphys/tests/photon/test_structurefunctions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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))