Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions src/eko/evolution_operator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from .. import basis_rotation as br
from .. import interpolation, mellin
from .. import scale_variations as sv
from ..io.types import EvolutionMethod
from ..kernels import ev_method
from ..kernels import non_singlet as ns
from ..kernels import non_singlet_qed as qed_ns
from ..kernels import singlet as s
Expand Down Expand Up @@ -600,7 +602,7 @@ def quad_ker_qed(
return ker


class Operator(sv.ModeMixin):
class Operator(sv.ScaleVariationModeMixin):
"""Internal representation of a single EKO.

The actual matrices are computed upon calling :meth:`compute`.
Expand Down Expand Up @@ -780,6 +782,11 @@ def labels(self):
labels.extend(br.singlet_unified_labels)
return labels

@property
def ev_method(self):
"""Return the evolution method."""
return ev_method(EvolutionMethod(self.config["method"]))

def quad_ker(self, label, logx, areas):
"""Return partially initialized integrand function.

Expand All @@ -803,7 +810,7 @@ def quad_ker(self, label, logx, areas):
order=self.order,
mode0=label[0],
mode1=label[1],
method=self.config["method"],
method=self.ev_method,
is_log=self.int_disp.log,
logx=logx,
areas=areas,
Expand Down
8 changes: 4 additions & 4 deletions src/eko/evolution_operator/__init__.py.patch
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,10 @@ index 1c759c5c..5eb394d0 100644
- return ker
-
-
class Operator(sv.ModeMixin):
class Operator(sv.ScaleVariationModeMixin):
"""Internal representation of a single EKO.

@@ -780,50 +282,6 @@ class Operator(sv.ModeMixin):
@@ -780,50 +282,6 @@ class Operator(sv.ScaleVariationModeMixin):
labels.extend(br.singlet_unified_labels)
return labels

Expand Down Expand Up @@ -588,7 +588,7 @@ index 1c759c5c..5eb394d0 100644
def initialize_op_members(self):
"""Init all operators with the identity or zeros."""
eye = OpMember(
@@ -846,10 +304,7 @@ class Operator(sv.ModeMixin):
@@ -846,10 +304,7 @@ class Operator(sv.ScaleVariationModeMixin):
else:
self.op_members[n] = zero.copy()

Expand All @@ -600,7 +600,7 @@ index 1c759c5c..5eb394d0 100644
"""Run the integration for each grid point.

Parameters
@@ -864,18 +319,56 @@ class Operator(sv.ModeMixin):
@@ -864,18 +319,56 @@ class Operator(sv.ScaleVariationModeMixin):
"""
column = []
k, logx = log_grid
Expand Down
2 changes: 1 addition & 1 deletion src/eko/evolution_operator/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"""In particular, only the ``operator`` and ``error`` fields are expected."""


class OperatorGrid(sv.ModeMixin):
class OperatorGrid(sv.ScaleVariationModeMixin):
"""Collection of evolution operators for several scales.

The operator grid is the driver class of the evolution.
Expand Down
44 changes: 37 additions & 7 deletions src/eko/evolution_operator/operator_matrix_element.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""The |OME| for the non-trivial matching conditions in the |VFNS| evolution."""

import copy
import enum
import functools
import logging

Expand All @@ -20,6 +21,33 @@
logger = logging.getLogger(__name__)


class MatchingMethods(enum.IntEnum):
"""Enumerate matching methods."""

FORWARD = enum.auto()
BACKWARD_EXACT = enum.auto()
BACKWARD_EXPANDED = enum.auto()


def matching_method(s: InversionMethod) -> MatchingMethods:
"""Return the matching method.

Parameters
----------
s :
string representation

Returns
-------
i :
int representation

"""
if s is not None:
return MatchingMethods["BACKWARD_" + s.value.upper()]
return MatchingMethods.FORWARD


@nb.njit(cache=True)
def build_ome(A, matching_order, a_s, backward_method):
r"""Construct the matching expansion in :math:`a_s` with the appropriate method.
Expand All @@ -32,7 +60,7 @@ def build_ome(A, matching_order, a_s, backward_method):
perturbation matching order
a_s : float
strong coupling, needed only for the exact inverse
backward_method : InversionMethod or None
backward_method : MatchingMethods
empty or method for inverting the matching condition (exact or expanded)

Returns
Expand All @@ -51,7 +79,7 @@ def build_ome(A, matching_order, a_s, backward_method):
ome = np.eye(len(A[0]), dtype=np.complex_)
A = A[:, :, :]
A = np.ascontiguousarray(A)
if backward_method is InversionMethod.EXPANDED:
if backward_method is MatchingMethods.BACKWARD_EXPANDED:
# expended inverse
if matching_order[0] >= 1:
ome -= a_s * A[0]
Expand All @@ -68,7 +96,7 @@ def build_ome(A, matching_order, a_s, backward_method):
if matching_order[0] >= 3:
ome += a_s**3 * A[2]
# need inverse exact ? so add the missing pieces
if backward_method is InversionMethod.EXACT:
if backward_method is MatchingMethods.BACKWARD_EXACT:
ome = np.linalg.inv(ome)
return ome

Expand Down Expand Up @@ -216,7 +244,9 @@ class OperatorMatrixElement(Operator):

def __init__(self, config, managers, nf, q2, is_backward, L, is_msbar):
super().__init__(config, managers, Segment(q2, q2, nf))
self.backward_method = config["backward_inversion"] if is_backward else None
self.backward_method = matching_method(
config["backward_inversion"] if is_backward else None
)
if is_backward:
self.is_intrinsic = True
else:
Expand All @@ -241,7 +271,7 @@ def labels(self):
logger.warning("%s: skipping non-singlet sector", self.log_label)
else:
labels.append((200, 200))
if self.is_intrinsic or self.backward_method is not None:
if self.is_intrinsic or self.backward_method is not MatchingMethods.FORWARD:
# intrinsic labels, which are not zero at NLO
labels.append((br.matching_hminus_pid, br.matching_hminus_pid))
# These contributions are always 0 for the moment
Expand All @@ -257,7 +287,7 @@ def labels(self):
(br.matching_hplus_pid, 100),
]
)
if self.is_intrinsic or self.backward_method is not None:
if self.is_intrinsic or self.backward_method is not MatchingMethods.FORWARD:
labels.extend(
[
(21, br.matching_hplus_pid),
Expand Down Expand Up @@ -329,7 +359,7 @@ def compute(self):
self.log_label,
self.order[0],
self.order[1],
self.backward_method,
MatchingMethods(self.backward_method).name,
)

self.integrate()
34 changes: 34 additions & 0 deletions src/eko/kernels/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
"""The solutions to the |DGLAP| equations."""

import enum

from ..io.types import EvolutionMethod


class EvoMethods(enum.IntEnum):
"""Enumerate evolution methods."""

ITERATE_EXACT = enum.auto()
ITERATE_EXPANDED = enum.auto()
PERTURBATIVE_EXACT = enum.auto()
PERTURBATIVE_EXPANDED = enum.auto()
TRUNCATED = enum.auto()
ORDERED_TRUNCATED = enum.auto()
DECOMPOSE_EXACT = enum.auto()
DECOMPOSE_EXPANDED = enum.auto()


def ev_method(s: EvolutionMethod) -> EvoMethods:
"""Return the evolution method.

Parameters
----------
s :
string representation

Returns
-------
i :
int representation

"""
return EvoMethods[s.value.upper().replace("-", "_")]
27 changes: 14 additions & 13 deletions src/eko/kernels/non_singlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np

from .. import beta
from . import EvoMethods
from . import as4_evolution_integrals as as4_ei
from . import evolution_integrals as ei

Expand Down Expand Up @@ -355,7 +356,7 @@ def dispatcher(
----------
order : tuple(int,int)
perturbation order
method : str
method : int
method
gamma_ns : numpy.ndarray
non-singlet anomalous dimensions
Expand All @@ -378,38 +379,38 @@ def dispatcher(
# use always exact in LO
if order[0] == 1:
return lo_exact(gamma_ns, a1, a0, betalist)
if method == "ordered-truncated":
if method is EvoMethods.ORDERED_TRUNCATED:
return eko_ordered_truncated(
gamma_ns, a1, a0, betalist, order, ev_op_iterations
)
if method == "truncated":
if method is EvoMethods.TRUNCATED:
return eko_truncated(gamma_ns, a1, a0, betalist, order, ev_op_iterations)

# NLO
if order[0] == 2:
if method in [
"iterate-expanded",
"decompose-expanded",
"perturbative-expanded",
EvoMethods.ITERATE_EXPANDED,
EvoMethods.DECOMPOSE_EXPANDED,
EvoMethods.PERTURBATIVE_EXPANDED,
]:
return nlo_expanded(gamma_ns, a1, a0, betalist)
# if method in ["iterate-exact", "decompose-exact", "perturbative-exact"]:
# exact is left
return nlo_exact(gamma_ns, a1, a0, betalist)
# NNLO
if order[0] == 3:
if method in [
"iterate-expanded",
"decompose-expanded",
"perturbative-expanded",
EvoMethods.ITERATE_EXPANDED,
EvoMethods.DECOMPOSE_EXPANDED,
EvoMethods.PERTURBATIVE_EXPANDED,
]:
return nnlo_expanded(gamma_ns, a1, a0, betalist)
return nnlo_exact(gamma_ns, a1, a0, betalist)
# N3LO
if order[0] == 4:
if method in [
"iterate-expanded",
"decompose-expanded",
"perturbative-expanded",
EvoMethods.ITERATE_EXPANDED,
EvoMethods.DECOMPOSE_EXPANDED,
EvoMethods.PERTURBATIVE_EXPANDED,
]:
return n3lo_expanded(gamma_ns, a1, a0, betalist)
return n3lo_exact(gamma_ns, a1, a0, betalist)
Expand Down
4 changes: 2 additions & 2 deletions src/eko/kernels/non_singlet_qed.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def as4_exact(gamma_ns, a1, a0, beta):
@nb.njit(cache=True)
def dispatcher(
order,
method,
_method,
gamma_ns,
as_list,
aem_half,
Expand All @@ -164,7 +164,7 @@ def dispatcher(
----------
order : tuple(int,int)
perturbation order
method : str
method : int
method
gamma_ns : numpy.ndarray
non-singlet anomalous dimensions
Expand Down
19 changes: 10 additions & 9 deletions src/eko/kernels/singlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ekore import anomalous_dimensions as ad

from .. import beta
from . import EvoMethods
from . import as4_evolution_integrals as as4_ei
from . import evolution_integrals as ei

Expand Down Expand Up @@ -579,7 +580,7 @@ def dispatcher( # pylint: disable=too-many-return-statements
----------
order : tuple(int,int)
perturbative order
method : str
method : int
method
gamma_singlet : numpy.ndarray
singlet anomalous dimensions matrices
Expand Down Expand Up @@ -609,9 +610,9 @@ def dispatcher( # pylint: disable=too-many-return-statements
return lo_exact(gamma_singlet, a1, a0, betalist)

# Common method for NLO and NNLO
if method in ["iterate-exact", "iterate-expanded"]:
if method in [EvoMethods.ITERATE_EXACT, EvoMethods.ITERATE_EXPANDED]:
return eko_iterate(gamma_singlet, a1, a0, betalist, order, ev_op_iterations)
if method == "perturbative-exact":
if method is EvoMethods.PERTURBATIVE_EXACT:
return eko_perturbative(
gamma_singlet,
a1,
Expand All @@ -622,7 +623,7 @@ def dispatcher( # pylint: disable=too-many-return-statements
ev_op_max_order,
True,
)
if method == "perturbative-expanded":
if method is EvoMethods.PERTURBATIVE_EXPANDED:
return eko_perturbative(
gamma_singlet,
a1,
Expand All @@ -633,19 +634,19 @@ def dispatcher( # pylint: disable=too-many-return-statements
ev_op_max_order,
False,
)
if method in ["truncated", "ordered-truncated"]:
if method in [EvoMethods.TRUNCATED, EvoMethods.ORDERED_TRUNCATED]:
return eko_truncated(gamma_singlet, a1, a0, betalist, order, ev_op_iterations)
# These methods are scattered for nlo and nnlo
if method == "decompose-exact":
if method is EvoMethods.DECOMPOSE_EXACT:
if order[0] == 2:
return nlo_decompose_exact(gamma_singlet, a1, a0, betalist)
elif order[0] == 3:
if order[0] == 3:
return nnlo_decompose_exact(gamma_singlet, a1, a0, betalist)
return n3lo_decompose_exact(gamma_singlet, a1, a0, nf)
if method == "decompose-expanded":
if method is EvoMethods.DECOMPOSE_EXPANDED:
if order[0] == 2:
return nlo_decompose_expanded(gamma_singlet, a1, a0, betalist)
elif order[0] == 3:
if order[0] == 3:
return nnlo_decompose_expanded(gamma_singlet, a1, a0, betalist)
return n3lo_decompose_expanded(gamma_singlet, a1, a0, nf)
raise NotImplementedError("Selected method is not implemented")
Loading