GEMDAT-repos / GEMDAT

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

Fix Orientations IO #293

Closed SCiarella closed 3 months ago

SCiarella commented 3 months ago

This PR improves the Orientations class. In particular, this PR implements a Strategy design pattern to allow users to select which transformations to use and their order.

Previous methods of Orientations have been reformatted into the abstract classes Normalize, Conventional, and Symmetrize that perform their respective transformation. The user will then access Orientation.transformed_trajectory to get the result of any series of transformations, instead of using different _get* methods.

The specific outcomes of the PR are the following:

The corresponding notebook has been updated.

SCiarella commented 3 months ago

Thanks @stefsmeets for the suggestions!

I'm wondering if we can simplify it a bit, from:

transforms = ['Normalize', 'Conventional', 'Symmetrize']
vasp_orientations.set_transformation(transforms)
transformed_traj = vasp_orientations.execute_transformations()

to

transforms = ['Normalize', 'Conventional', 'Symmetrize']
transformed_traj = vasp_orientations.transform(transforms)

I have used this approach, it makes total sense!

SCiarella commented 3 months ago

Moreover, this PR partially covers #286 because now rectilinear_plot uses Orientations.transformed_trajectory which can be any series of transformations. @tfamprikis can you check if this solves the problem described in #286?