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

Automatise numerical FONLL #153

Merged
merged 25 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b6f9621
init speeding up nfonll
giacomomagni Feb 15, 2024
e7dbfb1
add combine Fk tables
giacomomagni Feb 15, 2024
29312c9
restore commands
giacomomagni Feb 15, 2024
4f3c94d
improve logging
giacomomagni Feb 15, 2024
e930699
remove creation of num fonll theories from eko command
giacomomagni Feb 15, 2024
6300c9d
init fonll docs
giacomomagni Feb 15, 2024
739f7ca
init fonll docs
giacomomagni Feb 15, 2024
c74f940
more on docs
giacomomagni Feb 15, 2024
28b8fe8
Fix FONLL-B bug
andreab1997 Feb 20, 2024
89a066a
Update docs/source/overview/running.rst
giacomomagni Feb 20, 2024
01cc3a2
Update docs/source/overview/running.rst
giacomomagni Feb 20, 2024
09a0686
Update docs/source/overview/running.rst
giacomomagni Feb 20, 2024
42d22d4
Update docs/source/overview/running.rst
giacomomagni Mar 6, 2024
78b3fb8
Update docs/source/overview/running.rst
giacomomagni Mar 6, 2024
efe91fb
Update docs/source/overview/running.rst
giacomomagni Mar 6, 2024
676cf60
Update docs/source/overview/running.rst
giacomomagni Mar 6, 2024
05ea71e
Update docs/source/overview/running.rst
giacomomagni Mar 6, 2024
1673333
Update docs/source/overview/running.rst
giacomomagni Mar 6, 2024
415f0f9
Update docs/source/overview/running.rst
giacomomagni Mar 6, 2024
f38eec4
clarify "usual" in docs
giacomomagni Mar 6, 2024
fbb4c55
Split docs
felixhekhorn Mar 7, 2024
3365f2e
reorganize fonll commands
giacomomagni Mar 8, 2024
2c755c6
fix pineko help
giacomomagni Mar 8, 2024
1b88551
fix issue #138
giacomomagni Mar 8, 2024
78c2138
fix test
giacomomagni Mar 8, 2024
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
80 changes: 78 additions & 2 deletions docs/source/overview/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ This is a two step process:



