Use constexpr for physical constants and move them into gmx namespace
authorJoe Jordan <ejjordan12@gmail.com>
Tue, 9 Mar 2021 14:33:55 +0000 (14:33 +0000)
committerPaul Bauer <paul.bauer.q@gmail.com>
Tue, 9 Mar 2021 14:33:55 +0000 (14:33 +0000)
The physical constants that are part of the public API are converted from
defines to constexprs and are moved into the gmx namespace. This means
that many files are touched with tirvial changes. The benefit is that
now the risk of symbol collision is reduced in cases where a library
might depend on these constants.

Additionally, in the same vein of library cleanup, the math/utility
header is removed from units header and included only in the sources
that actually need it.

85 files changed:
api/legacy/include/gromacs/math/units.h
src/gromacs/applied_forces/awh/awh.cpp
src/gromacs/applied_forces/awh/dimparams.h
src/gromacs/applied_forces/electricfield.cpp
src/gromacs/ewald/ewald.cpp
src/gromacs/ewald/long_range_correction.cpp
src/gromacs/ewald/pme_gpu_internal.cpp
src/gromacs/ewald/pme_gpu_types.h
src/gromacs/ewald/pme_solve.cpp
src/gromacs/fileio/pdbio.cpp
src/gromacs/fileio/tngio.cpp
src/gromacs/gmxana/anadih.cpp
src/gromacs/gmxana/angle_correction.h
src/gromacs/gmxana/gmx_angle.cpp
src/gromacs/gmxana/gmx_awh.cpp
src/gromacs/gmxana/gmx_bar.cpp
src/gromacs/gmxana/gmx_bundle.cpp
src/gromacs/gmxana/gmx_chi.cpp
src/gromacs/gmxana/gmx_clustsize.cpp
src/gromacs/gmxana/gmx_current.cpp
src/gromacs/gmxana/gmx_density.cpp
src/gromacs/gmxana/gmx_densorder.cpp
src/gromacs/gmxana/gmx_dipoles.cpp
src/gromacs/gmxana/gmx_dos.cpp
src/gromacs/gmxana/gmx_enemat.cpp
src/gromacs/gmxana/gmx_energy.cpp
src/gromacs/gmxana/gmx_hbond.cpp
src/gromacs/gmxana/gmx_nmeig.cpp
src/gromacs/gmxana/gmx_nmens.cpp
src/gromacs/gmxana/gmx_nmtraj.cpp
src/gromacs/gmxana/gmx_rama.cpp
src/gromacs/gmxana/gmx_sham.cpp
src/gromacs/gmxana/gmx_sigeps.cpp
src/gromacs/gmxana/gmx_spol.cpp
src/gromacs/gmxana/gmx_tcaf.cpp
src/gromacs/gmxana/gmx_traj.cpp
src/gromacs/gmxana/gmx_velacc.cpp
src/gromacs/gmxana/gmx_wham.cpp
src/gromacs/gmxana/hxprops.cpp
src/gromacs/gmxana/pp2shift.cpp
src/gromacs/gmxana/thermochemistry.cpp
src/gromacs/gmxpreprocess/calch.cpp
src/gromacs/gmxpreprocess/convparm.cpp
src/gromacs/gmxpreprocess/editconf.cpp
src/gromacs/gmxpreprocess/gen_maxwell_velocities.cpp
src/gromacs/gmxpreprocess/gen_vsite.cpp
src/gromacs/gmxpreprocess/genion.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/hizzie.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/gmxpreprocess/solvate.cpp
src/gromacs/gmxpreprocess/topshake.cpp
src/gromacs/gmxpreprocess/vsite_parm.cpp
src/gromacs/gmxpreprocess/x2top.cpp
src/gromacs/imd/imd.cpp
src/gromacs/listed_forces/bonded.cpp
src/gromacs/listed_forces/restcbt.cpp
src/gromacs/mdlib/calc_verletbuf.cpp
src/gromacs/mdlib/calcmu.cpp
src/gromacs/mdlib/coupling.cpp
src/gromacs/mdlib/dispersioncorrection.cpp
src/gromacs/mdlib/energyoutput.cpp
src/gromacs/mdlib/expanded.cpp
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/lincs.cpp
src/gromacs/mdlib/rf_util.cpp
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdlib/update.cpp
src/gromacs/mdlib/updategroups.cpp
src/gromacs/mdrun/replicaexchange.cpp
src/gromacs/mdrun/shellfc.cpp
src/gromacs/mdrun/tpi.cpp
src/gromacs/mimic/communicator.cpp
src/gromacs/modularsimulator/parrinellorahmanbarostat.cpp
src/gromacs/modularsimulator/velocityscalingtemperaturecoupling.cpp
src/gromacs/pbcutil/pbc.cpp
src/gromacs/pulling/pull.cpp
src/gromacs/selection/params.cpp
src/gromacs/selection/sm_insolidangle.cpp
src/gromacs/tables/forcetable.cpp
src/gromacs/tools/check.cpp
src/gromacs/tools/pme_error.cpp
src/gromacs/trajectoryanalysis/modules/angle.cpp
src/gromacs/trajectoryanalysis/modules/freevolume.cpp
src/gromacs/trajectoryanalysis/modules/sasa.cpp

index a83a006c8491d112d39b53b91e625d848fe30816..cf869851efab7de0f47c7ca9445bb5d4a6477b25 100644 (file)
 #ifndef GMX_MATH_UNITS_H
 #define GMX_MATH_UNITS_H
 
+#include <cmath>
+
 /*
  * Physical constants to be used in Gromacs.
  * No constants (apart from 0, 1 or 2) should
  * be anywhere else in the code.
  */
 
-#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)          /* Exact definition of the calorie */
-#define E_CHARGE (1.602176634e-19) /* Exact definition, Coulomb NIST 2018 CODATA */
-
-#define AMU (1.66053906660e-27)                     /* kg, NIST 2018 CODATA  */
-#define BOLTZMANN (1.380649e-23)                    /* (J/K, Exact definition, NIST 2018 CODATA */
-#define AVOGADRO (6.02214076e23)                    /* 1/mol, Exact definition, NIST 2018 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.62607015e-34)                    /* J/Hz, Exact definition, NIST 2018 CODATA */
-#define PLANCK (PLANCK1 * AVOGADRO / (PICO * KILO)) /* (kJ/mol) ps */
-
-#define EPSILON0_SI (8.8541878128e-12) /* F/m,  NIST 2018 CODATA */
+namespace gmx
+{
+
+constexpr double c_angstrom       = 1e-10;
+constexpr double c_kilo           = 1e3;
+constexpr double c_nano           = 1e-9;
+constexpr double c_pico           = 1e-12;
+constexpr double c_nm2A           = c_nano / c_angstrom;
+constexpr double c_rad2Deg        = 180.0 / M_PI;
+constexpr double c_deg2Rad        = M_PI / 180.0;
+constexpr double c_cal2Joule      = 4.184;           /* Exact definition of the calorie */
+constexpr double c_electronCharge = 1.602176634e-19; /* Exact definition, Coulomb NIST 2018 CODATA */
+
+constexpr double c_amu       = 1.66053906660e-27; /* kg, NIST 2018 CODATA  */
+constexpr double c_boltzmann = 1.380649e-23;      /* (J/K, Exact definition, NIST 2018 CODATA */
+constexpr double c_avogadro  = 6.02214076e23;     /* 1/mol, Exact definition, NIST 2018 CODATA */
+constexpr double c_universalGasConstant = c_boltzmann * c_avogadro;        /* (J/(mol K))  */
+constexpr double c_boltz                = c_universalGasConstant / c_kilo; /* (kJ/(mol K)) */
+constexpr double c_faraday              = c_electronCharge * c_avogadro;   /* (C/mol)      */
+constexpr double c_planck1 = 6.62607015e-34; /* J/Hz, Exact definition, NIST 2018 CODATA */
+constexpr double c_planck  = (c_planck1 * c_avogadro / (c_pico * c_kilo)); /* (kJ/mol) ps */
+
+constexpr double c_epsilon0Si = 8.8541878128e-12; /* F/m,  NIST 2018 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))
+constexpr double c_epsilon0 =
+        ((c_epsilon0Si * c_nano * c_kilo) / (c_electronCharge * c_electronCharge * c_avogadro));
 
-#define SPEED_OF_LIGHT (2.99792458e05)  /* units of nm/ps, Exact definition, NIST 2018 CODATA */
-#define ATOMICMASS_keV (931494.10242)   /* Atomic mass in keV, NIST 2018 CODATA   */
-#define ELECTRONMASS_keV (510.99895000) /* Electron mas in keV, NIST 2018 CODATA  */
+constexpr double c_speedOfLight =
+        2.99792458e05; /* units of nm/ps, Exact definition, NIST 2018 CODATA */
 
-#define RYDBERG (1.0973731568160e-02) /* nm^-1, NIST 2018 CODATA */
+constexpr double c_rydberg = 1.0973731568160e-02; /* nm^-1, NIST 2018 CODATA */
 
-#define ONE_4PI_EPS0 (1.0 / (4.0 * M_PI * EPSILON0))
-#define FACEL (10.0 * ONE_4PI_EPS0)
+constexpr double c_one4PiEps0 = (1.0 / (4.0 * M_PI * c_epsilon0));
 
 /* 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
+ * 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)
+constexpr double c_barMdunits = (1e5 * c_nano * c_pico * c_pico / c_amu);
+constexpr double c_presfac    = 1.0 / c_barMdunits;
 
-/* DEBYE2ENM should be (1e-21*PICO)/(SPEED_OF_LIGHT*E_CHARGE*NANO*NANO),
+/* c_debye2Enm should be (1e-21*c_pico)/(c_speedOfLight*c_electronCharge*c_nano*c_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)
+constexpr double c_debye2Enm = (1e-15 / (c_speedOfLight * c_electronCharge));
+constexpr double c_enm2Debye = 1.0 / c_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)
+/* c_fieldfac is also Faraday's constant and c_electronCharge/(1e6 amu) */
+constexpr double c_fieldfac = c_faraday / c_kilo;
 
 /* to convert AU to MD units: */
-#define HARTREE2KJ ((2.0 * RYDBERG * PLANCK * SPEED_OF_LIGHT) / AVOGADRO)
-#define BOHR2NM (0.0529177210903) /* nm^-1, NIST 2018 CODATA */
-#define HARTREE_BOHR2MD (HARTREE2KJ * AVOGADRO / BOHR2NM)
+constexpr double c_hartree2Kj     = ((2.0 * c_rydberg * c_planck * c_speedOfLight) / c_avogadro);
+constexpr double c_bohr2Nm        = 0.0529177210903; /* nm^-1, NIST 2018 CODATA */
+constexpr double c_hartreeBohr2Md = (c_hartree2Kj * c_avogadro / c_bohr2Nm);
 
+} // namespace gmx
 
 /* The four basic units */
 #define unit_length "nm"
 #define unit_mass "u"
 #define unit_energy "kJ/mol"
 
-/* Temperature unit, T in this unit times BOLTZ give energy in unit_energy */
+/* Temperature unit, T in this unit times c_boltz give energy in unit_energy */
 #define unit_temp_K "K"
 
-/* Charge unit, electron charge, involves ONE_4PI_EPS0 */
+/* Charge unit, electron charge, involves c_one4PiEps0 */
 #define unit_charge_e "e"
 
-/* Pressure unit, pressure in basic units times PRESFAC gives this unit */
+/* Pressure unit, pressure in basic units times c_presfac gives this unit */
 #define unit_pres_bar "bar"
 
-/* Dipole unit, debye, conversion from the unit_charge_e involves ENM2DEBYE */
+/* Dipole unit, debye, conversion from the unit_charge_e involves c_enm2Debye */
 #define unit_dipole_D "D"
 
 /* Derived units from basic units only */
 /* Other derived units */
 #define unit_surft_bar unit_pres_bar " " unit_length
 
-/* SI units, conversion from basic units involves NANO, PICO and AMU */
+/* SI units, conversion from basic units involves c_nano, c_pico and amu */
 #define unit_length_SI "m"
 #define unit_time_SI "s"
 #define unit_mass_SI "kg"
index 8c80087391383c18879a6134af4c0e4c12532f1b..d55853d93303f7c55c0a543af5b0f6f1140807a6 100644 (file)
@@ -215,7 +215,7 @@ Awh::Awh(FILE*                 fplog,
     }
 
     /* Initialize all the biases */
