Ejemplo n.º 1
0
 def benchmark_APFEL_vfns_threshold(self):
     Q2s = np.power([30, 96, 150], 2)
     alphas_ref = 0.118
     scale_ref = 91.0 ** 2
     threshold_list = np.power([30, 95, 240], 2)
     thresholds_ratios = np.power((2.34, 1.0, 0.5), 2)
     apfel_vals_dict = {
         1: np.array(
             [0.011543349125207046, 0.00930916017456183, 0.008683622955304702]
         ),
         2: np.array(
             [0.011530819844835012, 0.009312638352288492, 0.00867793622077099]
         ),
     }
     # collect my values
     for order in [1, 2]:
         as_VFNS = StrongCoupling(
             alphas_ref,
             scale_ref,
             threshold_list,
             thresholds_ratios,
             order=order,
             method="expanded",
         )
         my_vals = []
         for Q2 in Q2s:
             print(Q2)
             my_vals.append(as_VFNS.a_s(Q2))
         # get APFEL numbers - if available else use cache
         apfel_vals = apfel_vals_dict[order]
         if use_APFEL:
             # run apfel
             apfel.CleanUp()
             apfel.SetTheory("QCD")
             apfel.SetPerturbativeOrder(order)
             apfel.SetAlphaEvolution("expanded")
             apfel.SetAlphaQCDRef(alphas_ref, np.sqrt(scale_ref))
             apfel.SetVFNS()
             apfel.SetPoleMasses(*np.sqrt(threshold_list))
             apfel.SetMassMatchingScales(*np.sqrt(thresholds_ratios))
             apfel.SetRenFacRatio(1)
             apfel.InitializeAPFEL()
             # collect a_s
             apfel_vals_cur = []
             for Q2 in Q2s:
                 apfel_vals_cur.append(apfel.AlphaQCD(np.sqrt(Q2)) / (4.0 * np.pi))
             print(apfel_vals_cur)
             np.testing.assert_allclose(apfel_vals, np.array(apfel_vals_cur))
         # check myself to APFEL
         np.testing.assert_allclose(apfel_vals, np.array(my_vals))
Ejemplo n.º 2
0
 def test_labels(self):
     # setup objs
     theory_card = {
         "alphas": 0.35,
         "PTO": 0,
         "ModEv": "TRN",
         "fact_to_ren_scale_ratio": 1.0,
         "Qref": np.sqrt(2),
         "nfref": None,
         "Q0": np.sqrt(2),
         "NfFF": 3,
         "IC": 1,
         "IB": 0,
         "mc": 1.0,
         "mb": 4.75,
         "mt": 173.0,
         "kcThr": np.inf,
         "kbThr": np.inf,
         "ktThr": np.inf,
         "MaxNfPdf": 6,
         "MaxNfAs": 6,
     }
     for skip_singlet in [True, False]:
         for skip_ns in [True, False]:
             operators_card = {
                 "Q2grid": [1, 10],
                 "interpolation_xgrid": [0.1, 1.0],
                 "interpolation_polynomial_degree": 1,
                 "interpolation_is_log": True,
                 "debug_skip_singlet": skip_singlet,
                 "debug_skip_non_singlet": skip_ns,
                 "ev_op_max_order": 1,
                 "ev_op_iterations": 1,
                 "backward_inversion": "exact",
             }
             g = OperatorGrid.from_dict(
                 theory_card,
                 operators_card,
                 ThresholdsAtlas.from_dict(theory_card),
                 StrongCoupling.from_dict(theory_card),
                 InterpolatorDispatcher.from_dict(operators_card),
             )
             o = OperatorMatrixElement(g.config, g.managers, 10)
             labels = o.labels()
             test_labels = ["NS_qq", "NS_Hq"]
             for l in test_labels:
                 if skip_ns:
                     assert l not in labels
                 else:
                     assert l in labels
             test_labels = ["S_qq", "S_Hq", "S_gg", "S_Hg", "S_gH"]
             for l in test_labels:
                 if skip_singlet:
                     assert l not in labels
                 else:
                     assert l in labels