Inherit |EKO| from Existing Theory
"""""""""""""""""""""""""""""""""""
Inherit |EKO| or grids from Existing Theory
"""""""""""""""""""""""""""""""""""""""""""

You can reuse the |EKO| from a different theory by running::

pineko theory inherit-ekos SOURCE_THEORY_ID TARGET_THEORY_ID DATASET1 DATASET2 ...

You can reuse the grid from a different theory by running::

pineko theory inherit-grids SOURCE_THEORY_ID TARGET_THEORY_ID DATASET1 DATASET2 ...

The relation between the source theory and the target theory is non-trivial [5]_.

Expand All @@ -54,6 +57,79 @@ Note that you can also convolute a single grid with a single eko (obtaining a si
If necessary it is possible to specify the values of the *renormalization* and *factorization* scale variations with
the options ``--xir`` and ``--xif``.


Generating FONLL FK Tables
--------------------------

In order to generate FK tables with (numerical) |FONLL| the different flavor schemes
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved
need to be evolved separately and joined together in a single FK table only
in the final step.

There are 2 workflows possible, one in which all the steps are performed individually
and one that is more automatize.
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved

The automatize workflows always assumes that |FONLL| is performed both for
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved
charm and bottom effects.

The manual procedure works as follow:

1. Generate 7 theories for all the different flavor patches with command::

pineko fonll_tcards THEORY_ID

The different flavor patches are named following the convention:

* ``THEORY_ID00`` : |FFNS| :math:`n_f=3`
* ``THEORY_ID01`` : |FFN0| :math:`n_f=3`
* ``THEORY_ID02`` : massless component of |FFNS| :math:`n_f=4`
* ``THEORY_ID03`` : massive component of |FFNS| :math:`n_f=4`
* ``THEORY_ID05`` : massless component of |FFNS| :math:`n_f=5`
* ``THEORY_ID06`` : massive component of |FFNS| :math:`n_f=5`
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved

where for |FFNS| :math:`n_f=4,5` massive and massless parts are splitted to
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved
allow for a damping option.

2. Generate the grids corrisponding to all the 7 theories with the external program.
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this is a bit ugly. I understand wanting to keep things modular, but I think we should really have a step-by-step guide somewhere that explains how to use pinefarm/yadism together with pineko to create nFONLL FKtables. We will put it in the paper, but it would also be good to have it in a living document, i.e. docs, somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but this is why I wanted a single place where you can run everything...
As far as pineko is concerned we can add a link to pinefarm of pineline (although the page would be non existing yet.)


3. Generate the operator cards for each theory with the usual command.
Note that, in principle, only 3 ekos are needed, as there are only 3 different :math:`n_f` patches.
So you might speed up the procedure taking advantage of inherit-ekos.

4. Generate the ekos for each theory with the usual commands.
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved

5. Generate the FK tables each of the 7 theories with the usual commands.

6. Combine the various FK tables into a single file, using the command::

pineko combine_fonll THEORY_ID DATASET --FFNS3 THEORY_ID00 --FFN03 THEORY_ID01 --FFNS4til THEORY_ID02 --FFNS4bar THEORY_ID03 --FFN04 THEORY_ID04 --FFNS5til THEORY_ID05 --FFNS5bar THEORY_ID06

where the first 3 theories are needed to perform |FONLL| on charm effects,
while the last 4 are needed to include also bottom effects.

The automatize procedure can be faster, but it might be less flexible.
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved
In this case the workflows is:

1. Generate 7 theories for all the different flavor patches with the command::

pineko fonll_tcards THEORY_ID

See above for the intermediate theories naming convention.

2. Generate the grids corrisponding to all the 7 theories with the external program.
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved

3. Generate the ekos for only 3 theories and inherit the others running::
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved

pineko fonll_ekos THEORY_ID DATASET1 DATASET2 ...

Note: this is usually an expensive operation as multiple ekos are run sequentially.
Depending on the resources that you have available it might be more convinient
giacomomagni marked this conversation as resolved.
Show resolved Hide resolved
to call the command separately for each DATASET.

4. Generate the final |FONLL| FK table directly running::

pineko fonll_fks THEORY_ID DATASET1 DATASET2 ...


Other functionalities
---------------------

Expand Down
7 changes: 7 additions & 0 deletions docs/source/shared/abbreviations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@
.. |FFNS| replace::
:abbr:`FFNS (Fixed Flavor Number Scheme)`

.. |FFN0| replace::
:abbr:`FFN0 (Asymptotic Fixed Flavor Number Scheme)`

.. |VFNS| replace::
:abbr:`VFNS (Variable Flavor Number Scheme)`

.. |FONLL| replace::
:abbr:`FONLL (Fixed Order Next-to-Leading Log)`



.. perturbative orders
.. |LO| replace::
Expand Down
208 changes: 116 additions & 92 deletions src/pineko/cli/fonll.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import click
import rich

from .. import configs, fonll, parser, theory_card
from .. import configs, fonll, theory, theory_card
from ..fonll import TheoryCardError
from ._base import command

config_setting = click.option(
Expand All @@ -18,29 +19,13 @@
)


class TheoryCardError(Exception):
"""Raised when asked for FONLL theory cards with an original tcard as input that is not asking for FONLL."""


class InconsistentInputsError(Exception):
"""Raised if the inputs are not consistent with FONLL."""


def cfgpath(name, grid):
"""Path of the fktable in 'name' called 'grid' if it exists, else None."""
path = configs.configs["paths"]["fktables"] / name / grid
return path if path.exists() else None


def grids_names(yaml_file):
"""Return the list of the grids in the yaml file."""
yaml_content = parser._load_yaml(yaml_file)
# Turn the operands and the members into paths (and check all of them exist)
ret = []
for operand in yaml_content["operands"]:
for member in operand:
ret.append(f"{member}.{parser.EXT}")
return ret
def load_config(cfg):
"""Iterate a subcommand on a given theory and list of datasets."""
path = configs.detect(cfg)
base_configs = configs.load(path)
configs.configs = configs.defaults(base_configs)
if cfg is not None:
print(f"Configurations loaded from '{path}'")


@command.command("combine_fonll")
Expand Down Expand Up @@ -69,83 +54,122 @@ def subcommand(
cfg,
):
"""Combine the different FKs needed to produce the FONLL prescription."""
path = configs.detect(cfg)
base_configs = configs.load(path)
configs.configs = configs.defaults(base_configs)
if cfg is not None:
print(f"Configurations loaded from '{path}'")

# Checks

if not ffns3 or not ffn03:
raise InconsistentInputsError("ffns3 and/or ffn03 is not provided.")

if ffns4til is None or ffns4bar is None:
raise InconsistentInputsError(
"At least one of ffns4til and ffns4bar should be provided."
)

# Do we consider two masses, i.e. mc and mb
if any([ffns5til, ffns5bar, ffn04]):
if (ffns5til is None and ffns5bar is None) or ffn04 is None:
raise InconsistentInputsError(
"To include nf5 contributions, ffn04 and at least one between ffns5til and ffns5bar are mandatory"
)

# Get theory info
tcard = theory_card.load(theoryid)
if tcard["DAMP"] == 1:
if not "DAMPPOWERc" in tcard or not "DAMPPOWERb" in tcard:
raise InconsistentInputsError(
"If DAMP is set, set also DAMPPOWERb and DAMPPOWERc"
)
else:
tcard["DAMPPOWERb"] = 0
tcard["DAMPPOWERc"] = 0
# Getting the paths to the grids
grids_name = grids_names(configs.configs["paths"]["ymldb"] / f"{dataset}.yaml")
for grid in grids_name:
# Checking if it already exists
new_fk_path = configs.configs["paths"]["fktables"] / str(theoryid) / grid
if new_fk_path.exists():
if not overwrite:
rich.print(
f"[green]Success:[/] skipping existing FK Table {new_fk_path}"
)
return
fonll.produce_combined_fk(
*(
cfgpath(str(name), grid)
for name in (
ffns3,
ffn03,
ffns4til,
ffns4bar,
ffn04,
ffns5til,
ffns5bar,
)
),
theoryid,
damp=(tcard["DAMP"], tcard["DAMPPOWERc"], tcard["DAMPPOWERb"]),
cfg=cfg,
)
if new_fk_path.exists():
rich.print(f"[green]Success:[/] Wrote FK table to {new_fk_path}")
else:
rich.print(f"[red]Failure:[/]")
load_config(cfg)
fonll.assembly_combined_fk(
theoryid,
dataset,
ffns3,
ffn03,
ffns4til,
ffns4bar,
ffn04,
ffns5til,
ffns5bar,
overwrite,
cfg,
)


@command.command("fonll_tcards")
@click.argument("theoryID", type=int)
@config_setting
def fonll_tcards(theoryid, cfg):
"""Produce the FONLL tcards starting from the original tcard given by the theoryID."""
path = configs.detect(cfg)
base_configs = configs.load(path)
configs.configs = configs.defaults(base_configs)
load_config(cfg)

tcard = theory_card.load(theoryid)
tcard_parent_path = theory_card.path(theoryid).parent
if "FONLL" not in tcard["FNS"]:
raise TheoryCardError("The theorycard does not correspond to an FONLL scheme.")
fonll.dump_tcards(tcard, tcard_parent_path, theoryid)


@command.command("fonll_ekos")
felixhekhorn marked this conversation as resolved.
Show resolved Hide resolved
@click.argument("theoryID", type=click.INT)
@click.argument("datasets", type=click.STRING, nargs=-1)
@click.option("--overwrite", is_flag=True, help="Allow files to be overwritten")
@config_setting
def fonll_ekos(theoryid, datasets, overwrite, cfg):
"""Command to generate numerical FONLL ekos.

