Periodic boundary conditions on a rotated box

I would like to generate a box with random orientation and periodic boundary conditions. However pbc does not trivially preserve the distances for rotated and non orthogonal lattices. Is there any configuration of parameters e.g the box size as a function of the orientation that would preserve the periodicity? If not, would it make sense to create an enhancement on the lammps source code in order to compute values such as distance or angles accounting for this non-canonical periodicity?


If you are thinking of, for example, Lees-Edwards boundary conditions, those are available in LAMMPS using triclinic simulation cells and fix deform or the UEF package.

Otherwise, it is unclear what exactly you are trying to do. What exactly are you orienting with respect to what? Free space and isotropic, homogeneous bulk systems do not have preferred directions. Those systems that do have preferred directions either have preferred directions that are PBC compatible (such as block copolymer phases and bilayer membranes) or cannot be simulated in PBC (like quasicrystals).

Hi @tomasfbouvier,

I think your message is quite confusing due to its wording. The LAMMPS box is not dependant on the atoms configuration inside it. As such you can have a rotated or non-orthogonal crystal structure inside it even with an orthogonal box, as long as the box lengths match the periodicity of the crystal along the 3 axes directions.

Consider for example the fact that the lattice command generates an abstract lattice and the region and create_box commands generate a box in LAMMPS. If didn’t use the lattice to define your region but use the lattice to populate the box with atoms, the populated populations will be the one of the lattice inside the box, without regard of periodicity (incomplete cells will still be populated).

Now your problem is rather vague, what do you mean with “pbc does not trivially preserve the distances for rotated and non orthogonal lattices”? Rotated lattices might have different period along axes of the box compared to their non-rotated counterpart but if you create the box using rotated lattices as a reference, you should not have any periodicity issue. You would end up with different box lengths but that is to be expected.


Thank you very much to both for your detailed answers. What I am trying is to generate a periodic box that contains a randomly oriented diamond lattice in Si with the purpose of randomising ion recoil directions (irradiation). As a consequence of the rotation the period changes and hence the box lengths have to be rescaled. I am yet trying to figure out which is the scaling factor if we start from a cubic box. Hopefully your answers should help me.

@Germain would you mind giving a bit more details? Should use the lattice command after the create_box command in order to populate my lattice? I did not get yet how to use the rotated lattice as a reference and yet populate incomplete cells. This is my code snippet
lattice diamond 5.43 orient x {r[0,0]} {r[0,1]} {r[0,2]} orient y {r[1,0]} {r[1,1]} {r[1,2]} orient z {r[2,0]} {r[2,1]} {r[2,2]}
region mybox block -{lx} {lx} -54.3 54.3 -54.3 54.3 units box
create_box 1 mybox
create_atoms 1 region mybox
where r is the a matrix that represents my axes rotation.

P.S.: Sorry for the confusing wording. I was well aware that most of this forum’s answers started complaining about how confusing the question was so I tried my best. I would appreciate feedback on how the question is formulated for doing it better next time.

Hi Tomas,

Thanks for asking how you could have improved your initial question, that’s a great question to ask :slight_smile: I guess the main way you could have improved your initial question would be to be more specific. LAMMPS is used in a very wide range of contexts, so specific contextual information is very helpful to answerers who are trying to get to a specific answer for you as well! (As an example, I gave suggestions that are more relevant to fluid simulations, whereas now I know you are thinking about solid state simulations.)

I think you’d also really help us (and yourself!) now by drawing out what you think the lattice will look like, say, for two different orientations. Draw it with explicit periodic images to be clear how you think particles will relate to each other at the edges. For example, here’s Wikipedia’s depiction of a particle crossing a periodic boundary (link):

Because they include multiple periodic images it’s quite clear what’s happening in both the main box and in each periodic image.

1 Like

With this you have basically two subsystems: 1) the crystal 2) the atom(s) that is/are impacting it. Since all you care about is the relative orientation, why do you try to modify the one that is hard to change under periodic boundary conditions? Why not just keep the crystal in a fixed location and instead randomly change the impact location and direction vectors? This is what is commonly done when people study irradiation impact cascades, for example.

1 Like

Hi Axel,
Thank you for answering. I am indeed doing irradiation cascades. Sampling the location and direction of my recoils is precisely what I am trying to avoid. The reason is because we noted that for our purposes the cascades can be encapsulated in much smaller regions than a cubic box. In other words asuming that no secondary recoils are generated (which is safe at low energies) the primary damage’s spread is much more longitudinal than transversal. If we are able to rotate the box in the direction of the recoil we can slice the fraction of atoms that are likely to be involved in the cascade and speed up calculations.

This seems to me like what we call “premature optimisation”. If you know for sure that the damage will be limited to a thin longitudinal pencil, then you can simulate a thin longitudinal pencil without PBC. If you did simulate a pencil, PBC-ed into an infinite bundle of pencils, it would take longer than without PBC (with all the accounting for particles and interactions going across images), and more importantly you wouldn’t be simulating a single impactor, you’d be simulating a large shower of parallel impactors with a model lacking any long-range phonons.

But I’m still not sure the thing you want to do is even mathematically possible. After all, consider your basic bcc lattice, which has one basis atom at (0, 0, 0) and another at (0.5, 0.5, 0.5), in a repeating cube of length 1. Now let’s “rotate” the lattice and move that center atom to, say, (0.55, 0.45, 0.5), while leaving the cube the same. What you get is not a “rotated bcc” – it’s a completely different lattice (with a much smaller symmetry group, for example).

Really, draw the thing you’re trying to make. Otherwise I really don’t know whether what I’m describing is what you are intending or not.

1 Like

I agree with @srtee you are trying to avoid one problem and are creating a much bigger problem in the process. In my experience, those simulations neither require excessively large systems, nor need to be run for very long times, but are “conveniently parallel” (or “embarrassingly parallel”, if you don’t mind to be politically incorrect) since you can run - after proper equilibration and saving a suitable data file - many different initial conditions concurrently. Considering, that CPU time is rather easy to get to these days and your needs are not very high compared to other simulation problems, what are you trying to optimize for and how much do you expect to gain from it?

In addition, I am not convinced that you can discard even small motions that easily, since you have a material that is not very compressible, so any sound waves will travel well and far. Using typical system sizes, you may already miss out on some details, since the size of the periodic box limits as how low a frequency of motion is actually supported.

That said, you can already optimize your simulation time with using fix dt/reset by adjusting the length of the time step and thus the resolution of time integration to the speed of the fastest atoms. As second possible optimization (and much more rigorous as well) would be to figure out a new variant of r-RESPA time stepping, where force computations are saved by recomputing forces of atoms that move slower less frequent. That would be some significant programming effort, though.

1 Like

Good insights were given here. I think Axel’s analyses is correct from what I understand to your problem. Maybe you tackled the problem through the wrong angles.

Concerning the wording of your question, notice that several words have a very precise meaning in the context of LAMMPS (fix, box, lattice, pbc…) and that these meanings sometimes overlap with their more general meaning when phrasing a problem. :wink:

Finally I think some answers were provided for your problem and that they point in a very different direction, but if you still want to get a better understanding of the relationship between lattice and simulation boxes, I would advice you to play around and try to make several simulation boxes from scratch with easy to analyse lattices. Then you could compare what happens when modifying parameters and options. Keep the documentation close and figure out what’s happening. That’s the best you could do to learn more about how it works.

1 Like