Skip to content

Commit f5a66a6

Browse files
committed
Factorize masses computation
1 parent 39dba83 commit f5a66a6

File tree

4 files changed

+60
-25
lines changed

4 files changed

+60
-25
lines changed

src/eko/io/runcards.py

+37-7
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@
1313
import numpy.typing as npt
1414

1515
from .. import basis_rotation as br
16-
from .. import interpolation
16+
from .. import interpolation, msbar_masses
1717
from .. import version as vmod
18-
from ..quantities.heavy_quarks import HeavyQuarkMasses, MatchingScales, QuarkMassScheme
18+
from ..couplings import couplings_mod_ev
19+
from ..quantities.heavy_quarks import (
20+
HeavyQuarkMasses,
21+
MatchingRatios,
22+
MatchingScales,
23+
QuarkMassScheme,
24+
)
1925
from .dictlike import DictLike
2026
from .types import (
2127
CouplingsRef,
@@ -52,11 +58,35 @@ class TheoryCard(DictLike):
5258
"""List of heavy quark masses."""
5359
quark_masses_scheme: QuarkMassScheme
5460
"""Scheme used to specify heavy quark masses."""
55-
matching: MatchingScales
61+
matching: MatchingRatios
5662
"""Matching scale of heavy quark masses"""
5763
xif: float
5864
"""Ratio between factorization scale and process scale."""
5965

66+
@property
67+
def matching_scales(self) -> MatchingScales:
68+
"""Compute matching scales."""
69+
return np.power(list(iter(self.matching)), 2.0) * np.power(
70+
list(iter(self.quark_masses)), 2.0
71+
)
72+
73+
74+
def masses(theory: TheoryCard, evmeth: EvolutionMethod):
75+
"""Compute masses in the chosen scheme."""
76+
if theory.quark_masses_scheme is QuarkMassScheme.MSBAR:
77+
return msbar_masses.compute(
78+
theory.quark_masses,
79+
theory.couplings,
80+
theory.order,
81+
couplings_mod_ev(evmeth),
82+
np.power(list(iter(theory.matching)), 2.0),
83+
xif2=theory.xif**2,
84+
).tolist()
85+
if theory.quark_masses_scheme is QuarkMassScheme.POLE:
86+
return [mq.value**2 for mq in theory.quark_masses]
87+
88+
raise ValueError(f"Unknown mass scheme '{theory.quark_masses_scheme}'")
89+
6090

6191
@dataclass
6292
class Debug(DictLike):
@@ -80,6 +110,10 @@ class Configs(DictLike):
80110
"""
81111
ev_op_iterations: int
82112
"""Number of intervals in which to break the global path."""
113+
scvar_method: Optional[ScaleVariationsMethod]
114+
""""""
115+
inversion_method: Optional[InversionMethod]
116+
"""Which method to use for backward matching conditions."""
83117
interpolation_polynomial_degree: int
84118
"""Degree of elements of the intepolation polynomial basis."""
85119
interpolation_is_log: bool
@@ -90,10 +124,6 @@ class Configs(DictLike):
90124
"""If `true` do polarized evolution."""
91125
time_like: bool
92126
"""If `true` do time-like evolution."""
93-
scvar_method: Optional[ScaleVariationsMethod]
94-
""""""
95-
inversion_method: Optional[InversionMethod]
96-
"""Which method to use for backward matching conditions."""
97127
n_integration_cores: int = 1
98128
"""Number of cores used to parallelize integration."""
99129

src/eko/quantities/heavy_quarks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import enum
44

55
from ..io.dictlike import DictLike
6-
from ..io.types import LinearScale, reference_running
6+
from ..io.types import LinearScale, SquaredScale, reference_running
77

88
FLAVORS = "cbt"
99

@@ -40,7 +40,7 @@ def __getitem__(self, key: int):
4040
QuarkMass = LinearScale
4141
QuarkMassRef = reference_running(QuarkMass)
4242
HeavyQuarkMasses = _heavy_quark(QuarkMassRef)
43-
MatchingScale = LinearScale
43+
MatchingScale = SquaredScale
4444
MatchingScales = _heavy_quark(MatchingScale)
4545
MatchingRatio = float
4646
MatchingRatios = _heavy_quark(MatchingRatio)

src/eko/runner/legacy.py

+2-16
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55

66
import numpy as np
77

8-
from .. import interpolation, msbar_masses
8+
from .. import interpolation
99
from ..couplings import Couplings, couplings_mod_ev
1010
from ..evolution_operator.grid import OperatorGrid
1111
from ..io import EKO, Operator, runcards
1212
from ..io.types import RawCard
13-
from ..quantities.heavy_quarks import QuarkMassScheme
1413
from ..thresholds import ThresholdsAtlas
1514
from . import commons
1615

@@ -62,20 +61,7 @@ def __init__(
6261
)
6362

6463
# setup the Threshold path, compute masses if necessary
65-
masses = None
66-
if new_theory.quark_masses_scheme is QuarkMassScheme.MSBAR:
67-
masses = msbar_masses.compute(
68-
new_theory.quark_masses,
69-
new_theory.couplings,
70-
new_theory.order,
71-
couplings_mod_ev(new_operator.configs.evolution_method),
72-
np.power(list(iter(new_theory.matching)), 2.0),
73-
xif2=new_theory.xif**2,
74-
).tolist()
75-
elif new_theory.quark_masses_scheme is QuarkMassScheme.POLE:
76-
masses = [mq.value**2 for mq in new_theory.quark_masses]
77-
else:
78-
raise ValueError(f"Unknown mass scheme '{new_theory.quark_masses_scheme}'")
64+
masses = runcards.masses(new_theory, new_operator.configs.evolution_method)
7965

8066
# call explicitly iter to explain the static analyzer that is an
8167
# iterable

src/eko/runner/recipes.py

+19
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
from dataclasses import dataclass
44

55
from .. import EKO
6+
from .. import scale_variations as sv
7+
from ..io import runcards
68
from ..io.dictlike import DictLike
79
from ..io.types import SquaredScale
10+
from ..thresholds import ThresholdsAtlas
811

912

1013
@dataclass
@@ -33,3 +36,19 @@ class MatchingRecipe(Recipe):
3336
def create(eko: EKO):
3437
"""Create all associated recipes."""
3538
_ = eko.theory_card.matching
39+
40+
masses = runcards.masses(
41+
eko.theory_card, eko.operator_card.configs.evolution_method
42+
)
43+
44+
tc = ThresholdsAtlas(
45+
masses=masses,
46+
q2_ref=eko.operator_card.mu20,
47+
nf_ref=eko.theory_card.num_flavs_init,
48+
thresholds_ratios=None,
49+
max_nf=eko.theory_card.num_flavs_max_pdf,
50+
)
51+
52+
for mu2 in eko.mu2grid:
53+
expanded = eko.operator_card.configs.scvar_method is sv.Modes.expanded
54+
mu2f = mu2 * eko.theory_card.xif**2 if expanded else mu2

0 commit comments

Comments
 (0)