error in conversion of cube to xsf file

Dear all,

I need to convert cube files to xsf files for some simulations (details not important).

While searching for various options to perform this conversion I found ASE as one option (Version 3.27.0). However, problems arise with the following script:

import ase
from ase.io.cube import read_cube_data
from ase.io import write

data, atoms = read_cube_data(“electron_density.cube“)

origin = atoms.info.get(“cube_origin“, (0, 0, 0))

write(“electron_density-ASE.xsf“, atoms, data=data, origin = origin)

While it yields an xsf-file, the cell dimensions are changed the grid data appears shifted with respect to the atomic coordinates.

An attempted fix did not work:

cell = atoms.set_cell([3, 3, 6]) # example for lattice vector

atoms.set_pbc([True, True, True])

atoms.wrap()

I tried the same conversion with the c2x program and it yields the desired xsf file.
The described shifts become immediately apparent when opening the files with VESTA (version 3.90.3a).

I would appreciate it if someone could point out my mistake or if this is a bug.

Kind regards,
Max

p.s. Please excuse me for not attaching example files. This was unfortunately blocked.

Hi,

Normally it is possible to attach files. Maybe the file was too large and it needs to run on a smaller file, or you could generate the cubedata programmatically so the script reproduces the problem without any external files. I would need a functioning minimal example in order to look at this.

1 Like