Possible bug in Ovito reading xyz file

Hi Ovito-team,

I was trying to visualize a structure made with ase (atomic simulation environment) with Ovito.

I wrote the structure to an xyz file with ase to be able to visualize it. However, when replicating the cell in x, a non-periodic structure appeared. When replicating the same structure in the python/ase tool, nothing seemed wrong. I then decided to write to a lammpsfile and visualize it with Ovito again, nothing was wrong.

Admittedly, it could be a problem with writing as well. Below, the code used to generate the structure and the xyz and lammps files:

import ase

from ase import build
from ase import visualize
from ase import io
surf = ase.build.surface(‘Pt’, (5,5,4), 20, 40, periodic = True)
surf = ase.build.make_supercell(surf, [[1,1,0],[0,2,0],[0,0,1]], wrap=True, tol=1e-05)
surf = ase.build.make_supercell(surf, [[1,0,0],[4,1,0],[0,0,1]], wrap=True, tol=1e-05)
surf.rotate(surf.cell[0], (1,0,0) , rotate_cell=True)
ase.io.write(‘test.xyz’, surf, format=‘xyz’)
ase.io.write(‘test.lammps’, surf, format=‘lammps-data’, atom_style=‘full’)
ase.visualize.view(surf)

See the image below to see what I mean with “non-periodic”. On the left, the xyz file, on the right the lammpsfile.

I solved the problem for myself, by just writing it to another filetype, but I thought it might be nice to report it as a bug.

Kind regards,
Justina

Hi Justina,

Thank you for reporting your observation. The issue you’ve encountered is not a bug in OVITO but rather a limitation associated with the XYZ file format. The plain xyz format does not include information about the simulation cell. Therefore, OVITO calculates the bounding box based on the particles’ positions, using this as an approximate cell. This estimation may differ from the original cell, potentially causing issues at the periodic boundaries.

The LAMMPS dump and data formats do include simulation cell information. When using these formats, OVITO reads the cell data directly from the file, ensuring proper periodicity.

If you rely on the xyz format, you can instead use the extended xyz format. This format includes the simulation cell and additional details in the comment line, effectively addressing the issue.

ASE is able to output the extended xyz file for you structure using the following command:

ase.io.write("test.exyz", surf, format="extxyz")
1 Like