Ejemplo n.º 3
0
 def test_a_s(self):
     """Tests the value of alpha_s (for now only at LO)
     for a given set of parameters
     """
     # TODO @JCM: we need a source for this!
     known_val = 0.0091807954
     ref_alpha_s = 0.1181
     ref_mu2 = 90
     ask_q2 = 125
     as_FFNS_LO = StrongCoupling(
         ref_alpha_s, ref_mu2, [0, 0, np.inf], (1.0, 1.0, 1.0), order=0
     )
     # check local
     np.testing.assert_approx_equal(
         as_FFNS_LO.a_s(ref_mu2), ref_alpha_s / 4.0 / np.pi
     )
     # check high
     result = as_FFNS_LO.a_s(ask_q2)
     np.testing.assert_approx_equal(result, known_val, significant=7)
Ejemplo n.º 4
0
 def benchmark_lhapdf_ffns_lo(self):
     """test FFNS LO towards LHAPDF"""
     Q2s = [1, 1e1, 1e2, 1e3, 1e4]
     alphas_ref = 0.118
     scale_ref = 91.0 ** 2
     nf = 4
     # collect my values
     threshold_holder = thresholds.ThresholdsAtlas.ffns(nf)
     as_FFNS_LO = StrongCoupling(
         alphas_ref,
         scale_ref,
         threshold_holder.area_walls[1:-1],
         (1.0, 1.0, 1.0),
         order=0,
     )
     my_vals = []
     for Q2 in Q2s:
         my_vals.append(as_FFNS_LO.a_s(Q2))
     # get LHAPDF numbers - if available else use cache
     lhapdf_vals = np.array(
         [
             0.031934929816669545,
             0.019801241565290697,
             0.01434924187307247,
             0.01125134004424113,
             0.009253560493881005,
         ]
     )
     if use_LHAPDF:
         # run lhapdf
         as_lhapdf = lhapdf.mkBareAlphaS("analytic")
         as_lhapdf.setOrderQCD(1)
         as_lhapdf.setFlavorScheme("FIXED", nf)
         Lambda2 = self._get_Lambda2_LO(alphas_ref / (4.0 * np.pi), scale_ref, nf)
         as_lhapdf.setLambda(nf, np.sqrt(Lambda2))
         # collect a_s
         lhapdf_vals_cur = []
         for Q2 in Q2s:
             lhapdf_vals_cur.append(as_lhapdf.alphasQ2(Q2) / (4.0 * np.pi))
         # print(lhapdf_vals_cur)
         np.testing.assert_allclose(lhapdf_vals, np.array(lhapdf_vals_cur))
     # check myself to LHAPDF
     np.testing.assert_allclose(lhapdf_vals, np.array(my_vals), rtol=5e-4)
Ejemplo n.º 5
0
 def _get_operator_grid(self, use_FFNS=True):
     theory_card, operators_card = self._get_setup(use_FFNS)
     # create objects
     basis_function_dispatcher = interpolation.InterpolatorDispatcher.from_dict(
         operators_card)
     threshold_holder = ThresholdsAtlas.from_dict(theory_card)
     a_s = StrongCoupling.from_dict(theory_card)
     return OperatorGrid.from_dict(
         theory_card,
         operators_card,
         threshold_holder,
         a_s,
         basis_function_dispatcher,
     )
Ejemplo n.º 6
0
 def test_ref(self):
     # prepare
     thresh_setups = [
         (np.inf, np.inf, np.inf),
         (0, np.inf, np.inf),
         (2, 4, 175),
     ]
     alphas_ref = 0.118
     scale_ref = 91.0**2
     for thresh_setup in thresh_setups:
         for order in [0, 1, 2]:
             for method in ["exact", "expanded"]:
                 # create
                 sc = StrongCoupling(
                     alphas_ref,
                     scale_ref,
                     thresh_setup,
                     (1.0, 1.0, 1.0),
                     order,
                     method,
                 )
                 np.testing.assert_approx_equal(sc.a_s(scale_ref),
                                                alphas_ref / 4.0 / np.pi)
Ejemplo n.º 7
0
 def test_sanity(self):
     """Sanity checks for the input"""
     # errors
     with pytest.raises(ValueError):
         theory_card, operators_card = self._get_setup(True)
         basis_function_dispatcher = interpolation.InterpolatorDispatcher.from_dict(
             operators_card)
         threshold_holder = ThresholdsAtlas.from_dict(theory_card)
         a_s = StrongCoupling.from_dict(theory_card)
         theory_card.update({"ModEv": "wrong"})
         OperatorGrid.from_dict(
             theory_card,
             operators_card,
             threshold_holder,
             a_s,
             basis_function_dispatcher,
         )
