Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / math / units.h
index d241c5ee01c32f6c16090a42c83dfe6e982463ea..1dcfb3cf95cb3b614cc0e5479af14d2476e34a72 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2014,2015,2018, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2018,2019, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 
 #include "gromacs/math/utilities.h"
 
-#define ANGSTROM         (1e-10)                           /* Old...   */
-#define KILO             (1e3)                             /* Thousand */
-#define NANO             (1e-9)                            /* A Number */
-#define PICO             (1e-12)                           /* A Number */
-#define A2NM             (ANGSTROM/NANO)                   /* NANO             */
-#define NM2A             (NANO/ANGSTROM)                   /* 10.0             */
-#define RAD2DEG          (180.0/M_PI)                      /* Conversion       */
-#define DEG2RAD          (M_PI/180.0)                      /* id               */
-#define CAL2JOULE        (4.184)                           /* id               */
-#define E_CHARGE         (1.602176565e-19)                 /* Coulomb, NIST 2010 CODATA */
-
-#define AMU              (1.660538921e-27)                 /* kg, NIST 2010 CODATA  */
-#define BOLTZMANN        (1.3806488e-23)                   /* (J/K, NIST 2010 CODATA */
-#define AVOGADRO         (6.02214129e23)                   /* no unit, NIST 2010 CODATA */
-#define RGAS             (BOLTZMANN*AVOGADRO)              /* (J/(mol K))  */
-#define BOLTZ            (RGAS/KILO)                       /* (kJ/(mol K)) */
-#define FARADAY          (E_CHARGE*AVOGADRO)               /* (C/mol)      */
-#define ELECTRONVOLT     (E_CHARGE*AVOGADRO/KILO)          /* (kJ/mol)   */
-#define PLANCK1          (6.62606957e-34)                  /* J s, NIST 2010 CODATA */
-#define PLANCK           (PLANCK1*AVOGADRO/(PICO*KILO))    /* (kJ/mol) ps */
-
-#define EPSILON0_SI      (8.854187817e-12)                 /* F/m,  NIST 2010 CODATA */
+#define ANGSTROM (1e-10)           /* Old...   */
+#define KILO (1e3)                 /* Thousand */
+#define NANO (1e-9)                /* A Number */
+#define PICO (1e-12)               /* A Number */
+#define A2NM (ANGSTROM / NANO)     /* NANO             */
+#define NM2A (NANO / ANGSTROM)     /* 10.0             */
+#define RAD2DEG (180.0 / M_PI)     /* Conversion       */
+#define DEG2RAD (M_PI / 180.0)     /* id               */
+#define CAL2JOULE (4.184)          /* id               */
+#define E_CHARGE (1.602176565e-19) /* Coulomb, NIST 2010 CODATA */
+
+#define AMU (1.660538921e-27)                       /* kg, NIST 2010 CODATA  */
+#define BOLTZMANN (1.3806488e-23)                   /* (J/K, NIST 2010 CODATA */
+#define AVOGADRO (6.02214129e23)                    /* no unit, NIST 2010 CODATA */
+#define RGAS (BOLTZMANN * AVOGADRO)                 /* (J/(mol K))  */
+#define BOLTZ (RGAS / KILO)                         /* (kJ/(mol K)) */
+#define FARADAY (E_CHARGE * AVOGADRO)               /* (C/mol)      */
+#define ELECTRONVOLT (E_CHARGE * AVOGADRO / KILO)   /* (kJ/mol)   */
+#define PLANCK1 (6.62606957e-34)                    /* J s, NIST 2010 CODATA */
+#define PLANCK (PLANCK1 * AVOGADRO / (PICO * KILO)) /* (kJ/mol) ps */
+
+#define EPSILON0_SI (8.854187817e-12) /* F/m,  NIST 2010 CODATA */
 /* Epsilon in our MD units: (e^2 / Na (kJ nm)) == (e^2 mol/(kJ nm)) */
-#define EPSILON0         ((EPSILON0_SI*NANO*KILO)/(E_CHARGE*E_CHARGE*AVOGADRO))
+#define EPSILON0 ((EPSILON0_SI * NANO * KILO) / (E_CHARGE * E_CHARGE * AVOGADRO))
 
-#define SPEED_OF_LIGHT   (2.99792458E05)                   /* nm/ps, NIST 2010 CODATA */
-#define ATOMICMASS_keV   (931494.061)                      /* Atomic mass in keV, NIST 2010 CODATA   */
-#define ELECTRONMASS_keV (510.998928)                      /* Electron mas in keV, NIST 2010 CODATA  */
+#define SPEED_OF_LIGHT (2.99792458E05) /* nm/ps, NIST 2010 CODATA */
+#define ATOMICMASS_keV (931494.061)    /* Atomic mass in keV, NIST 2010 CODATA   */
+#define ELECTRONMASS_keV (510.998928)  /* Electron mas in keV, NIST 2010 CODATA  */
 
-#define RYDBERG          (1.0973731568539e-02)             /* nm^-1, NIST 2010 CODATA */
+#define RYDBERG (1.0973731568539e-02) /* nm^-1, NIST 2010 CODATA */
 
