libAtoms / ExtXYZ.jl

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

(Request) Support for molecular XYZs without Lattice key #16

Closed joegilkes closed 2 years ago

joegilkes commented 2 years ago

Hi James,

I was just wondering if there would be any interest in making this compatible with extXYZ files that don't include a Lattice key, i.e. for molecular geometries with no inherent unit cell?

I'd really like to use this as a simple, lightweight library for doing some low-level manipulation of molecular xyz files within Julia, but unfortunately the hard requirement for a unit cell to be provided means this package won't work on those files.

Thanks!

jameskermode commented 2 years ago

Good question. I'm not adverse to supporting molecular geometries, just have never needed to. There is already an optional pbc key that you can use to signify open boundary conditions, so it would make sense to allow Lattice to be left out in those cases.

I'm not sure if this can be done only by making changes in this package, but I'm open to a PR which tries to do that if you'd be willing to try it out. It may be that we'd need to change the specification/implementation of the underlying C parser, but that's also possible.

Also, you will see in #15 that I'm planning to add an interface to https://github.com/JuliaMolSim/AtomsBase.jl in some form in the near future. I'm not sure how that deals with open boundary conditions either at this point.

cortner commented 2 years ago

Is it a problem to just provide a trivial cell, or to just ignore the cell with no PBC? Or is the issue that you want to use existing datasets that come without the cell?

gabor1 commented 2 years ago

I would support this enhancement because it would mean that some old XYZ files could also be read (ones with empty second lines. It's not complete backwards compatibility because we still require the second line to be a sequence of =

joegilkes commented 2 years ago

That's mostly the issue yes, I'm working within a workflow that writes extXYZs from one program and I want to read/manipulate/write them within Julia. It would definitely be possible to prepend/remove the Lattice key as necessary, it would just feel a bit clunky to have to do so.

I'm up for looking into the code and seeing if I can get it working solely within the package. For the most part it appears like it would be simple, but I'm not familiar with the C backend so I can't predict how the call to extxyz_write_ll would be handled in the event that there wasn't a Lattice key in the info dict. I'll take a look tomorrow and report back.

joegilkes commented 2 years ago

Appears to be a simple fix, opened PR #17.

jameskermode commented 2 years ago

v0.1.5 tagged and released