Improve CUDA codegen flags
[alexxy/gromacs.git] / api / nblib / basicdefinitions.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2020,2021, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*! \inpublicapi \file
36  * \brief
37  * Implements some definitions that are identical to those of gromacs
38  *
39  * \author Victor Holanda <victor.holanda@cscs.ch>
40  * \author Joe Jordan <ejjordan@kth.se>
41  * \author Prashanth Kanduri <kanduri@cscs.ch>
42  * \author Sebastian Keller <keller@cscs.ch>
43  * \author Artem Zhmurov <zhmurov@gmail.com>
44  */
45 #ifndef NBLIB_BASICDEFINITIONS_H
46 #define NBLIB_BASICDEFINITIONS_H
47
48 #include <cmath>
49
50 // from utility/real.h
51 #if GMX_DOUBLE
52 #    ifndef HAVE_REAL
53 typedef double real;
54 #        define HAVE_REAL
55 #    endif
56 #else /* GMX_DOUBLE */
57 #    ifndef HAVE_REAL
58 typedef float real;
59 #        define HAVE_REAL
60 #    endif
61 #endif /* GMX_DOUBLE */
62
63 namespace nblib
64 {
65
66 namespace detail
67 {
68 // from math/units.h
69 constexpr const float  KILO      = 1e3;             /* Thousand */
70 constexpr const double NANO      = 1e-9;            /* A Number */
71 constexpr const double E_CHARGE  = 1.602176634e-19; /* Exact definition, Coulomb NIST 2018 CODATA */
72 constexpr const double BOLTZMANN = 1.380649e-23;    /* (J/K, Exact definition, NIST 2018 CODATA */
73 constexpr const double AVOGADRO  = 6.02214076e23;   /* 1/mol, Exact definition, NIST 2018 CODATA */
74 constexpr const double RGAS      = (BOLTZMANN * AVOGADRO); /* (J/(mol K))  */
75 constexpr const double EPSILON0_SI = 8.8541878128e-12;     /* F/m,  NIST 2018 CODATA */
76 constexpr const double EPSILON0 = ((EPSILON0_SI * NANO * KILO) / (E_CHARGE * E_CHARGE * AVOGADRO));
77
78 // from pbc/ishift.h
79 constexpr const int D_BOX_Z = 1;
80 constexpr const int D_BOX_Y = 1;
81 constexpr const int D_BOX_X = 2;
82 constexpr const int N_BOX_Z = (2 * D_BOX_Z + 1);
83 constexpr const int N_BOX_Y = (2 * D_BOX_Y + 1);
84 constexpr const int N_BOX_X = (2 * D_BOX_X + 1);
85 constexpr const int N_IVEC  = (N_BOX_Z * N_BOX_Y * N_BOX_X);
86 } // namespace detail
87
88 //! Needed for generating Bolzmann velocity distribution (kJ/(mol K))
89 constexpr const real BOLTZ = (detail::RGAS / detail::KILO); /*  */
90
91 #ifndef M_PI
92 //! Required work-around for platforms that don't implement POSIX-style cmath header
93 #    define M_PI 3.14159265358979323846
94 #endif
95
96 //! Charge multiplication factor for Coulomb interactions
97 constexpr const real ONE_4PI_EPS0 = (1.0 / (4.0 * M_PI * detail::EPSILON0));
98
99 //! Conversion factor from degrees to radians
100 constexpr const real DEG2RAD = M_PI / 180.0;
101
102 //! The number of shift vectors needed for pbc
103 constexpr const int numShiftVectors = detail::N_IVEC;
104
105 // from math/vectypes.h
106 constexpr const int dimX = 0; /* Defines for indexing in vectors */
107 constexpr const int dimY = 1;
108 constexpr const int dimZ = 2;
109
110 constexpr const int dimSize = 3;
111 typedef real        rvec[dimSize];
112 typedef real        matrix[dimSize][dimSize];
113 } // namespace nblib
114
115
116 #endif // NBLIB_BASICDEFINITIONS_H