예제 #1
0
#!/usr/bin/env python3
from pySecDec.integral_interface import IntegralLibrary
import sympy as sp

if __name__ == "__main__":

    # load c++ library
    box1L = IntegralLibrary('box1L/box1L_pylink.so')

    # choose integrator
    box1L.use_Vegas()

    # integrate
    str_integral_without_prefactor, str_prefactor, str_integral_with_prefactor = box1L(
        real_parameters=[4.0, -0.75, 1.25, 1.0], verbose=True)

    # convert complex numbers from c++ to sympy notation
    str_integral_with_prefactor = str_integral_with_prefactor.replace(
        ',', '+I*')
    str_prefactor = str_prefactor.replace(',', '+I*')
    str_integral_without_prefactor = str_integral_without_prefactor.replace(
        ',', '+I*')

    # convert result to sympy expressions
    integral_with_prefactor = sp.sympify(
        str_integral_with_prefactor.replace('+/-', '*value+error*'))
    integral_with_prefactor_err = sp.sympify(
        str_integral_with_prefactor.replace('+/-', '*value+error*'))
    prefactor = sp.sympify(str_prefactor)
    integral_without_prefactor = sp.sympify(
        str_integral_without_prefactor.replace('+/-', '*value+error*'))
예제 #2
0
#!/usr/bin/env python3

from pySecDec.integral_interface import IntegralLibrary
import sympy as sp

if __name__ == "__main__":

    # load c++ library
    triangle2L = IntegralLibrary('triangle2L/triangle2L_pylink.so')

    # choose integrator
    triangle2L.use_Vegas() # ``flags=2``: verbose --> see Cuba manual

    number_of_real_parameters = int(triangle2L.info['number_of_real_parameters'])
    number_of_complex_parameters = int(triangle2L.info['number_of_complex_parameters'])

    with open('kinematics.input') as f:
      with open('results_P126.txt', 'w') as resultsfile:
        for line in f:
            point = line.split()
            assert len(point) == 1+number_of_real_parameters+number_of_complex_parameters, "Invalid point: " + str(point)

            # convert to float and complex
            name = point[0]
            vals_real_parameters = [float(point[1+i]) for i in range(number_of_real_parameters)]
            vals_complex_parameters = [complex(point[1+number_of_real_parameters+i]) for i in range(number_of_complex_parameters)]

            # compute the integral
            str_integral_without_prefactor, str_prefactor, str_integral_with_prefactor = triangle2L(vals_real_parameters,vals_complex_parameters, verbose=True)