Ejemplo n.º 8
0
 def test_from_dict(self):
     d = {
         "alphas": 0.118,
         "Qref": 91.0,
         "nfref": None,
         "Q0": 1,
         "PTO": 0,
         "ModEv": "EXA",
         "fact_to_ren_scale_ratio": 1.0,
         "mc": 2.0,
         "mb": 4.0,
         "mt": 175.0,
         "kcThr": 1.0,
         "kbThr": 1.0,
         "ktThr": 1.0,
         "MaxNfAs": 6,
     }
     sc = StrongCoupling.from_dict(d)
     assert sc.a_s(d["Qref"]**2) == d["alphas"] / (4.0 * np.pi)
Ejemplo n.º 9
0
 def benchmark_LHA_paper(self):
     """Check to :cite:`Giele:2002hx` and :cite:`Dittmar:2005ed`"""
     # LO - FFNS
     # note that the LO-FFNS value reported in :cite:`Giele:2002hx`
     # was corrected in :cite:`Dittmar:2005ed`
     as_FFNS_LO = StrongCoupling(
         0.35, 2, (0, np.inf, np.inf), (1.0, 1.0, 1.0), order=0
     )
     me = as_FFNS_LO.a_s(1e4) * 4 * np.pi
     ref = 0.117574
     np.testing.assert_approx_equal(me, ref, significant=6)
     # LO - VFNS
     threshold_list = [2, pow(4.5, 2), pow(175, 2)]
     as_VFNS_LO = StrongCoupling(0.35, 2, threshold_list, (1.0, 1.0, 1.0), order=0)
     me = as_VFNS_LO.a_s(1e4) * 4 * np.pi
     ref = 0.122306
     np.testing.assert_approx_equal(me, ref, significant=6)
Ejemplo n.º 10
0
 def test_exact_LO(self):
     # prepare
     thresh_setups = [
         (np.inf, np.inf, np.inf),
         (0, np.inf, np.inf),
         (2, 4, 175),
     ]
     alphas_ref = 0.118
     scale_ref = 91.0**2
     for thresh_setup in thresh_setups:
         # in LO expanded  = exact
         sc_expanded = StrongCoupling(alphas_ref, scale_ref, thresh_setup,
                                      (1.0, 1.0, 1.0), 0, "expanded")
         sc_exact = StrongCoupling(alphas_ref, scale_ref, thresh_setup,
                                   (1.0, 1.0, 1.0), 0, "exact")
         for q2 in [1, 1e1, 1e2, 1e3, 1e4]:
             np.testing.assert_allclose(sc_expanded.a_s(q2),
                                        sc_exact.a_s(q2),
                                        rtol=5e-4)
Ejemplo n.º 11
0
 def benchmark_APFEL_ffns(self):
     Q2s = [1e1, 1e2, 1e3, 1e4]
     alphas_ref = 0.118
     scale_ref = 91.0 ** 2
     nf = 4
     apfel_vals_dict = {
         0: np.array(
             [
                 0.01980124164841284,
                 0.014349241933308077,
                 0.01125134009147229,
                 0.009253560532725833,
             ]
         ),
         1: np.array(
             [
                 0.021603236069744878,
                 0.014887068327193985,
                 0.01139235082295531,
                 0.009245832041857378,
             ]
         ),
         2: np.array(
             [
                 0.02204088975651748,
                 0.014966690529271008,
                 0.011406500825908607,
                 0.009245271638953058,
             ]
         ),
     }
     # collect my values
     threshold_holder = thresholds.ThresholdsAtlas.ffns(nf)
     for order in [0, 1, 2]:
         as_FFNS = StrongCoupling(
             alphas_ref,
             scale_ref,
             threshold_holder.area_walls[1:-1],
             (1.0, 1.0, 1.0),
             order=order,
             method="expanded",
         )
         my_vals = []
         for Q2 in Q2s:
             my_vals.append(as_FFNS.a_s(Q2))
         # get APFEL numbers - if available else use cache
         apfel_vals = apfel_vals_dict[order]
         if use_APFEL:
             # run apfel
             apfel.CleanUp()
             apfel.SetTheory("QCD")
             apfel.SetPerturbativeOrder(order)
             apfel.SetAlphaEvolution("expanded")
             apfel.SetAlphaQCDRef(alphas_ref, np.sqrt(scale_ref))
             apfel.SetFFNS(nf)
             apfel.SetRenFacRatio(1)
             # collect a_s
             apfel_vals_cur = []
             for Q2 in Q2s:
                 apfel_vals_cur.append(apfel.AlphaQCD(np.sqrt(Q2)) / (4.0 * np.pi))
             # print(apfel_vals_cur)
             np.testing.assert_allclose(apfel_vals, np.array(apfel_vals_cur))
         # check myself to APFEL
         np.testing.assert_allclose(apfel_vals, np.array(my_vals))
