ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
constants.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef UTILS_CONSTANTS_HPP
20#define UTILS_CONSTANTS_HPP
21
22#include "device_qualifier.hpp"
23
24#include <boost/math/constants/constants.hpp>
25
26namespace Utils {
27
28/*************************************************************/
29/** \name Mathematical, physical and chemical constants. */
30/*************************************************************/
31/**@{*/
32
33/**
34 * @brief Ratio of diameter and circumference of a circle.
35 */
36template <class T = double> DEVICE_QUALIFIER constexpr T pi() {
37 return T(3.14159265358979323846264338328L);
38}
39
40/**
41 * @brief One over square root of pi.
42 */
43template <class T = double> DEVICE_QUALIFIER constexpr T sqrt_pi_i() {
44 return T(0.56418958354775627928034964498L);
45}
46
47/**
48 * @brief Euler-Mascheroni constant.
49 */
50template <class T = double> DEVICE_QUALIFIER constexpr T gamma() {
51 return T(0.57721566490153286060651209008L);
52}
53
54/**
55 * @brief Natural logarithm of 2.
56 */
57template <class T = double> DEVICE_QUALIFIER constexpr T ln_2() {
58 return T(0.6931471805599453094172321214581766L);
59}
60
61/**
62 * @brief Square root of 2.
63 */
64template <class T = double> DEVICE_QUALIFIER constexpr T sqrt_2() {
65 return T(1.4142135623730950488016887242096981L);
66}
67
68/**
69 * @brief Cube root of 2.
70 */
71template <class T = double> DEVICE_QUALIFIER constexpr T cbrt_2() {
72 return T(1.25992104989487316476721060727822835057025L);
73}
74
75/**@}*/
76
77/// error code if no error occurred
78#define ES_OK 0
79/// error code if an error occurred
80#define ES_ERROR 1
81
82} // namespace Utils
83
84#endif
#define DEVICE_QUALIFIER
DEVICE_QUALIFIER constexpr T cbrt_2()
Cube root of 2.
Definition constants.hpp:71
DEVICE_QUALIFIER constexpr T pi()
Ratio of diameter and circumference of a circle.
Definition constants.hpp:36
DEVICE_QUALIFIER constexpr T ln_2()
Natural logarithm of 2.
Definition constants.hpp:57
DEVICE_QUALIFIER constexpr T sqrt_2()
Square root of 2.
Definition constants.hpp:64
DEVICE_QUALIFIER constexpr T gamma()
Euler-Mascheroni constant.
Definition constants.hpp:50
DEVICE_QUALIFIER constexpr T sqrt_pi_i()
One over square root of pi.
Definition constants.hpp:43