gudrunhe / secdec

a program to evaluate dimensionally regulated parameter integrals numerically
GNU General Public License v3.0
25 stars 5 forks source link

AttributeError: 'mpz' object has no attribute 'denominator' when attempting an asymptotic expansion #31

Closed vsht closed 1 year ago

vsht commented 1 year ago

Hi,

using the following code to perform an asymptotic expansion of a 2-scale 2-loop SCET-integral with an analytic regulator (the first two propagators)

#!/usr/bin/env python3
from pySecDec import sum_package, loop_package, loop_regions, LoopIntegralFromPropagators
import pySecDec as psd

li = LoopIntegralFromPropagators(
['n*q1 + nb*q1', 'n*q2 + nb*q2', 'q1**2', '-m**2 + q2**2', 'm**2 - n*q1 - m**2*nb*q1 + q1**2 + n*q2 + m**2*nb*q2 - 2*q1*q2 + q2**2', '-1 + 2*m**2 - m**4 - n*q1 + m**2*n*q1 + nb*q1 - m**2*nb*q1 + q1**2'],

loop_momenta = ['q1', 'q2'],
powerlist = ['n1', 'n1', 1, 1, 2, 1],
dimensionality = '4 - 2*eps',
Feynman_parameters = 'x',
replacement_rules = [('nb**2','0'), ('n**2','0'), ('n*nb','2')],
regulators = ['eps', 'n1']
)

regions_generator_args = loop_regions(
name = 'loopint',
loop_integral = li,
smallness_parameter = 'm',
expansion_by_regions_order = 0,
contour_deformation = True,
additional_prefactor = '(1)*exp(2*EulerGamma*eps)',
decomposition_method = 'geometric'
)

sum_package(
name = 'loopint',
package_generators = regions_generator_args,
regulators = li.regulators,
requested_orders = [0,0],
real_parameters = ['m']
)

I get

Total number of regions: 11
Region (-2,0,-4,-2,-2,0,1), smallness parameter lowest order is 2
Region (-2,0,0,-2,-2,-4,1), smallness parameter lowest order is 2
Region (-1,-1,-2,-2,-1,0,1), smallness parameter lowest order is 2
Region (-1,-1,0,-2,-1,-2,1), smallness parameter lowest order is 2
Region (0,-1,-1,-2,-2,-1,1), smallness parameter lowest order is 0
Region (0,-1,-1,-2,-1,0,1), smallness parameter lowest order is 1
Region (0,-1,0,-2,-1,-1,1), smallness parameter lowest order is 1
Region (0,-1,0,-2,0,0,1), smallness parameter lowest order is 2
Region (0,0,-2,-2,-2,0,1), smallness parameter lowest order is 0
Region (0,0,0,-2,-2,-2,1), smallness parameter lowest order is 0
Region (0,0,0,0,0,0,1), smallness parameter lowest order is 0
running "sum_package" for loopint
running "make_package" for "loopint_region_0_m1_m1_m2_m2_m1_1_expansion_order_0"
computing Jacobian determinant for primary sector 0
total number sectors before symmetry finding: 10
total number sectors after symmetry finding (iterative): 10
total number sectors after symmetry finding (light Pak): 10
total number sectors after symmetry finding (full Pak): 10
writing FORM files for sector 1
writing FORM files for sector 2
writing FORM files for sector 3
writing FORM files for sector 4
writing FORM files for sector 5
writing FORM files for sector 6
writing FORM files for sector 7
writing FORM files for sector 8
writing FORM files for sector 9
writing FORM files for sector 10
expanding the prefactor m**(-4*eps - n1)*exp(2*EulerGamma*eps)*exp(-I*pi*(2*n1 + 5))*gamma(2*eps + 2*n1 + 1)/gamma(n1)**2 (regulators: [eps, n1] , orders: [1 5] )
Traceback (most recent call last):
  File "generate_int.py", line 40, in <module>
    real_parameters = ['m']
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/pySecDec/code_writer/sum_package.py", line 541, in sum_package
    for j, package_generator in enumerate(package_generators)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/pySecDec/code_writer/sum_package.py", line 541, in <listcomp>
    for j, package_generator in enumerate(package_generators)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/pySecDec/code_writer/sum_package.py", line 267, in _generate_one_term
    return make_package(**package_generator._asdict())
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/pySecDec/code_writer/make_package.py", line 2113, in make_package
    expanded_prefactor = expand_sympy(prefactor, regulators, required_prefactor_orders)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/pySecDec/expansion.py", line 381, in expand_sympy
    return recursion(expression, variables, orders, 0)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/pySecDec/expansion.py", line 376, in recursion
    coeffs[i] = recursion(coeff, variables, orders, index + 1)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/pySecDec/expansion.py", line 350, in recursion
    current_term = next(expansion_generator)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/core/expr.py", line 2960, in <genexpr>
    return (s.subs(xpos, x) for s in rv)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/core/expr.py", line 3020, in yield_lseries
    o = Order(si, x)*x
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/core/cache.py", line 72, in wrapper
    retval = cfunc(*args, **kwargs)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/series/order.py", line 200, in __new__
    expr = expr.factor()
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/core/expr.py", line 3674, in factor
    return factor(self, *gens, **args)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/polytools.py", line 6370, in factor
    return _generic_factor(f, gens, args, method='factor')
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/polytools.py", line 6042, in _generic_factor
    return _symbolic_factor(sympify(expr), opt, method)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/polytools.py", line 5982, in _symbolic_factor
    coeff, factors = _symbolic_factor_list(together(expr, fraction=opt['fraction']), opt, method)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/polytools.py", line 5947, in _symbolic_factor_list
    _coeff, _factors = func()
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/polytools.py", line 3316, in factor_list
    coeff, factors = f.rep.factor_list()
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/polyclasses.py", line 795, in factor_list
    coeff, factors = dmp_factor_list(f.rep, f.lev, f.dom)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/factortools.py", line 1391, in dmp_factor_list
    coeff, factors = dmp_zz_i_factor(f, u, K0)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/factortools.py", line 1213, in dmp_zz_i_factor
    content, fac_prim = dmp_ground_primitive(fac_num_ZZ_I, u, K1)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/densetools.py", line 719, in dmp_ground_primitive
    cont = dmp_ground_content(f, u, K)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/densetools.py", line 650, in dmp_ground_content
    cont = K.gcd(cont, dmp_ground_content(c, v, K))
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/densetools.py", line 638, in dmp_ground_content
    return dup_content(f, K)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/densetools.py", line 605, in dup_content
    cont = K.gcd(cont, c)
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/domains/field.py", line 66, in gcd
    p = ring.gcd(self.numer(a), self.numer(b))
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/domains/gaussiandomains.py", line 378, in numer
    return ZZ_I.convert(a * self.denom(a))
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/domains/gaussiandomains.py", line 385, in denom
    denom_ZZ = ZZ.lcm(QQ.denom(a.x), QQ.denom(a.y))
  File "/users/ttp/shtabovenko/.local/lib/python3.6/site-packages/sympy/polys/domains/gmpyrationalfield.py", line 92, in denom
    return a.denominator
