MD simulations in hexagon prism unit cell

Dear all,

  I have a system of carbon model in hexagon prism unit cell. I would
like to study diffusion of Nitrogen in the carbon model. Lammps does
not support hexagon prism unit cell. Can someone please point out how
to start/which part of the LAMMPS need to change.

I think the only portion to change is the PBC in LAMMPS. Also, can
someone please tell me if neighboring list being created depend on the
type of simulation box.

Best Regards,

Dear Surendra

LAMMPS allows you to use triclinic boundary conditions, and you could use them to build a hexagonal system (or at least one that’s -almost- hexagonal).

…however the shape of the of the simulation boundary box and the shape of the unit cell of your crystal need not be the same. In your case, I’m guessing it might be both easier and slightly more computationally efficient to simulate a hexagonal crystal using rectangular boundary conditions. To clarify what I mean, there are some pictures of these kinds of arrangements on the moltemplate web page, (but of course, you don’t have to use moltemplate to set your simulation up this way)

(Scroll to the right hand side of the page. The blue wireframe box shows the simulation boundaries, and they are defined in the “” file)
Also see this example:


Dear Andrew,

  many thanks for your message. I have to modify the PBC criteria for
hexagon prism unit cell. Can someone tell me which subroutines use
PBC. It will help me a lot.

Also, is neighbor list created for orthogonal box. Can I use it for
hexagon prism unit cell.

Best Regards,

c boundary conditions,bnd you could use

Dear Andrew,

  many thanks for your message. I want to know if image flags are used
during MD simulation. I cannot think of providing image box for
hexagon prism unit cell (not hexagonal). I can wrap the coordinates
back into simulation box, but it is not trivial to set image flags for
my system.

Best Regards,

Why? Is LAMMPS giving you an error message or warning message about your image flags? What is that error message? Have you looked for that error message here:

You control the boundaries of the box either by

  1. editing your DATA file (assuming you are using a LAMMPS DATA file to store the initial coordinates of the atoms in your system). Near the top of the data file, there is a “Boundary” section. You control the size and shape of the boundary there. See:

(In moltemplate, this is called the “Data Boundary” section.)

  1. using the “change_box” input script command. For details, see:

Why are you worried about how LAMMPS calculates the neighborlist? LAMMPS can simulate systems with rectangular or triclinic/hexagonal boundary conditions, and LAMMPS should calculate the neighborlist correctly regardless. In my previous post I suggested it might be more convenient to use rectangular boundaries instead of hexagonal boundaries, but both are possible in LAMMPS.

It seems to me that you should look at some of the LAMMPS examples. I found the “peptide” exam to be particularly helpful.

There is a list of turning here:

and some nice videos here:

If you are using moltemplate, the introduction/tutorial chapter (chapter 4) provides a list of helpful LAMMPS and VMD commands you will need.


Dear Andrew,

  I am using hexagon prism unit cell. The boundaries of the simulation
cell is below :

                               2 1


                                3 4


Thus 1 to 6 marks the corners of my simulation cell.. The PBC in this
system is different than orthogonal or hexagonal system. I have to
change the neighbors calculation routine and PBC routine.

Best Regards,


please note that you are about to set yourself up for public
embarrassment and ridicule.

a) the kind of changes you would need to do to LAMMPS to support a
different kind of cell representation are **substantial**.
it is not just a couple of subroutines. it is all over the place.
check out the changes required for a triclinic cell. i counted over
1000 places where this is tested for and where special subroutines are
implemented. ...and a lot of the triclinic code can utilize the
orthogonal cell code by switching between fractional coordinate
representation (which is orthogonal) and conventional coordinates.
specifically the parallel communication for setting up the domain
decomposition and communication of ghost atom information (forward and
reverse) and the border communication for particle exchange with
neighboring cells is a major effort. major effort meaning of the order
of years of your time spent programming and debugging.

b) on top of that, what you claim you need to do is _not at all_ needed.
you can **easily** represent your hexagonal system with a triclinic
cell that is tilted in the xy plane, and if you build a supercell from
two primitive triclinic cells, you can even use an orthogonal cell. i
recommend the latter, as it makes many things easier.

since this is essentially a 2d problem, i suggest you pick up a piece
of quad-ruled paper, draw it out, and you'll see. draw four hexagons
(one over two over one) and connect the centers, you will get a
rhombus, that covers the same area as one hexagon. add more hexagons
and more rhombi you will see clearly that you cover the same volume
with hexagons and rhombi and that both are a space-filling lattice.

or pick up a book about crystallography, read about bravais lattices,
and you'll see.

or google it for a bit, and you'll see.


Fair enough. Now I see why you are confused. A "hexagonal" unit cell
is not a hexagon.
Take a look at this web link:
According to popular convention at least, a "hexagonal" unit cell is a
specific kind of triclinic (rhombohedral) unit cell with 60 and 120
degree angles in the XY plane. You can use this kind of
diamond-shaped unit cell to build a periodic system with hexagonal
symmetry. For this reason, nobody bothers to write software which
supports boundary conditions which are actually shaped like hexagons,
but I did not get the impression you are asking for this feature. It
sounded like you just want to find a way to run your simulations of
graphene/graphite. Just try using rectangular boundaries, and make
your box large enough that it encloses an integer number of
diamond-shaped unit cells. Here's that picture from the example I
mentioned earlier again:
   As this discussion is no longer specific to LAMMPS, perhaps we
should continue in private.
  (Incidentally, I recall some simulation software programs support
"truncated octahedron" shaped periodic boundaries, but they do it for
a very specific reason, and I always thought it was not worth the
considerable labor.)