In this tutorial you will learn how to construct a twin boundary with Atomsk.
For the purpose of this tutorial, let us assume that we want to study a (111) twin boundary in aluminium (Al). For that purpose, construct a cell of aluminium with the orientation X=, Y=, Z=. In addition, the system is duplicated 8 times along the Y direction:
atomsk --create fcc 4.02 Al orient [11-2]  [-110] -duplicate 1 8 1 Al_cell.xsf
With this command, a first monocrystal of aluminium is created and saved in the file "Al_cell.xsf".
Now, mirror the previous system. The mirror plane is normal to Y=, and placed at Y=0. Note that only atom positions are mirrored with respect to that plane (and not the box), hence after the mirror operation all atoms are out of the box. Use the option "-wrap", so that atoms are shifted back into the box:
atomsk Al_cell.xsf -mirror 0 Y -wrap Al_mirror.xsf
Note that the mirrored system is saved into a new file, "Al_mirror.xsf".
Now, all that remains to do is stack the mirrored crystal on top of the initial one:
atomsk --merge Y 2 Al_cell.xsf Al_mirror.xsf Al_final.cfg
The final system may be visualized with Atomeye or Ovito:
The twin boundary is clearly visible in the middle of the cell. If periodic boundary conditions are assumed, then an equivalent twin boundary exists at the border of the cell (i.e. at Y=0).
Note that this atomic structure is not optimized, and may require to be relaxed with either ab initio or force-field simulation.
In the method above, the size of a twin is entirely determined in the step 1, when using the option "-duplicate". Instead of duplicating the system 8 times along Y, you may duplicate it 10 or 20 times. In the end, it will result in different distances between twin boundaries.