Open stefsmeets opened 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.
@alexandrosvasi @AstyLavrinenko Please provide us with example data for Lamps/gromacs/cp2k
@alexandrosvasi @AstyLavrinenko Can you give us an update on this?
We now have some data to test with for LAMMPS
See available formats here:
https://pymatgen.org/pymatgen.io.html
Minimum target is to be able to load these into a
Trajectory
.