I generated sets of xyz coordinates for four atoms in two diatomic molecules’ dimers. where each of Al1, F1, Al2, F2 have their coordinates x,y and z coordinates in a separate array. each array is 33177600 long meaning I have 33177600 configurations. I want to efficiently generate an xyz file that contains the coordinates of all the configurations.
I used a for loop with an ASe library atoms object to do so, but I think there might be a more computationally efficient way of doing it. I want to avoid the for loop and use NumPy, pandas, or other efficient methods for this task. Thanks!
import numpy as np
import ase
from ase import io
from ase import Atoms
atoms=[]
for i in range(5):
atoms.append(Atoms(['Al','F','Al','F'], positions=[(x_al1[i], y_al1[i], z_al1[i]), (x_f1[i], y_f1[i], z_f1[i]),(x_al2[i], y_al2[i], z_al2[i]),(x_f2[i], y_f2[i], z_f2[i])]))
ase.io.write(filename='tryj.xyz',images=atoms)
The output xyz file looks like this for five configurations
4
Properties=species:S:1:pos:R:3 pbc="F F F"
Al 2.57624552 -0.00195309 0.00000000
F 3.20148847 0.00277378 0.00000000
Al -0.25834347 0.00195220 -0.00005894
F 0.36689949 -0.00277251 0.00008371
4
Properties=species:S:1:pos:R:3 pbc="F F F"
Al 2.57624552 -0.00195309 0.00000000
F 3.20148847 0.00277378 0.00000000
Al -0.25834347 0.00188505 -0.00051102
F 0.36689949 -0.00267715 0.00072575
4
Properties=species:S:1:pos:R:3 pbc="F F F"
Al 2.57624552 -0.00195309 0.00000000
F 3.20148847 0.00277378 0.00000000
Al -0.25834347 0.00149618 -0.00125539
F 0.36689949 -0.00212488 0.00178290
4
Properties=species:S:1:pos:R:3 pbc="F F F"
Al 2.57624552 -0.00195309 0.00000000
F 3.20148847 0.00277378 0.00000000
Al -0.25834347 0.00058919 -0.00186210
F 0.36689949 -0.00083677 0.00264455
4
Properties=species:S:1:pos:R:3 pbc="F F F"
Al 2.57624552 -0.00195309 0.00000000
F 3.20148847 0.00277378 0.00000000
Al -0.25834347 -0.00058919 -0.00186210
F 0.36689949 0.00083677 0.00264455
Mahmoud Amr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.