Distributions
This module contains functions to compute distributions of atomic positions and interatomic distances.
snow.descriptors.distributions
pddf_calculator(coords, bin_width, use_lattice_units, lattice=None)
Computes the pair distance distribution function for a given set of coordinates of atoms. Please note that this function will count each pair once e.g. will consider (i,j) but not (j,i)
If use_lattice_units=True, bin_width should be provided in lattice units (alat) and the pddf is returned in lattice units. If use_lattice_units=False, the bin width should be provided in the coordinates units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
ndarray
|
Array of the coordinates of the atoms forming the system. |
required |
bin_width
|
float
|
width of the bins to bin the distances in the system. It should be provided in lattice units if use_lattice_units==True, and in the same units as coords if use_lattice==False |
required |
use_lattice_units
|
bool
|
If True, the PDDF is returned in units of the lattice constant (passed as the 'lattice' argument) and the bin_width should be given in units of the lattice constant. If False, the PDDF is returned in the units of coords, and the bin_width should be given in the same units as coords. |
required |
lattice
|
float
|
Specify a value for the lattice parameter of your structure in the same units as coords. Only needed if use_lattice_units is True |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bin_centers |
ndarray
|
the values of the interatomic distances corresponding to each bin |
dist_count |
ndarray
|
the count of distances for the each bin |
Source code in snow/descriptors/distributions.py
pddf_calculator_by_elements(species, coords, elements, bin_width, use_lattice_units, lattice=None, cutoff=None)
Computes the chemical element-wise pair distance distribution function (PDDF) for a given set of coordinates. Please note that this function will count each pair once e.g. will consider (i,j) but not (j,i)
This function only considers distances between atoms of specified chemical elements (A-A, A-B, or B-B). It can be decided whether to use lattice units or not. Histogram counting is used for efficiency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
species
|
list[str]
|
List of atomic species corresponding to each coordinate. |
required |
coords
|
ndarray
|
Array of the coordinates of the atoms forming the system. |
required |
elements
|
list[str]
|
The elements of which to consider the pairs (i.e. [A,A], or [A,B], or [B,B], given A and B two chemical species in your system) |
required |
bin_width
|
float
|
width of the bins to bin the distances in the system. It should be provided in lattice units if use_lattice_units==True, and in the same units as coords if use_lattice==False |
required |
use_lattice_units
|
bool
|
If True, the PDDF is computed and returned in units of the lattice constant (passed as the 'lattice' argument) and the bin_width should be given in units of the lattice constant. If False, the PPDF is returned in the units of coords, and the bin_width should be given in the same units as coords. |
required |
lattice
|
float
|
Specify a value for the lattice parameter of your structure in the same units as coords. Only needed if use_lattice_units is set to True |
None
|
cutoff
|
float
|
If specified, only distances up to this value are taken into account for the histogram calculation |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bin_centers |
ndarray
|
the values of the interatomic distances corresponding to each bin |
dist_count |
ndarray
|
the count of distances for the each bin |
Source code in snow/descriptors/distributions.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 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 | |
gdr_notnorm_calculator(coords, cut_off, bin_count=None, bin_precision=None)
Computes the (unnormalized) Radial Distribution Function as defined in "Understanding Molecular Simulation" by Frenkel and Smit, for each atom concentric shells with a certain bin precision (or number of bins) are constructed and the density of atoms found in each shell is computed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
ndarray
|
XYZ coordinates of atoms, shape (n_atoms, 3). |
required |
cut_off
|
float
|
Cutoff distance for finding pairs in angstroms. |
required |
bin_count
|
int
|
Number of bins, by default None. Either bin_count or bin_precision should be specified. |
None
|
bin_precision
|
float
|
Bin precision, by default None. Either bin_count or bin_precision should be specified. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bin_centers |
ndarray
|
the values of the interatomic distances corresponding to each bin |
rdf |
ndarray
|
unnormalized g(r) values |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither bin_count nor bin_precision was specified. |
Source code in snow/descriptors/distributions.py
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 221 222 223 224 225 226 227 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 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
com_rdf_calculator(coords, bin_width, com=None, elements=None)
Compute the Radial Distribution Function: a distribution of all the distances wrt to the center of mass of the system. The com can be provided as an argument or computed by the function (in this case, pass the list of chemical elements in your system as an argument)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
ndarray
|
coordinates of atoms in the system |
required |
bin_width
|
float
|
bin width for binning of the distribution |
required |
com
|
ndarray
|
center of mass of the system (as a three-elements coordinates array). If None (default), it is computed |
None
|
elements
|
list[str]
|
chemical species of the atoms in the system used in the center of mass calculation. If None, provide the com as an argument to the function |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bin_centers |
ndarray
|
the values of the interatomic distances corresponding to each bin |
dist_count |
ndarray
|
the count of distances for the each bin |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither the list of elements nor the center of mass was specified. |
Source code in snow/descriptors/distributions.py
cut_layers(elements, coords_frame, layer_height, cutting_ax='z', species_A=None, species_B=None)
Cuts a single frame into layers and compute the distribution of atoms in the layers.
Computes the distribution of atoms per layer of width layer_height. The axis along which (perpendicular)
planes are cut can be specified as either 'z' (default), 'x', 'y', or a user-defined np.ndarray
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elements
|
ndarray
|
chemical symbols of the atoms provided - Shape (n_atoms,) |
required |
coords_frame
|
ndarray
|
coordinates of the atoms provided - Shape (n_atoms, 3) |
required |
cutting_ax
|
str or ndarray
|
either 'x', 'y', 'z', or a (3, ) np.ndarray such as (1,1,0) |
'z'
|
species_A
|
str(optional)
|
chemical specie 1 to filter the coords and get a chemical specie-wise count of atoms per layer |
None
|
species_B
|
str(optional)
|
chemical specie 2 to filter the coords and get a chemical specie-wise count of atoms per layer |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
layer_number |
ndarray
|
Layer indices, shape (n_layers,). |
layer_ntot |
ndarray
|
Total atom count per layer, shape (n_layers,). |
layer_na |
ndarray
|
Atom count per layer for species_A, shape (n_layers,). Only returned if species_A is not None. |
layer_nb |
ndarray
|
Atom count per layer for species_B, shape (n_layers,). Only returned if species_B is not None. |
Source code in snow/descriptors/distributions.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 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 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | |