def test_beta(): """beta-wrapper""" nf = 3 np.testing.assert_allclose(beta.beta(0, nf), beta.beta_0(nf)) np.testing.assert_allclose(beta.beta(1, nf), beta.beta_1(nf)) np.testing.assert_allclose(beta.beta(2, nf), beta.beta_2(nf)) with pytest.raises(ValueError): beta.beta(3, 3)
def test_der_nnlo_exa(): """exact NNLO derivative""" nf = 3 a0 = 0.3 a1 = 0.1 delta_a = -1e-6 # 02 rhs = 1.0 / ( beta.beta(0, nf) * a1 + beta.beta(1, nf) * a1 ** 2 + beta.beta(2, nf) * a1 ** 3 ) lhs = ( ei.j02_exact(a1 + 0.5 * delta_a, a0, nf) - ei.j02_exact(a1 - 0.5 * delta_a, a0, nf) ) / delta_a np.testing.assert_allclose(rhs, lhs, atol=np.abs(delta_a)) # in fact O(delta_a^2) # 12 rhs = 1.0 / (beta.beta(0, nf) + beta.beta(1, nf) * a1 + beta.beta(2, nf) * a1 ** 2) lhs = ( ei.j12_exact(a1 + 0.5 * delta_a, a0, nf) - ei.j12_exact(a1 - 0.5 * delta_a, a0, nf) ) / delta_a np.testing.assert_allclose(rhs, lhs, atol=np.abs(delta_a)) # in fact O(delta_a^2) # 12 rhs = a1 / (beta.beta(0, nf) + beta.beta(1, nf) * a1 + beta.beta(2, nf) * a1 ** 2) lhs = ( ei.j22_exact(a1 + 0.5 * delta_a, a0, nf) - ei.j22_exact(a1 - 0.5 * delta_a, a0, nf) ) / delta_a np.testing.assert_allclose(rhs, lhs, atol=np.abs(delta_a)) # in fact O(delta_a^2)
def test_ode_nlo(): nf = 3 ev_op_iterations = 10 gamma_ns = np.random.rand(2) + 0j delta_a = -1e-6 a0 = 0.3 for a1 in [0.1, 0.2]: r = (a1 * gamma_ns[0] + a1**2 * gamma_ns[1]) / ( beta.beta(0, nf) * a1**2 + beta.beta(1, nf) * a1**3) for method in ["iterate-exact"]: rhs = r * ns.dispatcher(1, method, gamma_ns, a1, a0, nf, ev_op_iterations) lhs = (ns.dispatcher(1, method, gamma_ns, a1 + 0.5 * delta_a, a0, nf, ev_op_iterations) - ns.dispatcher(1, method, gamma_ns, a1 - 0.5 * delta_a, a0, nf, ev_op_iterations)) / delta_a np.testing.assert_allclose(lhs, rhs, atol=np.abs(delta_a))
def test_der_nlo_exp(): """expanded NLO derivative""" nf = 3 a0 = 0.3 a1 = 0.1 delta_a = -1e-6 # 01 rhs = 1.0 / (beta.beta(0, nf) * a1 + beta.beta(1, nf) * a1 ** 2) lhs = ( ei.j01_expanded(a1 + 0.5 * delta_a, a0, nf) - ei.j01_expanded(a1 - 0.5 * delta_a, a0, nf) ) / delta_a np.testing.assert_allclose(rhs, lhs, atol=np.abs((beta.b(1, nf) * a1) ** 2)) # 11 rhs = 1.0 / (beta.beta(0, nf) + beta.beta(1, nf) * a1) lhs = ( ei.j11_expanded(a1 + 0.5 * delta_a, a0, nf) - ei.j11_expanded(a1 - 0.5 * delta_a, a0, nf) ) / delta_a np.testing.assert_allclose(rhs, lhs, atol=np.abs(beta.b(1, nf) * a1))
def test_der_lo(): """LO derivative""" nf = 3 a0 = 5 a1 = 3 delta_a = -1e-6 rhs = 1.0 / (beta.beta(0, nf) * a1) lhs = ( ei.j00(a1 + 0.5 * delta_a, a0, nf) - ei.j00(a1 - 0.5 * delta_a, a0, nf) ) / delta_a np.testing.assert_allclose(rhs, lhs)
def test_ode_lo(): nf = 3 ev_op_iterations = 10 gamma_ns = np.random.rand(1) + 0j delta_a = -1e-6 a0 = 0.3 for a1 in [0.1, 0.2]: r = a1 * gamma_ns / (beta.beta(0, nf) * a1**2) for method in methods: rhs = r * ns.dispatcher(0, method, gamma_ns, a1, a0, nf, ev_op_iterations) lhs = (ns.dispatcher(0, method, gamma_ns, a1 + 0.5 * delta_a, a0, nf, ev_op_iterations) - ns.dispatcher(0, method, gamma_ns, a1 - 0.5 * delta_a, a0, nf, ev_op_iterations)) / delta_a np.testing.assert_allclose(lhs, rhs, atol=np.abs(delta_a))
def _get_Lambda2_LO(self, as_ref, scale_ref, nf): """Transformation to Lambda_QCD""" beta0 = beta(0, nf) return scale_ref * np.exp(-1.0 / (as_ref * beta0))
def test_der_nnlo_exp(): """expanded NNLO derivative""" nf = 3 a0 = 0.3 a1 = 0.1 delta_a = -1e-6 # Integrals are expanded to the order 0( a_s^3 ) so they can match the derivative to a_s^2 # The corresponding prefactor prorpotional to a_s^2 are included in the tollerance. # 02 rhs = 1.0 / ( beta.beta(0, nf) * a1 + beta.beta(1, nf) * a1 ** 2 + beta.beta(2, nf) * a1 ** 3 ) lhs = ( ei.j02_expanded(a1 + 0.5 * delta_a, a0, nf) - ei.j02_expanded(a1 - 0.5 * delta_a, a0, nf) ) / delta_a toll = ( (-beta.b(1, nf) ** 3 + 2 * beta.b(2, nf) * beta.b(1, nf)) / beta.beta(0, nf) * a1 ** 2 ) np.testing.assert_allclose(rhs, lhs, atol=np.abs(toll)) # 12 rhs = 1.0 / (beta.beta(0, nf) + beta.beta(1, nf) * a1 + beta.beta(2, nf) * a1 ** 2) lhs = ( ei.j12_expanded(a1 + 0.5 * delta_a, a0, nf) - ei.j12_expanded(a1 - 0.5 * delta_a, a0, nf) ) / delta_a toll = (beta.b(1, nf) ** 2 - beta.b(2, nf)) / beta.beta(0, nf) * a1 ** 2 np.testing.assert_allclose(rhs, lhs, atol=np.abs(toll)) # 22 rhs = a1 / (beta.beta(0, nf) + beta.beta(1, nf) * a1 + beta.beta(2, nf) * a1 ** 2) lhs = ( ei.j22_expanded(a1 + 0.5 * delta_a, a0, nf) - ei.j22_expanded(a1 - 0.5 * delta_a, a0, nf) ) / delta_a np.testing.assert_allclose( rhs, lhs, atol=np.abs(beta.b(1, nf) / beta.beta(0, nf) * a1 ** 2) )