"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c

:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Section_commands.html#comm)

:line

velocity command :h3

[Syntax:]

velocity group-ID style args keyword value ... :pre

group-ID = ID of group of atoms whose velocity will be changed :ulb,l
style = {create} or {set} or {scale} or {ramp} or {zero} :l
  {create} args = temp seed
    temp = temperature value (temperature units)
    seed = random # seed (positive integer)
  {set} args = vx vy vz
    vx,vy,vz = velocity value or NULL (velocity units)
    any of vx,vy,vz van be a variable (see below)
  {scale} arg = temp
    temp = temperature value (temperature units)
  {ramp} args = vdim vlo vhi dim clo chi
    vdim = {vx} or {vy} or {vz}
    vlo,vhi = lower and upper velocity value (velocity units)
    dim = {x} or {y} or {z}
    clo,chi = lower and upper coordinate bound (distance units)
  {zero} arg = {linear} or {angular}
    {linear} = zero the linear momentum
    {angular} = zero the angular momentum :pre

zero or more keyword/value pairs may be appended :l
keyword = {dist} or {sum} or {mom} or {rot} or {temp} or {loop} or {units} :l
  {dist} value = {uniform} or {gaussian}
  {sum} value = {no} or {yes}
  {mom} value = {no} or {yes} 
  {rot} value = {no} or {yes} 
  {temp} value = temperature ID
  {loop} value = {all} or {local} or {geom}
  {units} value = {box} or {lattice} :pre
:ule

[Examples:]

velocity all create 300.0 4928459 rot yes dist gaussian
velocity border set NULL 4.0 v_vz sum yes units box
velocity flow scale 300.0
velocity flow ramp vx 0.0 5.0 y 5 25 temp mytemp
velocity all zero linear :pre

[Description:]

Set or change the velocities of a group of atoms in one of several
styles.  For each style, there are required arguments and optional
keyword/value parameters.  Not all options are used by each style.
Each option has a default as listed below.

The {create} style generates an ensemble of velocities using a random
number generator with the specified seed as the specified temperature.

The {set} style sets the velocities of all atoms in the group to the
specified values.  If any component is specified as NULL, then it is
not set.  Any of the vx,vy,vz velocity components can be specified as
an equal-style or atom-style "variable"_variable.html.  If the value
is a variable, it should be specified as v_name, where name is the
variable name.  In this case, the variable will be evaluated, and its
value used to determine the velocity component.

Equal-style variables can specify formulas with various mathematical
functions, and include "thermo_style"_thermo_style.html command
keywords for the simulation box parameters or other parameters.

Atom-style variables can specify the same formulas as equal-style
variables but can also include per-atom values, such as atom
coordinates.  Thus it is easy to specify a spatially-dependent
velocity field.

The {scale} style computes the current temperature of the group of
atoms and then rescales the velocities to the specified temperature.

The {ramp} style is similar to that used by the "compute
temp/ramp"_compute_temp_ramp.html command.  Velocities ramped
uniformly from vlo to vhi are applied to dimension vx, or vy, or vz.
The value assigned to a particular atom depends on its relative
coordinate value (in dim) from clo to chi.  For the example above, an
atom with y-coordinate of 10 (1/4 of the way from 5 to 25), would be
assigned a x-velocity of 1.25 (1/4 of the way from 0.0 to 5.0).  Atoms
outside the coordinate bounds (less than 5 or greater than 25 in this
case), are assigned velocities equal to vlo or vhi (0.0 or 5.0 in this
case).

The {zero} style adjusts the velocities of the group of atoms so that
the aggregate linear or angular momentum is zero.  No other changes
are made to the velocities of the atoms.

All temperatures specified in the velocity command are in temperature
units; see the "units"_units.html command.  The units of velocities and
coordinates depend on whether the {units} keyword is set to {box} or
{lattice}, as discussed below.

For all styles, no atoms are assigned z-component velocities if the
simulation is 2d; see the "dimension"_dimension.html command.

:line

The keyword/value option pairs are used in the following ways by the
various styles.

The {dist} option is used by {create}.  The ensemble of generated
velocities can be a {uniform} distribution from some minimum to
maximum value, scaled to produce the requested temperature.  Or it can
be a {gaussian} distribution with a mean of 0.0 and a sigma scaled to
produce the requested temperature.

The {sum} option is used by all styles, except {zero}.  The new
velocities will be added to the existing ones if sum = yes, or will
replace them if sum = no.

The {mom} and {rot} options are used by {create}.  If mom = yes, the
linear momentum of the newly created ensemble of velocities is zeroed;
if rot = yes, the angular momentum is zeroed.

The {temp} option is used by {create} and {scale} to specify a
"compute"_compute.html that calculates temperature in a desired way.
If this option is not specified, {create} and {scale} calculate
temperature using a compute that is defined as follows:

compute velocity_temp group-ID temp :pre

where group-ID is the same ID used in the velocity command. i.e. the
group of atoms whose velocity is being altered.  This compute is
deleted when the velocity command is finished.  See the "compute
temp"_compute_temp.html command for details.  If the computed
temperature should have degrees-of-freedom removed due to fix
constraints (e.g. SHAKE or rigid-body constraints), then the
appropriate fix command must be specified before the velocity command
is issued.

:line

The {loop} option is used by {create} in the following ways.

If loop = all, then each processor loops over all atoms in the
simulation to create velocities, but only stores velocities for atoms
it owns.  This can be a slow loop for a large simulation.  If atoms
were read from a data file, the velocity assigned to a particular atom
will be the same, independent of how many processors are being used.
This will not be the case if atoms were created using the
"create_atoms"_create_atoms.html command, since atom IDs will likely
be assigned to atoms differently.

If loop = local, then each processor loops over only its atoms to
produce velocities.  The random number seed is adjusted to give a
different set of velocities on each processor.  This is a fast loop,
but the velocity assigned to a particular atom will depend on which
processor owns it.  Thus the results will always be different when a
simulation is run on a different number of processors.

If loop = geom, then each processor loops over only its atoms.  For
each atom a unique random number seed is created, based on the atom's
xyz coordinates.  A velocity is generated using that seed.  This is a
fast loop and the velocity assigned to a particular atom will be the
same, independent of how many processors are used.  However, the set
of generated velocities may be more correlated than if the {all} or
{local} options are used.

Note that the {loop geom} option will not necessarily assign identical
velocities for two simulations run on different machines.  This is
because the computations based on xyz coordinates are sensitive to
tiny differences in the double-precision value for a coordinate as
stored on a particular machine.

:line

The {units} option is used by {set} and {ramp}.  If units = box, 
the velocities and coordinates specified in the velocity command are
in the standard units described by the "units"_units.html command
(e.g. Angstroms/fmsec for real units).  If units = lattice, velocities
are in units of lattice spacings per time (e.g. spacings/fmsec) and
coordinates are in lattice spacings.  The "lattice"_lattice.html
command must have been previously used to define the lattice spacing.

[Restrictions:] none

[Related commands:]

"fix shake"_fix_shake.html, "lattice"_lattice.html

[Default:]

The option defaults are dist = uniform, sum = no, mom = yes, rot = no,
temp = full style on group-ID, loop = all, and units = lattice.