Ejemplo n.º 12
0
    def benchmark_lhapdf_zmvfns_lo(self):
        """test ZM-VFNS LO towards LHAPDF"""
        Q2s = [1, 1e1, 1e2, 1e3, 1e4]
        alphas_ref = 0.118
        scale_ref = 900
        m2c = 2
        m2b = 25
        m2t = 1500
        threshold_list = [m2c, m2b, m2t]
        # compute all Lambdas
        # Lambda2_5 = self._get_Lambda2_LO(alphas_ref / (4.0 * np.pi), scale_ref, 5)
        # as_FFNS_LO_5 = StrongCoupling(
        #    alphas_ref, scale_ref, 0, "FFNS", nf=5, method="expanded"
        # )
        # Lambda2_6 = self._get_Lambda2_LO(as_FFNS_LO_5.a_s(m2t), m2t, 6)
        # as_b = as_FFNS_LO_5.a_s(m2b)
        # Lambda2_4 = self._get_Lambda2_LO(as_b, m2b, 4)
        # as_FFNS_LO_4 = StrongCoupling(
        #    as_b * 4.0 * np.pi, m2b, 0, "FFNS", nf=4, method="expanded"
        # )
        # Lambda2_3 = self._get_Lambda2_LO(as_FFNS_LO_4.a_s(m2c), m2c, 3)

        # collect my values
        as_VFNS_LO = StrongCoupling(
            alphas_ref, scale_ref, threshold_list, (1.0, 1.0, 1.0), order=0
        )
        my_vals = []
        for Q2 in Q2s:
            my_vals.append(as_VFNS_LO.a_s(Q2))
        # LHAPDF cache
        lhapdf_vals = np.array(
            [
                0.01932670387675251,
                0.014008394237618302,
                0.011154570468393434,
                0.009319430765984453,
                0.008084615274633044,
            ]
        )
        if use_LHAPDF:
            # run lhapdf - actually, let's use a different implementation here!
            # as_lhapdf = lhapdf.mkBareAlphaS("analytic")
            as_lhapdf = lhapdf.mkBareAlphaS("ODE")
            as_lhapdf.setOrderQCD(1)
            as_lhapdf.setFlavorScheme("VARIABLE", -1)
            as_lhapdf.setAlphaSMZ(alphas_ref)
            as_lhapdf.setMZ(np.sqrt(scale_ref))
            for k in range(3):
                as_lhapdf.setQuarkMass(1 + k, 0)
            for k, m2 in enumerate(threshold_list):
                as_lhapdf.setQuarkMass(4 + k, np.sqrt(m2))
            # as_lhapdf.setLambda(3, np.sqrt(Lambda2_3))
            # as_lhapdf.setLambda(4, np.sqrt(Lambda2_4))
            # as_lhapdf.setLambda(5, np.sqrt(Lambda2_5))
            # as_lhapdf.setLambda(6, np.sqrt(Lambda2_6))
            # collect a_s
            lhapdf_vals_cur = []
            for Q2 in Q2s:
                lhapdf_vals_cur.append(as_lhapdf.alphasQ2(Q2) / (4.0 * np.pi))
            # print(lhapdf_vals_cur)
            np.testing.assert_allclose(lhapdf_vals, np.array(lhapdf_vals_cur))
        # check - tolerance is determined from
        # Max absolute difference: 2.58611282e-06
        # Max relative difference: 0.00013379
        np.testing.assert_allclose(lhapdf_vals, np.array(my_vals), rtol=1.5e-4)