-#define ONE_4PI_EPS0     (1.0/(4.0*M_PI*EPSILON0))
-#define FACEL            (10.0*ONE_4PI_EPS0)
+#define ONE_4PI_EPS0 (1.0 / (4.0 * M_PI * EPSILON0))
+#define FACEL (10.0 * ONE_4PI_EPS0)
 
 /* Pressure in MD units is:
  * 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
  */
-#define BAR_MDUNITS      (1e5*NANO*PICO*PICO/AMU)
-#define PRESFAC          (1.0/BAR_MDUNITS)
+#define BAR_MDUNITS (1e5 * NANO * PICO * PICO / AMU)
+#define PRESFAC (1.0 / BAR_MDUNITS)
 
 /* DEBYE2ENM should be (1e-21*PICO)/(SPEED_OF_LIGHT*E_CHARGE*NANO*NANO),
  * but we need to factor out some of the exponents to avoid single-precision overflows.
  */
-#define DEBYE2ENM        (1e-15/(SPEED_OF_LIGHT*E_CHARGE))
-#define ENM2DEBYE        (1.0/DEBYE2ENM)
+#define DEBYE2ENM (1e-15 / (SPEED_OF_LIGHT * E_CHARGE))
+#define ENM2DEBYE (1.0 / DEBYE2ENM)
 
 /* to convert from a acceleration in (e V)/(amu nm) */
 /* FIELDFAC is also Faraday's constant and E_CHARGE/(1e6 AMU) */
-#define FIELDFAC         (FARADAY/KILO)
+#define FIELDFAC (FARADAY / KILO)
 
 /* to convert AU to MD units: */
-#define HARTREE2KJ       ((2.0*RYDBERG*PLANCK*SPEED_OF_LIGHT)/AVOGADRO)
-#define BOHR2NM          (0.052917721092)                  /* nm^-1, NIST 2010 CODATA */
-#define HARTREE_BOHR2MD  (HARTREE2KJ*AVOGADRO/BOHR2NM)
+#define HARTREE2KJ ((2.0 * RYDBERG * PLANCK * SPEED_OF_LIGHT) / AVOGADRO)
+#define BOHR2NM (0.052917721092) /* nm^-1, NIST 2010 CODATA */
+#define HARTREE_BOHR2MD (HARTREE2KJ * AVOGADRO / BOHR2NM)
 
 
 /* The four basic units */
-#define unit_length   "nm"
-#define unit_time     "ps"
-#define unit_mass     "u"
-#define unit_energy   "kJ/mol"
+#define unit_length "nm"
+#define unit_time "ps"
+#define unit_mass "u"
+#define unit_energy "kJ/mol"
 
 /* Temperature unit, T in this unit times BOLTZ give energy in unit_energy */
-#define unit_temp_K   "K"
+#define unit_temp_K "K"
 
 /* Charge unit, electron charge, involves ONE_4PI_EPS0 */
 #define unit_charge_e "e"
 #define unit_dipole_D "D"
 
 /* Derived units from basic units only */
-#define unit_vel      unit_length "/" unit_time
-#define unit_volume   unit_length "^3"
-#define unit_invtime  "1/" unit_time
+#define unit_vel unit_length "/" unit_time
+#define unit_volume unit_length "^3"
+#define unit_invtime "1/" unit_time
 
 /* Other derived units */
 #define unit_surft_bar unit_pres_bar " " unit_length
 
 /* SI units, conversion from basic units involves NANO, PICO and AMU */
-#define unit_length_SI  "m"
-#define unit_time_SI    "s"
-#define unit_mass_SI    "kg"
+#define unit_length_SI "m"
+#define unit_time_SI "s"
+#define unit_mass_SI "kg"
 
 #define unit_density_SI unit_mass_SI "/" unit_length_SI "^3"
 #define unit_invvisc_SI unit_length_SI " " unit_time_SI "/" unit_mass_SI
 
 /* The routines below can be used for converting units from or to GROMACS
    internal units. */
-enum {
-    eg2cAngstrom, eg2cNm, eg2cBohr, eg2cKcal_Mole,
-    eg2cHartree, eg2cHartree_e, eg2cAngstrom3, eg2cCoulomb,
-    eg2cDebye, eg2cElectron, eg2cBuckingham, eg2cNR
+enum
+{
+    eg2cAngstrom,
+    eg2cNm,
+    eg2cBohr,
+    eg2cKcal_Mole,
+    eg2cHartree,
+    eg2cHartree_e,
+    eg2cAngstrom3,
+    eg2cCoulomb,
+    eg2cDebye,
+    eg2cElectron,
+    eg2cBuckingham,
+    eg2cNR
 };
 
 /* Convert value x to GROMACS units. Energy -> Energy, Length -> Length etc.
@@ -153,9 +163,9 @@ extern double convert2gmx(double x, int unit);
 extern double gmx2convert(double x, int unit);
 
 /* Convert the string to one of the units supported. Returns -1 if not found. */
-extern int string2unit(char *string);
+extern int string2unit(charstring);
 
 /* Convert the unit to a string. Return NULL when unit is out of range. */
-extern const char *unit2string(int unit);
+extern const charunit2string(int unit);
 
 #endif