Programming in LAMMPS
In our program, we have three input files. The first file is the LAMMPS script, which is the main program. The second file is the lattice input file. This is an optional file since it is possible to input the lattice in the main script, either using the LAMMPS own commands for lattice generation or inserting the lattice atoms manually. In the second case, it is preferable to use an input file. For example, our 3x3x3 cell units lattice can be seen in this input file. The third input file is the input file for the interatomic potential parameters. This file is different for each potential used, so it is recommended to read the apropriate page on the lammps manual.
The LAMMPS Script
boundary p p p
atom_modify map array
#Create Simulation Box
pair_coeff* * SiN.Tersoff N Si
thermo_style custom temp pe ke lx ly lz cella cellb cellc cellalpha cellbeta cellgamma
dump q1 all xyz 10 ini*.xyz
dump_modify q1 element N Si
minimuze 1.0e-5 1.0e-5 1000 1000
fix 1 all nvt temp 300 300 1
compute q2 all stress/atom virial
dump q2 all custom 1000 NVTs.*.stress c_q2 c_q2 c_q2
dump q3 all xyz 1000 NVT.*.xyz
dump_modify q3 element N Si
The script starts with the initialization of the simulation. This initialization tells us, essentially, what are the units of the simulation, what are the boundary condition (for example, here we have a periodical boundary condition at each surface to simulate a bulk material).
The next section is the potential energy minimization which allows us to get a more precise and stable lattice under the selected potential as we inserted an initial lattice which is close, but not exactly the equilibrium lattice, therefore getting a high potential energy. Without this case the time of the thermalization will be larger or we may even get a temperature divergence.The minimization section has also some outputs (with the dump command and the thermo command).
The next section is the NVT siumulation. Here we keep the volume, temperature and number of atoms as a constant, and see what happens to the pressure and to the stresses. We also get the position of the atoms and get some nice visualization of the lattice (as will be presented later). This is the main part of the scriptThe exact direction for running the simulation can befound here.
Issues during simulation
In the course of this project, several issues were raised and solved. This is a list of the problems encountered and their solutions:
- Building the input files is presented here
- Temperature exploding and positive potential energy: During the first runs of the simulations, the temperature in the output was "all over the place", running from 0 to 100000K. This, of course was terrible, but solved quickly by using the minimization proceadure before the simulation begins.
- Choosing the correct ensemble was not a large issue, but some thought was needed. The goal of this simulation is to measure stress or pressure, and therefore the volume was to be kept constant. More ensemble options in lammps could be found in the fix command
- How to delete a single atom? In the delete_atoms command there are few options, non seems to fit at a first glance. The porosity option deletes a random fraction of the atoms and may be used to delete a random single atom. But I wanted to conrol which atom I delete. The use the option of region was plausible, but hard to do since I needed to give a very exact region which would include only one atom. Finally I got the idea to use the group option which deletes a predefined group of atoms, and if we define a group containing a single atom, then we would delete this atom. So the solution was to add after the minimization section a new section for this operation:
group qdel id 189
delete_atoms group qdel
- Types of outputs: There are several types of output which we used in the LAMMPS code. First, the execution run has always an output to a file named log.lammps. This output can be customized using the command
Thermo_style, whis can be found on the lammps manual here.
The second output is to dump a file every so often. Two types of file were dumped in this simulation. one is an .xyz file which is used for input to the visualization of the lattice. The second type was called .stress, but was actually used just like a .txt file and was imported to excel for further analysis.
The LAMMPS Manual: Lammps Manual