Ejemplo n.º 13
0
 def benchmark_lhapdf_exact(self):
     """test exact towards LHAPDF"""
     Q2s = [1e1, 1e2, 1e3, 1e4]
     alphas_ref = 0.118
     scale_ref = 90 ** 2
     # collect my values
     threshold_holder = thresholds.ThresholdsAtlas.ffns(3)
     # LHAPDF cache
     lhapdf_vals_dict = {
         0: np.array(
             [
                 0.021634715590772086,
                 0.014937700253543466,
                 0.011406683936848657,
                 0.009225845071914008,
             ]
         ),
         1: np.array(
             [
                 0.025027589743439077,
                 0.015730666136188308,
                 0.011590962671090168,
                 0.009215179641099218,
             ]
         ),
         2: np.array(
             [
                 0.02571700975829869,
                 0.015837212322787945,
                 0.011610856755395813,
                 0.009214183512196827,
             ]
         ),
     }
     for order in range(2 + 1):
         sc = StrongCoupling(
             alphas_ref,
             scale_ref,
             threshold_holder.area_walls[1:-1],
             (1.0, 1.0, 1.0),
             order=order,
             method="exact",
         )
         my_vals = []
         for Q2 in Q2s:
             my_vals.append(sc.a_s(Q2))
         lhapdf_vals = lhapdf_vals_dict[order]
         if use_LHAPDF:
             as_lhapdf = lhapdf.mkBareAlphaS("ODE")
             as_lhapdf.setOrderQCD(1 + order)
             as_lhapdf.setFlavorScheme("FIXED", 3)
             as_lhapdf.setAlphaSMZ(alphas_ref)
             as_lhapdf.setMZ(np.sqrt(scale_ref))
             # collect a_s
             lhapdf_vals_cur = []
             for Q2 in Q2s:
                 lhapdf_vals_cur.append(as_lhapdf.alphasQ2(Q2) / (4.0 * np.pi))
             # print(lhapdf_vals_cur)
             np.testing.assert_allclose(lhapdf_vals, np.array(lhapdf_vals_cur))
         # check
         np.testing.assert_allclose(lhapdf_vals, np.array(my_vals), rtol=2e-4)
Ejemplo n.º 14
0
 def benchmark_apfel_exact(self):
     """test exact towards APFEL"""
     Q2s = [1e1, 1e2, 1e3, 1e4]
     alphas_ref = 0.118
     scale_ref = 90 ** 2
     # collect my values
     threshold_holder = thresholds.ThresholdsAtlas.ffns(3)
     # LHAPDF cache
     apfel_vals_dict = {
         0: np.array(
             [
                 0.021635019899707245,
                 0.014937719308417242,
                 0.01140668497649318,
                 0.009225844999427163,
             ]
         ),
         1: np.array(
             [
                 0.025027723843261098,
                 0.015730685887616093,
                 0.01159096381106341,
                 0.009215179564010682,
             ]
         ),
         2: np.array(
             [
                 0.025717091835015565,
                 0.01583723253352162,
                 0.011610857909393214,
                 0.009214183434685514,
             ]
         ),
     }
     for order in range(2 + 1):
         sc = StrongCoupling(
             alphas_ref,
             scale_ref,
             threshold_holder.area_walls[1:-1],
             (1.0, 1.0, 1.0),
             order=order,
             method="exact",
         )
         my_vals = []
         for Q2 in Q2s:
             my_vals.append(sc.a_s(Q2))
         # get APFEL numbers - if available else use cache
         apfel_vals = apfel_vals_dict[order]
         if use_APFEL:
             # run apfel
             apfel.CleanUp()
             apfel.SetTheory("QCD")
             apfel.SetPerturbativeOrder(order)
             apfel.SetAlphaEvolution("exact")
             apfel.SetAlphaQCDRef(alphas_ref, np.sqrt(scale_ref))
             apfel.SetFFNS(3)
             apfel.SetRenFacRatio(1)
             apfel.InitializeAPFEL()
             # collect a_s
             apfel_vals_cur = []
             for Q2 in Q2s:
                 apfel_vals_cur.append(apfel.AlphaQCD(np.sqrt(Q2)) / (4.0 * np.pi))
             # print(apfel_vals_cur)
             np.testing.assert_allclose(apfel_vals, np.array(apfel_vals_cur))
         # check myself to APFEL
         np.testing.assert_allclose(apfel_vals, np.array(my_vals), rtol=2e-4)
