I hope you are doing well. I have a question regarding a triclinic box in LAMMPS. When calculating the volume of the system, I found that lammps use the formula v = (xhi - xlo) * (yhi - ylo) * (zhi - zlo) where xhi, xlo, etc., are values defined in the input data file i thought i will be different since there is tilt factors. However, I am wondering how LAMMPS calculates these xhi, xlo, yhi, ylo, zhi, and zlo values for the system, especially in the case of a triclinic box?
I am not sure about how LAMMPS does the exact calculation, but if you only change the tilt factors of the simulation box, the overall volume will remain the same (if this is what you were worrying about, but I guess not).
I would point you towards the documentation for triclinic boxes where I think your questions will be answered (8.2.3. Triclinic (non-orthogonal) simulation boxes — LAMMPS documentation). Essentially, LAMMPS uses the restricted triclinic system, which means that if you were to only change the tilt factors of your box, the xhi, xlo, yhi, ylo, zhi, and zlo values would not change.
Hello chrisp, thank you for your answer,
yes exactly, but for example at timetep x, and the atom moves, how are the new xlo … determined? as well as the tilt factors?
I am not sure I understood your question. As you said, all the simulation box parameters are defined in the input data. Why would they change because of atom movement? The only reason for the limits and tilt factors to change would be because you want them to, e.g. through a fix deform or by setting up a barostat.
These are not calculated but are input parameters.
Here is a simple example for the case of a 2d system. Consider a square with the edges at (0,0), (0,2), (2,0), and (2,2). Then you have xlo = 0, xhi = 2, ylo = 0, yhi = 2. Now if you have a 45 degree tilt, your square edges become (0,0), (0,2), (2,1), and (2,3) and the xy tilt factor changes from 0 to 1.
Below is a minimal input file to demonstrate. It creates the following images:
dimension 2
read_data data.tilt
write_dump all image square.ppm type type box yes 0.025
change_box all xy final 1.0
write_data data.tilted
write_dump all image tilted.ppm type type box yes 0.025
And the corresponding data file “data.tilt”
# 2d square box with 1 atom
1 atoms
1 atom types
0.0 2.0 xlo xhi
0.0 2.0 ylo yhi
-0.1 0.1 zlo zhi
0.0 0.0 0.0 xy xz yz
Masses
1 1.0
Atoms
1 1 1.0 1.0 0.0
Nothing is computed of those unless you apply a fix that changes the box tilt or box dimensions. With regular time integration, only the atom positions are updated and they have no impact on the box dimensions with the default of periodic boundary conditions.
Thank you, akohlmey, for your reply. I apologize for not being very clear in my initial question. Yes, I was asking about what happens when the box changes, for example, in the case of an NPT simulation. After looking deeper into it, I now understand that LAMMPS doesn’t calculate the tilt or box dimensions directly from the atom coordinates but rather reads or adjusts them as needed.
The reason I wanted to know how LAMMPS calculates these values is that I initially thought it might involve some mathematical transformation (similar to how we calculate the dimensions for an orthogonal box by taking the minimum and maximum of atom coordinates) to obtain the tilt factors based on the atom positions.
That is only an approximation. As mentioned, the box dimensions are an input parameter and are maintained independently from the atom positions. For example look at the in.lj input in the bench folder. Here, the box dimensions are defined during the “create_box” command and then the box is filled with atoms (using the same lattice spacing and lattice data). If you have a data file, the box dimensions are required to be provided in the data file header. For bulk systems, the box dimensions are typically slightly larger than the min-max distance between atoms.
There you have a well defined propagation of the box dimension (and tilt, if requested) by coupling the box parameters to a fictitious harmonic oscillator which is influenced by relevant pressure components. In these cases, LAMMPS will update the atom positions when the box dimensions are modified in response to pressure. The process works be converting atom positions to fractional coordinates, then change the box dimensions, and then convert the atom positions back to regular cartesian.