GEMDAT-repos / GEMDAT

Python toolkit for molecular dynamics analysis
https://gemdat.readthedocs.io
Apache License 2.0
22 stars 3 forks source link

Add support for data from other formats #47

Open stefsmeets opened 1 year ago

stefsmeets commented 1 year ago

See available formats here:

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

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

v1kko commented 1 year ago

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 commented 8 months ago

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

stefsmeets commented 5 months ago

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

stefsmeets commented 4 months ago

We now have some data to test with for LAMMPS