Ejemplo n.º 15
0
 def benchmark_APFEL_vfns_fact_to_ren(self):
     Q2s = [
         1.5 ** 2,
         2 ** 2,
         3 ** 2,
         4 ** 2,
         70 ** 2,
         80 ** 2,
         90 ** 2,
         100 ** 2,
         110 ** 2,
         120 ** 2,
     ]
     alphas_ref = 0.118
     scale_ref = 91.0 ** 2
     fact_to_ren_lin_list = [0.567, 2.34]
     threshold_list = np.power([2, 2 * 4, 2 * 92], 2)
     apfel_vals_dict_list = [
         {
             0: np.array(
                 [
                     0.02536996716194434,
                     0.02242405760517867,
                     0.019270297766607315,
                     0.017573474616674672,
                     0.009758787415866933,
                     0.00956761747052419,
                     0.009405104970805002,
                     0.00926434063784546,
                     0.009140585174416013,
                     0.009030457524243522,
                 ]
             ),
             1: np.array(
                 [
                     0.02892091611225328,
                     0.024548883236784783,
                     0.020329067356870584,
                     0.018489330048933994,
                     0.009777335619585536,
                     0.009576273535323533,
                     0.009405815393635488,
                     0.009258507721473314,
                     0.009129255945850333,
                     0.009014436496515657,
                 ]
             ),
             2: np.array(
                 [
                     0.029220134213545565,
                     0.024598646506863896,
                     0.020256507668384785,
                     0.018516529262400945,
                     0.00977816967988805,
                     0.009576658129637192,
                     0.009405846634492874,
                     0.009258253518802814,
                     0.009128766134980268,
                     0.009013748776298706,
                 ]
             ),
         },
         {
             0: np.array(
                 [
                     0.023451267902337505,
                     0.021080893784642736,
                     0.018452203115256843,
                     0.0170127532599337,
                     0.00974027424891201,
                     0.009551918909176069,
                     0.009403801918958557,
                     0.009275145889222168,
                     0.009161757943458262,
                     0.009060636882751797,
                 ]
             ),
             1: np.array(
                 [
                     0.028479841693964322,
                     0.02457741561064943,
                     0.020668723336288768,
                     0.01832324913740207,
                     0.00986337072082633,
                     0.009557712951433234,
                     0.009404279433906803,
                     0.009271211089740456,
                     0.009154091133886749,
                     0.009049764354779253,
                 ]
             ),
             2: np.array(
                 [
                     0.029458461672676982,
                     0.025177951225443865,
                     0.021006297788672076,
                     0.018449012475696365,
                     0.009880255980699394,
                     0.009557644276584587,
                     0.009404273824351815,
                     0.009271256953218584,
                     0.009154179878124983,
                     0.00904988942200004,
                 ]
             ),
         },
     ]
     for fact_to_ren_lin, apfel_vals_dict in zip(
         fact_to_ren_lin_list, apfel_vals_dict_list
     ):
         # collect my values
         for order in [0, 1, 2]:
             as_VFNS = StrongCoupling(
                 alphas_ref,
                 scale_ref,
                 1 / fact_to_ren_lin ** 2 * threshold_list,
                 (1.0, 1.0, 1.0),
                 order=order,
                 method="exact",
             )
             my_vals = []
             for Q2 in Q2s:
                 my_vals.append(as_VFNS.a_s(Q2, fact_to_ren_lin ** 2 * Q2))
             # get APFEL numbers - if available else use cache
             apfel_vals = apfel_vals_dict[order]
             if use_APFEL:
                 # run apfel
                 apfel.CleanUp()
                 apfel.SetTheory("QCD")
                 apfel.SetPerturbativeOrder(order)
                 apfel.SetAlphaEvolution("exact")
                 apfel.SetAlphaQCDRef(alphas_ref, np.sqrt(scale_ref))
                 apfel.SetVFNS()
                 apfel.SetPoleMasses(*np.sqrt(threshold_list))
                 apfel.SetRenFacRatio(1.0 / fact_to_ren_lin)
                 apfel.InitializeAPFEL()
                 # collect a_s
                 apfel_vals_cur = []
                 for Q2 in Q2s:
                     apfel_vals_cur.append(
                         apfel.AlphaQCD(np.sqrt(Q2)) / (4.0 * np.pi)
                     )
                 np.testing.assert_allclose(apfel_vals, np.array(apfel_vals_cur))
             # check myself to APFEL
             np.testing.assert_allclose(apfel_vals, np.array(my_vals), rtol=2.5e-5)
