libAtoms / ExtXYZ.jl

Extended XYZ read/write support for Julia
MIT License
13 stars 6 forks source link

Saving isolated molecules to a file results a file that cannot be read #47

Closed tjjarvinen closed 4 months ago

tjjarvinen commented 5 months ago

If you create isolated molecule with AtomsBase and save it using ExtXYZ and try to load the file

Here is a Working example:

using AtomsBase
using ExtXYZ
using Unitful

hydrogen = isolated_system([
        :H => [0, 0, 0.]u"Å",
        :H => [0, 0, 1.]u"Å"
])

ExtXYZ.save("example.xyz", hydrogen)

ExtXYZ.load("example.xyz")   # results in error

The saved file reads

2
pbc=[F, F, F] Lattice="inf 0.00000000 0.00000000 0.00000000 inf 0.00000000 0.00000000 0.00000000 inf" Properties=species:S:1:pos:R:3:velocities:R:3:Z:I:1
H         0.00000000       0.00000000       0.00000000         0.00000000       0.00000000       0.00000000          1
H         0.00000000       0.00000000       1.00000000         0.00000000       0.00000000       0.00000000          1

If you remove the lattice and pbc information from the file, then it works as intended.

So, one fix would be to check, if structure has infinite bounding box, and if yes then just remove cell information from the save.

jameskermode commented 5 months ago

I'll take a look. In my opinion keeping pbc=[F, F, F] but omitting the infinite lattice would be the best option, since this would then encode the open bounday conditions explictly rather than implicitly, but I don't remember right now if this is possible with the upstream extxyz library.

jameskermode commented 5 months ago

Could you take a look at #48? The test is not passing because of a unit conversion problem when comparing the read-in infinite lattice with the original one - if either @tjjarvinen or @mfherbst could advise on what I am doing wrong there that would be much appreciated.