Skip to content

Commit

Permalink
make ekos working
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomomagni committed Jun 4, 2024
1 parent ba90fea commit 95a157c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 37 deletions.
10 changes: 5 additions & 5 deletions src/pineko/evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def get_ekos_convolution_type(kv):
pineappl grid metadata
"""
if "convolution_type_1" in kv:
eko1 = kv["convolution_type_1"]
conv_type_1 = kv["convolution_type_1"]
# TODO: this case is now deprecated and should be remved from yadism and pinefarm
elif "polarized" in kv and kv["polarized"]:
eko1 = "polPDF"
conv_type_1 = "polPDF"
else:
eko1 = "PDF"
eko2 = kv.get("convolution_type_2", "PDF")
return eko1, eko2
conv_type_1 = "PDF"
conv_type_2 = kv.get("convolution_type_2", "PDF")
return conv_type_1, conv_type_2


def write_operator_card_from_file(
Expand Down
75 changes: 43 additions & 32 deletions src/pineko/theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def activate_logging(self, path, filename, activated_loggers=()):
logger_.setLevel(logging.INFO)
return True

def eko(self, name, _grid, tcard):
def eko(self, name, grid, tcard):
"""Compute a single eko.
Parameters
Expand All @@ -320,37 +320,48 @@ def eko(self, name, _grid, tcard):
paths["logs"]["eko"], f"{self.theory_id}-{name}.log", ("eko",)
)
# setup data
ocard = self.load_operator_card(name)
# For nFONLL mixed prescriptions (such as FONLL-B) the PTO written on
# the tcard is used to produce the grid by yadism and it might be different
# from the PTO needed for the PDF evolution (and so by EKO). Here we
# ensure that the PTO used in the EKO calculation reflects the real
# perturbative order of the prescription.
if "PTOEKO" in tcard:
tcard["PTO"] = tcard["PTOEKO"]
# The operator card has been already generated in the correct format
# The theory card needs to be converted to a format that eko can use
legacy_class = eko.io.runcards.Legacy(tcard, ocard)
new_theory = legacy_class.new_theory
new_op = eko.io.runcards.OperatorCard.from_dict(ocard)
eko_filename = self.ekos_path() / f"{name}.tar"
if eko_filename.exists():
if not self.overwrite:
rich.print(f"Skipping existing operator {eko_filename}")
return
eko_filename.unlink()
# do it!
logger.info("Start computation of %s", name)
start_time = time.perf_counter()
# Actual computation of the EKO
solve(new_theory, new_op, eko_filename)
logger.info(
"Finished computation of %s - took %f s",
name,
time.perf_counter() - start_time,
)
if eko_filename.exists():
rich.print(f"[green]Success:[/] Wrote EKO to {eko_filename}")
grid_kv = pineappl.grid.Grid.read(grid).key_values()
conv_type_a, conv_type_b = evolve.get_ekos_convolution_type(grid_kv)
if conv_type_a == conv_type_b:
names = [name]
else:
names = [
f"{name}_{conv_type_a}",
f"{name}_{conv_type_b}",
]

for name in names:
ocard = self.load_operator_card(name)
# For nFONLL mixed prescriptions (such as FONLL-B) the PTO written on
# the tcard is used to produce the grid by yadism and it might be different
# from the PTO needed for the PDF evolution (and so by EKO). Here we
# ensure that the PTO used in the EKO calculation reflects the real
# perturbative order of the prescription.
if "PTOEKO" in tcard:
tcard["PTO"] = tcard["PTOEKO"]
# The operator card has been already generated in the correct format
# The theory card needs to be converted to a format that eko can use
legacy_class = eko.io.runcards.Legacy(tcard, ocard)
new_theory = legacy_class.new_theory
new_op = eko.io.runcards.OperatorCard.from_dict(ocard)
eko_filename = self.ekos_path() / f"{name}.tar"
if eko_filename.exists():
if not self.overwrite:
rich.print(f"Skipping existing operator {eko_filename}")
return
eko_filename.unlink()
# do it!
logger.info("Start computation of %s", name)
start_time = time.perf_counter()
# Actual computation of the EKO
solve(new_theory, new_op, eko_filename)
logger.info(
"Finished computation of %s - took %f s",
name,
time.perf_counter() - start_time,
)
if eko_filename.exists():
rich.print(f"[green]Success:[/] Wrote EKO to {eko_filename}")

def ekos(self):
"""Compute all ekos."""
Expand Down

0 comments on commit 95a157c

Please sign in to comment.