Skip to content

jkriewald/lt2py

Repository files navigation

lt2py a python wrapper for LoopTools

CI

This is an unofficial python wrapper for the fortran77 code LoopTools using numpy.f2py for wrapping.

LoopTools, relying on the FF library Z. Phys. C46 (1990) 425, has been published in Comput. Phys. Commun. 118 (1999) 153 [hep-ph/9807565].

Please refer to the LoopTools documentation for the original code(s) available here: LT215Guide.pdf

Requirements

A working gfortran compiler, python>=3.9 and numpy>=1.26

Status

lt2py is intended as a lightweight research-facing wrapper around LoopTools. The package expects a working local Fortran toolchain and builds LoopTools during installation.

Installation

Download or clone the repository, navigate to the parent directory and run

python -m pip install .

This downloads LoopTools 2.16, builds it locally, builds the Python wrappers, and installs lt2py into the active Python environment.

(Optionally) run the tests with (requires pytest)

 python -m pytest

to ensure it's working properly on the system.

Several usage examples are available in the example_usage.ipynb notebook

Basic Usage

Once the code is pip installed and accessible, it can be imported via

import lt2py

There are several high-level functions that can be used to compute a single coefficient for a given $N$-point function (with real or complex masses), a vectorized version that accepts numpy arrays for momenta (and returns numpy arrays of the same shape), and functions that return all coefficients simultaneously in a dict (also vectorized).

The naming conventions and ordering of arguments follow the LoopTools conventions of Passarino-Veltman integrals. All masses/invariants are passed as squares, following the LoopTools convention.

To compute a single coefficient run for instance

print(lt2py.B0i('B0', p = 125.1**2, m1 = 80.4**2, m2 = 80.4**2))

The output is (banner is only shown at the start of each python session)

 ====================================================
   FF 2.0, a package to evaluate one-loop integrals
 written by G. J. van Oldenborgh, NIKHEF-H, Amsterdam
 ====================================================
 for the algorithms used see preprint NIKHEF-H 89/17,
 'New Algorithms for One-loop Integrals', by G.J. van
 Oldenborgh and J.A.M. Vermaseren, published in
 Zeitschrift fuer Physik C46(1990)425.
 ====================================================
(-8.213861016307662+0j)

Complex masses can be included as

print(lt2py.B0iC('B0', p = 125.1**2, m1 = (80.4+2.1j)**2, m2 = (80.4+2.1j)**2))

yielding

(-8.217480233169413-0.0950477923144383j)

All functions come with optional arguments that set e.g. the 't Hooft scale

print(lt2py.B0i('B0', p = 125.1**2, m1 = 80.4**2, m2 = 80.4**2, mudim = 1.))
print(lt2py.B0i('B0', p = 125.1**2, m1 = 80.4**2, m2 = 80.4**2, mudim = 1e6))

giving

(-8.213861016307662+0j)
(5.601649541656611+0j)

(See the example_usage.ipynb for further options)

To retrieve all coefficients at once use

print(lt2py.Bput(p = 125.1**2, m1 = 80.4**2, m2 = 80.4**2))

which returns a dictionary

{'B0': (-8.213861016307662-0j),
 'B1': (4.106930508153831+0j),
 'B00': (-14076.472207782195+0j),
 'B11': (-2.759522908311342-0j),
 'B001': (7038.236103891099+0j),
 'B111': (2.085819108390098+0j),
 'DB0': (5.263747675911996e-05+0j),
 'DB1': (-2.6318738379559977e-05-0j),
 'DB00': (0.6737037999212443+0j),
 'DB11': (1.5226706802547167e-05+0j),
 'DB001': (-0.33685189996062215+0j)}

(Complex masses are available via lt2py.BputC)

For all functions there are also vectorized versions, e.g.

import numpy as np
p_arr = np.array([0., 2., 91.2, 125.1, 173.])
lt2py.B0i_vec('B0', p = p_arr**2, m1 = 80.4**2, m2 = 80.4**2)

returning a numpy array

array([-8.77402835+0.j      , -8.77392521+0.j      ,
       -8.52548562+0.j      , -8.21386102+0.j      ,
       -7.05962324+1.158849j])

or

p_arr = np.array([0., 2.])
lt2py.Bput_vec(p = p_arr**2, m1 = 80.4**2, m2 = 80.4**2)

returning a dict of numpy arrays

{'B0': array([-8.77402835-0.j, -8.77392521-0.j]),
 'B1': array([4.38701418+0.j, 4.38696261+0.j]),
 'B00': array([-25126.28155713+0.j, -25123.35690164+0.j]),
 'B11': array([-2.92467612-0.j, -2.92464518-0.j]),
 'B001': array([12563.14077856-0.j, 12561.67845082+0.j]),
 'B111': array([2.19350709+0.j, 2.19348646+0.j]),
 'DB0': array([2.57831902e-05+0.j, 2.57863815e-05+0.j]),
 'DB1': array([-1.28915951e-05+0.j, -1.28931908e-05-0.j]),
 'DB00': array([0.73116903+0.j, 0.73115872+0.j]),
 'DB11': array([7.73495706e-06+0.j, 7.73586886e-06+0.j]),
 'DB001': array([-0.36558451+0.j, -0.36557936+0.j])}

License

The original lt2py wrapper code in this repository is distributed under the MIT license.

This package downloads and builds LoopTools during installation. LoopTools is developed and distributed separately and, according to the official LoopTools website, is distributed under the GNU Lesser General Public License (LGPL). LoopTools is not relicensed by this repository.

If you use this wrapper in scientific work, please also cite the original LoopTools/FF references listed above.

See THIRD_PARTY_NOTICES.md for a short summary of the third-party licensing situation.

About

A fast, Pythonic wrapper around LoopTools for scalar and tensor one-loop integrals, with vectorized APIs for fast phenomenology workflows.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors