LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands

### set command

Syntax:

    set style ID keyword values ...

- style = atom or group or region
- ID = atom ID or group ID or region ID
- one or more keyword/value pairs may be appended
- keyword = type or type/fraction or mol or x or y or z or vx or vy or vz or charge or dipole or dipole/random or quat/random or diameter or density or volume or image or bond or angle or dihedral or improper

        type value = atom type
        type/fraction values = type fraction seed
          type = new atom type
          fraction = fraction of selected atoms to set to new atom type
          seed = random # seed (positive integer)
        mol value = molecule ID
        x,y,z value = atom coordinate (distance units)
        vx,vy,vz value = velocity component (velocity units)
        charge value = atomic charge (charge units)
        dipole values = x y z
          x,y,z = orientation of dipole moment vector
        dipole/random value = seed
          seed = random # seed (positive integer) for dipole moment orientations
        quat values = a b c theta
          a,b,c = unit vector to rotate particle around via right-hand rule
          theta = rotation angle in degrees
        quat/random value = seed
          seed = random # seed (positive integer) for quaternion orientations
        diameter value = particle diameter (distance units)
        density value = particle density (mass/distance^3 units)
        volume value = particle volume (distance^3 units)
        image nx ny nz
          nx,ny,nz = which periodic image of the simulation box the atom is in
        bond value = bond type for all bonds between selected atoms
        angle value = angle type for all angles between selected atoms
        dihedral value = dihedral type for all dihedrals between selected atoms
        improper value = improper type for all impropers between selected atoms

Examples:

    set group solvent type 2
    set group solvent type/fraction 2 0.5 12393
    set group edge bond 4
    set region half charge 0.5
    set atom 100 x 0.5 vx 1.0
    set atom 1492 type 3

Description:

Set one or more properties of one or more atoms. Since atom properties are initially assigned by the read_data, read_restart or create_atoms commands, this command changes those assignments. This can be useful for overriding the default values assigned by the create_atoms command (e.g. charge = 0.0). It can be useful for altering pairwise and molecular force interactions, since force-field coefficients are defined in terms of types. It can be used to change the labeling of atoms by atom type when they are output in dump files. It can be useful for debugging purposes; i.e. positioning an atom at a precise location to compute subsequent forces or energy.

The style atom selects a single atom. The style group selects the entire group of atoms. The style region selects all atoms in the geometric region. The associated ID for each of these styles is either the unique atom ID (typically a number from 1 to N = the number of atoms in the simulation), the group ID, or the region ID. See the group and region commands for details of how to specify a group or region.

Keyword type sets the atom type for all selected atoms. The specified value must be from 1 to ntypes, where ntypes was set by the create_box command or the atom types field in the header of the data file read by the read_data command.

Keyword type/fraction sets the atom type for a fraction of the selected atoms. The actual number of atoms changed is not guaranteed to be exactly the requested fraction, but should be statistically close. Random numbers are used in such a way that a particular atom is changed or not changed, regardless of how many processors are being used.

Keyword mol sets the molecule ID for all selected atoms. The atom style being used must support the use of molecule IDs.

Keywords x, y, z, vx, vy, vz, and charge set the coordinates, velocity, or charge of all selected atoms. For charge, the atom style being used must support the use of atomic charge.

Keyword dipole uses the specified x,y,z values as components of a vector to set as the orientation of the dipole moment vectors of the selected atoms. The magnitude of the dipole moment for each atom is set by the dipole command.

Keyword dipole/random randomizes the orientation of the dipole moment vectors of the selected atoms. The magnitude of the dipole moment for each atom is set by the dipole command. For 2d systems, the z component of the orientation is set to 0.0. Random numbers are used in such a way that the orientation of a particular atom is the same, regardless of how many processors are being used.

Keyword quat uses the specified values to create a quaternion (4-vector) that represents the orientation of the selected atoms. Note that the shape command is used to specify the aspect ratios of an ellipsoidal particle, which is oriented by default with its x-axis along the simulation box's x-axis, and similarly for y and z. If this body is rotated (via the right-hand rule) by an angle theta around a unit rotation vector (a,b,c), then the quaternion that represents its new orientation is given by (cos(theta/2), a*sin(theta/2), b*sin(theta/2), c*sin(theta/2)). The theta and a,b,c values are the arguments to the quat keyword. LAMMPS normalizes the quaternion in case (a,b,c) was not specified as a unit vector. For 2d systems, the a,b,c values are ignored, since a rotation vector of (0,0,1) is the only valid choice.

Keyword quat/random randomizes the orientation of the quaternion of the selected atoms. Random numbers are used in such a way that the orientation of a particular atom is the same, regardless of how many processors are being used. For 2d systems, only orientations in the xy plane are generated.

For the dipole and quat keywords, the atom style being used must support the use of dipoles or quaternions.

Keyword diameter sets the size of all selected particles. If the particles have a per-atom mass and density, then it also sets their mass.

Keyword density sets the density of all selected particles. If the particles have a per-atom mass and diameter, then it also sets their mass. If the particles have a per-atom mass and volume (as defined by PeriDynamics), then it also sets their mass.

Keyword volume sets the volume of all selected particles, as defined by PeriDynamics.

Keyword image sets which image of the simulation box the atom is considered to be in. It is only applied to periodic dimensions. An image of 0 means it is inside the box as defined. A value of 2 means add 2 box lengths to get the true value. A value of -1 means subtract 1 box length to get the true value. LAMMPS updates these flags as atoms cross periodic boundaries during the simulation. The flags can be output with atom snapshots via the dump command. If a value of NULL is specified for any of nx,ny,nz, then the current image value for that dimension is unchanged.

This command can be useful after a system has been equilibrated and atoms have diffused one or more box lengths in various directions. This command can then reset the image values for atoms so that they are effectively inside the simulation box, e.g if a diffusion coefficient is about to be measured via the fix msd command. Care should be taken not to reset the image flags of two atoms in a bond to the same value if the bond straddles a periodic boundary (rather they should be different by +/- 1). This will not affect the dynamics of a simulation, but may mess up analysis of the trajectories if a LAMMPS diagnostic or your own analysis relies on the image flags to unwrap a molecule which straddles the periodic box.

For the diameter and density and volume keywords, the atom style being used must support the use of those parameters. For example, granular particles store a diameter and density. Peridynamic particles store a volume and density.

Keywords bond, angle, dihedral, and improper, set the bond type (angle type, etc) of all bonds (angles, etc) of selected atoms to the specified value from 1 to nbondtypes (nangletypes, etc). All atoms in a particular bond (angle, etc) must be selected atoms in order for the change to be made. The value of nbondtype (nangletypes, etc) was set by the bond types (angle types, etc) field in the header of the data file read by the read_data command.

Restrictions:

You cannot set an atom attribute (e.g. mol or q or volume) if the atom_style does not have that attribute.

This command requires inter-processor communication to coordinate the setting of bond types (angle types, etc). This means that your system must be ready to perform a simulation before using one of these keywords (force fields set, atom mass set, etc). This is not necessary for other keywords.

Using the region style with the bond (angle, etc) keywords can give unpredictable results if there are bonds (angles, etc) that straddle periodic boundaries. This is because the region may only extend up to the boundary and partner atoms in the bond (angle, etc) may have coordinates outside the simulation box if they are ghost atoms.

Related commands:

create_box, create_atoms, read_data

Default: none