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

Basic functions of rotation implementation #167

Closed
Tracked by #163
alexandrosvasi opened this issue Oct 17, 2023 · 5 comments · Fixed by #220
Closed
Tracked by #163

Basic functions of rotation implementation #167

alexandrosvasi opened this issue Oct 17, 2023 · 5 comments · Fixed by #220

Comments

@alexandrosvasi
Copy link

No description provided.

@tfamprikis
Copy link
Contributor

this issue refers to something completely different

@tfamprikis
Copy link
Contributor

tfamprikis commented Oct 19, 2023

The goal here is to keep track of the orientation of bonds and molecules throughout the simulation; and eventually quantify whether/how they might rotate.

The first thing to do is find and define what atoms are "bonded" with each other based on distances. Under the assumption that such bonds do not break during the simulation (non-reactive MD), this can be done for a single frame. Eventually, if we want to allow for reactive-MD then we need to do this every frame, but that is not priority. Our current working code works for tetrahedral molecules (e.g. methane CH4 , or a thiophosphate molecular anion, PS4^3-). We input the 'central' and 'satellite' atom types and the code finds the nearest satellite neighbors to each central atom with some arbitrary cutoff. This could be generalized by either inputting a cutoff or guessing based on a library of atomic sizes for each atom.

Then, for each bond, the orientation is calculated by considering the vector difference between satelite and central atom, for each frame. this is expressed in spherical coordinates. this is the reduced data for the following analysis/visualisation.

The orientational probability density can be calculated analogously to the spatial probability density, by dividing spherical coordinates into a grid. This can be visualized as a map (used cartopy for this). This can be transformed to a free energy in the same way as the spatial probability density as well (and eventually pathways found and barriers calculated)

The auto-correlation function (or self-correlation function) quantifies the degree and dynamics of correlation between the original orientation of a bond and its orientation in time t. The dot product between the original and current orientation is calculated for each bond, for each frame and then typically averaged for each bond in the system. This function start at 1 by definition, and then proceeds to decay. In a system where no rotation takes place it will plateau at some value (typically >0.9) indicative of modest local libration. In a system where bonds reorient, this will typically decay to 0. In the latter case we can fit an exponential decay and extract a characteristic (de)correlation time which quantifies the rotational/reorientational speed and is a main observable for the study of such systems. In order to quantify the error in this analysis, we can apply a similar approach to the error analysis of translational diffusivity from MSD, i.e. split the self-corellation function, calculate multiple correlation times and derive a standard deviation.

I will follow up with some rough code as examples - partly in matlab and partly python-, as soon as I get to clean it up, too self-consious to share it as it is rn

@stefsmeets
Copy link
Contributor

Thanks for the extensive explanation, that helps a lot! I indeed mixed up the two themes.

@tfamprikis
Copy link
Contributor

tfamprikis commented Oct 20, 2023

I've added an example analysis of an MD run here:

https://surfdrive.surf.nl/files/index.php/s/5ruIA57we0qcP5f

the first part is in matlab works as an addon to the old matlab code, it requires having run analyse_md.m first and generated a simulated_data.mat file (already provided for this example in /Li2SO4_HT_900K_gemdat)

satelllite_orb_matcher[...].m reads trajectories from the simulated_data.mat file and sets up the analysis described in the above comment. the goal is to generate, for each timestep, , vectors (and angles between vectors) that represent molecular bonds and molecular orientations. this is the variables called 'direction_cart' and 'degrees' in the current matlab code implementing this part to gemdat is the main priority.

I've added some examples of the figures generated by satelllite_orb_matcher[...].m in /matlab_generated_figures

after running satelllite_orb_matcher[...].m you can run a few python scripts that analyse/fit/plot the output (.csv) in /Li2SO4_HT_900K_gemdat

most of the code is probably written very badly and inefficiently atm... i'm not sure if you want to translate it or just straight up rewrite it.

@tfamprikis
Copy link
Contributor

please do let me know if any of the above is not clear.

it would be nice to have the first part of the satelllite_orb_matcher[...].m script integrated in gemdat rather quickly, since it's the basis for alot of things.

tfamprikis added a commit that referenced this issue Dec 11, 2023
adding functions to track orientations issue #167
@tfamprikis tfamprikis mentioned this issue Dec 11, 2023
@SCiarella SCiarella linked a pull request Jan 10, 2024 that will close this issue
SCiarella pushed a commit that referenced this issue Feb 6, 2024
adding functions to track orientations issue #167
stefsmeets added a commit that referenced this issue Mar 25, 2024
* test pull request

adding functions to track orientations issue #167

* test pull request

adding functions to track orientations issue #167

* Rebase and initial cleanup

* Add Orientations class

* Add Oh_point_group class

* Add Oh_point_group class

* refactor rotation

* Add rotolinear plot

Add bond length distribution plot

Add autocorrelation computation and plot

* Add tests for rotations

* Update src/gemdat/plots/__init__.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/plots/matplotlib/_rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/plots/matplotlib/_rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Replace nested loop in _compute_symmetric

* Use direct call to skewnorm.pdf

* Drop polar bins with normalization

* Remove masked array

* Pass Orientations to plotting functions

Fix choice of normalization in Orientations init

* Move cartesian_to_polar to .utils

* Add cart2sph test

Use _pbc_dist from pymatgen

* Use pymatgen.PointGroup instead of custom

* Lint

* Add tests

* Refactor test

* Update src/gemdat/plots/matplotlib/_rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/plots/matplotlib/_rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/plots/matplotlib/_rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Update src/gemdat/rotations.py

Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>

* Rename traj -> trajectory

Rename data -> orientations

* Directly use trajectory.time_step in plot_autocorrelation

* Use skewnorm.pdf directly

* Fix tests

---------

Co-authored-by: SCiarella <simoneciarella@gmail.com>
Co-authored-by: SCiarella <58949181+SCiarella@users.noreply.github.com>
Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants