Fix malformed CUDA version macro check
[alexxy/gromacs.git] / include / physics.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team,
6  * check out http://www.gromacs.org for more information.
7  * Copyright (c) 2012,2013, by the GROMACS development team, led by
8  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9  * others, as listed in the AUTHORS file in the top-level source
10  * directory and at http://www.gromacs.org.
11  *
12  * GROMACS is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 2.1
15  * of the License, or (at your option) any later version.
16  *
17  * GROMACS is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with GROMACS; if not, see
24  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
26  *
27  * If you want to redistribute modifications to GROMACS, please
28  * consider that scientific software is very special. Version
29  * control is crucial - bugs must be traceable. We will be happy to
30  * consider code for inclusion in the official distribution, but
31  * derived work must not be called official GROMACS. Details are found
32  * in the README & COPYING files - if they are missing, get the
33  * official version at http://www.gromacs.org.
34  *
35  * To help us fund GROMACS development, we humbly ask that you cite
36  * the research papers on the package. Check out http://www.gromacs.org.
37  */
38
39 #ifndef _physics_h
40 #define _physics_h
41
42 /*
43  * Physical constants to be used in Gromacs.
44  * No constants (apart from 0, 1 or 2) should
45  * be anywhere else in the code.
46  */
47
48 #include <math.h>
49
50 /* we do it anyway. */
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54
55 #ifndef M_PI
56 #ifdef _PI
57 #define M_PI _PI
58 #else
59 #define M_PI        3.14159265358979323846
60 #endif
61 #endif
62
63 #define ANGSTROM     (1e-10)                               /* Old...    */
64 #define KILO         (1e3)                                 /* Thousand  */
65 #define NANO         (1e-9)                                /* A Number  */
66 #define PICO         (1e-12)                               /* A Number  */
67 #define A2NM         (ANGSTROM/NANO)                       /* NANO              */
68 #define NM2A         (NANO/ANGSTROM)                       /* 10.0              */
69 #define RAD2DEG      (180.0/M_PI)                          /* Conversion        */
70 #define DEG2RAD      (M_PI/180.0)                          /* id                */
71 #define CAL2JOULE    (4.184)                               /* id                */
72 #define E_CHARGE         (1.60217733e-19)                  /* Coulomb   */
73
74 #define AMU              (1.6605402e-27)                   /* kg           */
75 #define BOLTZMANN    (1.380658e-23)                        /* (J/K)     */
76 #define AVOGADRO     (6.0221367e23)                        /* ()                */
77 #define RGAS             (BOLTZMANN*AVOGADRO)              /* (J/(mol K))  */
78 #define BOLTZ            (RGAS/KILO)                       /* (kJ/(mol K)) */
79 #define FARADAY          (E_CHARGE*AVOGADRO)               /* (C/mol)      */
80 #define ELECTRONVOLT     (E_CHARGE*AVOGADRO/KILO)          /* (kJ/mol)   */
81 #define PLANCK1          (6.6262e-34)                      /* J s */
82 #define PLANCK           (6.6262e-34*AVOGADRO/(PICO*KILO)) /* (kJ/mol) ps */
83
84 #define EPSILON0     (5.72765E-4)                          /* (e^2 / Na (kJ nm))
85                                                               == (e^2 mol/(kJ nm)) */
86
87 #define SPEED_OF_LIGHT   (2.9979245800E05)                 /* nm/ps                */
88 #define ATOMICMASS_keV   (940000.0)                        /* Atomic mass in keV   */
89 #define ELECTRONMASS_keV (512.0)                           /* Electron mas in keV  */
90
91 /* Improved accuracy (PL & EL, 20090421) */
92 #define FACEL        (332.0636930*CAL2JOULE) /* (10 * (ONE_4PI_EPS0)) */
93 #define ONE_4PI_EPS0     (FACEL*0.1)         /* 1/(4*pi*e0)*/
94 #define PRESFAC           (16.6054)          /* bar / pressure unity */
95 #define ENM2DEBYE         48.0321            /* Convert electron nm  *
96                                               * to debye             */
97 #define DEBYE2ENM         0.02081941
98 /* to convert from a acceleration in (e V)/(amu nm) */
99 /* FIELDFAC is also Faraday's constant and E_CHARGE/(1e6 AMU) */
100 #define FIELDFAC          (FARADAY/KILO)
101
102 /* to convert AU to MD units: */
103 #define HARTREE2KJ        4.3597482e-21
104 #define BOHR2NM           0.0529177249
105 #define HARTREE_BOHR2MD   (HARTREE2KJ*AVOGADRO/BOHR2NM)
106
107
108 /* The four basic units */
109 #define unit_length   "nm"
110 #define unit_time     "ps"
111 #define unit_mass     "u"
112 #define unit_energy   "kJ/mol"
113
114 /* Temperature unit, T in this unit times BOLTZ give energy in unit_energy */
115 #define unit_temp_K   "K"
116
117 /* Charge unit, electron charge, involves ONE_4PI_EPS0 */
118 #define unit_charge_e "e"
119
120 /* Pressure unit, pressure in basic units times PRESFAC gives this unit */
121 #define unit_pres_bar "bar"
122
123 /* Dipole unit, debye, conversion from the unit_charge_e involves ENM2DEBYE */
124 #define unit_dipole_D "D"
125
126 /* Derived units from basic units only */
127 #define unit_vel      unit_length "/" unit_time
128 #define unit_volume   unit_length "^3"
129 #define unit_invtime  "1/" unit_time
130
131 /* Other derived units */
132 #define unit_surft_bar unit_pres_bar " " unit_length
133
134 /* SI units, conversion from basic units involves NANO, PICO and AMU */
135 #define unit_length_SI  "m"
136 #define unit_time_SI    "s"
137 #define unit_mass_SI    "kg"
138
139 #define unit_density_SI unit_mass_SI "/" unit_length_SI "^3"
140 #define unit_invvisc_SI unit_length_SI " " unit_time_SI "/" unit_mass_SI
141
142 /* The routines below can be used for converting units from or to GROMACS
143    internal units. */
144 enum {
145     eg2cAngstrom, eg2cNm, eg2cBohr, eg2cKcal_Mole,
146     eg2cHartree, eg2cHartree_e, eg2cAngstrom3, eg2cCoulomb,
147     eg2cDebye, eg2cElectron, eg2cBuckingham, eg2cNR
148 };
149
150 /* Convert value x to GROMACS units. Energy -> Energy, Length -> Length etc.
151    The type of x is deduced from unit,
152    which should be taken from the enum above. */
153 extern double convert2gmx(double x, int unit);
154
155 /* Convert value x from GROMACS units to the desired one.
156    The type of return value is deduced from unit, see above */
157 extern double gmx2convert(double x, int unit);
158
159 /* Convert the string to one of the units supported. Returns -1 if not found. */
160 extern int string2unit(char *string);
161
162 /* Convert the unit to a string. Return NULL when unit is out of range. */
163 extern const char *unit2string(int unit);
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169
170 #endif  /* _physics_h */