pycp2k icon indicating copy to clipboard operation
pycp2k copied to clipboard

Support reading molecule through MDAnalysis?

Open xiki-tempula opened this issue 3 years ago • 2 comments

Currently, the ASE is used for loading coordinate, box size and element information. I wonder if it is possible to load the data through MDAnalysis.Universe? The coordinate, cell, atom type can be accessed via

>>> from MDAnalysis import Universe
>>> from MDAnalysis.tests.datafiles import CRD
>>> u = Universe(CRD)
>>> u.dimensions
array([0., 0., 0., 0., 0., 0.], dtype=float32)
>>> u.atoms.positions
array([[-11.921,  26.307,  10.41 ],
       [-11.447,  26.741,   9.595],
       [-12.44 ,  27.042,  10.926],
       ...,
       [-12.616,  28.099,  21.258],
       [-13.786,  28.568,  21.198],
       [-12.417,  26.877,  21.494]], dtype=float32)
>>> u.atoms.types
array(['N', 'H', 'H', ..., 'C', 'O', 'O'], dtype=object)

xiki-tempula avatar Mar 28 '21 19:03 xiki-tempula

Hi @xiki-tempula,

The slightly inconvenient method would be to use MDAnalysis.Universe to fill the input tree manually, or first convert it into an ase.Atoms object and use create_cell/create_coords.

It should be extremely simple to also add support for MDAnalysis.Universe in the create_cell/create_coords methods. Do you think you could create a pull request for this implementation? I would be glad to include it.

lauri-codes avatar Mar 30 '21 09:03 lauri-codes

@lauri-codes I will give it a try. I wonder how should one pass elements to pycp2k?

xiki-tempula avatar Mar 30 '21 09:03 xiki-tempula