gemdat.volume
This module contains functions related to dealing with volumetric data.
FreeEnergyVolume(data, lattice, label='volume', units=(lambda: Unit(''))())
dataclass
Bases: Volume
free_energy_graph(**kwargs)
Compute the graph of the free energy for networkx functions.
See gemdat.path.free_energy_graph for more info.
Source code in src/gemdat/volume.py
536 537 538 539 540 541 542 543 | |
optimal_n_paths(F_graph=None, **kwargs)
Calculate the n_paths shortest paths between two sites on the graph.
See gemdat.path.optimal_n_paths for more info.
Source code in src/gemdat/volume.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
optimal_path(F_graph=None, **kwargs)
Calculate the shortest cost-effective path using the desired method.
Parameters:
-
F_graph(Graph | None, default:None) βOptionally, define your own free energy graph. Otherwise, it will be calculated on the fly using default parameters.
-
**kwargsβThese parameters are passed to gemdat.path.optimal_path. See gemdat.path.optimal_path for more info.
Returns:
-
path(Pathway) βVoxel coordinates and energy of optimal path from start to stop.
Source code in src/gemdat/volume.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
optimal_percolating_path(**kwargs)
Calculate the optimal percolating path.
See gemdat.path.optimal_percolating_path for more info.
Source code in src/gemdat/volume.py
587 588 589 590 591 592 593 594 | |
Volume(data, lattice, label='volume', units=(lambda: Unit(''))())
dataclass
Container for volumetric data.
Parameters:
-
data(ndarray) βInput volume as 3D numpy array
-
lattice(Lattice) βLattice parameters for the volume
-
label(str, default:'volume') βLabel for the Volume
-
units(Unit | None, default:(lambda: Unit(''))()) βOptional unit for the data
voxel_size
property
Return voxel size in Angstrom.
find_peaks(pad=3, remove_outside=True, pbc_tol=1.0, **kwargs)
Find peaks using the Difference of Gaussian function in scikit- image.
Volume data are normalized to (0-1) prior to peak finding.
Parameters:
-
pad(int, default:3) βExtend the volume by this number of voxels by wrapping around. This helps finding maxima for blobs sitting at the edge of the unit cell.
-
remove_outside(bool, default:True) βIf True, remove peaks outside the lattice. Only applicable if pad > 0.
-
pbc_tol(float, default:1.0) βDistance threshold (Γ ngstrom) for merging peaks that coincide only across a periodic boundary (see
Volume._dedup_pbc_peaks). Set to 0 to disable. -
**kwargsβAdditional keyword arguments are passed to skimage.feature.blob_dog
Returns:
-
coords(ndarray) βList of coordinates
Source code in src/gemdat/volume.py
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 | |
frac_coords_to_voxel(frac_coords)
Convert fractional coordinates to voxel coordinates.
Parameters:
Returns:
-
ndarrayβOutput voxel coordinates
Source code in src/gemdat/volume.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
from_volumetric_data(volume)
classmethod
Create instance from VolumetricData.
Parameters:
-
volume(VolumetricData) βInput volumetric data
Source code in src/gemdat/volume.py
87 88 89 90 91 92 93 94 95 96 97 98 99 | |
get_free_energy(temperature)
Estimate the free energy from volume.
Parameters:
-
temperature(float) βThe temperature of the simulation
Returns:
-
free_energy(ndarray) βFree energy in eV on the voxel grid
Source code in src/gemdat/volume.py
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 526 527 | |
normalized()
Return normalized data.
Source code in src/gemdat/volume.py
74 75 76 | |
plot_3d(*, module, **kwargs)
See gemdat.plots.plot_3d for more info.
Source code in src/gemdat/volume.py
529 530 531 532 | |
probability()
Return probability data.
Source code in src/gemdat/volume.py
78 79 80 | |
site_to_voxel(site)
Convert site coordinates to voxel coordinates.
Parameters:
-
site(PeriodicSite) βInput site
Returns:
-
ndarrayβOutput voxel coordinates
Source code in src/gemdat/volume.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
to_structure(*, specie='X', background_level=0.1, peaks=None, return_occupancies=False, n_frames=None, snap_to_lower=False, **kwargs)
Converts a volume back to a structure using peak detection. Uses the 'centroid' method that takes the weighted centroid of all voxels in a labeled region (fast),
Parameters:
-
specie(str, default:'X') βSpecie to assign to the found sites, defaults to 'X'
-
background_level(float, default:0.1) βFraction of the maximum volume value to set as the minimum value for peak segmentation. Essentially sets
vol_min = background_level * max(vol). All values belowvol_minare masked in the peak search. Must be between 0 and 1 -
peaks(Optional[ndarray], default:None) βVoxel coordinates to use as starting points for watershed algorithm.
-
return_occupancies(bool, default:False) βIf True, assign a partial occupancy to each site, computed as the integrated (raw) density of the region divided by
n_frames. Sites merged during deduplication have their occupancies summed. -
n_frames(int | None, default:None) βNumber of frames the volume was generated from. Required when
return_occupanciesis True. -
snap_to_lower(bool, default:False) βA site sitting on a cell face is equally ~0.0 or ~1.0, and
modpicks inconsistently between the two. If True, coordinates within one voxel of the upper face are snapped to the lower end (0) so on-face sites get a single canonical representation. This trades a sub-voxel loss of precision for that consistency, so it is off by default; enable it when you specifically want boundary sites reported at the lower end of the axis. -
**kwargs(dict, default:{}) βThese keywords parameters are passed to gemdat.volume.Volume.find_peaks. Only applies if
peaks == None.
Returns:
-
structure(Structure) βOutput structure
Source code in src/gemdat/volume.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 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 | |
to_vasp_volume(structure, *, filename=None, other=None)
Convert to vasp volume.
Parameters:
-
structure(Structure) βstructure to include in the vasp file (e.g. trajectory structure) Also useful if you want to output the density for a select number of species, and show the host structure.
-
filename(Optional[str], default:None) βIf specified, save volume to this filename.
-
other(list[Volume], default:None) βOther volumes to store to the vasp volume. Lattice must match to this volumes lattice. The volume label is used as the key in the output volumetric data.
Returns:
-
vol_vasp(VolumetricData) βOutput volume
Source code in src/gemdat/volume.py
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 | |
voxel_to_cart_coords(voxel)
Convert voxel coordinates to cartesian coordinates.
Parameters:
Returns:
-
ndarrayβOutput cartesian coordinates
Source code in src/gemdat/volume.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
voxel_to_frac_coords(voxel)
Convert voxel coordinates to fractional coordinates.
Parameters:
Returns:
-
ndarrayβOutput fractional coordinates
Source code in src/gemdat/volume.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
trajectory_to_volume(trajectory, resolution=0.2)
Calculate density volume from a trajectory.
All coordinates are binned into voxels. The value of each voxel represents the number of coodinates that are associated with it.
Parameters:
-
trajectory(Trajectory) βInput trajectory
-
resolution(float, default:0.2) βMinimum resolution for the voxels in Angstrom
Returns:
-
vol(Volume) βOutput volume
Source code in src/gemdat/volume.py
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | |