From 7415aeafd02166aaa5b8e25e660b3c760ebf171f Mon Sep 17 00:00:00 2001 From: Alessandro Candido Date: Tue, 21 Nov 2023 15:14:03 +0100 Subject: [PATCH] Enforce default for matching order at post-init time --- src/eko/io/runcards.py | 50 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/eko/io/runcards.py b/src/eko/io/runcards.py index 7dbbe2b34..1fecfbc9b 100644 --- a/src/eko/io/runcards.py +++ b/src/eko/io/runcards.py @@ -1,9 +1,7 @@ """Structures to hold runcards information. -All energy scales in the runcards should be saved linearly, not the squared -value, for consistency. -Squares are consistenly taken inside. - +All energy scales in the runcards should be saved linearly, not the +squared value, for consistency. Squares are consistenly taken inside. """ from dataclasses import dataclass from math import nan @@ -48,10 +46,16 @@ class TheoryCard(DictLike): xif: float """Ratio between factorization scale and process scale.""" n3lo_ad_variation: N3LOAdVariation - """|N3LO| anomalous dimension variation: ``(gg_var, gq_var, qg_var, qq_var)``.""" + """|N3LO| anomalous dimension variation: ``(gg_var, gq_var, qg_var, + qq_var)``.""" matching_order: Optional[Order] = None """Matching conditions perturbative order tuple, ``(QCD, QED)``.""" + def __post_init__(self): + """Enforce defaults.""" + if self.matching_order is None: + self.matching_order = self.order + @dataclass class Debug(DictLike): @@ -71,6 +75,7 @@ class Configs(DictLike): """Evolution mode.""" ev_op_max_order: Order """Maximum order to use in U matrices expansion. + Used only in ``perturbative`` solutions. """ ev_op_iterations: int @@ -83,6 +88,7 @@ class Configs(DictLike): """Degree of elements of the intepolation polynomial basis.""" interpolation_is_log: bool r"""Whether to use polynomials in :math:`\log(x)`. + If `false`, polynomials are in :math:`x`. """ polarized: bool @@ -105,7 +111,8 @@ class OperatorCard(DictLike): # collections configs: Configs - """Specific configuration to be used during the calculation of these operators.""" + """Specific configuration to be used during the calculation of these + operators.""" debug: Debug """Debug configurations.""" @@ -276,7 +283,6 @@ def update(theory: Union[RawCard, TheoryCard], operator: Union[RawCard, Operator cards = update(theory, operator) assert update(*cards) == cards - """ if isinstance(theory, TheoryCard) or isinstance(operator, OperatorCard): # if one is not a dict, both have to be new cards @@ -291,13 +297,12 @@ def update(theory: Union[RawCard, TheoryCard], operator: Union[RawCard, Operator def default_atlas(masses: list, matching_ratios: list): r"""Create default landscape. - This method should not be used to write new runcards, but rather to have a - consistent default for comparison with other softwares and existing PDF - sets. - There is no one-to-one relation between number of running flavors and final - scales, unless matchings are all applied. But this is a custom choice, - since it is possible to have PDFs in different |FNS| at the same scales. - + This method should not be used to write new runcards, but rather to + have a consistent default for comparison with other softwares and + existing PDF sets. There is no one-to-one relation between number of + running flavors and final scales, unless matchings are all applied. + But this is a custom choice, since it is possible to have PDFs in + different |FNS| at the same scales. """ matchings = (np.array(masses) * np.array(matching_ratios)) ** 2 return Atlas(matchings.tolist(), (0.0, 0)) @@ -306,16 +311,15 @@ def default_atlas(masses: list, matching_ratios: list): def flavored_mugrid(mugrid: list, masses: list, matching_ratios: list): r"""Upgrade :math:`\mu^2` grid to contain also target number flavors. - It determines the number of flavors for the PDF set at the target scale, - inferring it according to the specified scales. - - This method should not be used to write new runcards, but rather to have a - consistent default for comparison with other softwares and existing PDF - sets. - There is no one-to-one relation between number of running flavors and final - scales, unless matchings are all applied. But this is a custom choice, - since it is possible to have PDFs in different |FNS| at the same scales. + It determines the number of flavors for the PDF set at the target + scale, inferring it according to the specified scales. + This method should not be used to write new runcards, but rather to + have a consistent default for comparison with other softwares and + existing PDF sets. There is no one-to-one relation between number of + running flavors and final scales, unless matchings are all applied. + But this is a custom choice, since it is possible to have PDFs in + different |FNS| at the same scales. """ atlas = default_atlas(masses, matching_ratios) return [(mu, nf_default(mu**2, atlas)) for mu in mugrid]