Create a crystal

In this example, we show two ways of creating a body centered cubic (BCC) crystal of iron atoms: from a one-line command, and from a control file. Then we will show an example using an HCP (hexagonal) cell. Let’s see how to create a BCC iron crystal  by replicating 10x10x10 the unit BCC cell:

FROM THE COMMAND LINE
lpmd-converter -i crystal3d:nx=10,ny=10,nz=10,type=bcc,symbol=Fe -L 28.0 -o xyz:file=iron_crystal.xyz
FROM CONTROL FILE
cell cubic 28.0
input module=crystal3d nx=10 ny=10 nz=10 type=bcc symbol=Fe
output module=xyz file=iron_crystal.xyz
Save the text above in a file called, for example, “crystal.control” and execute from the command line lpmd-converter crystal.control
    • -i = Determines the plugin to be used as an input. Possible input plugins are crystal3d (as above), xyz, lpmd, lammps, vasp, pdb, and any other available file format. It is the equivalent of module in the control file.
    • nx,ny,nz = These are options that are specific of the crystal3d plugin. They determine how many replications of the unit cell, specified by type, will be replicated in X, Y and Z directions.
    • type = Unit cell type. Values available are bcc (body centered cubic), fcc (face centered cubic), hcp (hexagonal closed packed) and sc (simple cell). These are all options that are exclusive to the crystal3d plugin.
    • -L = This is the equivalent of cell cubic or cell crystal in the control file. It indicates the lengths of the cell vectors (28 angstrom in the example above). One, three, or nine (with -V) arguments are accepted:
        -L <a>: One arguments indicates that the cell vectors has the same length, and perpendicular to each other (a cube whose edge length is a).
        -L <a,b,c>: Three arguments indicates the lengths of the three cell vectors (a prism of edges length a, b, and c).
        -V <ax,ay,az,bx,by,bz,cx,cy,cz>: If the cell vectors are not perpendicular, the cartesian coordinates of each vector can be given through this option.
    • -o = Determines the output format. As in -i, it can be any file format, such as xyzlpmdlammpsvasppdb, and any other available.
    • file = Name of the output file. This option is found in any plugin that represents an input/output file format.

Hexagonal cell

An example of an hexagonal cell in the VASP input format (POSCAR) is the following:

FROM THE COMMAND LINE
lpmd-converter -i crystal3d:nx=10,ny=10,nz=10,type=hcp,symbol=Fe -V 28,0,0,-14,24.248711,0,0,0,45.723809 -o vasp:file=iron_crystal.poscar
or
lpmd-converter -i crystal3d:nx=10,ny=10,nz=10,type=hcp,symbol=Fe -L 28,28,45.723809 --angles 90,90,120 -o vasp:file=iron_crystal.poscar
FROM CONTROL FILE
cell crystal a=28 b=28 c=45.723809 alpha=90 beta=90 gamma=120
# Alternative form:
# cell crystal ax=28 ay=0 az=0 bx=-14 by=24.248711 bz=0 cx=0 cy=0 cz=45.723809
input module=crystal3d nx=10 ny=10 nz=10 type=hcp symbol=Fe
output module=vasp file=iron_crystal.poscar
Save the text above in a file called, for example, “crystal.control” and execute from the command line lpmd-converter crystal.control
In this case, we have replicated the primitive HCP cell (which has 2 atoms) 10 times in each axis. The first axis (cell vector) is given by A=(28, 0, 0), B=(-14, 24.248711, 0), which is a rotation of 120º of vector A, and C=(0, 0, 45.723809), which correspond to the the lattice parameter (2.8 in this case) times sqrt(8/3) times the amount of replication in this axis, nz=10. We recall that the ideal c/a ratio in an HCP cell is sqrt(8/3).

The lattice parameter is determined by the length of each axis, and the amount of replicas of the unit cell in each axis.

  • In the first example, the first axis has a length a=28 Å, an we replicate nx=10 times in that axis. Then, the lattice parameter (or separation between unit cells) will be a=2.8 Å.
  • For orthorhombic cells, the length of each cell vector must correspond to the lattice parameter times the amount of replicas. For example, for nx=10ny=15nz=20, you should use -L 28,42,56. Then, in each direction the separation between unit cells will be a=2.8 Å
  • The number of atoms will always be the number of atoms in the unit cell times nx x ny x nz. The conventional unit cell of SC, BCC, HCP, and FCC have 1, 2, 2, and 4 atoms, respectively.

Creating a crystal from an external file (replicate unit cell)

When the unit or primitive cell is more complicated than FCC, BCC, HCP or SC, or when the unit cell has more than one atom type, we have to create a unit cell in an external file, and replicate that unit cell later. A list of Wyckoff of each Space Group is available at the
Bilbao Crystallographic Server

Consider the following primitive cell writen in the native LPMD format, called “lpmd”:

LPMD 2.0 L
HDR SYM X Y Z
8
5.64020 0.000000 0.000000 0.000000 5.64020 0.000000 0.000000 0.000000 5.64020
Na 0.0000000000000000 0.0000000000000000 0.0000000000000000
Na 0.0000000000000000 0.5000000000000000 0.5000000000000000
Na 0.5000000000000000 0.0000000000000000 0.5000000000000000
Na 0.5000000000000000 0.5000000000000000 0.0000000000000000
Cl 0.0000000000000000 0.0000000000000000 0.5000000000000000
Cl 0.0000000000000000 0.5000000000000000 0.0000000000000000
Cl 0.5000000000000000 0.0000000000000000 0.0000000000000000
Cl 0.5000000000000000 0.5000000000000000 0.5000000000000000
Save the lines above in a file called “NaCl_crystal.lpmd” (or download the file in the link above). This file has the position of every atom in this FCC cell with two atoms basis.
FROM THE COMMAND LINE
lpmd-converter -i lpmd:NaCl_unit.lpmd -r -u replicate:nx=4,ny=2,nz=3 -o vasp:file=NaCl_crystal.poscar -O optimize-simulation=false
FROM CONTROL FILE
set replacecell true
set optimize-simulation true
input module=lpmd file=NaCl_unit.lpmd

prepare replicate nx=4 ny=2 nz=3
output module=vasp file=NaCl_crystal.poscar
    • -r = Read the cell vectors from the input file. This option is the equivalent to set replacecell true in the control file, and replaces the previously discussed -L.
    • -O = Set additional options. In this case, we are setting optimize-simulation, explained below.
    • optimize-simulation = Preserve original lattice vectors. Set to false, allows to change cell vectors from the original values (by plugins like “replicate”).

That should create a crystal 96 Na atoms and 96 Cl atoms, written in the VASP program format for input files (POSCAR). The generated file, NaCl_crystal.poscar, should look like the lines below:

POSCAR file generated by LPMD's vasp plugin
 1.0
 22.56080000 0.00000000 0.00000000
 0.00000000 11.28040000 0.00000000
 0.00000000 0.00000000 16.92060000
 96 96
Direct
 0.00000000 0.00000000 0.00000000
 0.00000000 0.25000000 0.16666667
 0.12500000 0.00000000 0.16666667
.
.
.