From 9e8d44568ae766e241da8ba17aba3b4809b97134 Mon Sep 17 00:00:00 2001 From: Radonirinaunimi Date: Mon, 21 Aug 2023 10:50:49 +0200 Subject: [PATCH 1/4] Fix polarised TMC & Add Mathematica notebook --- extras/TMC/tmc-polarised.nb | 265 ++++++++++++++++++++++++++++++++++++ src/yadism/esf/tmc.py | 102 +++++++------- 2 files changed, 317 insertions(+), 50 deletions(-) create mode 100644 extras/TMC/tmc-polarised.nb diff --git a/extras/TMC/tmc-polarised.nb b/extras/TMC/tmc-polarised.nb new file mode 100644 index 000000000..aaa956309 --- /dev/null +++ b/extras/TMC/tmc-polarised.nb @@ -0,0 +1,265 @@ +(* Content-type: application/vnd.wolfram.mathematica *) + +(*** Wolfram Notebook File ***) +(* http://www.wolfram.com/nb *) + +(* CreatedBy='Mathematica 13.1' *) + +(*CacheID: 234*) +(* Internal cache information: +NotebookFileLineBreakTest +NotebookFileLineBreakTest +NotebookDataPosition[ 158, 7] +NotebookDataLength[ 8699, 257] +NotebookOptionsPosition[ 6652, 210] +NotebookOutlinePosition[ 7047, 226] +CellTagsIndexPosition[ 7004, 223] +WindowFrame->Normal*) + +(* Beginning of Notebook Content *) +Notebook[{ + +Cell[CellGroupData[{ +Cell["Unpolarised Functions (Checks)", "Section", + CellChangeTimes->{{3.891942612667219*^9, 3.891942619980386*^9}, + 3.8919426553087873`*^9, {3.892516811557219*^9, 3.892516813458126*^9}, { + 3.90151881315241*^9, + 3.901518814149658*^9}},ExpressionUUID->"98c37df0-07d4-4c4e-9a4a-\ +43acc8561205"], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{ + RowBox[{"Integrate", "[", + RowBox[{ + FractionBox["1", + SuperscriptBox["u", "2"]], ",", + RowBox[{"{", + RowBox[{"u", ",", "\[Xi]", ",", "1"}], "}"}], ",", " ", + RowBox[{"GenerateConditions", "->", " ", "False"}]}], "]"}], "//", + "Together"}]], "Input", + CellChangeTimes->{{3.891941832062599*^9, 3.891941898524683*^9}, { + 3.891942040623999*^9, 3.8919420747225847`*^9}, {3.891942141369632*^9, + 3.8919421542366467`*^9}, {3.891942187331708*^9, 3.8919421944400454`*^9}, { + 3.891942264563486*^9, 3.891942271275709*^9}}, + CellLabel->"In[5]:=",ExpressionUUID->"8e026d2d-9a30-48f3-85c2-9148babf0736"], + +Cell[BoxData[ + FractionBox[ + RowBox[{"1", "-", "\[Xi]"}], "\[Xi]"]], "Output", + CellChangeTimes->{{3.891941890036215*^9, 3.891941899479545*^9}, + 3.891942080009358*^9, 3.891942191152946*^9, 3.891942272600092*^9}, + CellLabel->"Out[5]=",ExpressionUUID->"4865a70c-5164-4263-a65b-c42f01f01439"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"Integrate", "[", + RowBox[{ + RowBox[{ + RowBox[{"(", + RowBox[{"u", "-", "\[Xi]"}], ")"}], + FractionBox["1", + SuperscriptBox["u", "2"]]}], ",", + RowBox[{"{", + RowBox[{"u", ",", "\[Xi]", ",", "1"}], "}"}], ",", + RowBox[{"GenerateConditions", "->", "False"}]}], "]"}]], "Input", + CellChangeTimes->{{3.891942290828051*^9, 3.891942312163238*^9}}, + CellLabel->"In[6]:=",ExpressionUUID->"f5448ba8-7182-4134-a81a-f67c7a767df4"], + +Cell[BoxData[ + RowBox[{ + RowBox[{"-", "1"}], "+", "\[Xi]", "-", + RowBox[{"Log", "[", "\[Xi]", "]"}]}]], "Output", + CellChangeTimes->{3.891942313093822*^9}, + CellLabel->"Out[6]=",ExpressionUUID->"bc225ade-0788-4fcd-8812-eedbd1129674"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"Integrate", "[", + RowBox[{ + RowBox[{ + RowBox[{"(", + FractionBox[ + RowBox[{"x", "+", "\[Xi]"}], "\[Xi]"], ")"}], + RowBox[{"(", + RowBox[{"u", "-", "\[Xi]"}], ")"}], + FractionBox["1", + SuperscriptBox["u", "2"]]}], ",", + RowBox[{"{", + RowBox[{"u", ",", "\[Xi]", ",", "1"}], "}"}], ",", + RowBox[{"GenerateConditions", "->", "False"}]}], "]"}]], "Input", + CellChangeTimes->{{3.891942404997665*^9, 3.8919424295571127`*^9}}, + CellLabel->"In[8]:=",ExpressionUUID->"92dd93ca-0849-40d0-ae77-c7cd7e9ff6ad"], + +Cell[BoxData[ + FractionBox[ + RowBox[{ + RowBox[{"(", + RowBox[{"x", "+", "\[Xi]"}], ")"}], " ", + RowBox[{"(", + RowBox[{ + RowBox[{"-", "1"}], "+", "\[Xi]", "-", + RowBox[{"Log", "[", "\[Xi]", "]"}]}], ")"}]}], "\[Xi]"]], "Output", + CellChangeTimes->{3.891942430581559*^9}, + CellLabel->"Out[8]=",ExpressionUUID->"6aeeba22-5377-4bbe-8e57-ffac9c8e9178"] +}, Open ]] +}, Open ]], + +Cell[CellGroupData[{ + +Cell["Polarised Functions", "Section", + CellChangeTimes->{{3.891942612667219*^9, 3.891942619980386*^9}, + 3.8919426553087873`*^9},ExpressionUUID->"780617a0-a13e-446e-a41f-\ +794ebc9e0101"], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"Integrate", "[", + RowBox[{ + RowBox[{"Log", "[", + FractionBox["u", "\[Xi]"], "]"}], ",", + RowBox[{"{", + RowBox[{"u", ",", "\[Xi]", ",", "1"}], "}"}], ",", + RowBox[{"GenerateConditions", "->", "False"}]}], "]"}]], "Input", + CellChangeTimes->{{3.8919425637989187`*^9, 3.891942579222939*^9}}, + CellLabel->"In[9]:=",ExpressionUUID->"3943c43c-e295-47a3-8de4-4e289e870625"], + +Cell[BoxData[ + RowBox[{ + RowBox[{"-", "1"}], "+", "\[Xi]", "+", + RowBox[{"Log", "[", + FractionBox["1", "\[Xi]"], "]"}]}]], "Output", + CellChangeTimes->{3.8919425822250967`*^9}, + CellLabel->"Out[9]=",ExpressionUUID->"c781e1f5-c759-4434-a46a-fbbbe6550643"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"Integrate", "[", + RowBox[{"1", ",", + RowBox[{"{", + RowBox[{"u", ",", "\[Xi]", ",", "1"}], "}"}], ",", + RowBox[{"GenerateConditions", "->", "False"}]}], "]"}]], "Input", + CellChangeTimes->{{3.8919423299320927`*^9, 3.891942339866638*^9}}, + CellLabel->"In[7]:=",ExpressionUUID->"77b044a9-7991-4cff-bf51-d55516c4bda3"], + +Cell[BoxData[ + RowBox[{"1", "-", "\[Xi]"}]], "Output", + CellChangeTimes->{3.891942340546136*^9}, + CellLabel->"Out[7]=",ExpressionUUID->"a84ae7c7-89f7-4c52-8b8b-e2a1abfdbcb4"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"Integrate", "[", + RowBox[{ + RowBox[{ + FractionBox["1", "u"], + RowBox[{"Log", "[", + FractionBox["u", "\[Xi]"], "]"}]}], ",", + RowBox[{"{", + RowBox[{"u", ",", "\[Xi]", ",", "1"}], "}"}], ",", + RowBox[{"GenerateConditions", "->", "False"}]}], "]"}]], "Input", + CellChangeTimes->{{3.901518922183077*^9, 3.901518929858604*^9}}, + CellLabel->"In[1]:=",ExpressionUUID->"c5f88b03-cbba-421b-93d7-d27eb5daa2a8"], + +Cell[BoxData[ + RowBox[{ + FractionBox["1", "2"], " ", + SuperscriptBox[ + RowBox[{"Log", "[", + FractionBox["1", "\[Xi]"], "]"}], "2"]}]], "Output", + CellChangeTimes->{3.901518940734714*^9}, + CellLabel->"Out[1]=",ExpressionUUID->"84113684-a972-408f-809f-45357f5024a3"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"Integrate", "[", + RowBox[{ + RowBox[{ + FractionBox["1", + SuperscriptBox["u", "2"]], + RowBox[{"Log", "[", + FractionBox["u", "\[Xi]"], "]"}]}], ",", + RowBox[{"{", + RowBox[{"u", ",", "\[Xi]", ",", "1"}], "}"}], ",", + RowBox[{"GenerateConditions", "->", "False"}]}], "]"}]], "Input", + CellChangeTimes->{{3.901533073319585*^9, 3.9015330763135347`*^9}}, + CellLabel->"In[2]:=",ExpressionUUID->"3f636281-ff2b-4641-b401-94e302e4232b"], + +Cell[BoxData[ + RowBox[{ + RowBox[{"-", "1"}], "+", + FractionBox["1", "\[Xi]"], "-", + RowBox[{"Log", "[", + FractionBox["1", "\[Xi]"], "]"}]}]], "Output", + CellChangeTimes->{3.901533077931086*^9}, + CellLabel->"Out[2]=",ExpressionUUID->"d77d09b8-a6f8-4c99-8eec-d760751af40e"] +}, Open ]] +}, Open ]] +}, +WindowSize->{1766, 948}, +WindowMargins->{{118, Automatic}, {Automatic, 23}}, +FrontEndVersion->"13.1 for Mac OS X x86 (64-bit) (June 16, 2022)", +StyleDefinitions->"Default.nb", +ExpressionUUID->"e912fce0-65d1-4e83-8d14-119a80577b85" +] +(* End of Notebook Content *) + +(* Internal cache information *) +(*CellTagsOutline +CellTagsIndex->{} +*) +(*CellTagsIndex +CellTagsIndex->{} +*) +(*NotebookFileOutline +Notebook[{ +Cell[CellGroupData[{ +Cell[580, 22, 299, 5, 67, "Section",ExpressionUUID->"98c37df0-07d4-4c4e-9a4a-43acc8561205"], +Cell[CellGroupData[{ +Cell[904, 31, 645, 14, 50, "Input",ExpressionUUID->"8e026d2d-9a30-48f3-85c2-9148babf0736"], +Cell[1552, 47, 293, 5, 51, "Output",ExpressionUUID->"4865a70c-5164-4263-a65b-c42f01f01439"] +}, Open ]], +Cell[CellGroupData[{ +Cell[1882, 57, 472, 12, 50, "Input",ExpressionUUID->"f5448ba8-7182-4134-a81a-f67c7a767df4"], +Cell[2357, 71, 236, 5, 34, "Output",ExpressionUUID->"bc225ade-0788-4fcd-8812-eedbd1129674"] +}, Open ]], +Cell[CellGroupData[{ +Cell[2630, 81, 563, 15, 50, "Input",ExpressionUUID->"92dd93ca-0849-40d0-ae77-c7cd7e9ff6ad"], +Cell[3196, 98, 369, 10, 51, "Output",ExpressionUUID->"6aeeba22-5377-4bbe-8e57-ffac9c8e9178"] +}, Open ]] +}, Open ]], +Cell[CellGroupData[{ +Cell[3614, 114, 189, 3, 67, "Section",ExpressionUUID->"780617a0-a13e-446e-a41f-794ebc9e0101"], +Cell[CellGroupData[{ +Cell[3828, 121, 408, 9, 47, "Input",ExpressionUUID->"3943c43c-e295-47a3-8de4-4e289e870625"], +Cell[4239, 132, 260, 6, 51, "Output",ExpressionUUID->"c781e1f5-c759-4434-a46a-fbbbe6550643"] +}, Open ]], +Cell[CellGroupData[{ +Cell[4536, 143, 350, 7, 30, "Input",ExpressionUUID->"77b044a9-7991-4cff-bf51-d55516c4bda3"], +Cell[4889, 152, 174, 3, 34, "Output",ExpressionUUID->"a84ae7c7-89f7-4c52-8b8b-e2a1abfdbcb4"] +}, Open ]], +Cell[CellGroupData[{ +Cell[5100, 160, 450, 11, 49, "Input",ExpressionUUID->"c5f88b03-cbba-421b-93d7-d27eb5daa2a8"], +Cell[5553, 173, 273, 7, 51, "Output",ExpressionUUID->"84113684-a972-408f-809f-45357f5024a3"] +}, Open ]], +Cell[CellGroupData[{ +Cell[5863, 185, 479, 12, 50, "Input",ExpressionUUID->"3f636281-ff2b-4641-b401-94e302e4232b"], +Cell[6345, 199, 279, 7, 74, "Output",ExpressionUUID->"d77d09b8-a6f8-4c99-8eec-d760751af40e"] +}, Open ]] +}, Open ]] +} +] +*) + diff --git a/src/yadism/esf/tmc.py b/src/yadism/esf/tmc.py index 83e1ad543..1b0662daf 100644 --- a/src/yadism/esf/tmc.py +++ b/src/yadism/esf/tmc.py @@ -47,16 +47,14 @@ def g2_ker(z, _args): @nb.njit("f8(f8,f8[:])", cache=True) -def k1_ker(_z, _args): +def h3_ker(_z, _args): return 1 @nb.njit("f8(f8,f8[:])", cache=True) -def k2_ker(z, _args): - return np.log(1 / z) - - -h3_ker = k1_ker +def k2_ker(z, args): + xi = args[0] + return z * np.log(1 / z) / xi class EvaluatedStructureFunctionTMC(abc.ABC): @@ -295,26 +293,6 @@ def _g2(self): # as we get a 1/z by the measure and an evaluation of 1-xi/z return self._convolute_FX("F2", g2_ker) - def _k1(self): - r""" - Compute the raw integral that enters the computation of `g` - making use of :py:meth:`_convolute_FX`. - - .. math:: - :nowrap: - - \begin{align*} - k_1(\xi,Q^2) &= \int_\xi^1 du \frac{g_1(u,Q^2)}{u}\\ - \end{align*} - - Returns - ------- - k1 : dict - ESF output for the integral - - """ - return self._convolute_FX("g1", k1_ker) - def _k2(self): r""" Compute the raw integral that enters the computation of `g` @@ -557,48 +535,72 @@ class ESFTMC_g1(EvaluatedStructureFunctionTMC): def __init__(self, SF, kinematics): super().__init__(SF, kinematics) - # Kinematic factor for ZM g1 - self._factor_shifted = self.x**2 / (self.xi * self.rho**3) + # Kinematic factor for ZM g1. Must be divided by `2\xi` to undo def. + self._factor_shifted = self.x / (self.xi * self.rho**3) / 2 / self.xi # Kinematic factor for common for `k1` & `k2` integral - self._factor_k1_k2 = (4 * self.x**2 * self.mu) / self.rho**3 + self._factor_k1_k2 = (4 * self.x**2 * self.mu) / self.rho**4 + + # Extra (1/2) appears when undoing the `2x` in the definition. # Kinematic factor specific for `k1` integral - self._factor_k1 = (self.x + self.xi) / self.xi + self._factor_k1 = (self.x + self.xi) / self.xi / 2 # Kinematic factor specific for `k2` integral - self._factor_k2 = (self.rho**2 - 3) / (2 * self.rho) + self._factor_k2 = (self.rho**2 - 3) / (2 * self.rho) / 2 def _get_result_approx(self): - # NOTE: The approximations are evaluated at the lower - # integral limit; ie by integrating the factors of `g1^0` - approx_k1 = 1 - self.xi - approx_k2 = self.xi - 1 - np.log(self.xi) - # collect g1 results + # Collect g1 result. g1out = self.sf.get_esf(self.sf.obs_name, self._shifted_kinematics).get_result() - # Combine the expressions - return g1out * ( - self._factor_shifted - + self._factor_k1_k2 - * (self._factor_k1 * approx_k1 + self._factor_k2 * approx_k2) + + # NOTE: The approximations are evaluated at the lower integral + # limit; ie by integrating the factors of `g1^0` from xi to 1. + # (1/2) appears when undoing the `2x` in the definition. + approx_k1 = (1 - self.xi) / self.xi + approx_k2 = 1 / self.xi - 1 + np.log(self.xi) + + # Combine the expressions and putting back `2\xi` + return ( + 2 + * self.xi + * ( + self._factor_shifted * g1out + + self._factor_k1_k2 + * (self._factor_k1 * approx_k1 + self._factor_k2 * approx_k2) + ) ) def _get_result_exact(self): - # collect g1 results + # Collect g1 result. g1out = self.sf.get_esf(self.sf.obs_name, self._shifted_kinematics).get_result() + # Call to the raw integrals - k1out = self._k1() + k1out = self._h2() k2out = self._k2() - # Combine the expressions - return self._factor_shifted * g1out + self._factor_k1_k2 * ( - self._factor_k1 * k1out + self._factor_k2 * k2out + + # Combine the expressions and putting back `2\xi` + return ( + 2 + * self.xi + * ( + self._factor_shifted * g1out + + self._factor_k1_k2 + * (self._factor_k1 * k1out + self._factor_k2 * k2out) + ) ) def _get_result_APFEL(self): - # collect g1 results + # Collect g1 result. g1out = self.sf.get_esf(self.sf.obs_name, self._shifted_kinematics).get_result() + # Call to the raw integrals - k1out = self._k1() - # Combine the expressions + k1out = self._h2() + + # Combine the expressions and putting back `2\xi` return ( - self._factor_shifted * g1out + self._factor_k1_k2 * self._factor_k1 * k1out + 2 + * self.xi + * ( + self._factor_shifted * g1out + + self._factor_k1_k2 * self._factor_k1 * k1out + ) ) From d9b6f7260db3f9b2a94fa5126560d7937f7a6223 Mon Sep 17 00:00:00 2001 From: Radonirinaunimi Date: Mon, 21 Aug 2023 11:03:15 +0200 Subject: [PATCH 2/4] Fix equation in documentation --- src/yadism/esf/tmc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/yadism/esf/tmc.py b/src/yadism/esf/tmc.py index 1b0662daf..59667491e 100644 --- a/src/yadism/esf/tmc.py +++ b/src/yadism/esf/tmc.py @@ -303,10 +303,10 @@ def _k2(self): \begin{align*} k_2(\xi,Q^2) &= \int_\xi^1 du \log(\frac{u}{\xi}) - \frac{g_1(u,Q^2)}{u}\\ + \frac{g_1(u,Q^2)}{u^2}\\ &= - \int_\xi^1 du \log(\frac{\xi}{u}) - \frac{g_1(u,Q^2)}{u}\\ - &= ((z\to -\log(z)) \otimes g_1(z))(\xi) + \frac{g_1(u,Q^2)}{u^2}\\ + &= ((z\to - \frac{z}{\xi} \log(z)) \otimes g_1(z))(\xi) \end{align*} Returns From 6f55294c58839162423889a9f949a5559fd91641 Mon Sep 17 00:00:00 2001 From: Radonirinaunimi Date: Thu, 24 Aug 2023 23:24:29 +0200 Subject: [PATCH 3/4] Fix tiny typo --- src/yadism/esf/tmc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/yadism/esf/tmc.py b/src/yadism/esf/tmc.py index 59667491e..e2822e235 100644 --- a/src/yadism/esf/tmc.py +++ b/src/yadism/esf/tmc.py @@ -557,15 +557,16 @@ def _get_result_approx(self): approx_k2 = 1 / self.xi - 1 + np.log(self.xi) # Combine the expressions and putting back `2\xi` - return ( + factors = ( 2 * self.xi * ( - self._factor_shifted * g1out + self._factor_shifted + self._factor_k1_k2 * (self._factor_k1 * approx_k1 + self._factor_k2 * approx_k2) ) ) + return factors * g1out def _get_result_exact(self): # Collect g1 result. From 08a0e2d5453078f49550a855304ecf77f5949bfd Mon Sep 17 00:00:00 2001 From: Radonirinaunimi Date: Tue, 17 Oct 2023 13:08:12 +0200 Subject: [PATCH 4/4] Re-direct h2 to k1 for g TMC --- src/yadism/esf/tmc.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/yadism/esf/tmc.py b/src/yadism/esf/tmc.py index e2822e235..da7b67f5a 100644 --- a/src/yadism/esf/tmc.py +++ b/src/yadism/esf/tmc.py @@ -293,6 +293,20 @@ def _g2(self): # as we get a 1/z by the measure and an evaluation of 1-xi/z return self._convolute_FX("F2", g2_ker) + def _k1(self): + r""" + Compute the raw integral that enters the computation of `g`. + + The form of the integrall is exactly the same as for `h2`. + + Returns + ------- + k1 : dict + ESF output for the integral + + """ + return self._h2() + def _k2(self): r""" Compute the raw integral that enters the computation of `g` @@ -573,7 +587,7 @@ def _get_result_exact(self): g1out = self.sf.get_esf(self.sf.obs_name, self._shifted_kinematics).get_result() # Call to the raw integrals - k1out = self._h2() + k1out = self._k1() k2out = self._k2() # Combine the expressions and putting back `2\xi`