Ejemplo n.º 16
0
 def benchmark_APFEL_vfns(self):
     Q2s = [1, 2 ** 2, 3 ** 2, 90 ** 2, 100 ** 2]
     alphas_ref = 0.118
     scale_ref = 91.0 ** 2
     threshold_list = np.power([2, 4, 175], 2)
     apfel_vals_dict = {
         0: np.array(
             [
                 0.028938898786215545,
                 0.021262022520127353,
                 0.018590827846469413,
                 0.009405104970805002,
                 0.00926434063784546,
             ]
         ),
         1: np.array(
             [
                 0.035670881093047654,
                 0.02337584106433519,
                 0.01985110421500437,
                 0.009405815313164215,
                 0.009258502199861199,
             ]
         ),
         2: np.array(
             [
                 0.03745593700854872,
                 0.023692463391822537,
                 0.019999870769373283,
                 0.009405846627291407,
                 0.009258253034683823,
             ]
         ),
     }
     # collect my values
     for order in [0, 1, 2]:
         as_VFNS = StrongCoupling(
             alphas_ref,
             scale_ref,
             threshold_list,
             (1.0, 1.0, 1.0),
             order=order,
             method="expanded",
         )
         my_vals = []
         for Q2 in Q2s:
             my_vals.append(as_VFNS.a_s(Q2))
         # get APFEL numbers - if available else use cache
         apfel_vals = apfel_vals_dict[order]
         if use_APFEL:
             # run apfel
             apfel.CleanUp()
             apfel.SetTheory("QCD")
             apfel.SetPerturbativeOrder(order)
             apfel.SetAlphaEvolution("expanded")
             apfel.SetAlphaQCDRef(alphas_ref, np.sqrt(scale_ref))
             apfel.SetVFNS()
             apfel.SetPoleMasses(*np.sqrt(threshold_list))
             apfel.SetRenFacRatio(1)
             apfel.InitializeAPFEL()
             # collect a_s
             apfel_vals_cur = []
             for Q2 in Q2s:
                 apfel_vals_cur.append(apfel.AlphaQCD(np.sqrt(Q2)) / (4.0 * np.pi))
             # print(apfel_vals_cur)
             np.testing.assert_allclose(apfel_vals, np.array(apfel_vals_cur))
         # check myself to APFEL
         np.testing.assert_allclose(apfel_vals, np.array(my_vals))
Ejemplo n.º 17
0
 def benchmark_pegasus_ffns(self):
     Q2s = [1e1, 1e2, 1e3, 1e4]
     alphas_ref = 0.118
     scale_ref = 91.0 ** 2
     nf = 4
     pegasus_vals_dict = {
         0: np.array(
             [
                 0.01980124164841284,
                 0.014349241933308077,
                 0.011251340091472288,
                 0.009253560532725833,
             ]
         ),
         1: np.array(
             [
                 0.021869297350539534,
                 0.014917847337312901,
                 0.011395004941942033,
                 0.00924584172632009,
             ]
         ),
         2: np.array(
             [
                 0.022150834782048476,
                 0.014974959766044743,
                 0.011407029399653526,
                 0.009245273177012448,
             ]
         ),
     }
     # collect my values
     threshold_holder = thresholds.ThresholdsAtlas.ffns(nf)
     for order in [0, 1, 2]:
         as_FFNS = StrongCoupling(
             alphas_ref,
             scale_ref,
             threshold_holder.area_walls[1:-1],
             (1.0, 1.0, 1.0),
             order=order,
             method="exact",
         )
         my_vals = []
         for Q2 in Q2s:
             my_vals.append(as_FFNS.a_s(Q2))
         # get APFEL numbers - if available else use cache
         pegasus_vals = pegasus_vals_dict[order]
         if use_PEGASUS:
             # run pegasus
             pegasus.colour.ca = 3.0
             pegasus.colour.cf = 4.0 / 3.0
             pegasus.colour.tr = 0.5
             pegasus.betafct()
             pegasus.aspar.naord = order
             pegasus.aspar.nastps = 20
             # collect a_s
             pegasus_vals_cur = []
             for Q2 in Q2s:
                 pegasus_vals_cur.append(
                     pegasus.__getattribute__("as")(
                         Q2, scale_ref, alphas_ref / (4.0 * np.pi), nf
                     )
                 )
             # print(pegasus_vals_cur)
             np.testing.assert_allclose(
                 pegasus_vals, np.array(pegasus_vals_cur), err_msg="order=%d" % order
             )
         # check myself to APFEL
         np.testing.assert_allclose(
             pegasus_vals, np.array(my_vals), rtol=1.5e-7, err_msg="order=%d" % order
         )
