added Verlet scheme and NxN non-bonded functionality
[gromacs.git] / include / physics.h
blobe707f0af20d3953fdf1af3d6436666720ea714a5
1 /*
2 *
3 * This source code is part of
4 *
5 * G R O M A C S
6 *
7 * GROningen MAchine for Chemical Simulations
8 *
9 * VERSION 3.2.0
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
32 * And Hey:
33 * Gromacs Runs On Most of All Computer Systems
36 #ifndef _physics_h
37 #define _physics_h
40 * Physical constants to be used in Gromacs.
41 * No constants (apart from 0, 1 or 2) should
42 * be anywhere else in the code.
45 #include <math.h>
47 /* we do it anyway. */
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
52 #ifndef M_PI
53 #ifdef _PI
54 #define M_PI _PI
55 #else
56 #define M_PI 3.14159265358979323846
57 #endif
58 #endif
60 #define ANGSTROM (1e-10) /* Old... */
61 #define KILO (1e3) /* Thousand */
62 #define NANO (1e-9) /* A Number */
63 #define PICO (1e-12) /* A Number */
64 #define A2NM (ANGSTROM/NANO) /* NANO */
65 #define NM2A (NANO/ANGSTROM) /* 10.0 */
66 #define RAD2DEG (180.0/M_PI) /* Conversion */
67 #define DEG2RAD (M_PI/180.0) /* id */
68 #define CAL2JOULE (4.184) /* id */
69 #define E_CHARGE (1.60217733e-19) /* Coulomb */
71 #define AMU (1.6605402e-27) /* kg */
72 #define BOLTZMANN (1.380658e-23) /* (J/K) */
73 #define AVOGADRO (6.0221367e23) /* () */
74 #define RGAS (BOLTZMANN*AVOGADRO) /* (J/(mol K)) */
75 #define BOLTZ (RGAS/KILO) /* (kJ/(mol K)) */
76 #define FARADAY (E_CHARGE*AVOGADRO) /* (C/mol) */
77 #define ELECTRONVOLT (E_CHARGE*AVOGADRO/KILO) /* (kJ/mol) */
78 #define PLANCK1 (6.6262e-34) /* J s */
79 #define PLANCK (6.6262e-34*AVOGADRO/(PICO*KILO)) /* (kJ/mol) ps */
81 #define EPSILON0 (5.72765E-4) /* (e^2 / Na (kJ nm))
82 == (e^2 mol/(kJ nm)) */
84 #define SPEED_OF_LIGHT (2.9979245800E05) /* nm/ps */
85 #define ATOMICMASS_keV (940000.0) /* Atomic mass in keV */
86 #define ELECTRONMASS_keV (512.0) /* Electron mas in keV */
88 /* Improved accuracy (PL & EL, 20090421) */
89 #define FACEL (332.0636930*CAL2JOULE)/* (10 * (ONE_4PI_EPS0)) */
90 #define ONE_4PI_EPS0 (FACEL*0.1) /* 1/(4*pi*e0)*/
91 #define PRESFAC (16.6054) /* bar / pressure unity */
92 #define ENM2DEBYE 48.0321 /* Convert electron nm *
93 * to debye */
94 #define DEBYE2ENM 0.02081941
95 /* to convert from a acceleration in (e V)/(amu nm) */
96 /* FIELDFAC is also Faraday's constant and E_CHARGE/(1e6 AMU) */
97 #define FIELDFAC (FARADAY/KILO)
99 /* to convert AU to MD units: */
100 #define HARTREE2KJ 4.3597482e-21
101 #define BOHR2NM 0.0529177249
102 #define HARTREE_BOHR2MD (HARTREE2KJ*AVOGADRO/BOHR2NM)
105 /* The four basic units */
106 #define unit_length "nm"
107 #define unit_time "ps"
108 #define unit_mass "u"
109 #define unit_energy "kJ/mol"
111 /* Temperature unit, T in this unit times BOLTZ give energy in unit_energy */
112 #define unit_temp_K "K"
114 /* Charge unit, electron charge, involves ONE_4PI_EPS0 */
115 #define unit_charge_e "e"
117 /* Pressure unit, pressure in basic units times PRESFAC gives this unit */
118 #define unit_pres_bar "bar"
120 /* Dipole unit, debye, conversion from the unit_charge_e involves ENM2DEBYE */
121 #define unit_dipole_D "D"
123 /* Derived units from basic units only */
124 #define unit_vel unit_length "/" unit_time
125 #define unit_volume unit_length "^3"
126 #define unit_invtime "1/" unit_time
128 /* Other derived units */
129 #define unit_surft_bar unit_pres_bar " " unit_length
131 /* SI units, conversion from basic units involves NANO, PICO and AMU */
132 #define unit_length_SI "m"
133 #define unit_time_SI "s"
134 #define unit_mass_SI "kg"
136 #define unit_density_SI unit_mass_SI "/" unit_length_SI "^3"
137 #define unit_invvisc_SI unit_length_SI " " unit_time_SI "/" unit_mass_SI
139 /* The routines below can be used for converting units from or to GROMACS
140 internal units. */
141 enum { eg2cAngstrom, eg2cNm, eg2cBohr, eg2cKcal_Mole,
142 eg2cHartree, eg2cHartree_e, eg2cAngstrom3, eg2cCoulomb,
143 eg2cDebye, eg2cElectron, eg2cBuckingham, eg2cNR };
145 /* Convert value x to GROMACS units. Energy -> Energy, Length -> Length etc.
146 The type of x is deduced from unit,
147 which should be taken from the enum above. */
148 extern double convert2gmx(double x,int unit);
150 /* Convert value x from GROMACS units to the desired one.
151 The type of return value is deduced from unit, see above */
152 extern double gmx2convert(double x,int unit);
154 /* Convert the string to one of the units supported. Returns -1 if not found. */
155 extern int string2unit(char *string);
157 /* Convert the unit to a string. Return NULL when unit is out of range. */
158 extern const char *unit2string(int unit);
160 #ifdef __cplusplus
162 #endif
165 #endif /* _physics_h */