Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrajectoryData does not preserve periodicity information #6376

Open
danielhollas opened this issue Apr 29, 2024 · 1 comment
Open

TrajectoryData does not preserve periodicity information #6376

danielhollas opened this issue Apr 29, 2024 · 1 comment

Comments

@danielhollas
Copy link
Collaborator

danielhollas commented Apr 29, 2024

How to turn a non-periodic structure into a periodic structure in a few simple steps, going from StructureData to TrajectoryData and back again

In [92]: s = StructureData(cell=None, pbc=(False, False, False))

In [93]: s.append_atom(position=[0.0, 0.0, 0.0], symbols='H')

In [94]: t = TrajectoryData(structurelist=(s,))

In [95]: t.get_step_structure(0).pbc
Out[95]: (True, True, True)

trying to store such a transformed structure leads to sadness (predictably)

----> 1 t.get_step_structure(0).store()

~/atmospec/aiida-core/src/aiida/orm/nodes/node.py in store(self)
    522             self._validate_storability()
--> 523             self._validate()
    524 
~/atmospec/aiida-core/src/aiida/orm/nodes/data/structure.py in _validate(self)
    920 
--> 921         _validate_dimensionality(self.pbc, self.cell)
    922 
~/atmospec/aiida-core/src/aiida/orm/nodes/data/structure.py in _validate_dimensionality(pbc, cell)
   2458     if dim['value'] == 0:
-> 2459         raise ValueError(f'Structure has periodicity {pbc} but {dim["dim"]}-d volume 0.')

Looking at the code, it seems like TrajectoryData does not track periodicity information at all, which is a bad news for everything except 3D-periodic structures.

This is currently a big issue for my app, since I am using TrajectoryData extensively to store molecular conformers.

cc @mbercx

@danielhollas
Copy link
Collaborator Author

Huh, seems like this is a known behaviour???

.. note:: The periodic boundary conditions are always set to True.

danielhollas added a commit to ispg-group/aiidalab-ispg that referenced this issue Apr 29, 2024
TrajectoryData does not track PBC, and so when we
extract StructureData from it, it will have the default
pbc=(True, True,True). Solution is simple, overwrite this.
See:
aiidateam/aiida-core#6376
danielhollas added a commit to ispg-group/aiidalab-ispg that referenced this issue Apr 29, 2024
TrajectoryData does not track PBC, and so when we
extract StructureData from it, it will have the default
pbc=(True, True,True). Solution is simple, overwrite this.
See:
aiidateam/aiida-core#6376
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants