Can't export .xyz file with connections

Hi everybody. I’m a new Avogadro user (Avogadro 1.93.0) and I’m struggling with the exportation of molecules.
I created my molecule and I exported it as .xyz file. I want to use this file as initial configuration for my simulation in which I use the ase module.
The problem is that only the positions are saved (i.e. I only have 4 columns, the atom name and the 3 coordinates), but ase requires 4 more columns (I assume them to be momenta and energy, but they are simply called “connettivity information” so I’m unsure), or at least this is my understanding, given the error message “could not assign tuple of length 4 to structure with 8 fields”.
How can I produce the right format?

Here it is what I get and the format I would like to get:

23
Lattice=“16.8 0.0 0.0 0.0 15.2 0.0 0.0 0.0 10.4” Properties=species:S:1:pos:R:3:initial_magmoms:R:1:forces:R:3 energy=-139.238765 pbc=“F F F”
C 9.00356 7.12893 5.20006
C 10.06981 8.05133 5.20001
C 10.63097 5.31475 5.20005
H 10.84370 4.24540 5.20007
H 12.19986 8.32883 5.19991
C 9.30790 5.75167 5.20010
H 8.50840 5.00786 5.20017
N 12.71607 5.88976 5.19990
C 11.38912 7.59816 5.19997



21
Lattice=“16.8 0.0 0.0 0.0 15.2 0.0 0.0 0.0 10.4” Properties=species:S:1:pos:R:3:initial_magmoms:R:1:forces:R:3 energy=-139.238765 pbc=“F F F”
C 9.00356000 7.12893100 5.20006400 0.00000000 -0.01044000 0.00060000 0.00001000
C 10.06981000 8.05133200 5.20001500 0.00000000 -0.01182000 -0.00828000 -0.00000000
C 10.63096800 5.31474800 5.20005300 0.00000000 -0.00092000 0.00236000 0.00001000
H 10.84370300 4.24540400 5.20007200 0.00000000 -0.01098000 -0.00303000 0.00000000
H 12.19986100 8.32883100 5.19991500 0.00000000 -0.01220000 0.00028000 0.00006000
C 9.30789700 5.75167100 5.20010200 0.00000000 0.00379000 0.00889000 0.00002000
H 8.50840400 5.00785500 5.20016600 0.00000000 0.00774000 0.01384000 0.00001000
H 12.71607200 5.88976400 5.19990200 0.00000000 -0.01109000 0.00338000 0.00002000
C 11.38912200 7.59815900 5.19997000 0.00000000 -0.01129000 0.00210000 -0.00003000

Welcome. FYI, there are much newer versions of Avogadro (1.97) - and there are definitely bug fixes and features in 1.97…

I’m a little confused by your report. Avogadro now supports the “extended XYZ” used by ASE (starting in version 1.94), but there’s something a little weird about the file you pasted:

This is used by ASE to decide what columns to expect:

  • one column for species S:1
  • three columns for position pos:R3
  • one column … I guess for magnetic moments? R:1
  • three columns for forces forces:R3

But the Avogadro code doesn’t write that header. Forces is actually interesting - I haven’t seen a file that includes force data on atoms, but I’ll add it.

Anyway, the error from ASE is that it sees the header on your file and expects 8 columns, but only sees 4.

The easiest way to solve your problem would be to edit the header, e.g.

Properties=species:S:1:pos:R:3 energy=-139.238765 pbc=“F F F”

And I’d suggest updating to 1.97 from https://two.avogadro.cc/ which should better support the extended XYZ files (including saving the header I mention above).

Thank you!very much I changed the header as you suggested and it worked!
I’ll try to update as well so that hopefully I won’t have to manually change the header every time.

Can you tell me a bit more about how you created the file / molecule? Did you read in a file, make some changes, and save again? I’m a bit surprised that 1.93 created that header so I want to make sure that bug doesn’t come back.

As you said, I read in a .xyz file, make changes and save it again.
I don’t know if I’m doing something wrong: I’m just adding a couple of atoms.

No, no you’re not doing anything wrong. It’s just that the original file had information that was picked up by Open Babel, and then the header is wrong when it gets saved.

The newer versions should read / write the extended XYZ natively.