Ejemplo n.º 18
0
    def test_compute(self, monkeypatch):
        # setup objs
        theory_card = {
            "alphas": 0.35,
            "PTO": 0,
            "ModEv": "TRN",
            "fact_to_ren_scale_ratio": 1.0,
            "Qref": np.sqrt(2),
            "nfref": None,
            "Q0": np.sqrt(2),
            "FNS": "FFNS",
            "NfFF": 3,
            "IC": 0,
            "IB": 0,
            "mc": 1.0,
            "mb": 4.75,
            "mt": 173.0,
            "kcThr": np.inf,
            "kbThr": np.inf,
            "ktThr": np.inf,
            "MaxNfPdf": 6,
            "MaxNfAs": 6,
        }
        operators_card = {
            "Q2grid": [1, 10],
            "interpolation_xgrid": [0.1, 1.0],
            "interpolation_polynomial_degree": 1,
            "interpolation_is_log": True,
            "debug_skip_singlet": True,
            "debug_skip_non_singlet": False,
            "ev_op_max_order": 1,
            "ev_op_iterations": 1,
            "backward_inversion": "exact",
        }
        g = OperatorGrid.from_dict(
            theory_card,
            operators_card,
            ThresholdsAtlas.from_dict(theory_card),
            StrongCoupling.from_dict(theory_card),
            InterpolatorDispatcher.from_dict(operators_card),
        )
        o = Operator(g.config, g.managers, 3, 2, 10)
        # fake quad
        monkeypatch.setattr(scipy.integrate, "quad",
                            lambda *args, **kwargs: np.random.rand(2))
        # LO
        o.compute()
        assert "NS_m" in o.op_members
        np.testing.assert_allclose(o.op_members["NS_m"].value,
                                   o.op_members["NS_p"].value)
        np.testing.assert_allclose(o.op_members["NS_v"].value,
                                   o.op_members["NS_p"].value)
        # NLO
        o.config["order"] = 1
        o.compute()
        assert not np.allclose(o.op_members["NS_p"].value,
                               o.op_members["NS_m"].value)
        np.testing.assert_allclose(o.op_members["NS_v"].value,
                                   o.op_members["NS_m"].value)

        # unity operators
        for n in range(0, 2 + 1):
            o1 = Operator(g.config, g.managers, 3, 2, 2)
            o1.config["order"] = n
            o1.compute()
            for k in br.non_singlet_labels:
                assert k in o1.op_members
                np.testing.assert_allclose(o1.op_members[k].value,
                                           np.eye(2),
                                           err_msg=k)
Ejemplo n.º 19
0
    def test_init(self):
        # prepare
        alphas_ref = 0.118
        scale_ref = 91.0**2
        nf = 4
        threshold_holder = thresholds.ThresholdsAtlas.ffns(nf)
        # create
        sc = StrongCoupling(alphas_ref, scale_ref,
                            threshold_holder.area_walls[1:-1], (1.0, 1.0, 1.0))
        assert sc.q2_ref == scale_ref
        assert sc.as_ref == alphas_ref / 4.0 / np.pi
        # from theory dict
        for ModEv in ["EXP", "EXA"]:
            for PTO in range(2 + 1):
                setup = dict(
                    alphas=alphas_ref,
                    Qref=np.sqrt(scale_ref),
                    nfref=None,
                    PTO=PTO,
                    ModEv=ModEv,
                    FNS="FFNS",
                    NfFF=nf,
                    Q0=2,
                    fact_to_ren_scale_ratio=1,
                    mc=2.0,
                    mb=4.0,
                    mt=175.0,
                    kcThr=1.0,
                    kbThr=1.0,
                    ktThr=1.0,
                    MaxNfAs=6,
                )
                sc2 = StrongCoupling.from_dict(setup)
                assert sc2.q2_ref == scale_ref
                assert sc2.as_ref == alphas_ref / 4.0 / np.pi

        # errors
        with pytest.raises(ValueError):
            StrongCoupling(0, scale_ref, threshold_holder.area_walls[1:-1],
                           (1.0, 1.0, 1.0))
        with pytest.raises(ValueError):
            StrongCoupling(alphas_ref, 0, threshold_holder.area_walls[1:-1],
                           (1.0, 1.0, 1.0))
        with pytest.raises(NotImplementedError):
            StrongCoupling(
                alphas_ref,
                scale_ref,
                threshold_holder.area_walls[1:-1],
                (1.0, 1.0, 1.0),
                3,
            )
        with pytest.raises(ValueError):
            StrongCoupling(
                alphas_ref,
                scale_ref,
                threshold_holder.area_walls[1:-1],
                (1.0, 1.0, 1.0),
                method="ODE",
            )
        with pytest.raises(ValueError):
            StrongCoupling.from_dict(
                dict(
                    alphas=alphas_ref,
                    Qref=np.sqrt(scale_ref),
                    nfref=None,
                    PTO=0,
                    ModEv="FAIL",
                ), )