Percolation¶
This notebook shows how to use GEMDAT to compute the shortest percolating path.
It first computes the free energy on a discretized gride from the trajectory, then it finds the nearest sites of the structure to each point of the grid to map the space. The density probability is also used to initialize the percolation search. The user has then to specify in which of the cartesian directions the percolation has to happen (multiple selection is allowed). After selecting the metric for path evaluation, GEMDAT returns the best percolating path.
As input you will need:
- discretized grid resolution
- float value
- Percolation directions
The resulting path can be analyzed and plotted in 3d, together with the energy profile along the path.
Loading data¶
Load simulation data and reference jump sites.
from gemdat import Trajectory
from gemdat.io import load_known_material
from gemdat.utils import VASPRUN
# Use your own data:
# VASPRUN = 'path/to/your/vasprun.xml'
trajectory = Trajectory.from_vasprun(VASPRUN)
diff_trajectory = trajectory.filter('Li')
sites = load_known_material('argyrodite', supercell=(2, 1, 1))
Get free energy volume¶
Percolation works with the free energy of the system. This can be obtained from the density volume of the diffusing element represented as the free energy.
volume = diff_trajectory.to_volume(resolution=0.45)
free_energy = volume.get_free_energy(temperature=trajectory.metadata['temperature'])
/home/stef/python/gemdat/src/gemdat/volume.py:372: RuntimeWarning: divide by zero encountered in log * np.log(prob)
Find best percolating path¶
Look for the lowest-energy path that percolates the system.
It is possible to set in which direction(s) the path has to percolate, with the percolate flag.
peaks = volume.find_peaks()
best_path = free_energy.optimal_percolating_path(peaks=peaks, percolate='x')
best_path
Path: (18, 15, 10) -> (62, 15, 10) Steps: 45 Total energy: 20.809 eV Dimensions: (44, 22, 22)
Plot the best percolating path.
fig1 = volume.plot_3d(paths=best_path, structure=sites)
fig1.show()
fig2 = best_path.plot_energy_along_path(structure=sites)
fig2.show()