randomly assign atoms on lattice points

Dear LAMMPS users and developers,

Greetings. I would like to try simulating a binary Lennard Jones fluid with atoms sitting on fcc lattice, namely, it is like a fcc crystal mostly with A atoms and the rest are B atoms. Due to the composition (A:B=4:1), the institutional ones (B) must be assigned randomly. Here I would like to see if there is a “minimum” in energy landscape for such pseudo fluid… So, instead of writing an data file by hand, is it possible to be done by LAMMPS? Thank you very much for the help and comments.


LC Liu

I haven't tried it myself, but I think the set type/fraction command should do what you want.

" 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. This keyword does not allow use of an atom-style variable."


Hi, Niall,

Thank you for the prompt help, and yes this is the command :). Here is my input for whoever needs it:

lattice fcc 1.2
region my_region block 0 5 0 5 0 5

create_box 2 my_region
create_atoms 1 box
group 1 type 1
set group 1 type/fraction 2 0.2 12345
group 2 type 2

LC Liu

Although this is not what you asked, I thought I'd mention that you
can do this with molecules too. (...using moltemplate. Never one to
let an opportunity pass without pushing moltemplate!)

For reference, the following moltemplate example creates a lipid
bilayer containing only one kind of lipid:

lipids = new DPPC
                   [32].move(7.5, 0, 0)
                   [37].move(3.75, 6.49519, 0)
                    [2].rot(180, 1, 0, 0)

(This creates a 3-dimensional array containing 32x37x2=2368 "DPPC"
molecules. The move() and rot() commands move them into a 2-D
hexagonal lattice with two layers. Of course, you must define the
"DPPC" molecule.)

Now to mix two different types of molecules together (for example
"DPPC" and "DLPC") you could do it this way:

lipids = new random([DPPC,DLPC], [0.5,0.5])
                   [32].move(7.5, 0, 0)
                   [37].move(3.75, 6.49519, 0)
                    [2].rot(180, 1, 0, 0)

The results (after periodic boundary conditions are applied) are shown here:
(These are simplified coarse-grained lipids with yellow and green head groups)

Note: the list of numbers [0.5,0.5] specify the probabilities. You
can also specify an random-seed, for example: "random([DPPC,DLPC],
[0.5,0.5], 12345)"

You can do this with more than two types of molecules, and you can do
this with 1-dimensional or 2-dimensional arrays as well. For example,
the next example makes a polymer (a 1-dimensional array) out of a
random mixture of 50 "2bead" and "3bead" monomers.

monomers = new
            [50].rot(180,1,0,0).move(2.95, 0, 0)

(See attached pictures.)

For more complex packing geometries, you can use a combination of
PACKMOL and moltemplate:

(Forgive me if you have seen all these examples before. I show these
pictures a lot.)
I think you can do similar things with other molecule builder tools too.