GEMDAT icon indicating copy to clipboard operation
GEMDAT copied to clipboard

Add support for data from other formats

Open stefsmeets opened this issue 2 years ago • 4 comments

See available formats here:

https://pymatgen.org/pymatgen.io.html

  • [x] VASP
  • [x] LAMMPS -> #327
  • [x] gromacs -> #330
  • [ ] cp2k

Minimum target is to be able to load these into a Trajectory.

stefsmeets avatar Jul 11 '23 12:07 stefsmeets

I looked into this a bit, and I find that probably the best solution is something very close to the one that we already have. The Data structure can be created with its arrays through the default constructor which can then be cached by the user if desired. This would generate the following code for any data format: <Note that some code has to be written at the TODO>

from pymatgem.io import correct_parser
from gemdat import Data

def generic_reader(file, cache):
  if Path(cache).exists():
          return Data.from_cache(cache)
  some_object = correct_parser(file);
  # `TODO` Massage `some_object` into correct format for `Data`
  massaged_data = {
              'structure'=structure, 
              'trajectory_coords': trajectory.coords,
              'species': structure.species,
              'lattice': structure.lattice,
              'time_step': run.parameters['POTIM'] * 1e-15,
              'temperature': run.parameters['TEBEG'],
              'parameters': run.parameters, }
  return Data(**massaged_data)

generic_reader("file","cache")
data.to_cache("cache")

I think we should offer this function as a way people can add new readers, for new data formats. If they have created one we can then implement it in GEMDAT.

It might also be possible to modularize the from_xxx functionality, but that would come at the cost of increased complexity. And new functions would still have to be written for new data formats.

v1kko avatar Jul 18 '23 13:07 v1kko

@alexandrosvasi @AstyLavrinenko Please provide us with example data for Lamps/gromacs/cp2k

v1kko avatar Feb 21 '24 12:02 v1kko

@alexandrosvasi @AstyLavrinenko Can you give us an update on this?

stefsmeets avatar May 27 '24 09:05 stefsmeets

We now have some data to test with for LAMMPS

stefsmeets avatar Jun 03 '24 08:06 stefsmeets