e72608c8b5bf6135d11c51d5e328bda8cd93c4a0
[alexxy/gromacs.git] / include / physics.h
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.
14
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.
19  * 
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.
26  * 
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.
29  * 
30  * For more info, check our website at http://www.gromacs.org
31  * 
32  * And Hey:
33  * Gromacs Runs On Most of All Computer Systems
34  */
35
36 #ifndef _physics_h
37 #define _physics_h
38
39 /*
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.
43  */
44
45 #include <math.h>
46
47 /* we do it anyway. */
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 #ifndef M_PI
53 #ifdef _PI
54 #define M_PI _PI
55 #else
56 #define M_PI        3.14159265358979323846
57 #endif
58 #endif
59
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      */
70
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 */
80
81 #define EPSILON0         (5.72765E-4)           /* (e^2 / Na (kJ nm))     
82                                                    == (e^2 mol/(kJ nm)) */
83                                                 
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  */
87
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)
98
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)
103
104
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"
110
111 /* Temperature unit, T in this unit times BOLTZ give energy in unit_energy */
112 #define unit_temp_K   "K"
113
114 /* Charge unit, electron charge, involves ONE_4PI_EPS0 */
115 #define unit_charge_e "e"
116
117 /* Pressure unit, pressure in basic units times PRESFAC gives this unit */
118 #define unit_pres_bar "bar"
119
120 /* Dipole unit, debye, conversion from the unit_charge_e involves ENM2DEBYE */
121 #define unit_dipole_D "D"
122
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
127
128 /* Other derived units */
129 #define unit_surft_bar unit_pres_bar " " unit_length
130
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"
135
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
138
139 #ifdef __cplusplus
140 }
141 #endif
142
143
144 #endif  /* _physics_h */
145
146