项目作者: andrewfowlie

项目描述 :
Thermal functions for finite-temperature effective field-theory in C++ with Python and Mathematica interfaces
高级语言: C++
项目地址: git://github.com/andrewfowlie/thermal_funcs.git
创建时间: 2017-07-04T07:47:46Z
项目社区:https://github.com/andrewfowlie/thermal_funcs

开源协议:BSD 3-Clause "New" or "Revised" License

下载


Thermal functions

Documentation
Build Status

We provide a C++ library and Python, Mathematica and Fortran interfaces to thermal functions, defined
\f[
J_{B/F}(y^2)=\Re\int_0^{\infty} dx\,x^2 \ln\left(1\mp\exp\left(-\sqrt{x^2 + y^2}\right)\right).
\f]

We offer Taylor expansion, numerical integration (quadrature), a Bessel function
representation, an approximation, a Hurwitz zeta function representation, and an upper bound for the integrals. First and second
derivatives with respect to \f$y^2\f$ are also implemented.

The accompanying manual is 1802.02720. If you use this library, please cite,

  1. @article{Fowlie:2018eiu,
  2. author = "Fowlie, Andrew",
  3. title = "{A fast C++ implementation of thermal functions}",
  4. doi = "10.1016/j.cpc.2018.02.015",
  5. year = "2018",
  6. eprint = "1802.02720",
  7. archivePrefix = "arXiv",
  8. primaryClass = "hep-ph"
  9. }

The documentation is at codedocs. To build this documentation in doxygen,

  1. make docs

Dependencies

The C++ requires gsl and gslcblas and a c++11 compiler. The Python interface requires Python 2 or 3, SWIG and a Python.h header file (which is part of python-dev in Ubuntu). The Mathematica interface was tested for Mathematica 11.

Build

Build the library via

  1. make lib

This should build ./lib/thermal_funcs.so. The header file is ./src/thermal_funcs.h.

Example

There is a C example ./src/example.cpp, built by

  1. make example

This should build a program ./bin/example, which when executed prints the result of evaluating a thermal function.

Python interface

Build the interface via

  1. make python

The interface

  1. from thermal_funcs import J_B, J_F
  2. J_F(100., method='quad')

is compatible with Python 2 and 3, though must be built for a specific version. It has no module dependencies. By default,
SWIG will build for your python --version. To alter this, change the PYTHON variable in the makefile to compile with
your chosen Python.h header. The derivatives are called by a keyword argument e.g., J_F(100., derivative=1).

Mathematica interface

This is slightly more involved. This may work in Linux if math is in your PATH:

  1. make mathematica

But otherwise you may have to tweak the ./src/makefile variable MATH_INC for the locations of your wscc linker and wstp.h header file. You can find this on any platform in Mathematica from FileNameJoin[{$InstallationDirectory, "SystemFiles", "Links", "WSTP", "DeveloperKit", $SystemID, "CompilerAdditions"}].

Then within Mathematica,

  1. Install["./src/math.exe"];
  2. Plot[{JB[ysq], JF[ysq]}, {ysq, -100, 100}]

Note well that you should use the correct (relative or absolute) path to ./src/math.exe in the command Install["./src/math.exe"]. The interface was built and tested with Mathematica 11.1.1. The derivatives are called by a keyword argument e.g., JB[100., derivative->1].

Debugging

If the executable ./src/math.exe was built but Install fails, try installing step by step to find debugging information. First, run the created executable,

  1. ./src/math.exe

This should prompt you to Create link:. Enter e.g. foo. Don’t exit that session. In Mathematica, try

  1. $VersionNumber
  2. link = LinkConnect["foo"]
  3. Install[link]
  4. JB[100]

to find the step that fails.

You can also try one of the pre-built examples provided by Mathematica, e.g.,

  1. Install["/usr/local/Wolfram/Mathematica/11.1/SystemFiles/Links/WSTP/DeveloperKit/Linux-x86-64/PrebuiltExamples/addtwo"]
  2. AddTwo[2, 2]

and re-building it locally,

  1. MATH=/usr/local/Wolfram/Mathematica/11.1/SystemFiles/Links/WSTP/DeveloperKit/Linux-x86-64/
  2. mkdir ~/addtwo
  3. cd ~/addtwo
  4. cp $MATH/WSTPExamples/addtwo* ./
  5. $MATH/CompilerAdditions/wscc addtwo.tm addtwo.c -o addtwo

then in Mathematica,

  1. Install["~/addtwo/addtwo"]
  2. AddTwo[2, 2]

This may help find the origin of any problems. You must, of course, replace the paths to the ones on your machine.

Fortran interface

There is a basic Fortran example, built by

  1. make fortran

and executed by

  1. ./bin/fortran_example

This requires a Fortran compiler with support for iso_c_binding, which is included in the Fortran 2003 or later standard and GNU extensions.

Acknowledgements

This Stack Exchange answer was helpful for removing linker warnings from wscc, and this one was helpful for automatically locating Mathematica header files.