gemdat.path
This module contains classes for computing optimal and percolating paths between sites.
Pathway(sites, energy, dims=None)
dataclass
Container class for paths between sites.
Attributes:
-
sites(list[tuple]) βList of voxel coordinates of the sites defining the path
-
energy(list[float]) βList of the energy along the path
-
dims([int, int, int] | None) βVoxel dimensions of bounding box. If set (usually to
Volume.dims), enable some site transformations.
start_site
property
Return first site.
stop_site
property
Return stop site.
total_energy
property
Return total energy for path.
frac_sites()
Return fractional site coordinates.
Note that these wrap around the periodic boundary conditions.
Returns:
-
ndarrayβFractional coordinates for sites
Source code in src/gemdat/path.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
path_over_structure(structure)
Find the nearest site of the structure to the path sites.
Parameters:
-
structure(Structure) βReference structure
Returns:
-
nearest_sites(list[PeriodicSite]) βList closest sites of the reference structure
Source code in src/gemdat/path.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
plot_energy_along_path(module, **kwargs)
See gemdat.plots.energy_along_path for more info.
Source code in src/gemdat/path.py
147 148 149 150 | |
total_length(lattice)
Return total length of pathway in Γ ngstrom.
Parameters:
-
lattice(Lattice) βLattice parameters
Returns:
-
length(FloatWithUnit) βTotal distance in Γ ngstrom
Source code in src/gemdat/path.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
wrapped_sites()
Wrap sites to bounding box.
Returns:
-
ndarrayβVoxel coordinates wrapped to bounding box.
Source code in src/gemdat/path.py
79 80 81 82 83 84 85 86 87 88 89 90 | |
calculate_path_difference(path1, path2)
Calculate the difference between two paths.
This difference is defined as the percentage of sites that are not shared between the two paths.
Parameters:
-
path1(list) βList of sites defining the first path
-
path2(list) βList of sites defining the second path
Returns:
-
difference(float) βDifference between the two paths
Source code in src/gemdat/path.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
free_energy_graph(F, max_energy_threshold=1e+20, diagonal=True)
Compute the graph of the free energy for networkx functions.
Parameters:
-
F(ndarray | FreeEnergyVolume) βFree energy on the 3d grid
-
max_energy_threshold(float, default:1e+20) βMaximum energy threshold for the path to be considered valid
-
diagonal(bool, default:True) βIf True, allows diagonal grid moves
Returns:
-
G(Graph) βGraph of free energy
Source code in src/gemdat/path.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
optimal_n_paths(F_graph, *, start, stop, method='dijkstra', n_paths=3, min_diff=0.15)
Calculate the n_paths shortest paths between two sites on the graph. This procedure is based the algorithm by Jin Y. Yen (https://doi.org/10.1287/mnsc.17.11.712) and its implementation in NetworkX. Only paths that are different by at least min_diff are considered.
.. warning:: Notice that this function in based on networkx.all_shortest_paths, which tends to identify first small variations of the optimal path. A custom graph pruning approach is suggested to accommodate different needs.
Parameters:
-
F_graph(Graph) βGraph of the free energy
-
start(Collection) βCoordinates of the starting point
-
stop(Collection) βCoordinates of the stopping point
-
method(str, default:'dijkstra') βMethod used to calculate the shortest path. Options are: - 'simple': Shortest, unweighted path - 'dijkstra': Dijkstra's algorithm - 'bellman-ford': Bellman-Ford algorithm - 'minmax-energy': Minmax energy algorithm - 'dijkstra-exp': Dijkstra's algorithm with exponential weights
-
n_paths(int, default:3) βNumber of paths to be calculated
-
min_diff(float, default:0.15) βMinimum difference between the paths
Returns:
-
list_of_paths(list[Pathway]) βList of the n_paths shortest paths between the start and stop sites
Source code in src/gemdat/path.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
optimal_path(F_graph, *, start, stop, method='dijkstra')
Calculate the shortest cost-effective path using the desired method.
Parameters:
-
F_graph(Graph) βGraph of the free energy
-
start(Collection) βCoordinates of the starting point
-
stop(Collection) βCoordinates of the stoping point
-
method(str, default:'dijkstra') βMethod used to calculate the shortest path. Options are: - 'simple': Shortest, unweighted path - 'dijkstra': Dijkstra's algorithm - 'bellman-ford': Bellman-Ford algorithm - 'minmax-energy': Minmax energy algorithm - 'dijkstra-exp': Dijkstra's algorithm with exponential weights
Returns:
-
path(Pathway) βOptimal path on the graph between start and stop
Source code in src/gemdat/path.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
optimal_percolating_path(F, *, peaks, percolate)
Calculate the optimal percolating path.
Parameters:
-
F(FreeEnergyVolume) βEnergy grid that will be used to calculate the shortest path
-
peaks(ndarray) βList of the peaks that correspond to high probability regions
-
percolate(str) βDirections to percolate, e.g. 'x' to consider paths that percolate along the x dimension, 'yz' for the y/z dimension, or any other combinition of 'x', 'y', and 'z'.
Returns:
-
best_percolating_path(Pathway) βOptimal path that percolates the graph in the specified directions
Source code in src/gemdat/path.py
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |