GEMDAT-repos / GEMDAT

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

Add method to create a graph from jumps #325

Closed stefsmeets closed 1 month ago

stefsmeets commented 1 month ago

This PR makes an attempt to calculate the activation energy graph from the jumps object. I implemented it as a directed graph, but it can easily be collapsed into a undirected graph.

>>> from gemdat import Trajectory, load_known_material
>>> from gemdat.utils import VASPRUN
>>> 
>>> trajectory = Trajectory.from_vasprun(VASPRUN)
>>> diff_trajectory = trajectory.filter('Li')
>>> 
>>> sites = load_known_material('argyrodite', supercell=(2, 1, 1))
>>> 
>>> transitions = trajectory.transitions_between_sites(
>>>     sites=sites,
>>>     floating_specie='Li',
>>> )
>>> 
>>> jumps = transitions.jumps()
>>> G = jumps.to_graph()
>>> list(G.adjacency())
[(94, {0: {'e_act': 0.08184877863639753}, 86: {'e_act': 0.17199768720154068}}),
 (0, {94: {'e_act': 0.07200775957630277}, 64: {'e_act': 0.20098168979635483}}),
 (86,
  {94: {'e_act': 0.1676656025734321},
   34: {'e_act': 0.09749500858643947},
   78: {'e_act': 0.20649062422834097}}),
 (2,
  {92: {'e_act': 0.19221497535660828},
   66: {'e_act': 0.13067877194389088},
   58: {'e_act': 0.15338995370169942},
   34: {'e_act': 0.19221497535660828}}),

You can also get the activation energy by site:

>>> jumps.activation_energy_between_sites(2, 92)
0.19221497535660828

to_graph() takes the min and max energy:

>>> G = jumps.to_graph(min_e_act=0.1, max_e_act=5.0)
...

Closes #322

stefsmeets commented 1 month ago

Hi @SCiarella @v9lgraf could you have a look at this PR and let me know if the implementation looks sensible to you? Also happy to take any other feedback you may have 😁