1. Create the 3 operator cards for the different flavor patches.
2. Run the 3 ekos for the different flavor patches.
3. Inherit the ekos.
"""
load_config(cfg)

for nf_id in ["00", "04", "05"]:
# create opcards
theory.TheoryBuilder(
f"{theoryid}{nf_id}", datasets, overwrite=overwrite
).opcards()

# run the ekos
theory.TheoryBuilder(
f"{theoryid}{nf_id}",
datasets,
silent=False,
clear_logs=True,
overwrite=overwrite,
).ekos()

# now inherit ekos
# nf=3
rich.print(f"[green] Inherit nf=3 ekos from theory {theoryid}00")
theory.TheoryBuilder(f"{theoryid}00", datasets, overwrite=overwrite).inherit_ekos(
f"{theoryid}01"
)
# nf=4
rich.print(f"[green] Inherit nf=4 ekos from theory {theoryid}04")
theory.TheoryBuilder(f"{theoryid}04", datasets, overwrite=overwrite).inherit_ekos(
f"{theoryid}02"
)
theory.TheoryBuilder(f"{theoryid}04", datasets, overwrite=overwrite).inherit_ekos(
f"{theoryid}03"
)
# nf=5
rich.print(f"[green] Inherit nf=5 ekos from theory {theoryid}05")
theory.TheoryBuilder(f"{theoryid}05", datasets, overwrite=overwrite).inherit_ekos(
f"{theoryid}06"
)


@command.command("fonll_fks")
@click.argument("theoryID", type=click.INT)
@click.argument("datasets", type=click.STRING, nargs=-1)
@click.option("--pdf", "-p", default=None, help="PDF set used for comparison")
@click.option("--overwrite", is_flag=True, help="Allow files to be overwritten")
@config_setting
def fonll_fks(theoryid, datasets, pdf, overwrite, cfg):
"""Command to generate numerical FONLL FK tables.

1. Produce the 7 FK tables needed for numerical FONLL.
2. Combine the FKtables into a single one.
"""
load_config(cfg)

# create the 7 FK tables
for th_suffix in range(0, 7):
theory.TheoryBuilder(
f"{theoryid}0{th_suffix}",
datasets,
silent=False,
clear_logs=True,
overwrite=overwrite,
).fks(pdf)

# combine
for dataset in datasets:
fonll.assembly_combined_fk(
theoryid,
dataset,
ffns3=f"{theoryid}00",
ffn03=f"{theoryid}01",
ffns4til=f"{theoryid}02",
ffns4bar=f"{theoryid}03",
ffn04=f"{theoryid}04",
ffns5til=f"{theoryid}05",
ffns5bar=f"{theoryid}06",
overwrite=overwrite,
cfg=cfg,
)
Loading
Loading