-    const double beta = 1 / (BOLTZ * inputRecord.opts.ref_t[0]);
+    const double beta = 1 / (gmx::c_boltz * inputRecord.opts.ref_t[0]);
     for (int k = 0; k < awhParams.numBias; k++)
     {
         const AwhBiasParams& awhBiasParams = awhParams.awhBiasParams[k];
@@ -240,7 +240,7 @@ Awh::Awh(FILE*                 fplog,
                     GMX_THROW(InvalidInputError(
                             "Pull geometry 'direction-periodic' is not supported by AWH"));
                 }
-                double conversionFactor = pull_coordinate_is_angletype(&pullCoord) ? DEG2RAD : 1;
+                double conversionFactor = pull_coordinate_is_angletype(&pullCoord) ? gmx::c_deg2Rad : 1;
                 pullCoordIndex.push_back(awhDimParams.coordIndex);
                 dimParams.push_back(DimParams::pullDimParams(
                         conversionFactor, awhDimParams.forceConstant, beta));
index 2b3ac017205328a12e114f0093ac8dcd1be5560e..11fc93f83c2b50c09ce0dc704eba0279c854b787 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, 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.
@@ -103,7 +103,7 @@ public:
      * Builder function for pull dimension parameters.
      *
      * \param[in] conversionFactor  Conversion factor from user coordinate units to bias internal
-     * units (=DEG2RAD for angles).
+     * units (=c_deg2Rad for angles).
      * \param[in] forceConstant     The harmonic force constant.
      * \param[in] beta              1/(k_B T).
      */
index 5be37f1de15eddf38688c85b7f1b4e1e196b6820..6c4381747aa9b5c4dda5caa4883eb25c333db04f 100644 (file)
@@ -312,7 +312,7 @@ void ElectricField::calculateForces(const ForceProviderInput& forceProviderInput
 
         for (int m = 0; (m < DIM); m++)
         {
-            const real fieldStrength = FIELDFAC * field(m, t);
+            const real fieldStrength = gmx::c_fieldfac * field(m, t);
 
             if (fieldStrength != 0)
             {
index 5f67078b6805e3bee292a57f3418014e9b68c29e..26185de74a0b59323509449e1a5a54e65f51246a 100644 (file)
@@ -173,7 +173,8 @@ real do_ewald(const t_inputrec& ir,
     }
 
     /* 1/(Vol*e0) */
-    real scaleRecip = 4.0 * M_PI / (boxDiag[XX] * boxDiag[YY] * boxDiag[ZZ]) * ONE_4PI_EPS0 / ir.epsilon_r;
+    real scaleRecip =
+            4.0 * M_PI / (boxDiag[XX] * boxDiag[YY] * boxDiag[ZZ]) * gmx::c_one4PiEps0 / ir.epsilon_r;
 
     snew(eir, et->kmax);
     for (n = 0; n < et->kmax; n++)
@@ -328,7 +329,7 @@ real ewald_charge_correction(const t_commrec*  cr,
         /* Apply charge correction */
         vol = box[XX][XX] * box[YY][YY] * box[ZZ][ZZ];
 
-        fac = M_PI * ONE_4PI_EPS0
+        fac = M_PI * gmx::c_one4PiEps0
               / (fr->ic->epsilon_r * 2.0 * vol * vol * gmx::square(fr->ic->ewaldcoeff_q));
 
         qs2A = fr->qsum[0] * fr->qsum[0];
index a746ae8bc865e7dd2f27dc0f0e47302a667f528c..ce2625717c2b2f52b304fcc8ff99cabcdeaeca95 100644 (file)
@@ -98,7 +98,7 @@ void ewald_LRcorrection(const int         numAtomsLocal,
     EwaldBoxZScaler boxScaler(ir);
     boxScaler.scaleBox(box, scaledBox);
 
-    one_4pi_eps = ONE_4PI_EPS0 / fr.ic->epsilon_r;
+    one_4pi_eps = gmx::c_one4PiEps0 / fr.ic->epsilon_r;
     Vexcl_q     = 0;
     dvdl_excl_q = 0;
     Vdipole[0]  = 0;
@@ -109,8 +109,8 @@ void ewald_LRcorrection(const int         numAtomsLocal,
      */
     for (i = 0; (i < DIM); i++)
     {
-        mutot[0][i] = mu_tot[0][i] * DEBYE2ENM;
-        mutot[1][i] = mu_tot[1][i] * DEBYE2ENM;
+        mutot[0][i] = mu_tot[0][i] * gmx::c_debye2Enm;
+        mutot[1][i] = mu_tot[1][i] * gmx::c_debye2Enm;
         dipcorrA[i] = 0;
         dipcorrB[i] = 0;
     }
@@ -122,7 +122,7 @@ void ewald_LRcorrection(const int         numAtomsLocal,
         case EwaldGeometry::ThreeD:
             if (ir.epsilon_surface != 0)
             {
-                dipole_coeff = 2 * M_PI * ONE_4PI_EPS0
+                dipole_coeff = 2 * M_PI * gmx::c_one4PiEps0
                                / ((2 * ir.epsilon_surface + fr.ic->epsilon_r) * boxVolume);
                 for (i = 0; (i < DIM); i++)
                 {
index 0d7ee39e234b0e321cfc04c2b8a85f6568dc2edc..028a66a35a9f30df54cdfc40e1628b878b9ae154 100644 (file)
@@ -898,7 +898,7 @@ static void pme_gpu_init(gmx_pme_t*           pme,
     GMX_ASSERT(pmeGpu->common->epsilon_r != 0.0F, "PME GPU: bad electrostatic coefficient");
 
     auto* kernelParamsPtr               = pme_gpu_get_kernel_params_base_ptr(pmeGpu);
-    kernelParamsPtr->constants.elFactor = ONE_4PI_EPS0 / pmeGpu->common->epsilon_r;
+    kernelParamsPtr->constants.elFactor = gmx::c_one4PiEps0 / pmeGpu->common->epsilon_r;
 }
 
 void pme_gpu_get_real_grid_sizes(const PmeGpu* pmeGpu, gmx::IVec* gridSize, gmx::IVec* paddedGridSize)
index 4274f095d99619e642b4e6d423e161af180a51bc..abf7a17ed002900ab17583d96f7256565b656ebb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019,2020,2021, 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.
@@ -100,7 +100,7 @@ static_assert(sizeof(DeviceBuffer<int>) == 8,
  */
 struct PmeGpuConstParams
 {
-    /*! \brief Electrostatics coefficient = ONE_4PI_EPS0 / pme->epsilon_r */
+    /*! \brief Electrostatics coefficient = c_one4PiEps0 / pme->epsilon_r */
     float elFactor;
     /*! \brief Virial and energy GPU array. Size is c_virialAndEnergyCount (7) floats.
      * The element order is virxx, viryy, virzz, virxy, virxz, viryz, energy. */
index 03ca35bfeee4c1ba085e00a1ac4a308344c584da..416f67b3e14aa3829d18a68992bad215b4d447a1 100644 (file)
@@ -352,7 +352,7 @@ int solve_pme_yzx(const gmx_pme_t* pme, t_complex* grid, real vol, bool computeE
     ivec                     local_ndata, local_offset, local_size;
     real                     elfac;
 
-    elfac = ONE_4PI_EPS0 / pme->epsilon_r;
+    elfac = gmx::c_one4PiEps0 / pme->epsilon_r;
 
     nx = pme->nkx;
     ny = pme->nky;
index 530459e2ab61e9413192448806d3b70f6f938def..2025fd17ae2163e79e71c7964f7f42cc5ac6ce19 100644 (file)
@@ -104,7 +104,7 @@ void gmx_write_pdb_box(FILE* out, PbcType pbcType, const matrix box)
 
     if (norm2(box[YY]) * norm2(box[ZZ]) != 0)
     {
-        alpha = RAD2DEG * gmx_angle(box[YY], box[ZZ]);
+        alpha = gmx::c_rad2Deg * gmx_angle(box[YY], box[ZZ]);
     }
     else
     {
@@ -112,7 +112,7 @@ void gmx_write_pdb_box(FILE* out, PbcType pbcType, const matrix box)
     }
     if (norm2(box[XX]) * norm2(box[ZZ]) != 0)
     {
-        beta = RAD2DEG * gmx_angle(box[XX], box[ZZ]);
+        beta = gmx::c_rad2Deg * gmx_angle(box[XX], box[ZZ]);
     }
     else
     {
@@ -120,7 +120,7 @@ void gmx_write_pdb_box(FILE* out, PbcType pbcType, const matrix box)
     }
     if (norm2(box[XX]) * norm2(box[YY]) != 0)
     {
-        gamma = RAD2DEG * gmx_angle(box[XX], box[YY]);
+        gamma = gmx::c_rad2Deg * gmx_angle(box[XX], box[YY]);
     }
     else
     {
@@ -206,7 +206,7 @@ static void read_cryst1(char* line, PbcType* pbcType, matrix box)
         {
             if (alpha != 90.0)
             {
-                cosa = std::cos(alpha * DEG2RAD);
+                cosa = std::cos(alpha * gmx::c_deg2Rad);
             }
             else
             {
@@ -214,7 +214,7 @@ static void read_cryst1(char* line, PbcType* pbcType, matrix box)
             }
             if (beta != 90.0)
             {
-                cosb = std::cos(beta * DEG2RAD);
+                cosb = std::cos(beta * gmx::c_deg2Rad);
             }
             else
             {
@@ -222,8 +222,8 @@ static void read_cryst1(char* line, PbcType* pbcType, matrix box)
             }
             if (gamma != 90.0)
             {
-                cosg = std::cos(gamma * DEG2RAD);
-                sing = std::sin(gamma * DEG2RAD);
+                cosg = std::cos(gamma * gmx::c_deg2Rad);
+                sing = std::sin(gamma * gmx::c_deg2Rad);
             }
             else
             {
index 90615238cc614f446b6976770cf3c4334a5ab842..485d3e35b21741d4e27e03eba96240c9fadfd71f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2018,2019,2020,2021, 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.
@@ -549,7 +549,7 @@ void gmx_tng_prepare_md_writing(gmx_tng_trajectory_t gmx_tng, const gmx_mtop_t*
 #if GMX_USE_TNG
     gmx_tng_add_mtop(gmx_tng, mtop);
     set_writing_intervals(gmx_tng, FALSE, ir);
-    tng_time_per_frame_set(gmx_tng->tng, ir->delta_t * PICO);
+    tng_time_per_frame_set(gmx_tng->tng, ir->delta_t * gmx::c_pico);
     gmx_tng->timePerFrameIsSet = true;
 #else
     GMX_UNUSED_VALUE(gmx_tng);
@@ -765,7 +765,7 @@ void gmx_tng_prepare_low_prec_writing(gmx_tng_trajectory_t gmx_tng, const gmx_mt
     gmx_tng_add_mtop(gmx_tng, mtop);
     add_selection_groups(gmx_tng, mtop);
     set_writing_intervals(gmx_tng, TRUE, ir);
-    tng_time_per_frame_set(gmx_tng->tng, ir->delta_t * PICO);
+    tng_time_per_frame_set(gmx_tng->tng, ir->delta_t * gmx::c_pico);
     gmx_tng->timePerFrameIsSet = true;
     gmx_tng_set_compression_precision(gmx_tng, ir->x_compression_precision);
 #else
@@ -801,7 +801,7 @@ void gmx_fwrite_tng(gmx_tng_trajectory_t gmx_tng,
 #    else
     static write_data_func_pointer    write_data           = tng_util_generic_with_time_write;
 #    endif
-    double  elapsedSeconds = elapsedPicoSeconds * PICO;
+    double  elapsedSeconds = elapsedPicoSeconds * gmx::c_pico;
     int64_t nParticles;
     char    compression;
 
@@ -1004,7 +1004,7 @@ float gmx_tng_get_time_of_final_frame(gmx_tng_trajectory_t gmx_tng)
     tng_num_frames_get(tng, &nFrames);
     tng_util_time_of_frame_get(tng, nFrames - 1, &time);
 
-    fTime = time / PICO;
+    fTime = time / gmx::c_pico;
     return fTime;
 #else
     GMX_UNUSED_VALUE(gmx_tng);
@@ -1271,8 +1271,8 @@ real getDistanceScaleFactor(gmx_tng_trajectory_t in)
     // GROMACS expects distances in nm
     switch (exp)
     {
-        case 9: distanceScaleFactor = NANO / NANO; break;
-        case 10: distanceScaleFactor = NANO / ANGSTROM; break;
+        case 9: distanceScaleFactor = gmx::c_nano / gmx::c_nano; break;
+        case 10: distanceScaleFactor = gmx::c_nano / gmx::c_angstrom; break;
         default: distanceScaleFactor = pow(10.0, exp + 9.0);
     }
 
@@ -1545,7 +1545,7 @@ gmx_bool gmx_read_next_tng_frame(gmx_tng_trajectory_t gmx_tng_input,
     fr->bStep = TRUE;
 
     // Convert the time to ps
-    fr->time  = frameTime / PICO;
+    fr->time  = frameTime / gmx::c_pico;
     fr->bTime = (frameTime > 0);
 
     // TODO This does not leak, but is not exception safe.
index e08ccbc075981fc1d90a01046688d210ee384cd2..4e1f89690b88acff68de05c4e828f5f6e48d8978 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -107,7 +107,7 @@ static int calc_RBbin(real phi, int gmx_unused multiplicity, real gmx_unused cor
 
 static int calc_Nbin(real phi, int multiplicity, real core_frac)
 {
-    static const real r360 = 360 * DEG2RAD;
+    static const real r360 = 360 * gmx::c_deg2Rad;
     real              rot_width, core_width, core_offset, low, hi;
     int               bin;
     /* with multiplicity 3 and core_frac 0.5
@@ -127,8 +127,8 @@ static int calc_Nbin(real phi, int multiplicity, real core_frac)
     {
         low = ((bin - 1) * rot_width) + core_offset;
         hi  = ((bin - 1) * rot_width) + core_offset + core_width;
-        low *= DEG2RAD;
-        hi *= DEG2RAD;
+        low *= gmx::c_deg2Rad;
+        hi *= gmx::c_deg2Rad;
         if ((phi > low) && (phi < hi))
         {
             return bin;
@@ -716,7 +716,7 @@ static real calc_fraction(const real angles[], int nangles)
 
     for (i = 0; i < nangles; i++)
     {
-        angle = angles[i] * RAD2DEG;
+        angle = angles[i] * gmx::c_rad2Deg;
 
         if (angle > 135 && angle < 225)
         {
index a1019ad1da1abe68ccfe27ac1980d5b87bc2169e..feed719fcfaa9611304a3041a550c373b88a95eb 100644 (file)
@@ -35,7 +35,6 @@
 #ifndef GMX_GMXANA_ANGLE_CORRECTION_H
 #define GMX_GMXANA_ANGLE_CORRECTION_H
 
-#include "gromacs/math/units.h"
 #include "gromacs/utility/real.h"
 
 /*! \brief
index 4fe720ba9d87c0e8df1373b57e30c92da879224d..684a7b15c37d737962c5a2ec6c602133353d47f0 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -312,7 +312,7 @@ int gmx_g_angle(int argc, char* argv[])
         out = xvgropen(opt2fn("-ov", NFILE, fnm), title, "Time (ps)", "Angle (degrees)", oenv);
         for (i = 0; (i < nframes); i++)
         {
-            fprintf(out, "%10.5f  %8.3f", time[i], aver_angle[i] * RAD2DEG);
+            fprintf(out, "%10.5f  %8.3f", time[i], aver_angle[i] * gmx::c_rad2Deg);
             if (bALL)
             {
                 for (j = 0; (j < nangles); j++)
@@ -320,11 +320,11 @@ int gmx_g_angle(int argc, char* argv[])
                     if (bPBC)
                     {
                         real dd = dih[j][i];
-                        fprintf(out, "  %8.3f", std::atan2(std::sin(dd), std::cos(dd)) * RAD2DEG);
+                        fprintf(out, "  %8.3f", std::atan2(std::sin(dd), std::cos(dd)) * gmx::c_rad2Deg);
                     }
                     else
                     {
-                        fprintf(out, "  %8.3f", dih[j][i] * RAD2DEG);
+                        fprintf(out, "  %8.3f", dih[j][i] * gmx::c_rad2Deg);
                     }
                 }
             }
@@ -372,7 +372,7 @@ int gmx_g_angle(int argc, char* argv[])
 
             if (bChandler)
             {
-                real     dval, sixty = DEG2RAD * 60;
+                real     dval, sixty = gmx::c_deg2Rad * 60;
                 gmx_bool bTest;
 
                 for (i = 0; (i < nangles); i++)
@@ -455,8 +455,8 @@ int gmx_g_angle(int argc, char* argv[])
     }
     aver /= nframes;
     double aversig = correctRadianAngleRange(aver);
-    aversig *= RAD2DEG;
-    aver *= RAD2DEG;
+    aversig *= gmx::c_rad2Deg;
+    aver *= gmx::c_rad2Deg;
     printf(" < angle >  = %g\n", aversig);
 
     if (mult == 3)
index 00b0b9a542e972e411ddcc0d688445015e25f8ad..690d932eeaa796eab57a10dad6d68696219ed530 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -630,8 +630,13 @@ int gmx_awh(int argc, char* argv[])
                 AwhGraphSelection awhGraphSelection =
                         (moreGraphs ? AwhGraphSelection::All : AwhGraphSelection::Pmf);
                 EnergyUnit energyUnit = (kTUnit ? EnergyUnit::KT : EnergyUnit::KJPerMol);
-                awhReader             = std::make_unique<AwhReader>(
-                        ir.awhParams, nfile, fnm, awhGraphSelection, energyUnit, BOLTZ * ir.opts.ref_t[0], block);
+                awhReader             = std::make_unique<AwhReader>(ir.awhParams,
+                                                        nfile,
+                                                        fnm,
+                                                        awhGraphSelection,
+                                                        energyUnit,
+                                                        gmx::c_boltz * ir.opts.ref_t[0],
+                                                        block);
             }
 
             awhReader->processAwhFrame(*block, frame->t, oenv);
index b70ffedf36c5851d9c214921c664e1ca7361c664..fa6c81011d09048029ca9701c875312bed5cedad 100644 (file)
@@ -1640,7 +1640,7 @@ static double calc_bar_lowlevel(sample_coll_t* ca, sample_coll_t* cb, double tem
     double DG0, DG1, DG2, dDG1;
     double n1, n2; /* numbers of samples as doubles */
 
-    kT   = BOLTZ * temp;
+    kT   = gmx::c_boltz * temp;
     beta = 1 / kT;
 
     /* count the numbers of samples */
@@ -1771,7 +1771,7 @@ static void calc_rel_entropy(sample_coll_t* ca, sample_coll_t* cb, double temp,
     double Wfac1, Wfac2;
     double n1, n2;
 
-    kT   = BOLTZ * temp;
+    kT   = gmx::c_boltz * temp;
     beta = 1 / kT;
 
     /* count the numbers of samples */
@@ -1885,7 +1885,7 @@ static void calc_dg_stddev(sample_coll_t* ca, sample_coll_t* cb, double temp, do
     double Wfac1, Wfac2;
     double n1, n2;
 
-    kT   = BOLTZ * temp;
+    kT   = gmx::c_boltz * temp;
     beta = 1 / kT;
 
     /* count the numbers of samples */
@@ -3622,7 +3622,7 @@ int gmx_bar(int argc, char* argv[])
     }
 
     /* print results in kT */
-    kT = BOLTZ * temp;
+    kT = gmx::c_boltz * temp;
 
     printf("\nTemperature: %g K\n", temp);
 
index 07564ee2d5b481165ba0445e3ee372c5663984a8..c4fa316f92326ab9ff1a1201248a6633c3da6c2f 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -391,27 +391,27 @@ int gmx_bundle(int argc, char* argv[])
             fprintf(flen, " %6g", bun.len[i]);
             fprintf(fdist, " %6g", norm(bun.mid[i]));
             fprintf(fz, " %6g", bun.mid[i][ZZ]);
-            fprintf(ftilt, " %6g", RAD2DEG * acos(bun.dir[i][ZZ]));
+            fprintf(ftilt, " %6g", gmx::c_rad2Deg * acos(bun.dir[i][ZZ]));
             comp = bun.mid[i][XX] * bun.dir[i][XX] + bun.mid[i][YY] * bun.dir[i][YY];
-            fprintf(ftiltr, " %6g", RAD2DEG * std::asin(comp / std::hypot(comp, bun.dir[i][ZZ])));
+            fprintf(ftiltr, " %6g", gmx::c_rad2Deg * std::asin(comp / std::hypot(comp, bun.dir[i][ZZ])));
             comp = bun.mid[i][YY] * bun.dir[i][XX] - bun.mid[i][XX] * bun.dir[i][YY];
-            fprintf(ftiltl, " %6g", RAD2DEG * std::asin(comp / std::hypot(comp, bun.dir[i][ZZ])));
+            fprintf(ftiltl, " %6g", gmx::c_rad2Deg * std::asin(comp / std::hypot(comp, bun.dir[i][ZZ])));
             if (bKink)
             {
                 rvec_sub(bun.end[0][i], bun.end[2][i], va);
                 rvec_sub(bun.end[2][i], bun.end[1][i], vb);
                 unitv(va, va);
                 unitv(vb, vb);
-                fprintf(fkink, " %6g", RAD2DEG * acos(iprod(va, vb)));
+                fprintf(fkink, " %6g", gmx::c_rad2Deg * acos(iprod(va, vb)));
                 cprod(va, vb, vc);
                 copy_rvec(bun.mid[i], vr);
                 vr[ZZ] = 0;
                 unitv(vr, vr);
-                fprintf(fkinkr, " %6g", RAD2DEG * std::asin(iprod(vc, vr)));
+                fprintf(fkinkr, " %6g", gmx::c_rad2Deg * std::asin(iprod(vc, vr)));
                 vl[XX] = vr[YY];
                 vl[YY] = -vr[XX];
                 vl[ZZ] = 0;
-                fprintf(fkinkl, " %6g", RAD2DEG * std::asin(iprod(vc, vl)));
+                fprintf(fkinkl, " %6g", gmx::c_rad2Deg * std::asin(iprod(vc, vl)));
             }
         }
         fprintf(flen, "\n");
index 9cafe37eac0bc0e1ff6e12fec5d2fe752554d7e6..a23ff444a65202e395f23b1d633326d0ef8b72c6 100644 (file)
@@ -130,7 +130,7 @@ static gmx_bool bAllowed(real phi, real psi)
 #define NPP asize(map)
     int x, y;
 
-#define INDEX(ppp) (((static_cast<int>(360 + (ppp)*RAD2DEG)) % 360) / 6)
+#define INDEX(ppp) (((static_cast<int>(360 + (ppp)*gmx::c_rad2Deg)) % 360) / 6)
     x = INDEX(phi);
     y = INDEX(psi);
 #undef INDEX
@@ -932,16 +932,18 @@ static void do_rama(int                     nf,
             Psi = dlist[i].j0[edPsi];
             for (j = 0; (j < nf); j++)
             {
-                phi = RAD2DEG * dih[Phi][j];
-                psi = RAD2DEG * dih[Psi][j];
+                phi = gmx::c_rad2Deg * dih[Phi][j];
+                psi = gmx::c_rad2Deg * dih[Psi][j];
                 fprintf(fp, "%10g  %10g\n", phi, psi);
                 if (bViol)
                 {
-                    fprintf(gp, "%d\n", static_cast<int>(!bAllowed(dih[Phi][j], RAD2DEG * dih[Psi][j])));
+                    fprintf(gp,
+                            "%d\n",
+                            static_cast<int>(!bAllowed(dih[Phi][j], gmx::c_rad2Deg * dih[Psi][j])));
                 }
                 if (bOm)
                 {
-                    omega = RAD2DEG * dih[Om][j];
+                    omega = gmx::c_rad2Deg * dih[Om][j];
                     mat[static_cast<int>(((phi * NMAT) / 360) + gmx::exactDiv(NMAT, 2))]
                        [static_cast<int>(((psi * NMAT) / 360) + gmx::exactDiv(NMAT, 2))] += omega;
                 }
@@ -1023,7 +1025,7 @@ static void do_rama(int                     nf,
             Xi2 = dlist[i].j0[edChi2];
             for (j = 0; (j < nf); j++)
             {
-                fprintf(fp, "%10g  %10g\n", RAD2DEG * dih[Xi1][j], RAD2DEG * dih[Xi2][j]);
+                fprintf(fp, "%10g  %10g\n", gmx::c_rad2Deg * dih[Xi1][j], gmx::c_rad2Deg * dih[Xi2][j]);
             }
             xvgrclose(fp);
         }
index b98b5b1db916725280f3806637c2c54c35c31446..44ec18ba8c880e2e82dc8e352de484f2334b4688 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2007, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -354,7 +354,7 @@ static void clust_size(const char*             ndx,
                             ekin += 0.5 * m * iprod(v[ai], v[ai]);
                         }
                     }
-                    temp = (ekin * 2.0) / (3.0 * tfac * max_clust_size * BOLTZ);
+                    temp = (ekin * 2.0) / (3.0 * tfac * max_clust_size * gmx::c_boltz);
                     fprintf(tp, "%10.3f  %10.3f\n", frameTime, temp);
                 }
             }
index 228ddaba0cbb3339936a5399b1e4511e24cd13b3..78c58596a921c0120e73931e4af4a7b16b0244e8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2008,2009,2010,2011,2012 by the GROMACS development team.
  * Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -58,7 +58,8 @@
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/smalloc.h"
 
-#define EPSI0 (EPSILON0 * E_CHARGE * E_CHARGE * AVOGADRO / (KILO * NANO)) /* EPSILON0 in SI units */
+constexpr double EPSI0 = (gmx::c_epsilon0 * gmx::c_electronCharge * gmx::c_electronCharge * gmx::c_avogadro
+                          / (gmx::c_kilo * gmx::c_nano)); /* c_epsilon0 in SI units */
 
 static void index_atom2mol(int* n, int* index, t_block* mols)
 {
@@ -640,11 +641,11 @@ static void dielectric(FILE*                   fmj,
     volume_av /= refr;
 
     prefactor = 1.0;
-    prefactor /= 3.0 * EPSILON0 * volume_av * BOLTZ * temp;
+    prefactor /= 3.0 * gmx::c_epsilon0 * volume_av * gmx::c_boltz * temp;
 
 
-    prefactorav = E_CHARGE * E_CHARGE;
-    prefactorav /= volume_av * BOLTZMANN * temp * NANO * 6.0;
+    prefactorav = gmx::c_electronCharge * gmx::c_electronCharge;
+    prefactorav /= volume_av * gmx::c_boltzmann * temp * gmx::c_nano * 6.0;
 
     fprintf(stderr, "Prefactor fit E-H: 1 / 6.0*V*k_B*T: %g\n", prefactorav);
 
@@ -694,7 +695,7 @@ static void dielectric(FILE*                   fmj,
         {
 
             printf("\nCalculating current autocorrelation ... \n");
-            sgk = calc_cacf(outf, prefactorav / PICO, cacf, time, nvfr, vfr, ie, nshift);
+            sgk = calc_cacf(outf, prefactorav / gmx::c_pico, cacf, time, nvfr, vfr, ie, nshift);
 
             if (ie > ii)
             {
index 950e69b231d0f4a726d1901f71ed3804f8035452..cade69fe5dd42564f16d67c9cf8c83bdf0acfd02 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -589,7 +589,7 @@ static void plot_density(double*                 slDensity[],
             }
             if (dens_opt[0][0] == 'm')
             {
-                fprintf(den, "   %12g", ddd * AMU / (NANO * NANO * NANO));
+                fprintf(den, "   %12g", ddd * gmx::c_amu / (gmx::c_nano * gmx::c_nano * gmx::c_nano));
             }
             else
             {
index f512024c4d9b62e726cad0ee9cd6622cff6cb567..b9bebf3c8b0d5b494085a0e4d48d604af7d30987 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2010-2018, The GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -228,8 +228,9 @@ static void density_in_time(const char*             fn,
             (*Densdevel)[*tblock] = Densslice;
         }
 
-        dscale = (*xslices) * (*yslices) * (*zslices) * AMU
-                 / (box[ax1][ax1] * box[ax2][ax2] * box[axis][axis] * nsttblock * (NANO * NANO * NANO));
+        dscale = (*xslices) * (*yslices) * (*zslices) * gmx::c_amu
+                 / (box[ax1][ax1] * box[ax2][ax2] * box[axis][axis] * nsttblock
+                    * (gmx::c_nano * gmx::c_nano * gmx::c_nano));
 
         if (bCenter)
         {
index 7e335775a401e3a0acdc98dcfa65f30404a83356..5f1d64283b3d626eaac42a45b3d93cb651b9040c 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -74,9 +74,9 @@
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/smalloc.h"
 
-#define e2d(x) ENM2DEBYE*(x)
-#define EANG2CM (E_CHARGE * 1.0e-10)    /* e Angstrom to Coulomb meter */
-#define CM2D (SPEED_OF_LIGHT * 1.0e+24) /* Coulomb meter to Debye */
+#define e2d(x) gmx::c_enm2Debye*(x)
+constexpr double EANG2CM = gmx::c_electronCharge * 1.0e-10; /* e Angstrom to Coulomb meter */
+constexpr double CM2D    = gmx::c_speedOfLight * 1.0e+24;   /* Coulomb meter to Debye */
 
 typedef struct
 {
@@ -440,7 +440,7 @@ static void print_gkrbin(const char* fn, t_gkrbin* gb, int ngrp, int nframes, re
         {
             cosav = 0;
         }
-        ener = -0.5 * cosav * ONE_4PI_EPS0 / (x1 * x1 * x1);
+        ener = -0.5 * cosav * gmx::c_one4PiEps0 / (x1 * x1 * x1);
 
         fprintf(fp, "%10.5e %12.5e %12.5e %12.5e %12.5e  %12.5e\n", x1, Gkr, cosav, hOO, gOO, ener);
 
@@ -673,7 +673,8 @@ static real calc_eps(double M_diff, double volume, double epsRF, double temp)
     double eps_0 = 8.854187817e-12; /* epsilon_0 in C^2 J^-1 m^-1 */
     double fac   = 1.112650021e-59; /* converts Debye^2 to C^2 m^2 */
 
-    A = M_diff * fac / (3 * eps_0 * volume * NANO * NANO * NANO * BOLTZMANN * temp);
+    A = M_diff * fac
+        / (3 * eps_0 * volume * gmx::c_nano * gmx::c_nano * gmx::c_nano * gmx::c_boltzmann * temp);
 
     if (epsRF == 0.0)
     {
index 1c4483c06902b18d2e51b21b526c3fb8895ca30a..25d2acc2f2be1b2a813758e785d87d3cf3216325 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2011-2018, The GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -190,12 +190,12 @@ static double calc_Shs(double f, double y)
 {
     double fy = f * y;
 
-    return BOLTZ * (std::log(calc_compress(fy)) + fy * (3 * fy - 4) / gmx::square(1 - fy));
+    return gmx::c_boltz * (std::log(calc_compress(fy)) + fy * (3 * fy - 4) / gmx::square(1 - fy));
 }
 
 static real wCsolid(real nu, real beta)
 {
-    real bhn = beta * PLANCK * nu;
+    real bhn = beta * gmx::c_planck * nu;
     real ebn, koko;
 
     if (bhn == 0)
@@ -212,7 +212,7 @@ static real wCsolid(real nu, real beta)
 
 static real wSsolid(real nu, real beta)
 {
-    real bhn = beta * PLANCK * nu;
+    real bhn = beta * gmx::c_planck * nu;
 
     if (bhn == 0)
     {
@@ -226,7 +226,7 @@ static real wSsolid(real nu, real beta)
 
 static real wAsolid(real nu, real beta)
 {
-    real bhn = beta * PLANCK * nu;
+    real bhn = beta * gmx::c_planck * nu;
 
     if (bhn == 0)
     {
@@ -240,7 +240,7 @@ static real wAsolid(real nu, real beta)
 
 static real wEsolid(real nu, real beta)
 {
-    real bhn = beta * PLANCK * nu;
+    real bhn = beta * gmx::c_planck * nu;
 
     if (bhn == 0)
     {
@@ -341,7 +341,7 @@ int gmx_dos(int argc, char* argv[])
         return 0;
     }
 
-    beta = 1 / (Temp * BOLTZ);
+    beta = 1 / (Temp * gmx::c_boltz);
 
     fplog = gmx_fio_fopen(ftp2fn(efLOG, NFILE, fnm), "w");
     fprintf(fplog, "Doing density of states analysis based on trajectory.\n");
@@ -527,15 +527,16 @@ int gmx_dos(int argc, char* argv[])
     DoS0 = dos[DOS][0];
 
     /* Note this eqn. is incorrect in Pascal2011a! */
-    Delta = ((2 * DoS0 / (9 * Natom)) * std::sqrt(M_PI * BOLTZ * Temp * Natom / tmass)
+    Delta = ((2 * DoS0 / (9 * Natom)) * std::sqrt(M_PI * gmx::c_boltz * Temp * Natom / tmass)
              * std::pow((Natom / V), 1.0 / 3.0) * std::pow(6.0 / M_PI, 2.0 / 3.0));
     f     = calc_fluidicity(Delta, toler);
     y     = calc_y(f, Delta, toler);
     z     = calc_compress(y);
-    Sig   = BOLTZ
-          * (5.0 / 2.0 + std::log(2 * M_PI * BOLTZ * Temp / (gmx::square(PLANCK)) * V / (f * Natom)));
+    Sig   = gmx::c_boltz
+          * (5.0 / 2.0
+             + std::log(2 * M_PI * gmx::c_boltz * Temp / (gmx::square(gmx::c_planck)) * V / (f * Natom)));
     Shs   = Sig + calc_Shs(f, y);
-    rho   = (tmass * AMU) / (V * NANO * NANO * NANO);
+    rho   = (tmass * gmx::c_amu) / (V * gmx::c_nano * gmx::c_nano * gmx::c_nano);
     sigHS = std::cbrt(6 * y * V / (M_PI * Natom));
 
     fprintf(fplog, "System = \"%s\"\n", *top.name);
@@ -567,7 +568,7 @@ int gmx_dos(int argc, char* argv[])
                   "\\f{4}S(\\f{12}n\\f{4})",
                   oenv);
     xvgr_legend(fp, asize(DoSlegend), DoSlegend, oenv);
-    recip_fac = bRecip ? (1e7 / SPEED_OF_LIGHT) : 1.0;
+    recip_fac = bRecip ? (1e7 / gmx::c_speedOfLight) : 1.0;
     for (j = 0; (j < nframes / 4); j++)
     {
         dos[DOS_DIFF][j]  = DoS0 / (1 + gmx::square(DoS0 * M_PI * nu[j] / (6 * f * Natom)));
@@ -583,7 +584,7 @@ int gmx_dos(int argc, char* argv[])
 
     /* Finally analyze the results! */
     wCdiff = 0.5;
-    wSdiff = Shs / (3 * BOLTZ); /* Is this correct? */
+    wSdiff = Shs / (3 * gmx::c_boltz); /* Is this correct? */
     wEdiff = 0.5;
     wAdiff = wEdiff - wSdiff;
     for (j = 0; (j < nframes / 4); j++)
@@ -598,7 +599,8 @@ int gmx_dos(int argc, char* argv[])
     fprintf(fplog, "Diffusion coefficient from VACF %g 10^-5 cm^2/s\n", DiffCoeff);
     fprintf(fplog, "Diffusion coefficient from DoS %g 10^-5 cm^2/s\n", 1000 * DoS0 / (12 * tmass * beta));
 
-    cP = BOLTZ * evaluate_integral(nframes / 4, nu, dos[DOS_CP], nullptr, int{ nframes / 4 }, &stddev);
+    cP = gmx::c_boltz
+         * evaluate_integral(nframes / 4, nu, dos[DOS_CP], nullptr, int{ nframes / 4 }, &stddev);
     fprintf(fplog, "Heat capacity %g J/mol K\n", 1000 * cP / Nmol);
     fprintf(fplog, "\nArrivederci!\n");
     gmx_fio_fclose(fplog);
index c03904be6d3e934b9b7bde03083b80b9fb622e02..fab46dce5204ad3251aec9571d158da8858b8219 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -419,7 +419,7 @@ int gmx_enemat(int argc, char* argv[])
                 }
                 eaver[i] /= nenergy;
             }
-            beta = 1.0 / (BOLTZ * reftemp);
+            beta = 1.0 / (gmx::c_boltz * reftemp);
             snew(efree, ngroups);
             snew(edif, ngroups);
             for (i = 0; (i < ngroups); i++)
index 47dcde2f60d9e1b927c85c50287a90db7d6c219d..b13a137695a5c90de5b663b0df87a74e04b5edef 100644 (file)
@@ -359,7 +359,8 @@ static void einstein_visco(const char*             fn,
             }
         }
         /* Convert to SI for the viscosity */
-        fac = (V * NANO * NANO * NANO * PICO * 1e10) / (2 * BOLTZMANN * T) / (nint - i);
+        fac = (V * gmx::c_nano * gmx::c_nano * gmx::c_nano * gmx::c_pico * 1e10)
+              / (2 * gmx::c_boltzmann * T) / (nint - i);
         fprintf(fp0, "%10g", i * dt);
         for (m = 0; (m <= nsets); m++)
         {
@@ -737,7 +738,7 @@ static void calc_fluctuation_props(FILE*       fp,
     const char* my_ener[] = { "Volume", "Enthalpy", "Temperature", "Total Energy" };
     int         ii[eNR];
 
-    NANO3 = NANO * NANO * NANO;
+    NANO3 = gmx::c_nano * gmx::c_nano * gmx::c_nano;
     if (!bDriftCorr)
     {
         fprintf(fp,
@@ -770,15 +771,15 @@ if ((ii[eVol] < nset) && (ii[eTemp] < nset))
 {
     vv    = edat->s[ii[eVol]].av * NANO3;
     varv  = gmx::square(edat->s[ii[eVol]].rmsd * NANO3);
-    kappa = (varv / vv) / (BOLTZMANN * tt);
+    kappa = (varv / vv) / (gmx::c_boltzmann * tt);
 }
 /* Enthalpy */
 hh = varh = NOTSET;
 if ((ii[eEnth] < nset) && (ii[eTemp] < nset))
 {
-    hh   = KILO * edat->s[ii[eEnth]].av / AVOGADRO;
-    varh = gmx::square(KILO * edat->s[ii[eEnth]].rmsd / AVOGADRO);
-    cp   = AVOGADRO * ((varh / nmol) / (BOLTZMANN * tt * tt));
+    hh   = gmx::c_kilo * edat->s[ii[eEnth]].av / gmx::c_avogadro;
+    varh = gmx::square(gmx::c_kilo * edat->s[ii[eEnth]].rmsd / gmx::c_avogadro);
+    cp   = gmx::c_avogadro * ((varh / nmol) / (gmx::c_boltzmann * tt * tt));
 }
 /* Total energy */
 if ((ii[eEtot] < nset) && (hh == NOTSET) && (tt != NOTSET))
@@ -787,7 +788,7 @@ if ((ii[eEtot] < nset) && (hh == NOTSET) && (tt != NOTSET))
        by checking whether the enthalpy was computed.
      */
     varet = gmx::square(edat->s[ii[eEtot]].rmsd);
-    cv    = KILO * ((varet / nmol) / (BOLTZ * tt * tt));
+    cv    = gmx::c_kilo * ((varet / nmol) / (gmx::c_boltz * tt * tt));
 }
 /* Alpha, dcp */
 if ((ii[eVol] < nset) && (ii[eEnth] < nset) && (ii[eTemp] < nset))
@@ -797,7 +798,7 @@ if ((ii[eVol] < nset) && (ii[eEnth] < nset) && (ii[eTemp] < nset))
     for (j = 0; (j < edat->nframes); j++)
     {
         v = edat->s[ii[eVol]].ener[j] * NANO3;
-        h = KILO * edat->s[ii[eEnth]].ener[j] / AVOGADRO;
+        h = gmx::c_kilo * edat->s[ii[eEnth]].ener[j] / gmx::c_avogadro;
         v_sum += v;
         h_sum += h;
         vh_sum += (v * h);
@@ -805,8 +806,8 @@ if ((ii[eVol] < nset) && (ii[eEnth] < nset) && (ii[eTemp] < nset))
     vh_aver = vh_sum / edat->nframes;
     v_aver  = v_sum / edat->nframes;
     h_aver  = h_sum / edat->nframes;
-    alpha   = (vh_aver - v_aver * h_aver) / (v_aver * BOLTZMANN * tt * tt);
-    dcp     = (v_aver * AVOGADRO / nmol) * tt * gmx::square(alpha) / (kappa);
+    alpha   = (vh_aver - v_aver * h_aver) / (v_aver * gmx::c_boltzmann * tt * tt);
+    dcp     = (v_aver * gmx::c_avogadro / nmol) * tt * gmx::square(alpha) / (kappa);
 }
 
 if (tt != NOTSET)
@@ -827,16 +828,18 @@ if (tt != NOTSET)
     {
         if (varv != NOTSET)
         {
-            fprintf(fp, "varv  =  %10g (m^6)\n", varv * AVOGADRO / nmol);
+            fprintf(fp, "varv  =  %10g (m^6)\n", varv * gmx::c_avogadro / nmol);
         }
     }
     if (vv != NOTSET)
     {
-        fprintf(fp, "Volume                                   = %10g m^3/mol\n", vv * AVOGADRO / nmol);
+        fprintf(fp, "Volume                                   = %10g m^3/mol\n", vv * gmx::c_avogadro / nmol);
     }
     if (varh != NOTSET)
     {
-        fprintf(fp, "Enthalpy                                 = %10g kJ/mol\n", hh * AVOGADRO / (KILO * nmol));
+        fprintf(fp,
+                "Enthalpy                                 = %10g kJ/mol\n",
+                hh * gmx::c_avogadro / (gmx::c_kilo * nmol));
     }
     if (alpha != NOTSET)
     {
@@ -1001,7 +1004,7 @@ static void analyse_ener(gmx_bool                bCorr,
         expEtot = 0;
         if (bFee)
         {
-            beta = 1.0 / (BOLTZ * reftemp);
+            beta = 1.0 / (gmx::c_boltz * reftemp);
             snew(fee, nset);
         }
         for (i = 0; (i < nset); i++)
@@ -1206,7 +1209,7 @@ static void analyse_ener(gmx_bool                bCorr,
                             0.0,
                             0);
 
-            factor = (Vaver * 1e-26 / (BOLTZMANN * Temp)) * Dt;
+            factor = (Vaver * 1e-26 / (gmx::c_boltzmann * Temp)) * Dt;
             fp     = xvgropen(visfn, buf, "Time (ps)", "\\8h\\4 (cp)", oenv);
             xvgr_legend(fp, asize(leg), leg, oenv);
 
@@ -1370,7 +1373,7 @@ static void fec(const char*             ene2fn,
     }
     fprintf(stdout, "\n%-24s %10s\n", "Energy", "dF = -kT ln < exp(-(EB-EA)/kT) >A");
     sum  = 0;
-    beta = 1.0 / (BOLTZ * reftemp);
+    beta = 1.0 / (gmx::c_boltz * reftemp);
     for (i = 0; i < nset; i++)
     {
         if (gmx_strcasecmp(leg[i], enm[set[i]].name) != 0)
@@ -1383,10 +1386,10 @@ static void fec(const char*             ene2fn,
             sum += std::exp(-dE * beta);
             if (fp)
             {
-                fprintf(fp, "%10g %10g %10g\n", time[j], dE, -BOLTZ * reftemp * std::log(sum / (j + 1)));
+                fprintf(fp, "%10g %10g %10g\n", time[j], dE, -gmx::c_boltz * reftemp * std::log(sum / (j + 1)));
             }
         }
-        aver = -BOLTZ * reftemp * std::log(sum / nenergy);
+        aver = -gmx::c_boltz * reftemp * std::log(sum / nenergy);
         fprintf(stdout, "%-24s %10g\n", leg[i], aver);
     }
     if (fp)
index b4795b68f5846f06c31ad8bf4d5a517ab64bd70d..51f34b51724e514ef622a4e62d93cff7233496a9 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2008, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -1741,14 +1741,14 @@ static real calc_dg(real tau, real temp)
 {
     real kbt;
 
-    kbt = BOLTZ * temp;
+    kbt = gmx::c_boltz * temp;
     if (tau <= 0)
     {
         return -666;
     }
     else
     {
-        return kbt * std::log(kbt * tau / PLANCK);
+        return kbt * std::log(kbt * tau / gmx::c_planck);
     }
 }
 
@@ -1865,7 +1865,7 @@ void analyse_corr(int  n,
                 compute_weighted_rates(
                         n, t, ct, nt, kt, sigma_ct, sigma_nt, sigma_kt, &k, &kp, &sigma_k, &sigma_kp, fit_start);
                 Q   = 0; /* quality_of_fit(chi2, 2);*/
-                ddg = BOLTZ * temp * sigma_k / k;
+                ddg = gmx::c_boltz * temp * sigma_k / k;
                 printf("Fitting paramaters chi^2 = %10g, Quality of fit = %10g\n", chi2, Q);
                 printf("The Rate and Delta G are followed by an error estimate\n");
                 printf("----------------------------------------------------------\n"
@@ -1876,7 +1876,7 @@ void analyse_corr(int  n,
                        1 / k,
                        calc_dg(1 / k, temp),
                        ddg);
-                ddg = BOLTZ * temp * sigma_kp / kp;
+                ddg = gmx::c_boltz * temp * sigma_kp / kp;
                 printf("Backward   %10.3f %6.2f   %8.3f  %10.3f %6.2f\n",
                        kp,
                        sigma_kp,
@@ -2695,7 +2695,7 @@ int gmx_hbond(int argc, char* argv[])
 
     /* process input */
     bSelected = FALSE;
-    ccut      = std::cos(acut * DEG2RAD);
+    ccut      = std::cos(acut * gmx::c_deg2Rad);
 
     if (bContact)
     {
@@ -3180,7 +3180,7 @@ int gmx_hbond(int argc, char* argv[])
                                                                             "for an hbond: %f",
                                                                             dist);
                                                                 }
-                                                                ang *= RAD2DEG;
+                                                                ang *= gmx::c_rad2Deg;
                                                                 __ADIST[static_cast<int>(ang / abin)]++;
                                                                 __RDIST[static_cast<int>(dist / rbin)]++;
                                                                 if (!bTwo)
index 560425e38e17b9ab0eb26b5a4c52ff7438f0c64d..7f308a16f054ae9e753f0512b9e357fff7f86653 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
 
 static double cv_corr(double nu, double T)
 {
-    double x  = PLANCK * nu / (BOLTZ * T);
+    double x  = gmx::c_planck * nu / (gmx::c_boltz * T);
     double ex = std::exp(x);
 
     if (nu <= 0)
     {
-        return BOLTZ * KILO;
+        return gmx::c_boltz * gmx::c_kilo;
     }
     else
     {
-        return BOLTZ * KILO * (ex * gmx::square(x) / gmx::square(ex - 1) - 1);
+        return gmx::c_boltz * gmx::c_kilo * (ex * gmx::square(x) / gmx::square(ex - 1) - 1);
     }
 }
 
 static double u_corr(double nu, double T)
 {
-    double x  = PLANCK * nu / (BOLTZ * T);
+    double x  = gmx::c_planck * nu / (gmx::c_boltz * T);
     double ex = std::exp(x);
 
     if (nu <= 0)
     {
-        return BOLTZ * T;
+        return gmx::c_boltz * T;
     }
     else
     {
-        return BOLTZ * T * (0.5 * x - 1 + x / (ex - 1));
+        return gmx::c_boltz * T * (0.5 * x - 1 + x / (ex - 1));
     }
 }
 
@@ -287,14 +287,14 @@ static real* allocateEigenvectors(int nrow, int first, int last, bool ignoreBegi
  */
 static double calcTranslationalHeatCapacity()
 {
-    return RGAS * 1.5;
+    return gmx::c_universalGasConstant * 1.5;
 }
 
 /*! \brief Compute internal energy due to translational motion
  */
 static double calcTranslationalInternalEnergy(double T)
 {
-    return BOLTZ * T * 1.5;
+    return gmx::c_boltz * T * 1.5;
 }
 
 /*! \brief Compute heat capacity due to rotational motion
@@ -307,11 +307,11 @@ static double calcRotationalInternalEnergy(gmx_bool linear, double T)
 {
     if (linear)
     {
-        return BOLTZ * T;
+        return gmx::c_boltz * T;
     }
     else
     {
-        return BOLTZ * T * 1.5;
+        return gmx::c_boltz * T * 1.5;
     }
 }
 
@@ -324,11 +324,11 @@ static double calcRotationalHeatCapacity(gmx_bool linear)
 {
     if (linear)
     {
-        return RGAS;
+        return gmx::c_universalGasConstant;
     }
     else
     {
-        return RGAS * 1.5;
+        return gmx::c_universalGasConstant * 1.5;
     }
 }
 
@@ -361,9 +361,9 @@ static void analyzeThermochemistry(FILE*                    fp,
     principal_comp(index.size(), index.data(), top.atoms.atom, as_rvec_array(x_com.data()), trans, inertia);
     bool linear = (inertia[XX] / inertia[YY] < linear_toler && inertia[XX] / inertia[ZZ] < linear_toler);
     // (kJ/mol ps)^2/(Dalton nm^2 kJ/mol K) =
-    // KILO kg m^2 ps^2/(s^2 mol g/mol nm^2 K) =
-    // KILO^2 10^18 / 10^24 K = 1/K
-    double rot_const = gmx::square(PLANCK) / (8 * gmx::square(M_PI) * BOLTZ);
+    // c_kilo kg m^2 ps^2/(s^2 mol g/mol nm^2 K) =
+    // c_kilo^2 10^18 / 10^24 K = 1/K
+    double rot_const = gmx::square(gmx::c_planck) / (8 * gmx::square(M_PI) * gmx::c_boltz);
     // Rotational temperature (1/K)
     rvec theta = { 0, 0, 0 };
     if (linear)
@@ -729,8 +729,8 @@ int gmx_nmeig(int argc, char* argv[])
      * light. Do this by first converting to omega^2 (units 1/s), take the square
      * root, and finally divide by the speed of light (nm/ps in gromacs).
      */
-    factor_gmx_to_omega2       = 1.0E21 / (AVOGADRO * AMU);
-    factor_omega_to_wavenumber = 1.0E-5 / (2.0 * M_PI * SPEED_OF_LIGHT);
+    factor_gmx_to_omega2       = 1.0E21 / (gmx::c_avogadro * gmx::c_amu);
+    factor_omega_to_wavenumber = 1.0E-5 / (2.0 * M_PI * gmx::c_speedOfLight);
 
     value = 0;
     for (i = begin; (i <= end); i++)
@@ -758,8 +758,8 @@ int gmx_nmeig(int argc, char* argv[])
             qu  = u_corr(nu, T);
             if (i > end - nharm)
             {
-                qcv += BOLTZ * KILO;
-                qu += BOLTZ * T;
+                qcv += gmx::c_boltz * gmx::c_kilo;
+                qu += gmx::c_boltz * T;
             }
             fprintf(qc, "%6d %15g %15g\n", i, qcv, qu);
             qcvtot += qcv;
index 2ddcc6a234c1c77c53cbe27bb2ff7d8a6205a477..63ae3e5226752c437bdfefd24c92f957af232da2 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -232,7 +232,7 @@ int gmx_nmens(int argc, char* argv[])
             /* (r-0.5) n times:  var_n = n * var_1 = n/12
                n=4:  var_n = 1/3, so multiply with 3 */
 
-            rfac  = std::sqrt(3.0 * BOLTZ * temp / eigval[iout[j]]);
+            rfac  = std::sqrt(3.0 * gmx::c_boltz * temp / eigval[iout[j]]);
             rhalf = 2.0 * rfac;
             rfac  = rfac / im;
 
index 006f66b2f9e91007d0e876a70c4a051879dcaaa6..1ee9de463eee51e1ec69f6aa649077cdb63830e4 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) 2013,2014,2015,2017,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2019,2020,2021, 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.
@@ -231,7 +231,7 @@ int gmx_nmtraj(int argc, char* argv[])
             /* Derive amplitude from temperature and eigenvalue if we can */
 
             /* Convert eigenvalue to angular frequency, in units s^(-1) */
-            omega = std::sqrt(eigval[kmode] * 1.0E21 / (AVOGADRO * AMU));
+            omega = std::sqrt(eigval[kmode] * 1.0E21 / (gmx::c_avogadro * gmx::c_amu));
             /* Harmonic motion will be x=x0 + A*sin(omega*t)*eigenvec.
              * The velocity is thus:
              *
@@ -261,10 +261,10 @@ int gmx_nmtraj(int argc, char* argv[])
             /* Convert Ekin from amu*(nm/s)^2 to J, i.e., kg*(m/s)^2
              * This will also be proportional to A^2
              */
-            Ekin *= AMU * 1E-18;
+            Ekin *= gmx::c_amu * 1E-18;
 
             /* Set the amplitude so the energy is kT/2 */
-            amplitude[i] = std::sqrt(0.5 * BOLTZMANN * temp / Ekin);
+            amplitude[i] = std::sqrt(0.5 * gmx::c_boltzmann * temp / Ekin);
         }
         else
         {
index c10b87746868f8ac2754741d888dcd1a575cc9e1..24c554cb8c584b140d5c19c478c6ac9da8323e32 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) 2013,2014,2015,2017,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2019,2020,2021, 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.
@@ -58,8 +58,8 @@ static void plot_rama(FILE* out, t_xrama* xr)
 
     for (i = 0; (i < xr->npp); i++)
     {
-        phi = xr->dih[xr->pp[i].iphi].ang * RAD2DEG;
-        psi = xr->dih[xr->pp[i].ipsi].ang * RAD2DEG;
+        phi = xr->dih[xr->pp[i].iphi].ang * gmx::c_rad2Deg;
+        psi = xr->dih[xr->pp[i].ipsi].ang * gmx::c_rad2Deg;
         fprintf(out, "%g  %g  %s\n", phi, psi, xr->pp[i].label);
     }
 }
index 2fe286abe11c14d1995744a161a0cd7ec400815d..44dffff46d3b1601c729fccc3743b4d4bd1dbb27 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -52,6 +52,7 @@
 #include "gromacs/gmxana/gstat.h"
 #include "gromacs/math/functions.h"
 #include "gromacs/math/units.h"
+#include "gromacs/math/utilities.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/topology/topology.h"
 #include "gromacs/utility/arraysize.h"
@@ -528,7 +529,7 @@ static void do_sham(const char* fn,
         bfac[i] = ibox[i] / (max_eig[i] - min_eig[i]);
     }
     /* Do the binning */
-    bref = 1 / (BOLTZ * Tref);
+    bref = 1 / (gmx::c_boltz * Tref);
     snew(bE, n);
     if (bGE || nenerT == 2)
     {
@@ -542,7 +543,7 @@ static void do_sham(const char* fn,
             }
             else
             {
-                bE[j] = (bref - 1 / (BOLTZ * enerT[1][j])) * enerT[0][j];
+                bE[j] = (bref - 1 / (gmx::c_boltz * enerT[1][j])) * enerT[0][j];
             }
             Emin = std::min(Emin, static_cast<double>(bE[j]));
         }
@@ -605,7 +606,7 @@ static void do_sham(const char* fn,
                 }
                 else if (idim[i] == -1)
                 {
-                    efac /= std::sin(DEG2RAD * eig[i][j]);
+                    efac /= std::sin(gmx::c_deg2Rad * eig[i][j]);
                 }
             }
             /* Update the probability */
@@ -635,7 +636,7 @@ static void do_sham(const char* fn,
         if (P[i] != 0)
         {
             Pmax = std::max(P[i], Pmax);
-            W[i] = -BOLTZ * Tref * std::log(P[i]);
+            W[i] = -gmx::c_boltz * Tref * std::log(P[i]);
             if (W[i] < Wmin)
             {
                 Wmin = W[i];
index e50ca4ee426b0457322c2e06b92c86cc4d86f2fb..6b102699f4ba0db2ba44456495625233a8aae120 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2012,2013,2014,2015,2017 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -53,7 +53,7 @@
 
 static real pot(real x, real qq, real c6, real cn, int npow)
 {
-    return cn * pow(x, -npow) - c6 / gmx::power6(x) + qq * ONE_4PI_EPS0 / x;
+    return cn * pow(x, -npow) - c6 / gmx::power6(x) + qq * gmx::c_one4PiEps0 / x;
 }
 
 static real bhpot(real x, real A, real B, real C)
@@ -64,7 +64,7 @@ static real bhpot(real x, real A, real B, real C)
 static real dpot(real x, real qq, real c6, real cn, int npow)
 {
     return -(npow * cn * std::pow(x, -npow - 1) - 6 * c6 / (x * gmx::power6(x))
-             + qq * ONE_4PI_EPS0 / gmx::square(x));
+             + qq * gmx::c_one4PiEps0 / gmx::square(x));
 }
 
 int gmx_sigeps(int argc, char* argv[])
index a787a78aeb802c1bb0b4d0ad278aef2a11fbb153..d4321ed96fd4e8defc814e2a42ce250cc1e0a5f8 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -335,7 +335,7 @@ int gmx_spol(int argc, char* argv[])
                 }
                 unitv(dir, dir);
 
-                svmul(ENM2DEBYE, dip, dip);
+                svmul(gmx::c_enm2Debye, dip, dip);
                 dip2 = norm2(dip);
                 sdip += std::sqrt(dip2);
                 sdip2 += dip2;
index a0d0ce2ae6f989cba0cb8c49572e4c50f347a592..92f543e2949bac187ceb8c8e997d614f25175c1f 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -241,7 +241,8 @@ static void process_tcaf(int                     nframes,
         fitparms[0] = 1;
         fitparms[1] = 1;
         do_lmfit(ncorr, tcaf[k], sig, dt, nullptr, 0, ncorr * dt, oenv, bDebugMode(), effnVAC, fitparms, 0, nullptr);
-        eta = 1000 * fitparms[1] * rho / (4 * fitparms[0] * PICO * norm2(kfac[k]) / (NANO * NANO));
+        eta = 1000 * fitparms[1] * rho
+              / (4 * fitparms[0] * gmx::c_pico * norm2(kfac[k]) / (gmx::c_nano * gmx::c_nano));
         fprintf(stdout, "k %6.3f  tau %6.3f  eta %8.5f 10^-3 kg/(m s)\n", norm(kfac[k]), fitparms[0], eta);
         fprintf(fp_vk, "%6.3f %g\n", norm(kfac[k]), eta);
         for (i = 0; i < ncorr; i++)
@@ -264,7 +265,7 @@ static void process_tcaf(int                     nframes,
             fitparms[1] = 1;
             do_lmfit(ncorr, tcafc[k], sig, dt, nullptr, 0, ncorr * dt, oenv, bDebugMode(), effnVAC, fitparms, 0, nullptr);
             eta = 1000 * fitparms[1] * rho
-                  / (4 * fitparms[0] * PICO * norm2(kfac[kset_c[k]]) / (NANO * NANO));
+                  / (4 * fitparms[0] * gmx::c_pico * norm2(kfac[kset_c[k]]) / (gmx::c_nano * gmx::c_nano));
             fprintf(stdout,
                     "k %6.3f  tau %6.3f  Omega %6.3f  eta %8.5f 10^-3 kg/(m s)\n",
                     norm(kfac[kset_c[k]]),
@@ -508,7 +509,7 @@ int gmx_tcaf(int argc, char* argv[])
 
     dt = (t1 - t0) / (nframes - 1);
 
-    rho *= sysmass / nframes * AMU / (NANO * NANO * NANO);
+    rho *= sysmass / nframes * gmx::c_amu / (gmx::c_nano * gmx::c_nano * gmx::c_nano);
     fprintf(stdout, "Density = %g (kg/m^3)\n", rho);
     process_tcaf(nframes,
                  dt,
index 53c71154a04e32a448b9ee73e65ac35c557d6b08..6526ccd7a26341508687e57a8bda682e5f47ef09 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -389,7 +389,7 @@ static real temp(rvec v[], const real mass[], int isize, const int index[])
         ekin2 += mass[j] * norm2(v[j]);
     }
 
-    return ekin2 / (3 * isize * BOLTZ);
+    return ekin2 / (3 * isize * gmx::c_boltz);
 }
 
 static void remove_jump(matrix box, int natoms, rvec xp[], rvec x[])
index 20c21c5b7a58b95d37feef9b443f0718d2bfd06d..b12cfbb021ac3ebf10244cb7682bd85fddb8de6d 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -161,7 +161,7 @@ static void calc_spectrum(int n, const real c[], real dt, const char* fn, gmx_ou
      * The timestep between saving the trajectory is
      * 1e7 is to convert nanometer to cm
      */
-    recip_fac = bRecip ? (1e7 / SPEED_OF_LIGHT) : 1.0;
+    recip_fac = bRecip ? (1e7 / gmx::c_speedOfLight) : 1.0;
     for (i = 0; (i < n); i += 2)
     {
         nu    = i / (2 * dt);
index 04d3106b365e49e7f9d4f40831db28e41005be7f..9f263dc3a09b3e55a02f952486f4b064f8f89cf3 100644 (file)
@@ -580,8 +580,8 @@ static void setup_acc_wham(const double* profile, t_UmbrellaWindow* window, int
                     }
                 }
                 /* Note: there are two contributions to bin k in the wham equations:
-                   i)  N[j]*exp(- U/(BOLTZ*opt->Temperature) + window[i].z[j])
-                   ii) exp(- U/(BOLTZ*opt->Temperature))
+                   i)  N[j]*exp(- U/(c_boltz*opt->Temperature) + window[i].z[j])
+                   ii) exp(- U/(c_boltz*opt->Temperature))
                    where U is the umbrella potential
                    If any of these number is larger wham_contrib_lim, I set contrib=TRUE
                  */
@@ -594,8 +594,9 @@ static void setup_acc_wham(const double* profile, t_UmbrellaWindow* window, int
                 {
                     U = tabulated_pot(distance, opt); /* Use tabulated potential     */
                 }
-                contrib1 = profile[k] * std::exp(-U / (BOLTZ * opt->Temperature));
-                contrib2 = window[i].N[j] * std::exp(-U / (BOLTZ * opt->Temperature) + window[i].z[j]);
+                contrib1 = profile[k] * std::exp(-U / (gmx::c_boltz * opt->Temperature));
+                contrib2 = window[i].N[j]
+                           * std::exp(-U / (gmx::c_boltz * opt->Temperature) + window[i].z[j]);
                 window[i].bContrib[j][k] = (contrib1 > wham_contrib_lim || contrib2 > wham_contrib_lim);
                 bAnyContrib              = bAnyContrib || window[i].bContrib[j][k];
                 if (window[i].bContrib[j][k])
@@ -689,7 +690,7 @@ static void calc_profile(double* profile, t_UmbrellaWindow* window, int nWindows
                             U = tabulated_pot(distance, opt); /* Use tabulated potential     */
                         }
                         denom += invg * window[j].N[k]
-                                 * std::exp(-U / (BOLTZ * opt->Temperature) + window[j].z[k]);
+                                 * std::exp(-U / (gmx::c_boltz * opt->Temperature) + window[j].z[k]);
                     }
                 }
                 profile[i] = num / denom;
@@ -755,7 +756,7 @@ static double calc_z(const double* profile, t_UmbrellaWindow* window, int nWindo
                         {
                             U = tabulated_pot(distance, opt); /* Use tabulated potential     */
                         }
-                        total += profile[k] * std::exp(-U / (BOLTZ * opt->Temperature));
+                        total += profile[k] * std::exp(-U / (gmx::c_boltz * opt->Temperature));
                     }
                     /* Avoid floating point exception if window is far outside min and max */
                     if (total != 0.0)
@@ -852,11 +853,11 @@ static void prof_normalization_and_unit(double* profile, t_UmbrellaOptions* opt)
     }
     else if (opt->unit == en_kJ)
     {
-        unit_factor = BOLTZ * opt->Temperature;
+        unit_factor = gmx::c_boltz * opt->Temperature;
     }
     else if (opt->unit == en_kCal)
     {
-        unit_factor = (BOLTZ / CAL2JOULE) * opt->Temperature;
+        unit_factor = (gmx::c_boltz / gmx::c_cal2Joule) * opt->Temperature;
     }
     else
     {
@@ -2711,7 +2712,7 @@ static void guessPotByIntegration(t_UmbrellaWindow* window, int nWindows, t_Umbr
      */
     for (j = 0; j < opt->bins; ++j)
     {
-        pot[j] = std::exp(-pot[j] / (BOLTZ * opt->Temperature));
+        pot[j] = std::exp(-pot[j] / (gmx::c_boltz * opt->Temperature));
     }
     calc_z(pot, window, nWindows, opt, TRUE);
 
index 66e4ddb1357be4c5bdfa758134c2c867122f8027..a51457a36915d165210dae5f7e437181bf76606e 100644 (file)
@@ -143,7 +143,7 @@ static real rot(rvec x1, const rvec x2)
     xx   = cp * x2[XX] + sp * x2[YY];
     yy   = -sp * x2[XX] + cp * x2[YY];
 
-    dphi = RAD2DEG * std::atan2(yy, xx);
+    dphi = gmx::c_rad2Deg * std::atan2(yy, xx);
 
     return dphi;
 }
@@ -190,7 +190,7 @@ real ca_phi(int gnx, const int index[], rvec x[])
         aj  = index[i + 1];
         ak  = index[i + 2];
         al  = index[i + 3];
-        phi = RAD2DEG
+        phi = gmx::c_rad2Deg
               * dih_angle(x[ai], x[aj], x[ak], x[al], nullptr, r_ij, r_kj, r_kl, m, n, &t1, &t2, &t3);
         phitot += phi;
     }
@@ -497,7 +497,7 @@ void calc_hxprops(int nres, t_bb bb[], const rvec x[])
             bb[i].d5 = norm(dx);
         }
 
-        bb[i].phi = RAD2DEG
+        bb[i].phi = gmx::c_rad2Deg
                     * dih_angle(x[bb[i].Cprev],
                                 x[bb[i].N],
                                 x[bb[i].CA],
@@ -511,7 +511,7 @@ void calc_hxprops(int nres, t_bb bb[], const rvec x[])
                                 &t1,
                                 &t2,
                                 &t3);
-        bb[i].psi = RAD2DEG
+        bb[i].psi = gmx::c_rad2Deg
                     * dih_angle(x[bb[i].N],
                                 x[bb[i].CA],
                                 x[bb[i].C],
@@ -527,9 +527,9 @@ void calc_hxprops(int nres, t_bb bb[], const rvec x[])
                                 &t3);
         bb[i].pprms2 = gmx::square(bb[i].phi - PHI_AHX) + gmx::square(bb[i].psi - PSI_AHX);
 
-        bb[i].jcaha += 1.4 * std::sin((bb[i].psi + 138.0) * DEG2RAD)
-                       - 4.1 * std::cos(2.0 * DEG2RAD * (bb[i].psi + 138.0))
-                       + 2.0 * std::cos(2.0 * DEG2RAD * (bb[i].phi + 30.0));
+        bb[i].jcaha += 1.4 * std::sin((bb[i].psi + 138.0) * gmx::c_deg2Rad)
+                       - 4.1 * std::cos(2.0 * gmx::c_deg2Rad * (bb[i].psi + 138.0))
+                       + 2.0 * std::cos(2.0 * gmx::c_deg2Rad * (bb[i].phi + 30.0));
     }
 }
 
index 707673c66208dca1c8666189e85c08a37bc35a7f..da8ae11dba2b99b7dfc9abdc7767c5b8676989ce 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) 2013,2014,2015,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2018,2019,2020,2021, 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.
@@ -119,13 +119,13 @@ static void dump_sd(const char* fn, t_shiftdata* sd)
     {
         snew(newdata[i], nny);
         phi      = i * 2 * M_PI / (nnx - 1);
-        x_phi[i] = phi * RAD2DEG - 180;
+        x_phi[i] = phi * gmx::c_rad2Deg - 180;
         for (j = 0; (j < nny); j++)
         {
             psi = j * 2 * M_PI / (nny - 1);
             if (i == 0)
             {
-                y_psi[j] = psi * RAD2DEG - 180;
+                y_psi[j] = psi * gmx::c_rad2Deg - 180;
             }
             /*if (((i % nfac) == 0) && ((j % nfac) == 0))
                newdata[i][j] = sd->data[i/nfac][j/nfac];
index 20bae48db82e9b999aea680d7bdd2444a77f888f..2b5d68988f386b3e03b7d65c91fd00df19d8b3ce 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020,2021, 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.
 
 static double eigval_to_frequency(double eigval)
 {
-    double factor_gmx_to_omega2 = 1.0E21 / (AVOGADRO * AMU);
+    double factor_gmx_to_omega2 = 1.0E21 / (gmx::c_avogadro * gmx::c_amu);
     return std::sqrt(std::max(0.0, eigval) * factor_gmx_to_omega2);
 }
 
 double calcZeroPointEnergy(gmx::ArrayRef<const real> eigval, real scale_factor)
 {
     // Convert frequency (ps^-1) to energy (kJ/mol)
-    double factor = PLANCK * PICO / (2.0 * M_PI);
+    double factor = gmx::c_planck * gmx::c_pico / (2.0 * M_PI);
     double zpe    = 0;
     for (auto& r : eigval)
     {
@@ -67,13 +67,13 @@ double calcVibrationalInternalEnergy(gmx::ArrayRef<const real> eigval, real temp
 {
     size_t nskip = linear ? 5 : 6;
     double Evib  = 0;
-    double hbar  = PLANCK1 / (2 * M_PI);
+    double hbar  = gmx::c_planck1 / (2 * M_PI);
     for (gmx::index i = nskip; i < eigval.ssize(); i++)
     {
         if (eigval[i] > 0)
         {
             double omega = scale_factor * eigval_to_frequency(eigval[i]);
-            double hwkT  = (hbar * omega) / (BOLTZMANN * temperature);
+            double hwkT  = (hbar * omega) / (gmx::c_boltzmann * temperature);
             // Prevent overflow by checking for unreasonably large numbers.
             if (hwkT < 100)
             {
@@ -92,20 +92,20 @@ double calcVibrationalInternalEnergy(gmx::ArrayRef<const real> eigval, real temp
             }
         }
     }
-    return temperature * BOLTZ * Evib;
+    return temperature * gmx::c_boltz * Evib;
 }
 
 double calcVibrationalHeatCapacity(gmx::ArrayRef<const real> eigval, real temperature, gmx_bool linear, real scale_factor)
 {
     size_t nskip = linear ? 5 : 6;
     double cv    = 0;
-    double hbar  = PLANCK1 / (2 * M_PI);
+    double hbar  = gmx::c_planck1 / (2 * M_PI);
     for (gmx::index i = nskip; i < eigval.ssize(); i++)
     {
         if (eigval[i] > 0)
         {
             double omega = scale_factor * eigval_to_frequency(eigval[i]);
-            double hwkT  = (hbar * omega) / (BOLTZMANN * temperature);
+            double hwkT  = (hbar * omega) / (gmx::c_boltzmann * temperature);
             // Prevent overflow by checking for unreasonably large numbers.
             if (hwkT < 100)
             {
@@ -124,20 +124,21 @@ double calcVibrationalHeatCapacity(gmx::ArrayRef<const real> eigval, real temper
             }
         }
     }
-    return RGAS * cv;
+    return gmx::c_universalGasConstant * cv;
 }
 
 double calcTranslationalEntropy(real mass, real temperature, real pressure)
 {
-    double kT = BOLTZ * temperature;
+    double kT = gmx::c_boltz * temperature;
 
     GMX_RELEASE_ASSERT(mass > 0, "Molecular mass should be larger than zero");
     GMX_RELEASE_ASSERT(pressure > 0, "Pressure should be larger than zero");
     GMX_RELEASE_ASSERT(temperature > 0, "Temperature should be larger than zero");
     // Convert bar to Pascal
-    double P = pressure * 1e5;
-    double qT = (std::pow(2 * M_PI * mass * kT / gmx::square(PLANCK), 1.5) * (kT / P) * (1e30 / AVOGADRO));
-    return RGAS * (std::log(qT) + 2.5);
+    double P  = pressure * 1e5;
+    double qT = (std::pow(2 * M_PI * mass * kT / gmx::square(gmx::c_planck), 1.5) * (kT / P)
+                 * (1e30 / gmx::c_avogadro));
+    return gmx::c_universalGasConstant * (std::log(qT) + 2.5);
 }
 
 double calcRotationalEntropy(real temperature, int natom, gmx_bool linear, const rvec theta, real sigma_r)
@@ -152,14 +153,14 @@ double calcRotationalEntropy(real temperature, int natom, gmx_bool linear, const
         {
             GMX_RELEASE_ASSERT(theta[0] > 0, "Theta should be larger than zero");
             double qR = temperature / (sigma_r * theta[0]);
-            sR        = RGAS * (std::log(qR) + 1);
+            sR        = gmx::c_universalGasConstant * (std::log(qR) + 1);
         }
         else
         {
             double Q = theta[XX] * theta[YY] * theta[ZZ];
             GMX_RELEASE_ASSERT(Q > 0, "Q should be larger than zero");
             double qR = std::sqrt(M_PI * std::pow(temperature, 3) / Q) / sigma_r;
-            sR        = RGAS * (std::log(qR) + 1.5);
+            sR        = gmx::c_universalGasConstant * (std::log(qR) + 1.5);
         }
     }
     return sR;
@@ -169,13 +170,13 @@ double calcQuasiHarmonicEntropy(gmx::ArrayRef<const real> eigval, real temperatu
 {
     size_t nskip = bLinear ? 5 : 6;
     double S     = 0;
-    double hbar  = PLANCK1 / (2 * M_PI);
+    double hbar  = gmx::c_planck1 / (2 * M_PI);
     for (gmx::index i = nskip; (i < eigval.ssize()); i++)
     {
         if (eigval[i] > 0)
         {
             double omega = scale_factor * eigval_to_frequency(eigval[i]);
-            double hwkT  = (hbar * omega) / (BOLTZMANN * temperature);
+            double hwkT  = (hbar * omega) / (gmx::c_boltzmann * temperature);
             double dS    = (hwkT / std::expm1(hwkT) - std::log1p(-std::exp(-hwkT)));
             S += dS;
             if (debug)
@@ -194,16 +195,16 @@ double calcQuasiHarmonicEntropy(gmx::ArrayRef<const real> eigval, real temperatu
             fprintf(debug, "eigval[%d] = %g\n", static_cast<int>(i + 1), static_cast<double>(eigval[i]));
         }
     }
-    return S * RGAS;
+    return S * gmx::c_universalGasConstant;
 }
 
 double calcSchlitterEntropy(gmx::ArrayRef<const real> eigval, real temperature, gmx_bool bLinear)
 {
     size_t nskip  = bLinear ? 5 : 6;
-    double hbar   = PLANCK1 / (2 * M_PI);               // J s
-    double kt     = BOLTZMANN * temperature;            // J
+    double hbar   = gmx::c_planck1 / (2 * M_PI);        // J s
+    double kt     = gmx::c_boltzmann * temperature;     // J
     double kteh   = kt * std::exp(2.0) / (hbar * hbar); // 1/(J s^2) = 1/(kg m^2)
-    double evcorr = NANO * NANO * AMU;
+    double evcorr = gmx::c_nano * gmx::c_nano * gmx::c_amu;
     if (debug)
     {
         fprintf(debug, "n = %td, kteh = %g evcorr = %g\n", ssize(eigval), kteh, evcorr);
@@ -214,5 +215,5 @@ double calcSchlitterEntropy(gmx::ArrayRef<const real> eigval, real temperature,
         double dd = 1 + kteh * eigval[i] * evcorr;
         deter += std::log(dd);
     }
-    return 0.5 * RGAS * deter;
+    return 0.5 * gmx::c_universalGasConstant * deter;
 }
index 24572cd44b9de91c3cdd5f748295373a40f3e1fe..18a2043ba203b7c475be6a622b1dec7ba7e8763e 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) 2010,2014,2015,2016,2019, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014,2015,2016,2019,2021, 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.
@@ -97,9 +97,9 @@ void calc_h_pos(int nht, rvec xa[], rvec xh[], int* l)
 #define alfaHpl (2 * M_PI / 3) /* 120 degrees */
 #define distH 0.1
 
-#define alfaCOM (DEG2RAD * 117)
-#define alfaCO (DEG2RAD * 121)
-#define alfaCOA (DEG2RAD * 115)
+#define alfaCOM (gmx::c_deg2Rad * 117)
+#define alfaCO (gmx::c_deg2Rad * 121)
+#define alfaCOA (gmx::c_deg2Rad * 115)
 
 #define distO 0.123
 #define distOA 0.125
index f06620e5b422af31a417471baf5f36ca5d433343..1712ec3c1658ed1d75a6435f3e853427e9c75f5d 100644 (file)
@@ -145,9 +145,9 @@ static int assign_param(t_functype                ftype,
     {
         case F_G96ANGLES:
             /* Post processing of input data: store cosine iso angle itself */
-            newparam->harmonic.rA  = cos(old[0] * DEG2RAD);
+            newparam->harmonic.rA  = cos(old[0] * gmx::c_deg2Rad);
             newparam->harmonic.krA = old[1];
-            newparam->harmonic.rB  = cos(old[2] * DEG2RAD);
+            newparam->harmonic.rB  = cos(old[2] * gmx::c_deg2Rad);
             newparam->harmonic.krB = old[3];
             break;
         case F_G96BONDS:
@@ -430,8 +430,8 @@ static int assign_param(t_functype                ftype,
             newparam->vsite.f = old[5];
             break;
         case F_VSITE3FAD:
-            newparam->vsite.a = old[1] * cos(DEG2RAD * old[0]);
-            newparam->vsite.b = old[1] * sin(DEG2RAD * old[0]);
+            newparam->vsite.a = old[1] * cos(gmx::c_deg2Rad * old[0]);
+            newparam->vsite.b = old[1] * sin(gmx::c_deg2Rad * old[0]);
             newparam->vsite.c = old[2];
             newparam->vsite.d = old[3];
             newparam->vsite.e = old[4];
index 085907a90b20a49238e6b2df7e8ddb7e31a66fab..7a64f7abdc753d56839c5a9d7c167ea96e041b77 100644 (file)
@@ -970,9 +970,9 @@ int gmx_editconf(int argc, char* argv[])
         printf("    center      :%7.3f%7.3f%7.3f (nm)\n", gc[XX], gc[YY], gc[ZZ]);
         printf("    box vectors :%7.3f%7.3f%7.3f (nm)\n", norm(box[XX]), norm(box[YY]), norm(box[ZZ]));
         printf("    box angles  :%7.2f%7.2f%7.2f (degrees)\n",
-               norm2(box[ZZ]) == 0 ? 0 : RAD2DEG * gmx_angle(box[YY], box[ZZ]),
-               norm2(box[ZZ]) == 0 ? 0 : RAD2DEG * gmx_angle(box[XX], box[ZZ]),
-               norm2(box[YY]) == 0 ? 0 : RAD2DEG * gmx_angle(box[XX], box[YY]));
+               norm2(box[ZZ]) == 0 ? 0 : gmx::c_rad2Deg * gmx_angle(box[YY], box[ZZ]),
+               norm2(box[ZZ]) == 0 ? 0 : gmx::c_rad2Deg * gmx_angle(box[XX], box[ZZ]),
+               norm2(box[YY]) == 0 ? 0 : gmx::c_rad2Deg * gmx_angle(box[XX], box[YY]));
         printf("    box volume  :%7.2f               (nm^3)\n", det(box));
     }
 
@@ -1005,7 +1005,7 @@ int gmx_editconf(int argc, char* argv[])
             real vol, dens;
 
             vol  = det(box);
-            dens = (mass * AMU) / (vol * NANO * NANO * NANO);
+            dens = (mass * gmx::c_amu) / (vol * gmx::c_nano * gmx::c_nano * gmx::c_nano);
             fprintf(stderr, "Volume  of input %g (nm^3)\n", vol);
             fprintf(stderr, "Mass    of input %g (a.m.u.)\n", mass);
             fprintf(stderr, "Density of input %g (g/l)\n", dens);
@@ -1125,7 +1125,7 @@ int gmx_editconf(int argc, char* argv[])
                rotangles[ZZ]);
         for (i = 0; i < DIM; i++)
         {
-            rotangles[i] *= DEG2RAD;
+            rotangles[i] *= gmx::c_deg2Rad;
         }
         rotate_conf(natom, x, v, rotangles[XX], rotangles[YY], rotangles[ZZ]);
     }
@@ -1235,9 +1235,9 @@ int gmx_editconf(int argc, char* argv[])
     {
         printf("new box vectors :%7.3f%7.3f%7.3f (nm)\n", norm(box[XX]), norm(box[YY]), norm(box[ZZ]));
         printf("new box angles  :%7.2f%7.2f%7.2f (degrees)\n",
-               norm2(box[ZZ]) == 0 ? 0 : RAD2DEG * gmx_angle(box[YY], box[ZZ]),
-               norm2(box[ZZ]) == 0 ? 0 : RAD2DEG * gmx_angle(box[XX], box[ZZ]),
-               norm2(box[YY]) == 0 ? 0 : RAD2DEG * gmx_angle(box[XX], box[YY]));
+               norm2(box[ZZ]) == 0 ? 0 : gmx::c_rad2Deg * gmx_angle(box[YY], box[ZZ]),
+               norm2(box[ZZ]) == 0 ? 0 : gmx::c_rad2Deg * gmx_angle(box[XX], box[ZZ]),
+               norm2(box[YY]) == 0 ? 0 : gmx::c_rad2Deg * gmx_angle(box[XX], box[YY]));
         printf("new box volume  :%7.2f               (nm^3)\n", det(box));
     }
 
index 2893816f3828918504402e7376a77768b8ee0660..b02735d60d481d607113e4516baff37f1755db72 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
 static void low_mspeed(real tempi, gmx_mtop_t* mtop, rvec v[], gmx::ThreeFry2x64<>* rng, const gmx::MDLogger& logger)
 {
     int                                    nrdf;
-    real                                   boltz;
     real                                   ekin, temp;
     gmx::TabulatedNormalDistribution<real> normalDist;
 
-    boltz = BOLTZ * tempi;
-    ekin  = 0.0;
-    nrdf  = 0;
+    ekin = 0.0;
+    nrdf = 0;
     for (const AtomProxy atomP : AtomRange(*mtop))
     {
         const t_atom& local = atomP.atom();
@@ -70,7 +68,7 @@ static void low_mspeed(real tempi, gmx_mtop_t* mtop, rvec v[], gmx::ThreeFry2x64
         if (mass > 0)
         {
             rng->restart(i, 0);
-            real sd = std::sqrt(boltz / mass);
+            real sd = std::sqrt(gmx::c_boltz * tempi / mass);
             for (int m = 0; (m < DIM); m++)
             {
                 v[i][m] = sd * normalDist(*rng);
@@ -79,7 +77,7 @@ static void low_mspeed(real tempi, gmx_mtop_t* mtop, rvec v[], gmx::ThreeFry2x64
             nrdf += DIM;
         }
     }
-    temp = (2.0 * ekin) / (nrdf * BOLTZ);
+    temp = (2.0 * ekin) / (nrdf * gmx::c_boltz);
     if (temp > 0)
     {
         real scal = std::sqrt(tempi / temp);
index 8c6ac3352e215457bd484e1fc47cb38616023826..201a412db02a2d693b5cc865f2f0747981fbb546 100644 (file)
@@ -754,7 +754,7 @@ static void add_vsites(gmx::ArrayRef<InteractionsOfType> plist,
     }         /* for i */
 }
 
-#define ANGLE_6RING (DEG2RAD * 120)
+#define ANGLE_6RING (gmx::c_deg2Rad * 120)
 
 /* cosine rule: a^2 = b^2 + c^2 - 2 b c cos(alpha) */
 /* get a^2 when a, b and alpha are given: */
@@ -1019,21 +1019,21 @@ static int gen_vsites_trp(PreprocessingAtomTypes*                  atype,
     b_CE3_HE3 = get_ddb_bond(vsitetop, "TRP", "CE3", "HE3");
     b_CZ3_HZ3 = get_ddb_bond(vsitetop, "TRP", "CZ3", "HZ3");
 
-    a_NE1_CE2_CD2 = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "NE1", "CE2", "CD2");
-    a_CE2_CD2_CG  = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CE2", "CD2", "CG");
-    a_CB_CG_CD2   = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CB", "CG", "CD2");
-    a_CD2_CG_CD1  = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CD2", "CG", "CD1");
-
-    a_CE2_CD2_CE3 = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CE2", "CD2", "CE3");
-    a_CD2_CE2_CZ2 = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CD2", "CE2", "CZ2");
-    a_CD2_CE3_CZ3 = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CD2", "CE3", "CZ3");
-    a_CE3_CZ3_HZ3 = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CE3", "CZ3", "HZ3");
-    a_CZ2_CH2_HH2 = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CZ2", "CH2", "HH2");
-    a_CE2_CZ2_HZ2 = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CE2", "CZ2", "HZ2");
-    a_CE2_CZ2_CH2 = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CE2", "CZ2", "CH2");
-    a_CG_CD1_HD1  = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CG", "CD1", "HD1");
-    a_HE1_NE1_CE2 = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "HE1", "NE1", "CE2");
-    a_CD2_CE3_HE3 = DEG2RAD * get_ddb_angle(vsitetop, "TRP", "CD2", "CE3", "HE3");
+    a_NE1_CE2_CD2 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "NE1", "CE2", "CD2");
+    a_CE2_CD2_CG  = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CE2", "CD2", "CG");
+    a_CB_CG_CD2   = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CB", "CG", "CD2");
+    a_CD2_CG_CD1  = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CD2", "CG", "CD1");
+
+    a_CE2_CD2_CE3 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CE2", "CD2", "CE3");
+    a_CD2_CE2_CZ2 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CD2", "CE2", "CZ2");
+    a_CD2_CE3_CZ3 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CD2", "CE3", "CZ3");
+    a_CE3_CZ3_HZ3 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CE3", "CZ3", "HZ3");
+    a_CZ2_CH2_HH2 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CZ2", "CH2", "HH2");
+    a_CE2_CZ2_HZ2 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CE2", "CZ2", "HZ2");
+    a_CE2_CZ2_CH2 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CE2", "CZ2", "CH2");
+    a_CG_CD1_HD1  = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CG", "CD1", "HD1");
+    a_HE1_NE1_CE2 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "HE1", "NE1", "CE2");
+    a_CD2_CE3_HE3 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TRP", "CD2", "CE3", "HE3");
 
     /* Calculate local coordinates.
      * y-axis (x=0) is the bond CD2-CE2.
@@ -1291,7 +1291,7 @@ static int gen_vsites_tyr(PreprocessingAtomTypes*                  atype,
     bond_ch   = get_ddb_bond(vsitetop, "TYR", "CD1", "HD1");
     bond_co   = get_ddb_bond(vsitetop, "TYR", "CZ", "OH");
     bond_oh   = get_ddb_bond(vsitetop, "TYR", "OH", "HH");
-    angle_coh = DEG2RAD * get_ddb_angle(vsitetop, "TYR", "CZ", "OH", "HH");
+    angle_coh = gmx::c_deg2Rad * get_ddb_angle(vsitetop, "TYR", "CZ", "OH", "HH");
 
     xi[atCG]  = -bond_cc + bond_cc * std::cos(ANGLE_6RING);
     xi[atCD1] = -bond_cc;
@@ -1471,30 +1471,30 @@ static int gen_vsites_his(t_atoms*                                 at,
     b_CE1_NE2     = get_ddb_bond(vsitetop, resname, "CE1", "NE2");
     b_CG_CD2      = get_ddb_bond(vsitetop, resname, "CG", "CD2");
     b_CD2_NE2     = get_ddb_bond(vsitetop, resname, "CD2", "NE2");
-    a_CG_ND1_CE1  = DEG2RAD * get_ddb_angle(vsitetop, resname, "CG", "ND1", "CE1");
-    a_CG_CD2_NE2  = DEG2RAD * get_ddb_angle(vsitetop, resname, "CG", "CD2", "NE2");
-    a_ND1_CE1_NE2 = DEG2RAD * get_ddb_angle(vsitetop, resname, "ND1", "CE1", "NE2");
-    a_CE1_NE2_CD2 = DEG2RAD * get_ddb_angle(vsitetop, resname, "CE1", "NE2", "CD2");
+    a_CG_ND1_CE1  = gmx::c_deg2Rad * get_ddb_angle(vsitetop, resname, "CG", "ND1", "CE1");
+    a_CG_CD2_NE2  = gmx::c_deg2Rad * get_ddb_angle(vsitetop, resname, "CG", "CD2", "NE2");
+    a_ND1_CE1_NE2 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, resname, "ND1", "CE1", "NE2");
+    a_CE1_NE2_CD2 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, resname, "CE1", "NE2", "CD2");
 
     if (ats[atHD1] != NOTSET)
     {
         b_ND1_HD1     = get_ddb_bond(vsitetop, resname, "ND1", "HD1");
-        a_CE1_ND1_HD1 = DEG2RAD * get_ddb_angle(vsitetop, resname, "CE1", "ND1", "HD1");
+        a_CE1_ND1_HD1 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, resname, "CE1", "ND1", "HD1");
     }
     if (ats[atHE2] != NOTSET)
     {
         b_NE2_HE2     = get_ddb_bond(vsitetop, resname, "NE2", "HE2");
-        a_CE1_NE2_HE2 = DEG2RAD * get_ddb_angle(vsitetop, resname, "CE1", "NE2", "HE2");
+        a_CE1_NE2_HE2 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, resname, "CE1", "NE2", "HE2");
     }
     if (ats[atHD2] != NOTSET)
     {
         b_CD2_HD2     = get_ddb_bond(vsitetop, resname, "CD2", "HD2");
-        a_NE2_CD2_HD2 = DEG2RAD * get_ddb_angle(vsitetop, resname, "NE2", "CD2", "HD2");
+        a_NE2_CD2_HD2 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, resname, "NE2", "CD2", "HD2");
     }
     if (ats[atHE1] != NOTSET)
     {
         b_CE1_HE1     = get_ddb_bond(vsitetop, resname, "CE1", "HE1");
-        a_NE2_CE1_HE1 = DEG2RAD * get_ddb_angle(vsitetop, resname, "NE2", "CE1", "HE1");
+        a_NE2_CE1_HE1 = gmx::c_deg2Rad * get_ddb_angle(vsitetop, resname, "NE2", "CE1", "HE1");
     }
 
     /* constraints between CG, CE1 and NE1 */
index 4d98124057e3f0d18aabafdc6efab39c3f47ad2d..049921fb4612a4488db0de1fac947c0c51083d68 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -540,7 +540,7 @@ int gmx_genion(int argc, char* argv[])
     {
         /* Compute number of ions to be added */
         vol   = det(box);
-        nsalt = gmx::roundToInt(conc * vol * AVOGADRO / 1e24);
+        nsalt = gmx::roundToInt(conc * vol * gmx::c_avogadro / 1e24);
         p_num = abs(nsalt * n_q);
         n_num = abs(nsalt * p_q);
     }
index fe22cd5b0f253ab7b2bacd79efad186a8eb1f148..67abdfc7ec663c5ae2bca8458e2b40e90de41c01 100644 (file)
@@ -1384,7 +1384,7 @@ static real calc_temp(const gmx_mtop_t* mtop, const t_inputrec* ir, rvec* v)
         nrdf += ir->opts.nrdf[g];
     }
 
-    return sum_mv2 / (nrdf * BOLTZ);
+    return sum_mv2 / (nrdf * gmx::c_boltz);
 }
 
 static real get_max_reference_temp(const t_inputrec* ir, warninp* wi)
@@ -2264,7 +2264,7 @@ int gmx_grompp(int argc, char* argv[])
                      * to be on the safe side with constraints.
                      */
                     const real totalEnergyDriftPerAtomPerPicosecond =
-                            2 * BOLTZ * buffer_temp / (ir->nsteps * ir->delta_t);
+                            2 * gmx::c_boltz * buffer_temp / (ir->nsteps * ir->delta_t);
 
                     if (ir->verletbuf_tol > 1.1 * driftTolerance * totalEnergyDriftPerAtomPerPicosecond)
                     {
index 83ba164b66bac4fca2a4ff4650a6e8e9358d0610..9278f09b5faacb126f5da51fcb3264fdc5b5a34d 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -145,7 +145,7 @@ static bool chk_hbonds(int i, t_atoms* pdba, rvec x[], const bool ad[], bool hbo
                 d2 = distance2(x[i], x[j]);
                 rvec_sub(x[i], xh, nh);
                 rvec_sub(x[aj], xh, oh);
-                a = RAD2DEG * acos(cos_angle(nh, oh));
+                a = gmx::c_rad2Deg * acos(cos_angle(nh, oh));
                 if ((d2 < dist2) && (a > angle))
                 {
                     hbond[i] = TRUE;
index c115cbeb9c385ca02cfdda484d985bfd2e868139..eaf605d85b4e6abcab3f9d5ee9943d7c590b66a6 100644 (file)
@@ -57,6 +57,7 @@
 #include "gromacs/gmxpreprocess/toputil.h"
 #include "gromacs/math/functions.h"
 #include "gromacs/math/units.h"
+#include "gromacs/math/utilities.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/mdlib/calc_verletbuf.h"
 #include "gromacs/mdrun/mdmodules.h"
@@ -4371,7 +4372,7 @@ void triple_check(const char* mdparin, t_inputrec* ir, gmx_mtop_t* sys, warninp_
              * of errors. The factor 0.5 is because energy distributes
              * equally over Ekin and Epot.
              */
-            max_T_error = 0.5 * tau * ir->verletbuf_tol / (nrdf_at * BOLTZ * T);
+            max_T_error = 0.5 * tau * ir->verletbuf_tol / (nrdf_at * gmx::c_boltz * T);
             if (max_T_error > T_error_warn)
             {
                 sprintf(warn_buf,
index 4d747607a404a98cff22ac2230f418ed9c3bbf9e..62ab86c576b55f2f43fc933429ef86dc621555f8 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -762,7 +762,7 @@ static void update_top(t_atoms*        atoms,
     vol = det(box);
 
     fprintf(stderr, "Volume                 :  %10g (nm^3)\n", vol);
-    fprintf(stderr, "Density                :  %10g (g/l)\n", (mtot * 1e24) / (AVOGADRO * vol));
+    fprintf(stderr, "Density                :  %10g (g/l)\n", (mtot * 1e24) / (gmx::c_avogadro * vol));
     fprintf(stderr, "Number of solvent molecules:  %5d   \n\n", nsol);
 
     /* open topology file and append sol molecules */
index acea8377c56e47ced99124548949c47acf12ed43..f26e044453d71459fd7fbe05453fbf5d39496fcd 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) 2013,2014,2015,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2018,2019,2020,2021, 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.
@@ -162,9 +162,9 @@ void make_shake(gmx::ArrayRef<InteractionsOfType> plist, t_atoms* atoms, int nsh
                                     }
                                     if (bFound)
                                     {
-                                        real param = std::sqrt(b_ij * b_ij + b_jk * b_jk
-                                                               - 2.0 * b_ij * b_jk
-                                                                         * cos(DEG2RAD * ang->c0()));
+                                        real param = std::sqrt(
+                                                b_ij * b_ij + b_jk * b_jk
+                                                - 2.0 * b_ij * b_jk * cos(gmx::c_deg2Rad * ang->c0()));
                                         std::vector<real> forceParm = { param, param };
                                         if (ftype == F_CONNBONDS || ftype_a == F_CONNBONDS)
                                         {
index 2c4133119b4fde4aad3e7eff61d08a35a3a2e5d4..36a77cd04c407a23735e9b91c1384ecf52bf9924 100644 (file)
@@ -376,7 +376,7 @@ static real get_angle(gmx::ArrayRef<const VsiteBondedInteraction> angles, t_iato
         if (((ai == ang.ai()) && (aj == ang.aj()) && (ak == ang.ak()))
             || ((ai == ang.ak()) && (aj == ang.aj()) && (ak == ang.ai())))
         {
-            angle = DEG2RAD * ang.parameterValue();
+            angle = gmx::c_deg2Rad * ang.parameterValue();
             break;
         }
     }
@@ -535,7 +535,7 @@ static bool calc_vsite3fad_param(InteractionOfType*                          vsi
     bError = (bij == NOTSET) || (aijk == NOTSET);
 
     vsite->setForceParameter(1, bij);
-    vsite->setForceParameter(0, RAD2DEG * aijk);
+    vsite->setForceParameter(0, gmx::c_rad2Deg * aijk);
 
     if (bSwapParity)
     {
@@ -601,8 +601,8 @@ static bool calc_vsite3out_param(PreprocessingAtomTypes*                     aty
         dH = bCN - bNH * std::cos(aCNH);
         rH = bNH * std::sin(aCNH);
         /* we assume the H's are symmetrically distributed */
-        rHx = rH * std::cos(DEG2RAD * 30);
-        rHy = rH * std::sin(DEG2RAD * 30);
+        rHx = rH * std::cos(gmx::c_deg2Rad * 30);
+        rHy = rH * std::sin(gmx::c_deg2Rad * 30);
         rM  = 0.5 * bMM;
         dM  = std::sqrt(gmx::square(bCM) - gmx::square(rM));
         a   = 0.5 * ((dH / dM) - (rHy / rM));
@@ -682,9 +682,9 @@ static bool calc_vsite4fd_param(InteractionOfType*                          vsit
                     .appendTextFormatted(
                             "virtual site %d: angle ijk = %f, angle ijl = %f, angle ijm = %f",
                             vsite->ai() + 1,
-                            RAD2DEG * aijk,
-                            RAD2DEG * aijl,
-                            RAD2DEG * aijm);
+                            gmx::c_rad2Deg * aijk,
+                            gmx::c_rad2Deg * aijl,
+                            gmx::c_rad2Deg * aijm);
             gmx_fatal(FARGS,
                       "invalid construction in calc_vsite4fd for atom %d: "
                       "cosakl=%f, cosakm=%f\n",
@@ -752,9 +752,9 @@ static bool calc_vsite4fdn_param(InteractionOfType*                          vsi
                     .appendTextFormatted(
                             "virtual site %d: angle ijk = %f, angle ijl = %f, angle ijm = %f",
                             vsite->ai() + 1,
-                            RAD2DEG * aijk,
-                            RAD2DEG * aijl,
-                            RAD2DEG * aijm);
+                            gmx::c_rad2Deg * aijk,
+                            gmx::c_rad2Deg * aijl,
+                            gmx::c_rad2Deg * aijm);
             gmx_fatal(FARGS,
                       "invalid construction in calc_vsite4fdn for atom %d: "
                       "pl=%f, pm=%f\n",
index b439d0ca456738278e4bde39f6cb6ff3c7becd79..876afdef94c6241d2b86adc6b32d52b9d1dac2ae 100644 (file)
@@ -270,7 +270,7 @@ static void calc_angles_dihs(InteractionsOfType* ang, InteractionsOfType* dih, c
         int  ai = angle.ai();
         int  aj = angle.aj();
         int  ak = angle.ak();
-        real th = RAD2DEG
+        real th = gmx::c_rad2Deg
                   * bond_angle(x[ai], x[aj], x[ak], bPBC ? &pbc : nullptr, r_ij, r_kj, &costh, &t1, &t2);
         angle.setForceParameter(0, th);
     }
@@ -281,7 +281,7 @@ static void calc_angles_dihs(InteractionsOfType* ang, InteractionsOfType* dih, c
         int  ak = dihedral.ak();
         int  al = dihedral.al();
         real ph =
-                RAD2DEG
+                gmx::c_rad2Deg
                 * dih_angle(x[ai], x[aj], x[ak], x[al], bPBC ? &pbc : nullptr, r_ij, r_kj, r_kl, m, n, &t1, &t2, &t3);
         dihedral.setForceParameter(0, ph);
     }
index cf1a9d81da7f24375995d2721728e4e8b64cac6c..aaec29e3ad02766cc8c3111462814e4182f05f86 100644 (file)
@@ -570,9 +570,9 @@ static int imd_send_rvecs(IMDSocket* socket, int nat, rvec* x, char* buffer)
     fill_header(reinterpret_cast<IMDHeader*>(buffer), IMD_FCOORDS, static_cast<int32_t>(nat));
     for (i = 0; i < nat; i++)
     {
-        sendx[0] = static_cast<float>(x[i][0]) * NM2A;
-        sendx[1] = static_cast<float>(x[i][1]) * NM2A;
-        sendx[2] = static_cast<float>(x[i][2]) * NM2A;
+        sendx[0] = static_cast<float>(x[i][0]) * gmx::c_nm2A;
+        sendx[1] = static_cast<float>(x[i][1]) * gmx::c_nm2A;
+        sendx[2] = static_cast<float>(x[i][2]) * gmx::c_nm2A;
         memcpy(buffer + c_headerSize + i * tuplesize, sendx, tuplesize);
     }
 
@@ -734,7 +734,7 @@ void ImdSession::Impl::prepareMDForces()
 void ImdSession::Impl::copyToMDForces()
 {
     int  i;
-    real conversion = CAL2JOULE * NM2A;
+    real conversion = gmx::c_cal2Joule * gmx::c_nm2A;
 
 
     for (i = 0; i < nforces; i++)
index 80ae6741de74293f3cb7182c6fb26d68ce658ca6..5460db9b6a64e330afb4753ec3ab23ffbf8b3637 100644 (file)
@@ -734,7 +734,7 @@ real polarize(int              nbonds,
         type = forceatoms[i++];
         ai   = forceatoms[i++];
         aj   = forceatoms[i++];
-        ksh  = gmx::square(md->chargeA[aj]) * ONE_4PI_EPS0 / forceparams[type].polarize.alpha;
+        ksh  = gmx::square(md->chargeA[aj]) * gmx::c_one4PiEps0 / forceparams[type].polarize.alpha;
 
         ki  = pbc_rvec_sub(pbc, x[ai], x[aj], dx); /*   3      */
         dr2 = iprod(dx, dx);                       /*   5              */
@@ -781,7 +781,7 @@ real anharm_polarize(int              nbonds,
         type = forceatoms[i++];
         ai   = forceatoms[i++];
         aj   = forceatoms[i++];
-        ksh = gmx::square(md->chargeA[aj]) * ONE_4PI_EPS0 / forceparams[type].anharm_polarize.alpha; /* 7*/
+        ksh = gmx::square(md->chargeA[aj]) * gmx::c_one4PiEps0 / forceparams[type].anharm_polarize.alpha; /* 7*/
         khyp  = forceparams[type].anharm_polarize.khyp;
         drcut = forceparams[type].anharm_polarize.drcut;
 
@@ -841,9 +841,9 @@ real water_pol(int             nbonds,
         type0  = forceatoms[0];
         aS     = forceatoms[5];
         qS     = md->chargeA[aS];
-        kk[XX] = gmx::square(qS) * ONE_4PI_EPS0 / forceparams[type0].wpol.al_x;
-        kk[YY] = gmx::square(qS) * ONE_4PI_EPS0 / forceparams[type0].wpol.al_y;
-        kk[ZZ] = gmx::square(qS) * ONE_4PI_EPS0 / forceparams[type0].wpol.al_z;
+        kk[XX] = gmx::square(qS) * gmx::c_one4PiEps0 / forceparams[type0].wpol.al_x;
+        kk[YY] = gmx::square(qS) * gmx::c_one4PiEps0 / forceparams[type0].wpol.al_y;
+        kk[ZZ] = gmx::square(qS) * gmx::c_one4PiEps0 / forceparams[type0].wpol.al_z;
         r_HH   = 1.0 / forceparams[type0].wpol.rHH;
         for (i = 0; (i < nbonds); i += 6)
         {
@@ -935,7 +935,7 @@ do_1_thole(const rvec xi, const rvec xj, rvec fi, rvec fj, const t_pbc* pbc, rea
     r12sq  = iprod(r12, r12);                                                     /*  5 */
     r12_1  = gmx::invsqrt(r12sq);                                                 /*  5 */
     r12bar = afac / r12_1;                                                        /*  5 */
-    v0     = qq * ONE_4PI_EPS0 * r12_1;                                           /*  2 */
+    v0     = qq * gmx::c_one4PiEps0 * r12_1;                                      /*  2 */
     ebar   = std::exp(-r12bar);                                                   /*  5 */
     v1     = (1 - (1 + 0.5 * r12bar) * ebar);                                     /*  4 */
     fscal  = ((v0 * r12_1) * v1 - v0 * 0.5 * afac * ebar * (r12bar + 1)) * r12_1; /* 9 */
@@ -1041,8 +1041,8 @@ angles(int             nbonds,
 
         *dvdlambda += harmonic(forceparams[type].harmonic.krA,
                                forceparams[type].harmonic.krB,
-                               forceparams[type].harmonic.rA * DEG2RAD,
-                               forceparams[type].harmonic.rB * DEG2RAD,
+                               forceparams[type].harmonic.rA * gmx::c_deg2Rad,
+                               forceparams[type].harmonic.rB * gmx::c_deg2Rad,
                                theta,
                                lambda,
                                &va,
@@ -1126,7 +1126,7 @@ angles(int             nbonds,
     alignas(GMX_SIMD_ALIGNMENT) std::int32_t aj[GMX_SIMD_REAL_WIDTH];
     alignas(GMX_SIMD_ALIGNMENT) std::int32_t ak[GMX_SIMD_REAL_WIDTH];
     alignas(GMX_SIMD_ALIGNMENT) real         coeff[2 * GMX_SIMD_REAL_WIDTH];
-    SimdReal                                 deg2rad_S(DEG2RAD);
+    SimdReal                                 deg2rad_S(gmx::c_deg2Rad);
     SimdReal                                 xi_S, yi_S, zi_S;
     SimdReal                                 xj_S, yj_S, zj_S;
     SimdReal                                 xk_S, yk_S, zk_S;
@@ -1364,11 +1364,11 @@ urey_bradley(int             nbonds,
         ai   = forceatoms[i++];
         aj   = forceatoms[i++];
         ak   = forceatoms[i++];
-        th0A = forceparams[type].u_b.thetaA * DEG2RAD;
+        th0A = forceparams[type].u_b.thetaA * gmx::c_deg2Rad;
         kthA = forceparams[type].u_b.kthetaA;
         r13A = forceparams[type].u_b.r13A;
         kUBA = forceparams[type].u_b.kUBA;
-        th0B = forceparams[type].u_b.thetaB * DEG2RAD;
+        th0B = forceparams[type].u_b.thetaB * gmx::c_deg2Rad;
         kthB = forceparams[type].u_b.kthetaB;
         r13B = forceparams[type].u_b.r13B;
         kUBB = forceparams[type].u_b.kUBB;
@@ -1527,7 +1527,7 @@ urey_bradley(int             nbonds,
         SimdReal rikz_S = zi_S - zk_S;
 
         const SimdReal ktheta_S = load<SimdReal>(coeff);
-        const SimdReal theta0_S = load<SimdReal>(coeff + GMX_SIMD_REAL_WIDTH) * DEG2RAD;
+        const SimdReal theta0_S = load<SimdReal>(coeff + GMX_SIMD_REAL_WIDTH) * gmx::c_deg2Rad;
         const SimdReal kUB_S    = load<SimdReal>(coeff + 2 * GMX_SIMD_REAL_WIDTH);
         const SimdReal r13_S    = load<SimdReal>(coeff + 3 * GMX_SIMD_REAL_WIDTH);
 
@@ -1621,7 +1621,7 @@ real quartic_angles(int             nbonds,
 
         theta = bond_angle(x[ai], x[aj], x[ak], pbc, r_ij, r_kj, &cos_theta, &t1, &t2); /*  41 */
 
-        dt = theta - forceparams[type].qangle.theta * DEG2RAD; /* 2          */
+        dt = theta - forceparams[type].qangle.theta * gmx::c_deg2Rad; /* 2          */
 
         dVdt = 0;
         va   = forceparams[type].qangle.c[0];
@@ -1913,8 +1913,8 @@ template<BondedKernelFlavor flavor>
 real dopdihs(real cpA, real cpB, real phiA, real phiB, int mult, real phi, real lambda, real* V, real* dvdlambda)
 {
     const real L1   = 1.0 - lambda;
-    const real ph0  = (L1 * phiA + lambda * phiB) * DEG2RAD;
-    const real dph0 = (phiB - phiA) * DEG2RAD;
+    const real ph0  = (L1 * phiA + lambda * phiB) * gmx::c_deg2Rad;
+    const real dph0 = (phiB - phiA) * gmx::c_deg2Rad;
     const real cp   = L1 * cpA + lambda * cpB;
 
     const real mdphi = mult * phi - ph0;
@@ -1937,8 +1937,8 @@ real dopdihs_min(real cpA, real cpB, real phiA, real phiB, int mult, real phi, r
 {
     real v, dvdlambda, mdphi, v1, sdphi, ddphi;
     real L1   = 1.0 - lambda;
-    real ph0  = (L1 * phiA + lambda * phiB) * DEG2RAD;
-    real dph0 = (phiB - phiA) * DEG2RAD;
+    real ph0  = (L1 * phiA + lambda * phiB) * gmx::c_deg2Rad;
+    real dph0 = (phiB - phiA) * gmx::c_deg2Rad;
     real cp   = L1 * cpA + lambda * cpB;
 
     mdphi = mult * (phi - ph0);
@@ -2046,7 +2046,7 @@ pdihs(int             nbonds,
     alignas(GMX_SIMD_ALIGNMENT) std::int32_t al[GMX_SIMD_REAL_WIDTH];
     alignas(GMX_SIMD_ALIGNMENT) real         buf[3 * GMX_SIMD_REAL_WIDTH];
     real *                                   cp, *phi0, *mult;
-    SimdReal                                 deg2rad_S(DEG2RAD);
+    SimdReal                                 deg2rad_S(gmx::c_deg2Rad);
     SimdReal                                 p_S, q_S;
     SimdReal                                 phi0_S, phi_S;
     SimdReal                                 mx_S, my_S, mz_S;
@@ -2313,8 +2313,8 @@ real idihs(int             nbonds,
         pB = forceparams[type].harmonic.rB;
 
         kk    = L1 * kA + lambda * kB;
-        phi0  = (L1 * pA + lambda * pB) * DEG2RAD;
-        dphi0 = (pB - pA) * DEG2RAD;
+        phi0  = (L1 * pA + lambda * pB) * gmx::c_deg2Rad;
+        dphi0 = (pB - pA) * gmx::c_deg2Rad;
 
         dp = phi - phi0;
 
@@ -2495,7 +2495,7 @@ real dihres(int             nbonds,
 
     L1 = 1.0 - lambda;
 
-    d2r = DEG2RAD;
+    d2r = gmx::c_deg2Rad;
 
     for (i = 0; (i < nbonds);)
     {
@@ -3323,8 +3323,8 @@ real cmap_dihs(int                 nbonds,
 
         /* Switch to degrees */
         dx    = 360.0 / cmap_grid->grid_spacing;
-        xphi1 = xphi1 * RAD2DEG;
-        xphi2 = xphi2 * RAD2DEG;
+        xphi1 = xphi1 * gmx::c_rad2Deg;
+        xphi2 = xphi2 * gmx::c_rad2Deg;
 
         for (i = 0; i < 4; i++) /* 16 */
         {
@@ -3361,7 +3361,7 @@ real cmap_dihs(int                 nbonds,
             df2 = tt * df2 + (3.0 * tc[i * 4 + 3] * tu + 2.0 * tc[i * 4 + 2]) * tu + tc[i * 4 + 1];
         }
 
-        fac = RAD2DEG / dx;
+        fac = gmx::c_rad2Deg / dx;
         df1 = df1 * fac;
         df2 = df2 * fac;
 
index 2da9dcf8fec015aec0d135b40ab8c274beb77d79..68326ebca3929eff65dd0a1d0766fc87e38c0719 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2017,2019, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2017,2019,2021, 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.
@@ -78,7 +78,7 @@ void compute_factors_restangles(int             type,
     double term_theta_theta_equil;
 
     k_bending          = forceparams[type].harmonic.krA;
-    theta_equil        = forceparams[type].harmonic.rA * DEG2RAD;
+    theta_equil        = forceparams[type].harmonic.rA * gmx::c_deg2Rad;
     theta_equil        = M_PI - theta_equil;
     cosine_theta_equil = cos(theta_equil);
 
@@ -135,7 +135,7 @@ void compute_factors_restrdihs(int             type,
     real norm_phi;
 
     /* Read parameters phi0 and k_torsion */
-    phi0        = forceparams[type].pdihs.phiA * DEG2RAD;
+    phi0        = forceparams[type].pdihs.phiA * gmx::c_deg2Rad;
     cosine_phi0 = cos(phi0);
     k_torsion   = forceparams[type].pdihs.cpA;
 
index e7cd5759d3d6a9cef8a7248f3635cf90f82f37ba..f29ff7303b793d2c7159a0874ea322f8944e7281 100644 (file)
@@ -792,7 +792,7 @@ static real displacementVariance(const t_inputrec& ir, real temperature, real ti
          * should be negligible (unless nstlist is extremely large, which
          * you wouldn't do anyhow).
          */
-        kT_fac = 2 * BOLTZ * temperature * timePeriod;
+        kT_fac = 2 * gmx::c_boltz * temperature * timePeriod;
         if (ir.bd_fric > 0)
         {
             /* This is directly sigma^2 of the displacement */
@@ -813,7 +813,7 @@ static real displacementVariance(const t_inputrec& ir, real temperature, real ti
     }
     else
     {
-        kT_fac = BOLTZ * temperature * gmx::square(timePeriod);
+        kT_fac = gmx::c_boltz * temperature * gmx::square(timePeriod);
     }
 
     return kT_fac;
@@ -981,7 +981,7 @@ real calcVerletBufferSize(const gmx_mtop_t&         mtop,
                   "interactions");
     }
 
-    elfac = ONE_4PI_EPS0 / ir.epsilon_r;
+    elfac = gmx::c_one4PiEps0 / ir.epsilon_r;
 
     // Determine the 1st and 2nd derivative for the electostatics
     pot_derivatives_t elec = { 0, 0, 0 };
index 83a61bed785e557cc689eb8f72a3a03910ad0389..982faf33e02020aa5a85eb91ec562d5de490faf2 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2012,2014,2015,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -79,7 +79,7 @@ void calc_mu(int                            start,
 
     for (m = 0; (m < DIM); m++)
     {
-        mu[m] *= ENM2DEBYE;
+        mu[m] *= gmx::c_enm2Debye;
     }
 
     if (nChargePerturbed)
@@ -94,9 +94,9 @@ void calc_mu(int                            start,
             mu_y += qB[i] * x[i][YY];
             mu_z += qB[i] * x[i][ZZ];
         }
-        mu_B[XX] = mu_x * ENM2DEBYE;
-        mu_B[YY] = mu_y * ENM2DEBYE;
-        mu_B[ZZ] = mu_z * ENM2DEBYE;
+        mu_B[XX] = mu_x * gmx::c_enm2Debye;
+        mu_B[YY] = mu_y * gmx::c_enm2Debye;
+        mu_B[ZZ] = mu_z * gmx::c_enm2Debye;
     }
     else
     {
index 9c3f8ef0cc4807125133c71e2809554b374902a2..005376d1227899ecede350d47dc1874c83317f08 100644 (file)
@@ -446,7 +446,7 @@ static void NHC_trotter(const t_grpopts*      opts,
                 Ekin = 2 * trace(tcstat->ekinh) * tcstat->ekinscaleh_nhc;
             }
         }
-        kT = BOLTZ * reft;
+        kT = gmx::c_boltz * reft;
 
         for (mi = 0; mi < mstepsi; mi++)
         {
@@ -572,7 +572,8 @@ static void boxv_trotter(const t_inputrec*     ir,
     pscal = calc_pres(ir->pbcType, nwall, box, ekinmod, vir, localpres) + pcorr;
 
     vol = det(box);
-    GW  = (vol * (MassQ->Winv / PRESFAC)) * (DIM * pscal - trace(ir->ref_p)); /* W is in ps^2 * bar * nm^3 */
+    GW  = (vol * (MassQ->Winv / gmx::c_presfac))
+         * (DIM * pscal - trace(ir->ref_p)); /* W is in ps^2 * bar * nm^3 */
 
     *veta += 0.5 * dt * GW;
 }
@@ -601,7 +602,7 @@ real calc_pres(PbcType pbcType, int nwall, const matrix box, const tensor ekin,
          * het systeem...
          */
 
-        fac = PRESFAC * 2.0 / det(box);
+        fac = gmx::c_presfac * 2.0 / det(box);
         for (n = 0; (n < DIM); n++)
         {
             for (m = 0; (m < DIM); m++)
@@ -625,7 +626,7 @@ real calc_temp(real ekin, real nrdf)
 {
     if (nrdf > 0)
     {
-        return (2.0 * ekin) / (nrdf * BOLTZ);
+        return (2.0 * ekin) / (nrdf * gmx::c_boltz);
     }
     else
     {
@@ -633,7 +634,7 @@ real calc_temp(real ekin, real nrdf)
     }
 }
 
-/*! \brief Sets 1/mass for Parrinello-Rahman in wInv; NOTE: PRESFAC is not included, so not in GROMACS units! */
+/*! \brief Sets 1/mass for Parrinello-Rahman in wInv; NOTE: c_presfac is not included, so not in GROMACS units! */
 static void calcParrinelloRahmanInvMass(const t_inputrec* ir, const matrix box, tensor wInv)
 {
     real maxBoxLength;
@@ -696,7 +697,7 @@ void parrinellorahman_pcoupl(FILE*             fplog,
 
     if (!bFirstStep)
     {
-        /* Note that PRESFAC does not occur here.
+        /* Note that c_presfac does not occur here.
          * The pressure and compressibility always occur as a product,
          * therefore the pressure unit drops out.
          */
@@ -972,7 +973,7 @@ void calculateScalingMatrixImplDetail<PressureCoupling::CRescale>(const t_inputr
     }
     real gauss  = 0;
     real gauss2 = 0;
-    real kt     = ir->opts.ref_t[0] * BOLTZ;
+    real kt     = ir->opts.ref_t[0] * gmx::c_boltz;
     if (kt < 0.0)
     {
         kt = 0.0;
@@ -986,7 +987,7 @@ void calculateScalingMatrixImplDetail<PressureCoupling::CRescale>(const t_inputr
             {
                 const real factor = compressibilityFactor(d, d, ir, dt);
                 mu[d][d]          = std::exp(-factor * (ir->ref_p[d][d] - scalar_pressure) / DIM
-                                    + std::sqrt(2.0 * kt * factor * PRESFAC / vol) * gauss / DIM);
+                                    + std::sqrt(2.0 * kt * factor * gmx::c_presfac / vol) * gauss / DIM);
             }
             break;
         case PressureCouplingType::SemiIsotropic:
@@ -996,13 +997,13 @@ void calculateScalingMatrixImplDetail<PressureCoupling::CRescale>(const t_inputr
             {
                 const real factor = compressibilityFactor(d, d, ir, dt);
                 mu[d][d]          = std::exp(-factor * (ir->ref_p[d][d] - xy_pressure) / DIM
-                                    + std::sqrt((DIM - 1) * 2.0 * kt * factor * PRESFAC / vol / DIM)
+                                    + std::sqrt((DIM - 1) * 2.0 * kt * factor * gmx::c_presfac / vol / DIM)
                                               / (DIM - 1) * gauss);
             }
             {
                 const real factor = compressibilityFactor(ZZ, ZZ, ir, dt);
                 mu[ZZ][ZZ]        = std::exp(-factor * (ir->ref_p[ZZ][ZZ] - pres[ZZ][ZZ]) / DIM
-                                      + std::sqrt(2.0 * kt * factor * PRESFAC / vol / DIM) * gauss2);
+                                      + std::sqrt(2.0 * kt * factor * gmx::c_presfac / vol / DIM) * gauss2);
             }
             break;
         case PressureCouplingType::SurfaceTension:
@@ -1014,12 +1015,12 @@ void calculateScalingMatrixImplDetail<PressureCoupling::CRescale>(const t_inputr
                 /* Notice: we here use ref_p[ZZ][ZZ] as isotropic pressure and ir->ref_p[d][d] as surface tension */
                 mu[d][d] = std::exp(
                         -factor * (ir->ref_p[ZZ][ZZ] - ir->ref_p[d][d] / box[ZZ][ZZ] - xy_pressure) / DIM
-                        + std::sqrt(4.0 / 3.0 * kt * factor * PRESFAC / vol) / (DIM - 1) * gauss);
+                        + std::sqrt(4.0 / 3.0 * kt * factor * gmx::c_presfac / vol) / (DIM - 1) * gauss);
             }
             {
                 const real factor = compressibilityFactor(ZZ, ZZ, ir, dt);
                 mu[ZZ][ZZ]        = std::exp(-factor * (ir->ref_p[ZZ][ZZ] - pres[ZZ][ZZ]) / DIM
-                                      + std::sqrt(2.0 / 3.0 * kt * factor * PRESFAC / vol) * gauss2);
+                                      + std::sqrt(2.0 / 3.0 * kt * factor * gmx::c_presfac / vol) * gauss2);
             }
             break;
         default:
@@ -1491,16 +1492,16 @@ extern void init_npt_masses(const t_inputrec* ir, t_state* state, t_extmass* Mas
 
         /* units are nm^3 * ns^2 / (nm^3 * bar / kJ/mol) = kJ/mol  */
         /* Consider evaluating eventually if this the right mass to use.  All are correct, some might be more stable  */
-        MassQ->Winv = (PRESFAC * trace(ir->compress) * BOLTZ * opts->ref_t[0])
+        MassQ->Winv = (gmx::c_presfac * trace(ir->compress) * gmx::c_boltz * opts->ref_t[0])
                       / (DIM * state->vol0 * gmx::square(ir->tau_p / M_2PI));
         /* An alternate mass definition, from Tuckerman et al. */
-        /* MassQ->Winv = 1.0/(gmx::square(ir->tau_p/M_2PI)*(opts->nrdf[0]+DIM)*BOLTZ*opts->ref_t[0]); */
+        /* MassQ->Winv = 1.0/(gmx::square(ir->tau_p/M_2PI)*(opts->nrdf[0]+DIM)*c_boltz*opts->ref_t[0]); */
         for (d = 0; d < DIM; d++)
         {
             for (n = 0; n < DIM; n++)
             {
-                MassQ->Winvm[d][n] =
-                        PRESFAC * ir->compress[d][n] / (state->vol0 * gmx::square(ir->tau_p / M_2PI));
+                MassQ->Winvm[d][n] = gmx::c_presfac * ir->compress[d][n]
+                                     / (state->vol0 * gmx::square(ir->tau_p / M_2PI));
                 /* not clear this is correct yet for the anisotropic case. Will need to reevaluate
                    before using MTTK for anisotropic states.*/
             }
@@ -1518,7 +1519,7 @@ extern void init_npt_masses(const t_inputrec* ir, t_state* state, t_extmass* Mas
             {
                 reft = std::max<real>(0, opts->ref_t[i]);
                 nd   = opts->nrdf[i];
-                kT   = BOLTZ * reft;
+                kT   = gmx::c_boltz * reft;
                 for (j = 0; j < nh; j++)
                 {
                     if (j == 0)
@@ -1695,7 +1696,7 @@ init_npt_vars(const t_inputrec* ir, t_state* state, t_extmass* MassQ, gmx_bool b
     if ((ir->tau_p > 0) && (opts->ref_t[0] > 0))
     {
         reft = std::max<real>(0, opts->ref_t[0]);
-        kT   = BOLTZ * reft;
+        kT   = gmx::c_boltz * reft;
         for (i = 0; i < nnhpres; i++)
         {
             for (j = 0; j < nh; j++)
@@ -1740,7 +1741,7 @@ static real energyNoseHoover(const t_inputrec* ir, const t_state* state, const t
 
         real nd   = ir->opts.nrdf[i];
         real reft = std::max<real>(ir->opts.ref_t[i], 0);
-        real kT   = BOLTZ * reft;
+        real kT   = gmx::c_boltz * reft;
 
         if (nd > 0.0)
         {
@@ -1768,7 +1769,7 @@ static real energyNoseHoover(const t_inputrec* ir, const t_state* state, const t
             }
             else /* Other non Trotter temperature NH control  -- no chains yet. */
             {
-                energy += 0.5 * BOLTZ * nd * gmx::square(ivxi[0]) / iQinv[0];
+                energy += 0.5 * gmx::c_boltz * nd * gmx::square(ivxi[0]) / iQinv[0];
                 energy += nd * ixi[0] * kT;
             }
         }
@@ -1788,7 +1789,7 @@ static real energyPressureMTTK(const t_inputrec* ir, const t_state* state, const
     {
         /* note -- assumes only one degree of freedom that is thermostatted in barostat */
         real reft = std::max<real>(ir->opts.ref_t[0], 0.0); /* using 'System' temperature */
-        real kT   = BOLTZ * reft;
+        real kT   = gmx::c_boltz * reft;
 
         for (int j = 0; j < nh; j++)
         {
@@ -1849,7 +1850,8 @@ real NPT_energy(const t_inputrec* ir, const t_state* state, const t_extmass* Mas
                     {
                         if (invMass[d][n] > 0)
                         {
-                            energyNPT += 0.5 * gmx::square(state->boxv[d][n]) / (invMass[d][n] * PRESFAC);
+                            energyNPT += 0.5 * gmx::square(state->boxv[d][n])
+                                         / (invMass[d][n] * gmx::c_presfac);
                         }
                     }
                 }
@@ -1861,7 +1863,7 @@ real NPT_energy(const t_inputrec* ir, const t_state* state, const t_extmass* Mas
                  * track of unwrapped box diagonal elements. This case is
                  * excluded in integratorHasConservedEnergyQuantity().
                  */
-                energyNPT += vol * trace(ir->ref_p) / (DIM * PRESFAC);
+                energyNPT += vol * trace(ir->ref_p) / (DIM * gmx::c_presfac);
                 break;
             }
             case PressureCoupling::Mttk:
@@ -1869,7 +1871,7 @@ real NPT_energy(const t_inputrec* ir, const t_state* state, const t_extmass* Mas
                 energyNPT += 0.5 * gmx::square(state->veta) / MassQ->Winv;
 
                 /* contribution from the PV term */
-                energyNPT += vol * trace(ir->ref_p) / (DIM * PRESFAC);
+                energyNPT += vol * trace(ir->ref_p) / (DIM * gmx::c_presfac);
 
                 if (ir->epc == PressureCoupling::Mttk)
                 {
@@ -2010,7 +2012,7 @@ void vrescale_tcoupl(const t_inputrec* ir, int64_t step, gmx_ekindata_t* ekind,
 
         if (opts->tau_t[i] >= 0 && opts->nrdf[i] > 0 && Ek > 0)
         {
-            Ek_ref1 = 0.5 * opts->ref_t[i] * BOLTZ;
+            Ek_ref1 = 0.5 * opts->ref_t[i] * gmx::c_boltz;
             Ek_ref  = Ek_ref1 * opts->nrdf[i];
 
             Ek_new = vrescale_resamplekin(Ek, Ek_ref, opts->nrdf[i], opts->tau_t[i] / dt, step, ir->ld_seed);
index 481c8597e79e9c96ff843df4f6a11838a216d356..2c8976f89ab78ef2c84783d4f631f24a87801f13 100644 (file)
@@ -634,7 +634,7 @@ DispersionCorrection::Correction DispersionCorrection::calculate(const matrix bo
             corr.virial += numCorr * density * avctwelve * iParams_.virdifftwelve_ / 3.0;
         }
         /* The factor 2 is because of the Gromacs virial definition */
-        corr.pressure = -2.0 * invvol * corr.virial * PRESFAC;
+        corr.pressure = -2.0 * invvol * corr.virial * gmx::c_presfac;
     }
 
     if (eFep_ != FreeEnergyPerturbationType::No)
index 571edc54c8feb7bec602550012ebf1ec82312406..1f75ff4781f444d79e26e978dc30041db3055b23 100644 (file)
@@ -908,7 +908,7 @@ void EnergyOutput::addDataAtEnergyStep(bool                    bDoDHDL,
             nboxs = boxs_nm.size();
         }
         vol  = box[XX][XX] * box[YY][YY] * box[ZZ][ZZ];
-        dens = (tmass * AMU) / (vol * NANO * NANO * NANO);
+        dens = (tmass * gmx::c_amu) / (vol * gmx::c_nano * gmx::c_nano * gmx::c_nano);
         add_ebin(ebin_, ib_, nboxs, bs, bSum);
         add_ebin(ebin_, ivol_, 1, &vol, bSum);
         add_ebin(ebin_, idens_, 1, &dens, bSum);
@@ -917,7 +917,7 @@ void EnergyOutput::addDataAtEnergyStep(bool                    bDoDHDL,
         {
             /* This is pV (in kJ/mol).  The pressure is the reference pressure,
                not the instantaneous pressure */
-            pv = vol * ref_p_ / PRESFAC;
+            pv = vol * ref_p_ / gmx::c_presfac;
 
             add_ebin(ebin_, ipv_, 1, &pv, bSum);
             enthalpy = pv + enerd->term[F_ETOT];
@@ -953,12 +953,12 @@ void EnergyOutput::addDataAtEnergyStep(bool                    bDoDHDL,
     if (ekind && ekind->cosacc.cos_accel != 0)
     {
         vol  = box[XX][XX] * box[YY][YY] * box[ZZ][ZZ];
-        dens = (tmass * AMU) / (vol * NANO * NANO * NANO);
+        dens = (tmass * gmx::c_amu) / (vol * gmx::c_nano * gmx::c_nano * gmx::c_nano);
         add_ebin(ebin_, ivcos_, 1, &(ekind->cosacc.vcos), bSum);
         /* 1/viscosity, unit 1/(kg m^-1 s^-1) */
         tmp = 1
-              / (ekind->cosacc.cos_accel / (ekind->cosacc.vcos * PICO) * dens
-                 * gmx::square(box[ZZ][ZZ] * NANO / (2 * M_PI)));
+              / (ekind->cosacc.cos_accel / (ekind->cosacc.vcos * gmx::c_pico) * dens
+                 * gmx::square(box[ZZ][ZZ] * gmx::c_nano / (2 * M_PI)));
         add_ebin(ebin_, ivisc_, 1, &tmp, bSum);
     }
     if (nE_ > 1)
index 965d92b4418d793aa568abf6ecd8563183413428..2a6837f6bdf790128c1be1e94f4c5b68b6211af5 100644 (file)
@@ -52,6 +52,7 @@
 #include "gromacs/listed_forces/orires.h"
 #include "gromacs/math/functions.h"
 #include "gromacs/math/units.h"
+#include "gromacs/math/utilities.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/mdlib/calcmu.h"
 #include "gromacs/mdlib/constr.h"
@@ -1402,15 +1403,16 @@ int ExpandedEnsembleDynamics(FILE*                 log,
             if (ir->bSimTemp)
             {
                 /* Note -- this assumes no mass changes, since kinetic energy is not added  . . . */
-                scaled_lamee[i] = enerd->foreignLambdaTerms.deltaH(i) / (simtemp->temperatures[i] * BOLTZ)
-                                  + enerd->term[F_EPOT]
-                                            * (1.0 / (simtemp->temperatures[i])
-                                               - 1.0 / (simtemp->temperatures[fep_state]))
-                                            / BOLTZ;
+                scaled_lamee[i] =
+                        enerd->foreignLambdaTerms.deltaH(i) / (simtemp->temperatures[i] * gmx::c_boltz)
+                        + enerd->term[F_EPOT]
+                                  * (1.0 / (simtemp->temperatures[i])
+                                     - 1.0 / (simtemp->temperatures[fep_state]))
+                                  / gmx::c_boltz;
             }
             else
             {
-                scaled_lamee[i] = enerd->foreignLambdaTerms.deltaH(i) / (expand->mc_temp * BOLTZ);
+                scaled_lamee[i] = enerd->foreignLambdaTerms.deltaH(i) / (expand->mc_temp * gmx::c_boltz);
                 /* mc_temp is currently set to the system reft unless otherwise defined */
             }
 
@@ -1427,7 +1429,8 @@ int ExpandedEnsembleDynamics(FILE*                 log,
             {
                 scaled_lamee[i] =
                         enerd->term[F_EPOT]
-                        * (1.0 / simtemp->temperatures[i] - 1.0 / simtemp->temperatures[fep_state]) / BOLTZ;
+                        * (1.0 / simtemp->temperatures[i] - 1.0 / simtemp->temperatures[fep_state])
+                        / gmx::c_boltz;
             }
         }
     }
index e231cb4b124887f408717bcb57c70b76b3cbad56..cda7d5743e33f9605c349d9bba22fff10102a478 100644 (file)
@@ -893,7 +893,7 @@ static interaction_const_t init_interaction_const(FILE*             fp,
     /* Set the Coulomb energy conversion factor */
     if (interactionConst.epsilon_r != 0)
     {
-        interactionConst.epsfac = ONE_4PI_EPS0 / interactionConst.epsilon_r;
+        interactionConst.epsfac = gmx::c_one4PiEps0 / interactionConst.epsilon_r;
     }
     else
     {
index 5b24e8be3f282b2ea0887397d2d53a4d20bf12f5..b5fe54be92ee94ebe18c38b6b53cc707de496279 100644 (file)
@@ -1096,7 +1096,7 @@ static void do_lincs(ArrayRefWithPadding<const RVec> xPadded,
 
     real wfac;
 
-    wfac = std::cos(DEG2RAD * wangle);
+    wfac = std::cos(gmx::c_deg2Rad * wangle);
     wfac = wfac * wfac;
 
     for (int iter = 0; iter < lincsd->nIter; iter++)
@@ -2151,7 +2151,7 @@ static void lincs_warning(gmx_domdec_t*                 dd,
                           int                           maxwarn,
                           int*                          warncount)
 {
-    real wfac = std::cos(DEG2RAD * wangle);
+    real wfac = std::cos(gmx::c_deg2Rad * wangle);
 
     fprintf(stderr,
             "bonds that rotated more than %g degrees:\n"
@@ -2183,7 +2183,7 @@ static void lincs_warning(gmx_domdec_t*                 dd,
                     " %6d %6d  %5.1f  %8.4f %8.4f    %8.4f\n",
                     ddglatnr(dd, i),
                     ddglatnr(dd, j),
-                    RAD2DEG * std::acos(cosine),
+                    gmx::c_rad2Deg * std::acos(cosine),
                     d0,
                     d1,
                     bllen[b]);
index 4584876236e0802897f58858caa0d3499ffd8349..3eea60f6787681a5cb459296061f540eea7d196d 100644 (file)
@@ -74,7 +74,7 @@ void calc_rffac(FILE* fplog, real eps_r, real eps_rf, real Rc, real* krf, real*
                 Rc,
                 *krf,
                 *crf,
-                ONE_4PI_EPS0 / eps_r);
+                gmx::c_one4PiEps0 / eps_r);
         // Make sure we don't lose resolution in pow() by casting real arg to double
         real rmin = gmx::invcbrt(static_cast<double>(*krf * 2.0));
         fprintf(fplog, "The electrostatics potential has its minimum at r = %g\n", rmin);
index b9e9bbc4a25075e1d6596062af42f9d4fdd7840c..0bcf0c5451e9eb77b6532f5ec1e826516099db23 100644 (file)
@@ -485,7 +485,7 @@ static real averageKineticEnergyEstimate(const t_grpopts& groupOptions)
         if (groupOptions.tau_t[g] >= 0)
         {
             nrdfCoupled += groupOptions.nrdf[g];
-            kineticEnergy += groupOptions.nrdf[g] * 0.5 * groupOptions.ref_t[g] * BOLTZ;
+            kineticEnergy += groupOptions.nrdf[g] * 0.5 * groupOptions.ref_t[g] * gmx::c_boltz;
         }
         else
         {
index 6b695e5c52060bf75959b6f1bae386fdd43d647c..16c722e915ed39bc763df6b5e759ebc3a5397826 100644 (file)
@@ -891,7 +891,7 @@ gmx_stochd_t::gmx_stochd_t(const t_inputrec& inputRecord)
                 && (reft > 0)) /* tau_t or ref_t = 0 means that no randomization is done */
             {
                 randomize_group[gt] = true;
-                boltzfac[gt]        = BOLTZ * opts->ref_t[gt];
+                boltzfac[gt]        = gmx::c_boltz * opts->ref_t[gt];
             }
             else
             {
@@ -909,7 +909,7 @@ void Update::Impl::update_temperature_constants(const t_inputrec& inputRecord)
         {
             for (int gt = 0; gt < inputRecord.opts.ngtc; gt++)
             {
-                sd_.bd_rf[gt] = std::sqrt(2.0 * BOLTZ * inputRecord.opts.ref_t[gt]
+                sd_.bd_rf[gt] = std::sqrt(2.0 * gmx::c_boltz * inputRecord.opts.ref_t[gt]
                                           / (inputRecord.bd_fric * inputRecord.delta_t));
             }
         }
@@ -917,7 +917,7 @@ void Update::Impl::update_temperature_constants(const t_inputrec& inputRecord)
         {
             for (int gt = 0; gt < inputRecord.opts.ngtc; gt++)
             {
-                sd_.bd_rf[gt] = std::sqrt(2.0 * BOLTZ * inputRecord.opts.ref_t[gt]);
+                sd_.bd_rf[gt] = std::sqrt(2.0 * gmx::c_boltz * inputRecord.opts.ref_t[gt]);
             }
         }
     }
@@ -925,7 +925,7 @@ void Update::Impl::update_temperature_constants(const t_inputrec& inputRecord)
     {
         for (int gt = 0; gt < inputRecord.opts.ngtc; gt++)
         {
-            real kT = BOLTZ * inputRecord.opts.ref_t[gt];
+            real kT = gmx::c_boltz * inputRecord.opts.ref_t[gt];
             /* The mass is accounted for later, since this differs per atom */
             sd_.sdsig[gt].V = std::sqrt(kT * (1 - sd_.sdc[gt].em * sd_.sdc[gt].em));
         }
index b8ed8dcadb80050b5e47cd7404370ea1ed1f0c52..3896550d9901c2cea270b900702a62f4494185fb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -522,9 +522,10 @@ static real constraintGroupRadius(const gmx_moltype_t&                     molty
         /* Set number of stddevs such that change of exceeding < 10^-9 */
         constexpr real c_numSigma = 6.0;
         /* Compute the maximally stretched angle */
-        const real eqAngle = angleParams.harmonic.rA * DEG2RAD;
+        const real eqAngle = angleParams.harmonic.rA * gmx::c_deg2Rad;
         const real fc      = angleParams.harmonic.krA;
-        const real maxAngle = eqAngle + c_numSigma * BOLTZ * temperature / ((numPartnerAtoms - 1) * fc);
+        const real maxAngle =
+                eqAngle + c_numSigma * gmx::c_boltz * temperature / ((numPartnerAtoms - 1) * fc);
         if (maxAngle >= M_PI)
         {
             return -1;
index d813cfdc97b87319c29266d346fa51f1fd495f10..67e19f212e6815c27b8179317b0280fb95049b76 100644 (file)
@@ -845,7 +845,7 @@ static real calc_delta(FILE* fplog, gmx_bool bPrint, struct gmx_repl_ex* re, int
     if (re->bNPT)
     {
         /* revist the calculation for 5.0.  Might be some improvements. */
-        dpV = (beta[ap] * re->pres[ap] - beta[bp] * re->pres[bp]) * (Vol[b] - Vol[a]) / PRESFAC;
+        dpV = (beta[ap] * re->pres[ap] - beta[bp] * re->pres[bp]) * (Vol[b] - Vol[a]) / gmx::c_presfac;
         if (bPrint)
         {
             fprintf(fplog, "  dpV = %10.3e  d = %10.3e\n", dpV, delta + dpV);
@@ -899,14 +899,14 @@ static void test_for_replica_exchange(FILE*                 fplog,
         /* temperatures of different states*/
         for (i = 0; i < re->nrepl; i++)
         {
-            re->beta[i] = 1.0 / (re->q[ereTEMP][i] * BOLTZ);
+            re->beta[i] = 1.0 / (re->q[ereTEMP][i] * gmx::c_boltz);
         }
     }
     else
     {
         for (i = 0; i < re->nrepl; i++)
         {
-            re->beta[i] = 1.0 / (re->temp * BOLTZ); /* we have a single temperature */
+            re->beta[i] = 1.0 / (re->temp * gmx::c_boltz); /* we have a single temperature */
         }
     }
     if (re->type == ereLAMBDA || re->type == ereTL)
index cd008e3b9de0a9c5dc41892729b13cd850fb200a..dfd8df643c78625686a9ee7b51f0e3f49402cfa3 100644 (file)
@@ -54,6 +54,7 @@
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/math/functions.h"
 #include "gromacs/math/units.h"
+#include "gromacs/math/utilities.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/math/vecdump.h"
 #include "gromacs/mdlib/constr.h"
@@ -454,7 +455,7 @@ gmx_shellfc_t* init_shell_flexcon(FILE*             fplog,
                                               aS + 1,
                                               mb + 1);
                                 }
-                                shell[nsi].k += gmx::square(qS) * ONE_4PI_EPS0
+                                shell[nsi].k += gmx::square(qS) * gmx::c_one4PiEps0
                                                 / ffparams->iparams[type].polarize.alpha;
                                 break;
                             case F_WATER_POL:
@@ -472,7 +473,7 @@ gmx_shellfc_t* init_shell_flexcon(FILE*             fplog,
                                          + ffparams->iparams[type].wpol.al_y
                                          + ffparams->iparams[type].wpol.al_z)
                                         / 3.0;
-                                shell[nsi].k += gmx::square(qS) * ONE_4PI_EPS0 / alpha;
+                                shell[nsi].k += gmx::square(qS) * gmx::c_one4PiEps0 / alpha;
                                 break;
                             default: gmx_fatal(FARGS, "Death Horror: %s, %d", __FILE__, __LINE__);
                         }
index 2eda48878568839abae065cc5b7b95c190837871..debaef5c311ccf7fef0b26855ead11a1dcccf1f6 100644 (file)
@@ -277,7 +277,7 @@ void LegacySimulator::do_tpi()
         }
         fprintf(fplog, "\n  The temperature for test particle insertion is %.3f K\n\n", temp);
     }
-    beta = 1.0 / (BOLTZ * temp);
+    beta = 1.0 / (gmx::c_boltz * temp);
 
     /* Number of insertions per frame */
     nsteps = inputrec->nsteps;
index 12dcf874d3f976913149edf461766bd8eb2ca813..177dc8813b0f883a2ecd2d98cc24e349da3eaee9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -141,7 +141,7 @@ void gmx::MimicCommunicator::sendInitData(gmx_mtop_t* mtop, PaddedHostVector<gmx
                 bonds.push_back(offset + at1 + 1);
                 bonds.push_back(offset + at2 + 1);
                 bondLengths.push_back(static_cast<double>(mtop->ffparams.iparams[contype].constr.dA)
-                                      / BOHR2NM);
+                                      / gmx::c_bohr2Nm);
             }
 
             for (int ncon = 0; ncon < nsettle; ++ncon)
@@ -165,11 +165,11 @@ void gmx::MimicCommunicator::sendInitData(gmx_mtop_t* mtop, PaddedHostVector<gmx
                 bonds.push_back(offset + h1 + 1);
                 bonds.push_back(offset + h2 + 1);
                 bondLengths.push_back(static_cast<double>(mtop->ffparams.iparams[contype].constr.dA)
-                                      / BOHR2NM);
+                                      / gmx::c_bohr2Nm);
                 bondLengths.push_back(static_cast<double>(mtop->ffparams.iparams[contype].constr.dA)
-                                      / BOHR2NM);
+                                      / gmx::c_bohr2Nm);
                 bondLengths.push_back(static_cast<double>(mtop->ffparams.iparams[contype].constr.dB)
-                                      / BOHR2NM);
+                                      / gmx::c_bohr2Nm);
             }
 
             nAtomsMol.push_back(type->atoms.nr);
@@ -234,9 +234,9 @@ void gmx::MimicCommunicator::sendInitData(gmx_mtop_t* mtop, PaddedHostVector<gmx
     std::vector<double> convertedCoords;
     for (auto& coord : coords)
     {
-        convertedCoords.push_back(static_cast<double>(coord[0]) / BOHR2NM);
-        convertedCoords.push_back(static_cast<double>(coord[1]) / BOHR2NM);
-        convertedCoords.push_back(static_cast<double>(coord[2]) / BOHR2NM);
+        convertedCoords.push_back(static_cast<double>(coord[0]) / gmx::c_bohr2Nm);
+        convertedCoords.push_back(static_cast<double>(coord[1]) / gmx::c_bohr2Nm);
+        convertedCoords.push_back(static_cast<double>(coord[2]) / gmx::c_bohr2Nm);
     }
 
     // sending array of coordinates
@@ -256,15 +256,15 @@ void gmx::MimicCommunicator::getCoords(PaddedHostVector<RVec>* x, const int nato
     MCL_receive(&*coords.begin(), 3 * natoms, TYPE_DOUBLE, 0);
     for (int j = 0; j < natoms; ++j)
     {
-        (*x)[j][0] = static_cast<real>(coords[j * 3] * BOHR2NM);
-        (*x)[j][1] = static_cast<real>(coords[j * 3 + 1] * BOHR2NM);
-        (*x)[j][2] = static_cast<real>(coords[j * 3 + 2] * BOHR2NM);
+        (*x)[j][0] = static_cast<real>(coords[j * 3] * gmx::c_bohr2Nm);
+        (*x)[j][1] = static_cast<real>(coords[j * 3 + 1] * gmx::c_bohr2Nm);
+        (*x)[j][2] = static_cast<real>(coords[j * 3 + 2] * gmx::c_bohr2Nm);
     }
 }
 
 void gmx::MimicCommunicator::sendEnergies(real energy)
 {
-    double convertedEnergy = energy / (HARTREE2KJ * AVOGADRO);
+    double convertedEnergy = energy / (gmx::c_hartree2Kj * gmx::c_avogadro);
     MCL_send(&convertedEnergy, 1, TYPE_DOUBLE, 0);
 }
 
@@ -273,9 +273,9 @@ void gmx::MimicCommunicator::sendForces(gmx::ArrayRef<gmx::RVec> forces, int nat
     std::vector<double> convertedForce;
     for (int j = 0; j < natoms; ++j)
     {
-        convertedForce.push_back(static_cast<real>(forces[j][0]) / HARTREE_BOHR2MD);
-        convertedForce.push_back(static_cast<real>(forces[j][1]) / HARTREE_BOHR2MD);
-        convertedForce.push_back(static_cast<real>(forces[j][2]) / HARTREE_BOHR2MD);
+        convertedForce.push_back(static_cast<real>(forces[j][0]) / gmx::c_hartreeBohr2Md);
+        convertedForce.push_back(static_cast<real>(forces[j][1]) / gmx::c_hartreeBohr2Md);
+        convertedForce.push_back(static_cast<real>(forces[j][2]) / gmx::c_hartreeBohr2Md);
     }
     MCL_send(&*convertedForce.begin(), convertedForce.size(), TYPE_DOUBLE, 0);
 }
index 81085d0cda1797465e6f61fc4eaea0355da9eb33..9b35825a6041451f1902f486d3ae8383ab85c6ac 100644 (file)
@@ -219,7 +219,7 @@ real ParrinelloRahmanBarostat::conservedEnergyContribution() const
     {
         for (int j = 0; j <= i; j++)
         {
-            real invMass = PRESFAC * (4 * M_PI * M_PI * inputrec_->compress[i][j])
+            real invMass = c_presfac * (4 * M_PI * M_PI * inputrec_->compress[i][j])
                            / (3 * inputrec_->tau_p * inputrec_->tau_p * maxBoxLength);
             if (invMass > 0)
             {
@@ -235,7 +235,7 @@ real ParrinelloRahmanBarostat::conservedEnergyContribution() const
      * track of unwrapped box diagonal elements. This case is
      * excluded in integratorHasConservedEnergyQuantity().
      */
-    energy += volume * trace(inputrec_->ref_p) / (DIM * PRESFAC);
+    energy += volume * trace(inputrec_->ref_p) / (DIM * c_presfac);
 
     return energy;
 }
index 95158d50342b871022510b5d8f31b07fa3c7a052..402b13a954b1361c83e5d818c57c74a380a6adf3 100644 (file)
@@ -138,7 +138,7 @@ public:
         }
 
         const real referenceKineticEnergy =
-                0.5 * temperatureCouplingData.referenceTemperature[temperatureGroup] * BOLTZ
+                0.5 * temperatureCouplingData.referenceTemperature[temperatureGroup] * gmx::c_boltz
                 * temperatureCouplingData.numDegreesOfFreedom[temperatureGroup];
 
         const real newKineticEnergy =
index dc66f205582802137c28301a8af76674d07662ac..3e6fbb662330101a9d3797c968fb841eebf51e91 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -167,7 +167,7 @@ const char* check_box(PbcType pbcType, const matrix box)
 void matrix_convert(matrix box, const rvec vec, const rvec angleInDegrees)
 {
     rvec angle;
-    svmul(DEG2RAD, angleInDegrees, angle);
+    svmul(gmx::c_deg2Rad, angleInDegrees, angle);
     box[XX][XX] = vec[XX];
     box[YY][XX] = vec[YY] * cos(angle[ZZ]);
     box[YY][YY] = vec[YY] * sin(angle[ZZ]);
index 41b5bbce40310cc2d5b3273eb6d788eaab8797ee..b0da21552c140cb42325a6e3cd2f253f089bafa7 100644 (file)
@@ -59,6 +59,7 @@
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/math/functions.h"
 #include "gromacs/math/units.h"
+#include "gromacs/math/utilities.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/math/vectypes.h"
 #include "gromacs/mdlib/gmx_omp_nthreads.h"
@@ -153,7 +154,7 @@ double pull_conversion_factor_userinput2internal(const t_pull_coord* pcrd)
 {
     if (pull_coordinate_is_angletype(pcrd))
     {
-        return DEG2RAD;
+        return gmx::c_deg2Rad;
     }
     else
     {
@@ -165,7 +166,7 @@ double pull_conversion_factor_internal2userinput(const t_pull_coord* pcrd)
 {
     if (pull_coordinate_is_angletype(pcrd))
     {
-        return RAD2DEG;
+        return gmx::c_rad2Deg;
     }
     else
     {
index 7bf73880fb52ed090b2418a05f552d5131846532..a5d23a9c480f670b13cba002f05edfe06998ac0b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2009,2010,2011,2012,2013 by the GROMACS development team.
  * Copyright (c) 2014,2015,2016,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -48,6 +48,7 @@
 #include <string>
 
 #include "gromacs/math/units.h"
+#include "gromacs/math/utilities.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/exceptions.h"
index bbcffa350e27b1477ce0331fad06e408e3bd5afd..3dd91a6ab5804c6c9259bd58fe87e4493548cd73 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2009,2010,2011,2012,2013 by the GROMACS development team.
  * Copyright (c) 2014,2015,2016,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -397,12 +397,12 @@ static void init_insolidangle(const gmx_mtop_t* /* top */,
         GMX_THROW(gmx::InvalidInputError("Angle cutoff should be > 0"));
     }
 
-    surf->angcut *= DEG2RAD;
+    surf->angcut *= gmx::c_deg2Rad;
 
     surf->distccut      = -std::cos(surf->angcut);
     surf->targetbinsize = surf->angcut / 2;
     surf->ntbins        = static_cast<int>(M_PI / surf->targetbinsize);
-    surf->tbinsize      = (180.0 / surf->ntbins) * DEG2RAD;
+    surf->tbinsize      = (180.0 / surf->ntbins) * gmx::c_deg2Rad;
 
     snew(surf->tbin, static_cast<int>(M_PI / surf->tbinsize) + 1);
     surf->maxbins = 0;
index 1006e07f1c544054fb525eb3f84cbd9755394dce..1059028d73c845c250a9f577b1d66ff77b8bde0c 100644 (file)
@@ -1420,10 +1420,10 @@ bondedtable_t make_bonded_table(FILE* fplog, const char* fn, int angle)
         /* Convert the table from degrees to radians */
         for (i = 0; i < td.nx; i++)
         {
-            td.x[i] *= DEG2RAD;
-            td.f[i] *= RAD2DEG;
+            td.x[i] *= gmx::c_deg2Rad;
+            td.f[i] *= gmx::c_rad2Deg;
         }
-        td.tabscale *= RAD2DEG;
+        td.tabscale *= gmx::c_rad2Deg;
     }
     tab.n     = td.nx;
     tab.scale = td.tabscale;
index 856fcee29204b0cd1b51ec2735af20c8f40f8869..d44370c0c608ba43eee1029c70fa92ca1b849fcc 100644 (file)
@@ -494,8 +494,8 @@ static void chk_tps(const char* fn, real vdw_fac, real bon_lo, real bon_hi)
                 ekin += 0.5 * atoms->atom[i].m * v[i][j] * v[i][j];
             }
         }
-        temp1 = (2.0 * ekin) / (natom * DIM * BOLTZ);
-        temp2 = (2.0 * ekin) / (natom * (DIM - 1) * BOLTZ);
+        temp1 = (2.0 * ekin) / (natom * DIM * gmx::c_boltz);
+        temp2 = (2.0 * ekin) / (natom * (DIM - 1) * gmx::c_boltz);
         fprintf(stderr, "Kinetic energy: %g (kJ/mol)\n", ekin);
         fprintf(stderr,
                 "Assuming the number of degrees of freedom to be "
index 51bebada584123d3a37141a8e570af3476dd3c9c..15ce914844092ece10d6960e3b0d54562b4971c9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2010,2011,2012,2013,2014 by the GROMACS development team.
  * Copyright (c) 2015,2016,2017,2018,2019 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -182,7 +182,7 @@ static real estimate_direct(t_inputinfo* info)
     e_dir = 2.0 * info->q2all * gmx::invsqrt(info->q2allnr * r_coulomb * info->volume);
     e_dir *= std::exp(-beta * beta * r_coulomb * r_coulomb);
 
-    return ONE_4PI_EPS0 * e_dir;
+    return gmx::c_one4PiEps0 * e_dir;
 }
 
 #define SUMORDER 6
@@ -776,7 +776,7 @@ static real estimate_reciprocal(t_inputinfo* info,
     e_rec = std::sqrt(e_rec1 + e_rec2 + e_rec3);
 
 
-    return ONE_4PI_EPS0 * e_rec;
+    return gmx::c_one4PiEps0 * e_rec;
 }
 
 
index 80138696cc3585e44b40ab68f8c0545cb381ccd3..53e101083117395d5af336c5a540a2430d8c65f3 100644 (file)
@@ -809,7 +809,7 @@ void Angle::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, TrajectoryA
                     break;
                 default: GMX_THROW(InternalError("invalid -g1 value"));
             }
-            dh.setPoint(n, angle * RAD2DEG, bPresent);
+            dh.setPoint(n, angle * gmx::c_rad2Deg, bPresent);
         }
     }
     dh.finishFrame();
index f67303c92f896f29d0e5b3655a6f0995728ac665..e9f7cbd82756f3a7b5154840c65e6317d0ca2d7c 100644 (file)
@@ -388,7 +388,7 @@ void FreeVolume::writeOutput()
     printf("Total volume %.2f +/- %.2f nm^3\n", Vaver, Verror);
 
     printf("Number of molecules %d total mass %.2f Dalton\n", nmol_, mtot_);
-    double RhoAver  = mtot_ / (Vaver * 1e-24 * AVOGADRO);
+    double RhoAver  = mtot_ / (Vaver * 1e-24 * gmx::c_avogadro);
     double RhoError = gmx::square(RhoAver / Vaver) * Verror;
     printf("Average molar mass: %.2f Dalton\n", mtot_ / nmol_);
 
index 9ccc4c8f0194efef25f00b96195187c466350f2e..00466715da6e04b5b094f2422aebc7f920310dbe 100644 (file)
@@ -1076,7 +1076,7 @@ void Sasa::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, TrajectoryAn
         {
             totmass += surfaceSel.position(i).mass();
         }
-        const real density = totmass * AMU / (totvolume * NANO * NANO * NANO);
+        const real density = totmass * gmx::c_amu / (totvolume * gmx::c_nano * gmx::c_nano * gmx::c_nano);
         vh.startFrame(frnr, fr.time);
         vh.setPoint(0, totvolume);
         vh.setPoint(1, density);