64e9cc93de3cdf5dd69c1d6d92fd4a17a91f9b3a
[alexxy/gromacs.git] / docs / reference-manual / periodic-boundary-conditions.rst
1 .. _pbc:
2
3 Periodic boundary conditions
4 ----------------------------
5
6 .. _fig-pbc:
7
8 .. figure:: plots/pbctric.*
9    :width: 9.00000cm
10
11    Periodic boundary conditions in two dimensions.
12
13 The classical way to minimize edge effects in a finite system is to
14 apply *periodic boundary conditions*. The atoms of the system to be
15 simulated are put into a space-filling box, which is surrounded by
16 translated copies of itself (:numref:`Fig. %s <fig-pbc>`). Thus
17 there are no boundaries of the system; the artifact caused by unwanted
18 boundaries in an isolated cluster is now replaced by the artifact of
19 periodic conditions. If the system is crystalline, such boundary
20 conditions are desired (although motions are naturally restricted to
21 periodic motions with wavelengths fitting into the box). If one wishes
22 to simulate non-periodic systems, such as liquids or solutions, the
23 periodicity by itself causes errors. The errors can be evaluated by
24 comparing various system sizes; they are expected to be less severe than
25 the errors resulting from an unnatural boundary with vacuum.
26
27 There are several possible shapes for space-filling unit cells. Some,
28 like the *rhombic dodecahedron* and the *truncated octahedron* :ref:`20 <refAdams79>` are closer to being a sphere than a cube is, and
29 are therefore better suited to the study of an approximately spherical
30 macromolecule in solution, since fewer solvent molecules are required to
31 fill the box given a minimum distance between macromolecular images. At
32 the same time, rhombic dodecahedra and truncated octahedra are special
33 cases of *triclinic* unit cells; the most general space-filling unit
34 cells that comprise all possible space-filling shapes \ :ref:`21 <refBekker95>`.
35 For this reason, |Gromacs| is based on the triclinic unit cell.
36
37 |Gromacs| uses periodic boundary conditions, combined with the 
38 *minimum image convention*: only one – the nearest – image of each particle is
39 considered for short-range non-bonded interaction terms. For long-range
40 electrostatic interactions this is not always accurate enough, and
41 |Gromacs| therefore also incorporates lattice sum methods such as Ewald
42 Sum, PME and PPPM.
43
44 |Gromacs| supports triclinic boxes of any shape. The simulation box (unit
45 cell) is defined by the 3 box vectors :math:`{\bf a}`,\ :math:`{\bf b}`
46 and :math:`{\bf c}`. The box vectors must satisfy the following
47 conditions:
48
49 .. math:: a_y = a_z = b_z = 0
50           :label: eqnboxrot
51
52 .. math:: a_x>0,~~~~b_y>0,~~~~c_z>0
53           :label: eqnboxshift
54
55 .. math:: |b_x| \leq \frac{1}{2} \, a_x,~~~~
56           |c_x| \leq \frac{1}{2} \, a_x,~~~~
57           |c_y| \leq \frac{1}{2} \, b_y
58           :label: eqnboxshift2
59
60 Equations :eq:`%s <eqnboxrot>` can always be satisfied by
61 rotating the box. Inequalities (:eq:`%s <eqnboxshift>`) and
62 (:eq:`%s <eqnboxshift2>`) can always be satisfied by adding
63 and subtracting box vectors.
64
65 Even when simulating using a triclinic box, |Gromacs| always keeps the
66 particles in a brick-shaped volume for efficiency, as illustrated in
67 :numref:`Fig. %s <fig-pbc>` for a 2-dimensional system. Therefore,
68 from the output trajectory it might seem that the simulation was done in
69 a rectangular box. The program :ref:`trjconv <gmx trjconv>` can be used to
70 convert the trajectory to a different unit-cell representation.
71
72 It is also possible to simulate without periodic boundary conditions,
73 but it is usually more efficient to simulate an isolated cluster of
74 molecules in a large periodic box, since fast grid searching can only be
75 used in a periodic system.
76
77 .. _fig-boxshapes:
78
79 .. figure:: plots/rhododec.*
80         :width: 5.00000cm
81
82         A rhombic dodecahedron (arbitrary orientation).
83
84
85 .. figure:: plots/truncoct.*
86         :width: 5.00000cm
87
88         A truncated octahedron (arbitrary orientation).
89
90 Some useful box types
91 ~~~~~~~~~~~~~~~~~~~~~
92
93 .. |mathd| replace:: :math:`d`
94 .. |mathd3| replace:: :math:`d^{3}`
95 .. |mathd23| replace:: :math:`\frac{1}{2}\sqrt{2}~d^{3}`
96 .. |mathd70| replace:: :math:`0.707~d^{3}`
97 .. |mathd43| replace:: :math:`\frac{4}{9}\sqrt{3}~d^{3}`
98 .. |mathd77| replace:: :math:`0.770~d^{3}`
99 .. |math12d| replace:: :math:`\frac{1}{2}~d`
100 .. |math13d| replace:: :math:`\frac{1}{3}~d`
101 .. |math13dn| replace:: :math:`-\frac{1}{3}~d`
102 .. |math12s2| replace:: :math:`\frac{1}{2}\sqrt{2}~d`
103 .. |math12s3| replace:: :math:`\frac{1}{2}\sqrt{3}~d`
104 .. |math16s3| replace:: :math:`\frac{1}{6}\sqrt{3}~d`
105 .. |math13s6| replace:: :math:`\frac{1}{3}\sqrt{6}~d`
106 .. |math23s2| replace:: :math:`\frac{2}{3}\sqrt{2}~d`
107 .. |math13s2| replace:: :math:`\frac{1}{3}\sqrt{2}~d`
108 .. |angbc| replace:: :math:`\angle` **bc** 
109 .. |angac| replace:: :math:`\angle` **ac** 
110 .. |angab| replace:: :math:`\angle` **ab** 
111 .. |90deg| replace:: :math:`90^\circ`
112 .. |60deg| replace:: :math:`60^\circ`
113 .. |71deg| replace:: :math:`71.53^\circ`
114 .. |109deg| replace:: :math:`109.47^\circ`
115
116 .. _table-boxtypes:
117
118 .. table:: Overview over different box types
119     :align: center
120     :widths: auto
121
122     +-------------+-----------+-----------+-----------------------------------+------------------------------+
123     | box type    | image     | box       | box vectors                       | box vector angles            | 
124     |             |           |           +---------+------------+------------+---------+----------+---------+
125     |             | distance  | volume    | **a**   | **b**      | **c**      | |angbc| | |angac|  | |angab| |
126     +=============+===========+===========+=========+============+============+=========+==========+=========+
127     |             |           |           | |mathd| |   0        |   0        |         |          |         |
128     |             |           |           +---------+------------+------------+         |          |         |
129     | cubic       | |mathd|   | |mathd3|  |   0     | |mathd|    |   0        | |90deg| | |90deg|  | |90deg| |
130     |             |           |           +---------+------------+------------+         |          |         |
131     |             |           |           |   0     |   0        | |mathd|    |         |          |         |
132     +-------------+-----------+-----------+---------+------------+------------+---------+----------+---------+
133     | rhombic     |           | |mathd23| | |mathd| | 0          | |math12d|  |         |          |         |
134     |             |           |           +---------+------------+------------+         |          |         |
135     | dodcahdron  | |mathd|   | |mathd70| | 0       | |mathd|    | |math12d|  | |60deg| | |60deg|  | |60deg| |
136     |             |           |           +---------+------------+------------+         |          |         |
137     | (xy-square) |           |           | 0       | 0          | |math12s2| |         |          |         |
138     +-------------+-----------+-----------+---------+------------+------------+---------+----------+---------+
139     | rhombic     |           | |mathd23| | |mathd| | |math12d|  | |math12d|  |         |          |         |
140     |             |           |           +---------+------------+------------+         |          |         |
141     | dodcahdron  | |mathd|   | |mathd70| | 0       | |math12s3| | |math16s3| | |60deg| | |60deg|  | |60deg| |
142     |             |           |           +---------+------------+------------+         |          |         |
143     | (xy-        |           |           | 0       | 0          | |math13s6| |         |          |         |
144     | hexagon)    |           |           |         |            |            |         |          |         |
145     +-------------+-----------+-----------+---------+------------+------------+---------+----------+---------+
146     | truncated   |           | |mathd43| | |mathd| | |math13d|  | |math13dn| |         |          |         |
147     |             |           |           +---------+------------+------------+         |          |         |
148     | octahedron  | |mathd|   | |mathd77| | 0       | |math23s2| | |math13s2| | |71deg| | |109deg| | |71deg| |
149     |             |           |           +---------+------------+------------+         |          |         |
150     |             |           |           | 0       | 0          | |math13s6| |         |          |         |
151     +-------------+-----------+-----------+---------+------------+------------+---------+----------+---------+
152
153 The three most useful box types for simulations of solvated systems are
154 described in :numref:`Table %s <table-boxtypes>`. The rhombic
155 dodecahedron (:numref:`Fig. %s <fig-boxshapes>`) is the smallest and
156 most regular space-filling unit cell. Each of the 12 image cells is at
157 the same distance. The volume is 71% of the volume of a cube having the
158 same image distance. This saves about 29% of CPU-time when simulating a
159 spherical or flexible molecule in solvent. There are two different
160 orientations of a rhombic dodecahedron that satisfy equations
161 :eq:`%s <eqnboxrot>`, :eq:`%s <eqnboxshift>` and
162 :eq:`%s <eqnboxshift2>`. The program :ref:`editconf <gmx editconf>`
163 produces the orientation which has a square intersection with the
164 xy-plane. This orientation was chosen because the first two box vectors
165 coincide with the x and y-axis, which is easier to comprehend. The other
166 orientation can be useful for simulations of membrane proteins. In this
167 case the cross-section with the xy-plane is a hexagon, which has an area
168 which is 14% smaller than the area of a square with the same image
169 distance. The height of the box (:math:`c_z`) should be changed to
170 obtain an optimal spacing. This box shape not only saves CPU time, it
171 also results in a more uniform arrangement of the proteins.
172
173 Cut-off restrictions
174 ~~~~~~~~~~~~~~~~~~~~
175
176 The minimum image convention implies that the cut-off radius used to
177 truncate non-bonded interactions may not exceed half the shortest box
178 vector:
179
180 .. math:: R_c < {\frac{1}{2}}\min(\|{\bf a}\|,\|{\bf b}\|,\|{\bf c}\|),
181           :label: eqnphysicalrc
182
183 because otherwise more than one image would be within the cut-off
184 distance of the force. When a macromolecule, such as a protein, is
185 studied in solution, this restriction alone is not sufficient: in
186 principle, a single solvent molecule should not be able to ‘see’ both
187 sides of the macromolecule. This means that the length of each box
188 vector must exceed the length of the macromolecule in the direction of
189 that edge *plus* two times the cut-off radius :math:`R_c`. It is,
190 however, common to compromise in this respect, and make the solvent
191 layer somewhat smaller in order to reduce the computational cost. For
192 efficiency reasons the cut-off with triclinic boxes is more restricted.
193 For grid search the extra restriction is weak:
194
195 .. math:: R_c < \min(a_x,b_y,c_z)
196          :label: eqngridrc
197    
198
199 For simple search the extra restriction is stronger:
200
201 .. math:: R_c < {\frac{1}{2}}\min(a_x,b_y,c_z)
202           :label: eqnsimplerc
203
204 Each unit cell (cubic, rectangular or triclinic) is surrounded by 26
205 translated images. A particular image can therefore always be identified
206 by an index pointing to one of 27 *translation vectors* and constructed
207 by applying a translation with the indexed vector (see :ref:`forces`).
208 Restriction :eq:`%s <eqngridrc>` ensures that only 26 images need to be
209 considered.