2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2012,2014,2015,2018,2019, The GROMACS development team.
7 * Copyright (c) 2020,2021, by the GROMACS development team, led by
8 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
9 * and including many others, as listed in the AUTHORS file in the
10 * top-level source directory and at http://www.gromacs.org.
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.
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.
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.
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.
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.
38 #ifndef GMX_MATH_UNITS_H
39 #define GMX_MATH_UNITS_H
44 * Physical constants to be used in Gromacs.
45 * No constants (apart from 0, 1 or 2) should
46 * be anywhere else in the code.
52 constexpr double c_angstrom = 1e-10;
53 constexpr double c_kilo = 1e3;
54 constexpr double c_nano = 1e-9;
55 constexpr double c_pico = 1e-12;
56 constexpr double c_nm2A = c_nano / c_angstrom;
57 constexpr double c_rad2Deg = 180.0 / M_PI;
58 constexpr double c_deg2Rad = M_PI / 180.0;
59 constexpr double c_cal2Joule = 4.184; /* Exact definition of the calorie */
60 constexpr double c_electronCharge = 1.602176634e-19; /* Exact definition, Coulomb NIST 2018 CODATA */
62 constexpr double c_amu = 1.66053906660e-27; /* kg, NIST 2018 CODATA */
63 constexpr double c_boltzmann = 1.380649e-23; /* (J/K, Exact definition, NIST 2018 CODATA */
64 constexpr double c_avogadro = 6.02214076e23; /* 1/mol, Exact definition, NIST 2018 CODATA */
65 constexpr double c_universalGasConstant = c_boltzmann * c_avogadro; /* (J/(mol K)) */
66 constexpr double c_boltz = c_universalGasConstant / c_kilo; /* (kJ/(mol K)) */
67 constexpr double c_faraday = c_electronCharge * c_avogadro; /* (C/mol) */
68 constexpr double c_planck1 = 6.62607015e-34; /* J/Hz, Exact definition, NIST 2018 CODATA */
69 constexpr double c_planck = (c_planck1 * c_avogadro / (c_pico * c_kilo)); /* (kJ/mol) ps */
71 constexpr double c_epsilon0Si = 8.8541878128e-12; /* F/m, NIST 2018 CODATA */
72 /* Epsilon in our MD units: (e^2 / Na (kJ nm)) == (e^2 mol/(kJ nm)) */
73 constexpr double c_epsilon0 =
74 ((c_epsilon0Si * c_nano * c_kilo) / (c_electronCharge * c_electronCharge * c_avogadro));
76 constexpr double c_speedOfLight =
77 2.99792458e05; /* units of nm/ps, Exact definition, NIST 2018 CODATA */
79 constexpr double c_rydberg = 1.0973731568160e-02; /* nm^-1, NIST 2018 CODATA */
81 constexpr double c_one4PiEps0 = (1.0 / (4.0 * M_PI * c_epsilon0));
83 /* Pressure in MD units is:
84 * 1 bar = 1e5 Pa = 1e5 kg m^-1 s^-2 = 1e-28 kg nm^-1 ps^-2 = 1e-28 / amu amu nm^1 ps ^2
86 constexpr double c_barMdunits = (1e5 * c_nano * c_pico * c_pico / c_amu);
87 constexpr double c_presfac = 1.0 / c_barMdunits;
89 /* c_debye2Enm should be (1e-21*c_pico)/(c_speedOfLight*c_electronCharge*c_nano*c_nano),
90 * but we need to factor out some of the exponents to avoid single-precision overflows.
92 constexpr double c_debye2Enm = (1e-15 / (c_speedOfLight * c_electronCharge));
93 constexpr double c_enm2Debye = 1.0 / c_debye2Enm;
95 /* to convert from a acceleration in (e V)/(amu nm) */
96 /* c_fieldfac is also Faraday's constant and c_electronCharge/(1e6 amu) */
97 constexpr double c_fieldfac = c_faraday / c_kilo;
99 /* to convert AU to MD units: */
100 constexpr double c_hartree2Kj = ((2.0 * c_rydberg * c_planck * c_speedOfLight) / c_avogadro);
101 constexpr double c_bohr2Nm = 0.0529177210903; /* nm^-1, NIST 2018 CODATA */
102 constexpr double c_hartreeBohr2Md = (c_hartree2Kj * c_avogadro / c_bohr2Nm);
106 /* The four basic units */
107 #define unit_length "nm"
108 #define unit_time "ps"
109 #define unit_mass "u"
110 #define unit_energy "kJ/mol"
112 /* Temperature unit, T in this unit times c_boltz give energy in unit_energy */
113 #define unit_temp_K "K"
115 /* Charge unit, electron charge, involves c_one4PiEps0 */
116 #define unit_charge_e "e"
118 /* Pressure unit, pressure in basic units times c_presfac gives this unit */
119 #define unit_pres_bar "bar"
121 /* Dipole unit, debye, conversion from the unit_charge_e involves c_enm2Debye */
122 #define unit_dipole_D "D"
124 /* Derived units from basic units only */
125 #define unit_vel unit_length "/" unit_time
126 #define unit_volume unit_length "^3"
127 #define unit_invtime "1/" unit_time
129 /* Other derived units */
130 #define unit_surft_bar unit_pres_bar " " unit_length
132 /* SI units, conversion from basic units involves c_nano, c_pico and amu */
133 #define unit_length_SI "m"
134 #define unit_time_SI "s"
135 #define unit_mass_SI "kg"
137 #define unit_density_SI unit_mass_SI "/" unit_length_SI "^3"
138 #define unit_invvisc_SI unit_length_SI " " unit_time_SI "/" unit_mass_SI