AttributeError: 'mpz' object has no attribute 'denominator'

This is on a KIT TTP machine with Python 3.6. I don't have that much experience using pySecDec for asymptotic expansions, so perhaps there is just something wrong with my input file?

magv commented 1 year ago

Hi, Vlad. I think we saw errors like this at some point; I think it was a sympy problem: it is set to use either gmpy or gmpy2 libraries for its integers, depending on which you have installed, but in practice it doesn't actually work with gmpy, only with gmpy2. Can you install the latest gmpy2 and check again?

(Also consider upgrading to newer Python; we're dropping Python 3.6 support in the next version: it has been unsupported for multiple years now, and the libraries we're dependent upon have dropped the support already).

vsht commented 1 year ago

Hi Vitaly,

thanks a lot for the prompt reply! Indeed, upon installing gmpy2 via

python3 -m pip install --user gmpy2

everything works as expected.

Unfortunately, something I didn't realize before is that when doing asymptotic expansions pySecDec requires the user to fix the smallness parameter(s) numerically. This is not so helpful if one is interested in the analytic structure of the expression (what powers and logs of the small variables show up). FIESTA returns exactly that kind of "semi-numerical" output, e.g.

(-2.83715408392799 + 15.70762763047966*I) + 
 ep^2*((-75.15051613464018 - 1.8215957883643*I) + 
   Log[m]^4*(0.66666666270028 + 0.00004152288909*pm[51]) + 
   Log[m]^3*((-6.66664931664225 - 8.37759646031364*I) + 
     0.01496568252389*pm[52]) + 
   Log[m]^2*((-8.05836763671348 + 62.83200473550008*I) + 
     0.18718974676163*pm[53]) + 
   Log[m]*((121.12849329071528 - 114.7367724383873*I) + 
     0.7539162846317*pm[54]) + 1.19861069562318*pm[55]) + 
 ep*((-33.19250256481778 + 23.51627736009916*I) + 
   Log[m]^3*(-1.33333332540056 + 0.00008304577819*pm[56]) + 
   Log[m]^2*((9.99997397496338 + 12.56639469047046*I) + 
     0.02244852378583*pm[57]) + 
   Log[m]*((8.05836763671348 - 62.83200473550008*I) + 
     0.18718974676163*pm[58]) + 0.39055093652919*pm[59]) + 
 Log[m]^2*(1.99999998810084 + 0.00012456866728*pm[60]) + 
 Log[m]*((-9.99997397496338 - 12.56639469047046*I) + 
   0.02244852378583*pm[61]) + 0.09422259505112*pm[62] + 
 ((2.49998731890744 + 3.14160429781107*I) + 
   Log[m]*(-1.99999998810084 + 0.00012456866728*pm[63]) + 
   0.01124758458693*pm[64])/ep + (0.49999995297059 + 0.00009478863749*pm[65])/
  ep^2

I guess that pySecDec could in principle do something similar, it's just not implemented as of now. But it certainly would be a very handy feature for the next major release :)

magv commented 1 year ago

Unfortunately, something I didn't realize before is that when doing asymptotic expansions pySecDec requires the user to fix the smallness parameter(s) numerically.

The API does seem to suggest this, but that's not the only possibility, and we agree that this is not the most useful way of using asymptotic expansion. Instead, we suggest users to take the terms that they get from e.g. loop_regions() and group them by the prefactor. Since the smallness parameter only enters the prefactors after the expansion, the dependence on it can be fully extracted, and you can get a similar symbolic+numeric expression.

We'll soon be releasing v1.6 with a demo of how this can be done.