git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@16053 f3b2605a-c512-4ea7-a41b...
[lammps.git] / doc / src / compute_global_atom.txt
blobf62efcff2ebc54b01920f98126b144c574c5b940
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 compute global/atom command :h3
11 [Syntax:]
13 compute ID group-ID style index input1 input2 ... :pre
15 ID, group-ID are documented in "compute"_compute.html command :ulb,l
16 global/atom = style name of this compute command :l
17 index = c_ID, c_ID\[N\], f_ID, f_ID\[N\], v_name :l
18   c_ID = per-atom vector calculated by a compute with ID
19   c_ID\[I\] = Ith column of per-atom array calculated by a compute with ID
20   f_ID = per-atom vector calculated by a fix with ID
21   f_ID\[I\] = Ith column of per-atom array calculated by a fix with ID
22   v_name = per-atom vector calculated by an atom-style variable with name :pre
23 one or more inputs can be listed :l
24 input = c_ID, c_ID\[N\], f_ID, f_ID\[N\], v_name :l
25   c_ID = global vector calculated by a compute with ID
26   c_ID\[I\] = Ith column of global array calculated by a compute with ID, I can include wildcard (see below)
27   f_ID = global vector calculated by a fix with ID
28   f_ID\[I\] = Ith column of global array calculated by a fix with ID, I can include wildcard (see below)
29   v_name = global vector calculated by a vector-style variable with name :pre
30 :ule
32 [Examples:]
34 compute 1 all global/atom c_chunk c_com\[1\\] c_com\[2\\] c_com\[3\\]
35 compute 1 all global/atom c_chunk c_com\[*\\] :pre
37 [Description:]
39 Define a calculation that assigns global values to each atom from
40 vectors or arrays of global values.  The specified {index} parameter
41 is used to determine which global value is assigned to each atom.
43 The {index} parameter must reference a per-atom vector or array from a
44 "compute"_compute.html or "fix"_fix.html or the evaluation of an
45 atom-style "variable"_variable.html.  Each {input} value must
46 reference a global vector or array from a "compute"_compute.html or
47 "fix"_fix.html or the evaluation of an vector-style
48 "variable"_variable.html.  Details are given below.
50 The {index} value for an atom is used as a index I (from 1 to N) into
51 the vector associated with each of the input values.  The Ith value
52 from the input vector becomes one output value for that atom.  If the
53 atom is not in the specified group, or the index I < 1 or I > M, where
54 M is the actual length of the input vector, then an output value of
55 0.0 is assigned to the atom.
57 An example of how this command is useful, is in the context of
58 "chunks" which are static or dyanmic subsets of atoms.  The "compute
59 chunk/atom"_compute_chunk_atom.html command assigns unique chunk IDs
60 to each atom.  It's output can be used as the {index} parameter for
61 this command.  Various other computes with "chunk" in their style
62 name, such as "compute com/chunk"_compute_com_chunk.html or "compute
63 msd/chunk"_compute_msd_chunk.html, calculate properties for each
64 chunk.  The output of these commands are global vectors or arrays,
65 with one or more values per chunk, and can be used as input values for
66 this command.  This command will then assign the global chunk value to
67 each atom in the chunk, producing a per-atom vector or per-atom array
68 as output.  The per-atom values can then be output to a dump file or
69 used by any command that uses per-atom values from a compute as input,
70 as discussed in "Section 6.15"_Section_howto.html#howto_15.
72 As a concrete example, these commands will calculate the displacement
73 of each atom from the center-of-mass of the molecule it is in, and
74 dump those values to a dump file.  In this case, each molecule is a
75 chunk.
77 compute cc1 all chunk/atom molecule
78 compute myChunk all com/chunk cc1
79 compute prop all property/atom xu yu zu
80 compute glob all global/atom c_cc1 c_myChunk\[*\]
81 variable dx atom c_prop\[1\]-c_glob\[1\]
82 variable dy atom c_prop\[2\]-c_glob\[2\]
83 variable dz atom c_prop\[3\]-c_glob\[3\]
84 variable dist atom sqrt(v_dx*v_dx+v_dy*v_dy+v_dz*v_dz)
85 dump 1 all custom 100 tmp.dump id xu yu zu c_glob\[1\] c_glob\[2\] c_glob\[3\] &
86      v_dx v_dy v_dz v_dist
87 dump_modify 1 sort id :pre
89 You can add these commands to the bench/in.chain script to see how
90 they work.
92 :line
94 Note that for input values from a compute or fix, the bracketed index
95 I can be specified using a wildcard asterisk with the index to
96 effectively specify multiple values.  This takes the form "*" or "*n"
97 or "n*" or "m*n".  If N = the size of the vector (for {mode} = scalar)
98 or the number of columns in the array (for {mode} = vector), then an
99 asterisk with no numeric values means all indices from 1 to N.  A
100 leading asterisk means all indices from 1 to n (inclusive).  A
101 trailing asterisk means all indices from n to N (inclusive).  A middle
102 asterisk means all indices from m to n (inclusive).
104 Using a wildcard is the same as if the individual columns of the array
105 had been listed one by one.  E.g. these 2 compute global/atom commands
106 are equivalent, since the "compute com/chunk"_compute_com_chunk.html
107 command creates a global array with 3 columns:
109 compute cc1 all chunk/atom molecule
110 compute com all com/chunk cc1
111 compute 1 all global/atom c_cc1 c_com\[1\] c_com\[2\] c_com\[3\]
112 compute 1 all global/atom c_cc1 c_com\[*\] :pre
114 :line
116 This section explains the {index} parameter.  Note that it must
117 reference per-atom values, as contrasted with the {input} values which
118 must reference global values.
120 Note that all of these options generate floating point values.  When
121 they are used as an index into the specified input vectors, they
122 simple rounded down to convert the value to integer indices.  The
123 final values should range from 1 to N (inclusive), since they are used
124 to access values from N-length vectors.
126 If {index} begins with "c_", a compute ID must follow which has been
127 previously defined in the input script.  The compute must generate
128 per-atom quantities.  See the individual "compute"_compute.html doc
129 page for details.  If no bracketed integer is appended, the per-atom
130 vector calculated by the compute is used.  If a bracketed integer is
131 appended, the Ith column of the per-atom array calculated by the
132 compute is used.  Users can also write code for their own compute
133 styles and "add them to LAMMPS"_Section_modify.html.  See the
134 discussion above for how I can be specified with a wildcard asterisk
135 to effectively specify multiple values.
137 If {index} begins with "f_", a fix ID must follow which has been
138 previously defined in the input script.  The Fix must generate
139 per-atom quantities.  See the individual "fix"_fix.html doc page for
140 details.  Note that some fixes only produce their values on certain
141 timesteps, which must be compatible with when compute global/atom
142 references the values, else an error results.  If no bracketed integer
143 is appended, the per-atom vector calculated by the fix is used.  If a
144 bracketed integer is appended, the Ith column of the per-atom array
145 calculated by the fix is used.  Users can also write code for their
146 own fix style and "add them to LAMMPS"_Section_modify.html.  See the
147 discussion above for how I can be specified with a wildcard asterisk
148 to effectively specify multiple values.
150 If {index} begins with "v_", a variable name must follow which has
151 been previously defined in the input script.  It must be an
152 "atom-style variable"_variable.html.  Atom-style variables can
153 reference thermodynamic keywords and various per-atom attributes, or
154 invoke other computes, fixes, or variables when they are evaluated, so
155 this is a very general means of generating per-atom quantities to use
156 as {index}.
158 :line
160 This section explains the kinds of {input} values that can be used.
161 Note that inputs reference global values, as contrasted with the
162 {index} parameter which must reference per-atom values.
164 If a value begins with "c_", a compute ID must follow which has been
165 previously defined in the input script.  The compute must generate a
166 global vector or array.  See the individual "compute"_compute.html doc
167 page for details.  If no bracketed integer is appended, the vector
168 calculated by the compute is used.  If a bracketed integer is
169 appended, the Ith column of the array calculated by the compute is
170 used.  Users can also write code for their own compute styles and "add
171 them to LAMMPS"_Section_modify.html.  See the discussion above for how
172 I can be specified with a wildcard asterisk to effectively specify
173 multiple values.
175 If a value begins with "f_", a fix ID must follow which has been
176 previously defined in the input script.  The fix must generate a
177 global vector or array.  See the individual "fix"_fix.html doc page
178 for details.  Note that some fixes only produce their values on
179 certain timesteps, which must be compatible with when compute
180 global/atom references the values, else an error results.  If no
181 bracketed integer is appended, the vector calculated by the fix is
182 used.  If a bracketed integer is appended, the Ith column of the array
183 calculated by the fix is used.  Users can also write code for their
184 own fix style and "add them to LAMMPS"_Section_modify.html.  See the
185 discussion above for how I can be specified with a wildcard asterisk
186 to effectively specify multiple values.
188 If a value begins with "v_", a variable name must follow which has
189 been previously defined in the input script.  It must be a
190 "vector-style variable"_variable.html.  Vector-style variables can
191 reference thermodynamic keywords and various other attributes of
192 atoms, or invoke other computes, fixes, or variables when they are
193 evaluated, so this is a very general means of generating a vector of
194 global quantities which the {index} parameter will reference for
195 assignement of global values to atoms.
197 :line
199 [Output info:]
201 If a single input is specified this compute produces a per-atom
202 vector.  If multiple inputs are specified, this compute produces a
203 per-atom array values, where the number of columns is equal to the
204 number of inputs specified.  These values can be used by any command
205 that uses per-atom vector or array values from a compute as input.
206 See "Section 6.15"_Section_howto.html#howto_15 for an overview of
207 LAMMPS output options.
209 The per-atom vector or array values will be in whatever units the
210 corresponsing input values are in.
212 [Restrictions:] none
214 [Related commands:]
216 "compute"_compute.html, "fix"_fix.html, "variable"_variable.html,
217 "compute chunk/atom"_compute_chunk_atom.html, "compute
218 reduce"_compute_reduce.html
220 [Default:] none