git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@16053 f3b2605a-c512-4ea7-a41b...
[lammps.git] / doc / src / kspace_style.txt
blob492d1d88e7436eb21f6fc0cc5142ca677cd77733
1 "LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c
3 :link(lws,http://lammps.sandia.gov)
4 :link(ld,Manual.html)
5 :link(lc,Section_commands.html#comm)
7 :line
9 kspace_style command :h3
11 [Syntax:]
13 kspace_style style value :pre
15 style = {none} or {ewald} or {ewald/disp} or {ewald/omp} or {pppm} or {pppm/cg} or {pppm/disp} or {pppm/tip4p} or {pppm/stagger} or {pppm/disp/tip4p} or {pppm/gpu} or {pppm/kk} or {pppm/omp} or {pppm/cg/omp} or {pppm/tip4p/omp} or {msm} or {msm/cg} or {msm/omp} or {msm/cg/omp} :ulb,l
16   {none} value = none
17   {ewald} value = accuracy
18     accuracy = desired relative error in forces
19   {ewald/disp} value = accuracy
20     accuracy = desired relative error in forces
21   {ewald/omp} value = accuracy
22     accuracy = desired relative error in forces
23   {pppm} value = accuracy
24     accuracy = desired relative error in forces
25   {pppm/cg} value = accuracy (smallq)
26     accuracy = desired relative error in forces
27     smallq = cutoff for charges to be considered (optional) (charge units)
28   {pppm/disp} value = accuracy
29     accuracy = desired relative error in forces
30   {pppm/tip4p} value = accuracy
31     accuracy = desired relative error in forces
32   {pppm/disp/tip4p} value = accuracy
33     accuracy = desired relative error in forces
34   {pppm/gpu} value = accuracy
35     accuracy = desired relative error in forces
36   {pppm/kk} value = accuracy
37     accuracy = desired relative error in forces
38   {pppm/omp} value = accuracy
39     accuracy = desired relative error in forces
40   {pppm/cg/omp} value = accuracy
41     accuracy = desired relative error in forces
42   {pppm/tip4p/omp} value = accuracy
43     accuracy = desired relative error in forces
44   {pppm/stagger} value = accuracy
45     accuracy = desired relative error in forces
46   {msm} value = accuracy
47     accuracy = desired relative error in forces
48   {msm/cg} value = accuracy (smallq)
49     accuracy = desired relative error in forces
50     smallq = cutoff for charges to be considered (optional) (charge units)
51   {msm/omp} value = accuracy
52     accuracy = desired relative error in forces
53   {msm/cg/omp} value = accuracy (smallq)
54     accuracy = desired relative error in forces
55     smallq = cutoff for charges to be considered (optional) (charge units) :pre
56 :ule
58 [Examples:]
60 kspace_style pppm 1.0e-4
61 kspace_style pppm/cg 1.0e-5 1.0e-6
62 kspace style msm 1.0e-4
63 kspace_style none :pre
65 [Description:]
67 Define a long-range solver for LAMMPS to use each timestep to compute
68 long-range Coulombic interactions or long-range 1/r^6 interactions.
69 Most of the long-range solvers perform their computation in K-space,
70 hence the name of this command.
72 When such a solver is used in conjunction with an appropriate pair
73 style, the cutoff for Coulombic or 1/r^N interactions is effectively
74 infinite.  If the Coulombic case, this means each charge in the system
75 interacts with charges in an infinite array of periodic images of the
76 simulation domain.
78 Note that using a long-range solver requires use of a matching "pair
79 style"_pair_style.html to perform consistent short-range pairwise
80 calculations.  This means that the name of the pair style contains a
81 matching keyword to the name of the KSpace style, as in this table:
83 Pair style : KSpace style
84 coul/long : ewald or pppm
85 coul/msm : msm
86 lj/long or buck/long : disp (for dispersion)
87 tip4p/long : tip4p :tb(s=:,ea=c)
89 :line
91 The {ewald} style performs a standard Ewald summation as described in
92 any solid-state physics text.
94 The {ewald/disp} style adds a long-range dispersion sum option for
95 1/r^6 potentials and is useful for simulation of interfaces
96 "(Veld)"_#Veld.  It also performs standard Coulombic Ewald summations,
97 but in a more efficient manner than the {ewald} style.  The 1/r^6
98 capability means that Lennard-Jones or Buckingham potentials can be
99 used without a cutoff, i.e. they become full long-range potentials.
100 The {ewald/disp} style can also be used with point-dipoles
101 "(Toukmaji)"_#Toukmaji and is currently the only kspace solver in
102 LAMMPS with this capability.
104 :line
106 The {pppm} style invokes a particle-particle particle-mesh solver
107 "(Hockney)"_#Hockney which maps atom charge to a 3d mesh, uses 3d FFTs
108 to solve Poisson's equation on the mesh, then interpolates electric
109 fields on the mesh points back to the atoms.  It is closely related to
110 the particle-mesh Ewald technique (PME) "(Darden)"_#Darden used in
111 AMBER and CHARMM.  The cost of traditional Ewald summation scales as
112 N^(3/2) where N is the number of atoms in the system.  The PPPM solver
113 scales as Nlog(N) due to the FFTs, so it is almost always a faster
114 choice "(Pollock)"_#Pollock.
116 The {pppm/cg} style is identical to the {pppm} style except that it
117 has an optimization for systems where most particles are uncharged.
118 Similarly the {msm/cg} style implements the same optimization for {msm}.
119 The optional {smallq} argument defines the cutoff for the absolute
120 charge value which determines whether a particle is considered charged
121 or not.  Its default value is 1.0e-5.
123 The {pppm/tip4p} style is identical to the {pppm} style except that it
124 adds a charge at the massless 4th site in each TIP4P water molecule.
125 It should be used with "pair styles"_pair_style.html with a
126 {tip4p/long} in their style name.
128 The {pppm/stagger} style performs calculations using two different
129 meshes, one shifted slightly with respect to the other.  This can
130 reduce force aliasing errors and increase the accuracy of the method
131 for a given mesh size.  Or a coarser mesh can be used for the same
132 target accuracy, which saves CPU time.  However, there is a trade-off
133 since FFTs on two meshes are now performed which increases the
134 compuation required.  See "(Cerutti)"_#Cerutti, "(Neelov)"_#Neelov,
135 and "(Hockney)"_#Hockney for details of the method.
137 For high relative accuracy, using staggered PPPM allows the mesh size
138 to be reduced by a factor of 2 in each dimension as compared to
139 regular PPPM (for the same target accuracy).  This can give up to a 4x
140 speedup in the KSpace time (8x less mesh points, 2x more expensive).
141 However, for low relative accuracy, the staggered PPPM mesh size may
142 be essentially the same as for regular PPPM, which means the method
143 will be up to 2x slower in the KSpace time (simply 2x more expensive).
144 For more details and timings, see
145 "Section 5"_Section_accelerate.html.
147 NOTE: Using {pppm/stagger} may not give the same increase in the
148 accuracy of energy and pressure as it does in forces, so some caution
149 must be used if energy and/or pressure are quantities of interest,
150 such as when using a barostat.
152 :line
154 The {pppm/disp} and {pppm/disp/tip4p} styles add a mesh-based long-range
155 dispersion sum option for 1/r^6 potentials "(Isele-Holder)"_#Isele-Holder,
156 similar to the {ewald/disp} style. The 1/r^6 capability means
157 that Lennard-Jones or Buckingham potentials can be used without a cutoff,
158 i.e. they become full long-range potentials.
160 For these styles, you will possibly want to adjust the default choice of
161 parameters by using the "kspace_modify"_kspace_modify.html command.
162 This can be done by either choosing the Ewald and grid parameters, or
163 by specifying separate accuracies for the real and kspace
164 calculations. When not making any settings, the simulation will stop with
165 an error message. Further information on the influence of the parameters
166 and how to choose them is described in "(Isele-Holder)"_#Isele-Holder,
167 "(Isele-Holder2)"_#Isele-Holder2 and the
168 "How-To"_Section_howto.html#howto_24 discussion.
170 :line
172 NOTE: All of the PPPM styles can be used with single-precision FFTs by
173 using the compiler switch -DFFT_SINGLE for the FFT_INC setting in your
174 lo-level Makefile.  This setting also changes some of the PPPM
175 operations (e.g. mapping charge to mesh and interpolating electric
176 fields to particles) to be performed in single precision.  This option
177 can speed-up long-range calulations, particularly in parallel or on
178 GPUs.  The use of the -DFFT_SINGLE flag is discussed in "this
179 section"_Section_start.html#start_2_4 of the manual. MSM does not
180 currently support the -DFFT_SINGLE compiler switch.
182 :line
184 The {msm} style invokes a multi-level summation method MSM solver,
185 "(Hardy)"_#Hardy or "(Hardy2)"_#Hardy2, which maps atom charge to a 3d
186 mesh, and uses a multi-level hierarchy of coarser and coarser meshes
187 on which direct coulomb solves are done.  This method does not use
188 FFTs and scales as N. It may therefore be faster than the other
189 K-space solvers for relatively large problems when running on large
190 core counts. MSM can also be used for non-periodic boundary conditions and
191 for mixed periodic and non-periodic boundaries.
193 MSM is most competitive versus Ewald and PPPM when only relatively
194 low accuracy forces, about 1e-4 relative error or less accurate,
195 are needed. Note that use of a larger coulomb cutoff (i.e. 15
196 angstroms instead of 10 angstroms) provides better MSM accuracy for
197 both the real space and grid computed forces.
199 Currently calculation of the full pressure tensor in MSM is expensive.
200 Using the "kspace_modify"_kspace_modify.html {pressure/scalar yes}
201 command provides a less expensive way to compute the scalar pressure
202 (Pxx + Pyy + Pzz)/3.0. The scalar pressure can be used, for example,
203 to run an isotropic barostat. If the full pressure tensor is needed,
204 then calculating the pressure at every timestep or using a fixed
205 pressure simulation with MSM will cause the code to run slower.
207 :line
209 The specified {accuracy} determines the relative RMS error in per-atom
210 forces calculated by the long-range solver.  It is set as a
211 dimensionless number, relative to the force that two unit point
212 charges (e.g. 2 monovalent ions) exert on each other at a distance of
213 1 Angstrom.  This reference value was chosen as representative of the
214 magnitude of electrostatic forces in atomic systems.  Thus an accuracy
215 value of 1.0e-4 means that the RMS error will be a factor of 10000
216 smaller than the reference force.
218 The accuracy setting is used in conjunction with the pairwise cutoff
219 to determine the number of K-space vectors for style {ewald} or the
220 grid size for style {pppm} or {msm}.
222 Note that style {pppm} only computes the grid size at the beginning of
223 a simulation, so if the length or triclinic tilt of the simulation
224 cell increases dramatically during the course of the simulation, the
225 accuracy of the simulation may degrade.  Likewise, if the
226 "kspace_modify slab"_kspace_modify.html option is used with
227 shrink-wrap boundaries in the z-dimension, and the box size changes
228 dramatically in z.  For example, for a triclinic system with all three
229 tilt factors set to the maximum limit, the PPPM grid should be
230 increased roughly by a factor of 1.5 in the y direction and 2.0 in the
231 z direction as compared to the same system using a cubic orthogonal
232 simulation cell.  One way to handle this issue if you have a long
233 simulation where the box size changes dramatically, is to break it
234 into shorter simulations (multiple "run"_run.html commands).  This
235 works because the grid size is re-computed at the beginning of each
236 run.  Another way to ensure the descired accuracy requirement is met
237 is to run a short simulation at the maximum expected tilt or length,
238 note the required grid size, and then use the
239 "kspace_modify"_kspace_modify.html {mesh} command to manually set the
240 PPPM grid size to this value for the long run.  The simulation then
241 will be "too accurate" for some portion of the run.
243 RMS force errors in real space for {ewald} and {pppm} are estimated
244 using equation 18 of "(Kolafa)"_#Kolafa, which is also referenced as
245 equation 9 of "(Petersen)"_#Petersen. RMS force errors in K-space for
246 {ewald} are estimated using equation 11 of "(Petersen)"_#Petersen,
247 which is similar to equation 32 of "(Kolafa)"_#Kolafa. RMS force
248 errors in K-space for {pppm} are estimated using equation 38 of
249 "(Deserno)"_#Deserno. RMS force errors for {msm} are estimated
250 using ideas from chapter 3 of "(Hardy)"_#Hardy, with equation 3.197
251 of particular note. When using {msm} with non-periodic boundary
252 conditions, it is expected that the error estimation will be too
253 pessimistic. RMS force errors for dipoles when using {ewald/disp}
254 are estimated using equations 33 and 46 of "(Wang)"_#Wang.
256 See the "kspace_modify"_kspace_modify.html command for additional
257 options of the K-space solvers that can be set, including a {force}
258 option for setting an absoulte RMS error in forces, as opposed to a
259 relative RMS error.
261 :line
263 Styles with a {gpu}, {intel}, {kk}, {omp}, or {opt} suffix are
264 functionally the same as the corresponding style without the suffix.
265 They have been optimized to run faster, depending on your available
266 hardware, as discussed in "Section 5"_Section_accelerate.html
267 of the manual.  The accelerated styles take the same arguments and
268 should produce the same results, except for round-off and precision
269 issues.
271 More specifically, the {pppm/gpu} style performs charge assignment and
272 force interpolation calculations on the GPU.  These processes are
273 performed either in single or double precision, depending on whether
274 the -DFFT_SINGLE setting was specified in your lo-level Makefile, as
275 discussed above.  The FFTs themselves are still calculated on the CPU.
276 If {pppm/gpu} is used with a GPU-enabled pair style, part of the PPPM
277 calculation can be performed concurrently on the GPU while other
278 calculations for non-bonded and bonded force calculation are performed
279 on the CPU.
281 The {pppm/kk} style also performs charge assignment and force
282 interpolation calculations on the GPU while the FFTs themselves are
283 calculated on the CPU in non-threaded mode.
285 These accelerated styles are part of the GPU, USER-INTEL,
286 KOKKOS, USER-OMP, and OPT packages respectively.  They are only
287 enabled if LAMMPS was built with those packages.  See the "Making
288 LAMMPS"_Section_start.html#start_3 section for more info.
290 See "Section 5"_Section_accelerate.html of the manual for
291 more instructions on how to use the accelerated styles effectively.
293 :line
295 [Restrictions:]
297 Note that the long-range electrostatic solvers in LAMMPS assume conducting
298 metal (tinfoil) boundary conditions for both charge and dipole
299 interactions. Vacuum boundary conditions are not currently supported.
301 The {ewald/disp}, {ewald}, {pppm}, and {msm} styles support
302 non-orthogonal (triclinic symmetry) simulation boxes. However,
303 triclinic simulation cells may not yet be supported by suffix versions
304 of these styles.
306 All of the kspace styles are part of the KSPACE package.  They are
307 only enabled if LAMMPS was built with that package.  See the "Making
308 LAMMPS"_Section_start.html#start_3 section for more info.  Note that
309 the KSPACE package is installed by default.
311 For MSM, a simulation must be 3d and one can use any combination of
312 periodic, non-periodic, or shrink-wrapped boundaries (specified using
313 the "boundary"_boundary.html command).
315 For Ewald and PPPM, a simulation must be 3d and periodic in all
316 dimensions.  The only exception is if the slab option is set with
317 "kspace_modify"_kspace_modify.html, in which case the xy dimensions
318 must be periodic and the z dimension must be non-periodic.
320 [Related commands:]
322 "kspace_modify"_kspace_modify.html, "pair_style
323 lj/cut/coul/long"_pair_lj.html, "pair_style
324 lj/charmm/coul/long"_pair_charmm.html, "pair_style
325 lj/long/coul/long"_pair_lj_long.html, "pair_style buck/coul/long"_pair_buck.html
327 [Default:]
329 kspace_style none :pre
331 :line
333 :link(Darden)
334 [(Darden)] Darden, York, Pedersen, J Chem Phys, 98, 10089 (1993).
336 :link(Deserno)
337 [(Deserno)] Deserno and Holm, J Chem Phys, 109, 7694 (1998).
339 :link(Hockney)
340 [(Hockney)] Hockney and Eastwood, Computer Simulation Using Particles,
341 Adam Hilger, NY (1989).
343 :link(Kolafa)
344 [(Kolafa)] Kolafa and Perram, Molecular Simualtion, 9, 351 (1992).
346 :link(Petersen)
347 [(Petersen)] Petersen, J Chem Phys, 103, 3668 (1995).
349 :link(Wang)
350 [(Wang)] Wang and Holm, J Chem Phys, 115, 6277 (2001).
352 :link(Pollock)
353 [(Pollock)] Pollock and Glosli, Comp Phys Comm, 95, 93 (1996).
355 :link(Cerutti)
356 [(Cerutti)] Cerutti, Duke, Darden, Lybrand, Journal of Chemical Theory
357 and Computation 5, 2322 (2009)
359 :link(Neelov)
360 [(Neelov)] Neelov, Holm, J Chem Phys 132, 234103 (2010)
362 :link(Veld)
363 [(Veld)] In 't Veld, Ismail, Grest, J Chem Phys, 127, 144711 (2007).
365 :link(Toukmaji)
366 [(Toukmaji)] Toukmaji, Sagui, Board, and Darden, J Chem Phys, 113,
367 10913 (2000).
369 :link(Isele-Holder)
370 [(Isele-Holder)] Isele-Holder, Mitchell, Ismail, J Chem Phys, 137,
371 174107 (2012).
373 :link(Isele-Holder2)
374 [(Isele-Holder2)] Isele-Holder, Mitchell, Hammond, Kohlmeyer, Ismail,
375 J Chem Theory Comput 9, 5412 (2013).
377 :link(Hardy)
378 [(Hardy)] David Hardy thesis: Multilevel Summation for the Fast
379 Evaluation of Forces for the Simulation of Biomolecules, University of
380 Illinois at Urbana-Champaign, (2006).
382 :link(Hardy2)
383 [(Hardy)] Hardy, Stone, Schulten, Parallel Computing 35 (2009)
384 164-177.